From cedbac6aefc10c31bafeb84f96c3f39119b53c7c Mon Sep 17 00:00:00 2001
From: Pin-chih Lin <johnylin@google.com>
Date: Tue, 29 May 2018 20:49:07 +0800
Subject: [PATCH] Revert "v4l2_codec2: Convert Android.mk to Android.bp"

The original commit breaks the build.

This reverts commit eb5a1bc7561150ce8bc8f1fdf3f28d863a412c44.

Bug: 32691050
Test: build image
---
 Android.bp       | 105 -----------------------------------------------
 Android.mk       |  97 +++++++++++++++++++++++++++++++++++++++++++
 cmds/Android.bp  |  36 ----------------
 cmds/Android.mk  |  42 +++++++++++++++++++
 tests/Android.bp |  65 -----------------------------
 tests/Android.mk |  78 +++++++++++++++++++++++++++++++++++
 vda/Android.bp   |  53 ------------------------
 vda/Android.mk   |  50 ++++++++++++++++++++++
 8 files changed, 267 insertions(+), 259 deletions(-)
 delete mode 100644 Android.bp
 create mode 100644 Android.mk
 delete mode 100644 cmds/Android.bp
 create mode 100644 cmds/Android.mk
 delete mode 100644 tests/Android.bp
 create mode 100644 tests/Android.mk
 delete mode 100644 vda/Android.bp
 create mode 100644 vda/Android.mk

diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 4335e61..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,105 +0,0 @@
-soong_namespace {
-    imports: [
-        "device/google/cheets2/codec2",
-        "hardware/google/av",
-    ],
-}
-
-cc_library_shared {
-    name: "libv4l2_codec2_arcva_factory",
-    vendor_available: true,
-    product_variables: {
-        arc: {
-            srcs: ["C2ArcVideoAcceleratorFactory.cpp"],
-
-            shared_libs: [
-                "libarcbridge",
-                "libarcbridgeservice",
-                "libarcvideobridge",
-                "libbinder",
-                "libchrome",
-                "liblog",
-                "libmojo",
-                "libutils",
-            ],
-
-            // -Wno-unused-parameter is needed for libchrome/base codes
-            cflags: [
-                "-Wall",
-                "-Werror",
-                "-Wno-unused-parameter",
-                "-std=c++14",
-            ],
-        },
-    },
-    clang: true,
-    export_include_dirs: [
-        "include",
-    ],
-}
-
-cc_library_shared {
-    name: "libv4l2_codec2",
-
-    srcs: [
-        "C2VDAComponent.cpp",
-        "C2VDAAdaptor.cpp",
-    ],
-
-    shared_libs: [
-        "libbinder",
-        "libchrome",
-        "liblog",
-        "libmedia",
-        "libstagefright",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_foundation",
-        "libstagefright_simple_c2component",
-        "libutils",
-        "libv4l2_codec2_vda",
-        "libvda_c2componentstore",
-    ],
-
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unknown-warning-option",
-        "-Wno-unused-lambda-capture",
-        "-Wno-unused-parameter",
-        "-std=c++14",
-    ],
-
-    clang: true,
-
-    sanitize: {
-        misc_undefined: [
-            "unsigned-integer-overflow",
-            "signed-integer-overflow",
-        ],
-    },
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-
-    product_variables: {
-        arc: {
-            srcs: ["C2VDAAdaptorProxy.cpp"],
-            exclude_srcs : ["C2VDAAdaptor.cpp"],
-            shared_libs: [
-                "libarcbridge",
-                "libarcbridgeservice",
-                "libmojo",
-                "libv4l2_codec2_arcva_factory",
-            ],
-            cflags: [
-                "-DV4L2_CODEC2_ARC",
-            ],
-        }
-    },
-    export_include_dirs: [
-        "include",
-    ],
-}
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..0ba1e46
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,97 @@
+# Build only if both hardware/google/av and device/google/cheets2/codec2 are
+# visible; otherwise, don't build any target under this repository.
+ifneq (,$(findstring hardware/google/av,$(PRODUCT_SOONG_NAMESPACES)))
+ifneq (,$(findstring device/google/cheets2/codec2,$(PRODUCT_SOONG_NAMESPACES)))
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+# Build C2ArcVideoAcceleratorFactory only in cheets build.
+ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+LOCAL_SRC_FILES:= \
+                   C2ArcVideoAcceleratorFactory.cpp \
+
+LOCAL_C_INCLUDES := \
+        $(TOP)/external/gtest/include \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/v4l2_codec2/include \
+
+LOCAL_MODULE:= libv4l2_codec2_arcva_factory
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES += libarcbridge \
+                          libarcbridgeservice \
+                          libarcvideobridge \
+                          libbinder \
+                          libchrome \
+                          liblog \
+                          libmojo \
+                          libutils \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS := -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CLANG := true
+
+include $(BUILD_SHARED_LIBRARY)
+include $(CLEAR_VARS)
+endif # ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+
+LOCAL_SRC_FILES:= \
+        C2VDAComponent.cpp \
+        C2VDAAdaptor.cpp   \
+
+LOCAL_C_INCLUDES += \
+        $(TOP)/device/google/cheets2/codec2/vdastore/include \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/gtest/include \
+        $(TOP)/external/v4l2_codec2/include \
+        $(TOP)/external/v4l2_codec2/vda \
+        $(TOP)/frameworks/av/media/libstagefright/include \
+        $(TOP)/hardware/google/av/codec2/include \
+        $(TOP)/hardware/google/av/codec2/vndk/include \
+        $(TOP)/hardware/google/av/media/codecs/base/include \
+
+LOCAL_MODULE:= libv4l2_codec2
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES := libbinder \
+                          libchrome \
+                          liblog \
+                          libmedia \
+                          libstagefright \
+                          libstagefright_codec2 \
+                          libstagefright_codec2_vndk \
+                          libstagefright_simple_c2component \
+                          libstagefright_foundation \
+                          libutils \
+                          libv4l2_codec2_vda \
+                          libvda_c2componentstore \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CFLAGS += -Wno-unused-lambda-capture -Wno-unknown-warning-option
+LOCAL_CLANG := true
+LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+# Build C2VDAAdaptorProxy only for ARC++ case.
+ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+LOCAL_CFLAGS += -DV4L2_CODEC2_ARC
+LOCAL_SRC_FILES += \
+                   C2VDAAdaptorProxy.cpp \
+
+LOCAL_SRC_FILES := $(filter-out C2VDAAdaptor.cpp, $(LOCAL_SRC_FILES))
+LOCAL_SHARED_LIBRARIES += libarcbridge \
+                          libarcbridgeservice \
+                          libmojo \
+                          libv4l2_codec2_arcva_factory \
+
+endif # ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif  #ifneq (,$(findstring device/google/cheets2/codec2,$(PRODUCT_SOONG_NAMESPACES)))
+endif  #ifneq (,$(findstring hardware/google/av,$(PRODUCT_SOONG_NAMESPACES)))
diff --git a/cmds/Android.bp b/cmds/Android.bp
deleted file mode 100644
index c7e7b16..0000000
--- a/cmds/Android.bp
+++ /dev/null
@@ -1,36 +0,0 @@
-cc_binary {
-    name: "v4l2_codec2_testapp",
-    srcs: ["codec2.cpp"],
-
-    include_dirs: [
-        "frameworks/native/include",
-    ],
-
-    shared_libs: [
-        "android.hardware.media.bufferpool@1.0",
-        "libbinder",
-        "libchrome",
-        "libcutils",
-        "libgui",
-        "liblog",
-        "libmedia",
-        "libmediaextractor",
-        "libstagefright",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_foundation",
-        "libstagefright_simple_c2component",
-        "libui",
-        "libutils",
-        "libv4l2_codec2",
-        "libv4l2_codec2_vda",
-    ],
-
-    // -Wno-unused-parameter is needed for libchrome/base codes
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-    ],
-    clang: true,
-}
diff --git a/cmds/Android.mk b/cmds/Android.mk
new file mode 100644
index 0000000..6cc84ae
--- /dev/null
+++ b/cmds/Android.mk
@@ -0,0 +1,42 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+        codec2.cpp \
+
+LOCAL_C_INCLUDES += \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/gtest/include \
+        $(TOP)/external/v4l2_codec2/include \
+        $(TOP)/external/v4l2_codec2/vda \
+        $(TOP)/frameworks/av/media/libstagefright/include \
+        $(TOP)/frameworks/native/include \
+        $(TOP)/hardware/google/av/codec2/include \
+        $(TOP)/hardware/google/av/codec2/vndk/include \
+	$(TOP)/hardware/google/av/media/codecs/base/include \
+
+LOCAL_MODULE := v4l2_codec2_testapp
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES := libbinder \
+                          libchrome \
+                          libcutils \
+                          libgui \
+                          liblog \
+                          libmedia \
+                          libmediaextractor \
+                          libstagefright \
+                          libstagefright_codec2 \
+                          libstagefright_foundation \
+                          libstagefright_codec2_vndk \
+                          libui \
+                          libutils \
+                          libv4l2_codec2 \
+                          libv4l2_codec2_vda \
+                          android.hardware.media.bufferpool@1.0 \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter
+LOCAL_CLANG := true
+
+include $(BUILD_EXECUTABLE)
diff --git a/tests/Android.bp b/tests/Android.bp
deleted file mode 100644
index 6c80002..0000000
--- a/tests/Android.bp
+++ /dev/null
@@ -1,65 +0,0 @@
-cc_test {
-    name: "C2VDACompIntf_test",
-
-    srcs: ["C2VDACompIntf_test.cpp"],
-
-    shared_libs: [
-        "libchrome",
-        "libcutils",
-        "liblog",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_simple_c2component",
-        "libutils",
-        "libv4l2_codec2",
-        "libv4l2_codec2_vda",
-    ],
-
-    cflags: [
-        "-Werror",
-        "-Wall",
-        "-std=c++14",
-    ],
-    clang: true,
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-}
-
-cc_test {
-    name: "C2VDAComponent_test",
-    srcs: ["C2VDAComponent_test.cpp"],
-
-    shared_libs: [
-        "android.hardware.media.bufferpool@1.0",
-        "libchrome",
-        "libcutils",
-        "liblog",
-        "libmedia",
-        "libmediaextractor",
-        "libstagefright",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_foundation",
-        "libstagefright_simple_c2component",
-        "libutils",
-        "libv4l2_codec2",
-        "libv4l2_codec2_vda",
-    ],
-
-    // -Wno-unused-parameter is needed for libchrome/base codes
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-        "-std=c++14",
-    ],
-    clang: true,
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-}
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000..4bafb4a
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,78 @@
+# Build the unit tests.
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE := C2VDACompIntf_test
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := \
+  C2VDACompIntf_test.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+  libchrome \
+  libcutils \
+  liblog \
+  libstagefright_codec2 \
+  libstagefright_codec2_vndk \
+  libutils \
+  libv4l2_codec2 \
+  libv4l2_codec2_vda \
+
+LOCAL_C_INCLUDES += \
+  $(TOP)/external/v4l2_codec2/include \
+  $(TOP)/external/v4l2_codec2/vda \
+  $(TOP)/hardware/google/av/codec2/include \
+  $(TOP)/hardware/google/av/codec2/vndk/include \
+  $(TOP)/hardware/google/av/media/codecs/base/include \
+
+LOCAL_CFLAGS += -Werror -Wall -std=c++14
+LOCAL_CLANG := true
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+include $(BUILD_NATIVE_TEST)
+
+
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE := C2VDAComponent_test
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := \
+  C2VDAComponent_test.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+  libchrome \
+  libcutils \
+  liblog \
+  libmedia \
+  libmediaextractor \
+  libstagefright \
+  libstagefright_codec2 \
+  libstagefright_codec2_vndk \
+  libstagefright_foundation \
+  libutils \
+  libv4l2_codec2 \
+  libv4l2_codec2_vda \
+  android.hardware.media.bufferpool@1.0 \
+
+LOCAL_C_INCLUDES += \
+  $(TOP)/external/libchrome \
+  $(TOP)/external/v4l2_codec2/include \
+  $(TOP)/external/v4l2_codec2/vda \
+  $(TOP)/frameworks/av/media/libstagefright/include \
+  $(TOP)/hardware/google/av/codec2/include \
+  $(TOP)/hardware/google/av/codec2/vndk/include \
+  $(TOP)/hardware/google/av/media/codecs/base/include \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CLANG := true
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+include $(BUILD_NATIVE_TEST)
diff --git a/vda/Android.bp b/vda/Android.bp
deleted file mode 100644
index 5f84535..0000000
--- a/vda/Android.bp
+++ /dev/null
@@ -1,53 +0,0 @@
-cc_library_shared {
-    name: "libv4l2_codec2_vda",
-    srcs: [
-        "bit_reader.cc",
-        "bit_reader_core.cc",
-        "bitstream_buffer.cc",
-        "h264_bit_reader.cc",
-        "h264_decoder.cc",
-        "h264_dpb.cc",
-        "h264_parser.cc",
-        "native_pixmap_handle.cc",
-        "picture.cc",
-        "ranges.cc",
-        "shared_memory_region.cc",
-        "v4l2_device.cc",
-        "v4l2_slice_video_decode_accelerator.cc",
-        "v4l2_video_decode_accelerator.cc",
-        "video_codecs.cc",
-        "video_decode_accelerator.cc",
-        "vp8_bool_decoder.cc",
-        "vp8_decoder.cc",
-        "vp8_parser.cc",
-        "vp8_picture.cc",
-        "vp9_bool_decoder.cc",
-        "vp9_compressed_header_parser.cc",
-        "vp9_decoder.cc",
-        "vp9_parser.cc",
-        "vp9_picture.cc",
-        "vp9_raw_bits_reader.cc",
-        "vp9_uncompressed_header_parser.cc",
-    ],
-
-    shared_libs: ["libchrome"],
-    // -Wno-unused-parameter is needed for libchrome/base codes
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-    ],
-    clang: true,
-    sanitize: {
-        misc_undefined: [
-            "unsigned-integer-overflow",
-            "signed-integer-overflow",
-        ],
-    },
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-    export_include_dirs: ["."],
-}
diff --git a/vda/Android.mk b/vda/Android.mk
new file mode 100644
index 0000000..12f0ea1
--- /dev/null
+++ b/vda/Android.mk
@@ -0,0 +1,50 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_CPP_EXTENSION:= .cc
+LOCAL_SRC_FILES:= \
+        bit_reader.cc       \
+        bit_reader_core.cc  \
+        bitstream_buffer.cc \
+        h264_bit_reader.cc  \
+        h264_decoder.cc     \
+        h264_dpb.cc         \
+        h264_parser.cc      \
+        native_pixmap_handle.cc \
+        picture.cc          \
+        ranges.cc           \
+        shared_memory_region.cc \
+        v4l2_device.cc      \
+        v4l2_slice_video_decode_accelerator.cc \
+        v4l2_video_decode_accelerator.cc \
+        video_codecs.cc     \
+        video_decode_accelerator.cc \
+        vp8_bool_decoder.cc \
+        vp8_decoder.cc      \
+        vp8_parser.cc       \
+        vp8_picture.cc      \
+        vp9_bool_decoder.cc \
+        vp9_compressed_header_parser.cc \
+        vp9_decoder.cc      \
+        vp9_parser.cc       \
+        vp9_picture.cc      \
+        vp9_raw_bits_reader.cc \
+        vp9_uncompressed_header_parser.cc \
+
+# gtest/include is for included file from libchrome/base/gtest_prod_util.h
+LOCAL_C_INCLUDES += \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/gtest/include \
+
+LOCAL_MODULE:= libv4l2_codec2_vda
+
+LOCAL_SHARED_LIBRARIES := libchrome \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter
+LOCAL_CLANG := true
+LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+include $(BUILD_SHARED_LIBRARY)
-- 
GitLab