Merge "Convert several libraries to soong." am: 3b680bb63e am: 087a92d552
am: e27390725c

Change-Id: I29902a81c198e62a703c03adc77f324542f1a4f0
diff --git a/ext4_utils/Android.bp b/ext4_utils/Android.bp
new file mode 100644
index 0000000..a2987aa
--- /dev/null
+++ b/ext4_utils/Android.bp
@@ -0,0 +1,70 @@
+// Copyright 2010 The Android Open Source Project
+
+cc_library {
+    name: "libext4_utils",
+    host_supported: true,
+    srcs: [
+        "make_ext4fs.c",
+        "ext4fixup.c",
+        "ext4_utils.c",
+        "allocate.c",
+        "contents.c",
+        "extent.c",
+        "indirect.c",
+        "sha1.c",
+        "wipe.c",
+        "crc16.c",
+        "ext4_sb.c",
+    ],
+    // Various instances of dereferencing a type-punned pointer in extent.c
+    cflags: ["-fno-strict-aliasing"],
+    export_include_dirs: ["include"],
+    shared_libs: [
+        "libsparse",
+    ],
+
+    target: {
+        host: {
+            static_libs: ["libsparse"],
+            shared_libs: ["libz-host"],
+        },
+        linux: {
+            static_libs: ["libselinux"],
+        },
+        darwin: {
+            static_libs: ["libselinux"],
+        },
+        windows: {
+            host_ldlibs: ["-lws2_32"],
+            enabled: true,
+        },
+
+        android: {
+            srcs: [
+                "key_control.cpp",
+                "ext4_crypt.cpp",
+            ],
+            shared_libs: [
+                "libbase",
+                "libselinux",
+            ],
+
+            static: {
+                srcs: [
+                    "ext4_crypt_init_extensions.cpp",
+                ],
+                static_libs: [
+                    "liblogwrap",
+                ]
+            },
+            shared: {
+                cflags: ["-DREAL_UUID"],
+                shared_libs: [
+                    "libcutils",
+                    "libext2_uuid",
+                    "libz",
+                ]
+            },
+        },
+    },
+}
diff --git a/ext4_utils/Android.mk b/ext4_utils/Android.mk
index 4287650..e59eb4a 100644
--- a/ext4_utils/Android.mk
+++ b/ext4_utils/Android.mk
@@ -2,41 +2,11 @@
 
 LOCAL_PATH:= $(call my-dir)
 
-libext4_utils_src_files := \
-    make_ext4fs.c \
-    ext4fixup.c \
-    ext4_utils.c \
-    allocate.c \
-    contents.c \
-    extent.c \
-    indirect.c \
-    sha1.c \
-    wipe.c \
-    crc16.c \
-    ext4_sb.c
-
 #
 # -- All host/targets including windows
 #
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(libext4_utils_src_files)
-LOCAL_MODULE := libext4_utils
-# Various instances of dereferencing a type-punned pointer in extent.c
-LOCAL_CFLAGS += -fno-strict-aliasing
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
-    $(LOCAL_PATH)/include
-LOCAL_STATIC_LIBRARIES := \
-    libsparse
-LOCAL_STATIC_LIBRARIES_darwin += libselinux
-LOCAL_STATIC_LIBRARIES_linux += libselinux
-LOCAL_MODULE_HOST_OS := darwin linux windows
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-
-include $(CLEAR_VARS)
 LOCAL_SRC_FILES := make_ext4fs_main.c
 LOCAL_MODULE := make_ext4fs
 LOCAL_C_INCLUDES := \
@@ -66,52 +36,9 @@
 # -- All host/targets excluding windows
 #
 
-libext4_utils_src_files += \
-    key_control.cpp \
-    ext4_crypt.cpp
-
 ifneq ($(HOST_OS),windows)
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(libext4_utils_src_files)
-LOCAL_MODULE := libext4_utils
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include \
-    system/core/logwrapper/include
-# Various instances of dereferencing a type-punned pointer in extent.c
-LOCAL_CFLAGS += -fno-strict-aliasing
-LOCAL_CFLAGS += -DREAL_UUID
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
-    $(LOCAL_PATH)/include
-LOCAL_SHARED_LIBRARIES := \
-    libbase \
-    libcutils \
-    libext2_uuid \
-    libselinux \
-    libsparse
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
-    $(libext4_utils_src_files) \
-    ext4_crypt_init_extensions.cpp
-LOCAL_MODULE := libext4_utils
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include
-# Various instances of dereferencing a type-punned pointer in extent.c
-LOCAL_CFLAGS += -fno-strict-aliasing
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
-    $(LOCAL_PATH)/include
-LOCAL_STATIC_LIBRARIES := \
-    liblogwrap \
-    libsparse \
-    libselinux \
-    libbase
-include $(BUILD_STATIC_LIBRARY)
-
-
-include $(CLEAR_VARS)
 LOCAL_SRC_FILES := make_ext4fs_main.c
 LOCAL_MODULE := make_ext4fs
 LOCAL_C_INCLUDES := \
diff --git a/f2fs_utils/Android.mk b/f2fs_utils/Android.mk
index f643ad2..32ed0ed 100644
--- a/f2fs_utils/Android.mk
+++ b/f2fs_utils/Android.mk
@@ -21,7 +21,7 @@
 LOCAL_STATIC_LIBRARIES := \
     libselinux \
     libsparse \
-    libext2_uuid-host \
+    libext2_uuid \
     libz
 LOCAL_MODULE := libf2fs_ioutils_host
 include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/libfec/Android.bp b/libfec/Android.bp
new file mode 100644
index 0000000..1145fc4
--- /dev/null
+++ b/libfec/Android.bp
@@ -0,0 +1,37 @@
+// Copyright 2015 The Android Open Source Project
+
+cc_library {
+    name: "libfec",
+    host_supported: true,
+    srcs: [
+        "fec_open.cpp",
+        "fec_read.cpp",
+        "fec_verity.cpp",
+        "fec_process.cpp",
+    ],
+    cflags: ["-Wall", "-Werror", "-O3", "-D_LARGEFILE64_SOURCE"],
+    export_include_dirs: ["include"],
+    // Exported header include/fec/io.h includes crypto_utils headers.
+    export_static_lib_headers: ["libcrypto_utils"],
+
+    static_libs: [
+        "libext4_utils",
+        "libfec_rs",
+        "libsquashfs_utils",
+        "libcrypto_utils",
+        "libcrypto",
+        "libcutils",
+        "libbase",
+    ],
+
+    target: {
+        host: {
+            cflags: ["-D_GNU_SOURCE", "-DFEC_NO_KLOG"]
+        },
+    },
+
+    clang: true,
+    sanitize: {
+        misc_undefined: ["integer"],
+    },
+}
diff --git a/libfec/Android.mk b/libfec/Android.mk
index 47ac556..12974bc 100644
--- a/libfec/Android.mk
+++ b/libfec/Android.mk
@@ -2,49 +2,4 @@
 #
 LOCAL_PATH := $(call my-dir)
 
-common_cflags := -Wall -Werror -O3 -D_LARGEFILE64_SOURCE
-
-common_c_includes := \
-    $(LOCAL_PATH)/include \
-    external/fec
-
-common_src_files := \
-    fec_open.cpp \
-    fec_read.cpp \
-    fec_verity.cpp \
-    fec_process.cpp
-
-common_static_libraries := \
-    libext4_utils \
-    libfec_rs \
-    libsquashfs_utils \
-    libcrypto_utils \
-    libcrypto \
-    libcutils \
-    libbase \
-
-include $(CLEAR_VARS)
-LOCAL_CFLAGS := $(common_cflags)
-LOCAL_C_INCLUDES := $(common_c_includes)
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_MODULE := libfec
-LOCAL_SRC_FILES := $(common_src_files)
-LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_CFLAGS := $(common_cflags) -D_GNU_SOURCE -DFEC_NO_KLOG
-LOCAL_C_INCLUDES := $(common_c_includes)
-LOCAL_CLANG := true
-ifeq ($(HOST_OS),linux)
-LOCAL_SANITIZE := integer
-endif
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_MODULE := libfec
-LOCAL_SRC_FILES := $(common_src_files)
-LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
-include $(BUILD_HOST_STATIC_LIBRARY)
-
 include $(LOCAL_PATH)/test/Android.mk
diff --git a/squashfs_utils/Android.bp b/squashfs_utils/Android.bp
new file mode 100644
index 0000000..c0d9b18
--- /dev/null
+++ b/squashfs_utils/Android.bp
@@ -0,0 +1,22 @@
+// Copyright 2015 The Android Open Source Project
+
+cc_library_static {
+    name: "libsquashfs_utils",
+    host_supported: true,
+    srcs: [
+        "squashfs_utils.c",
+    ],
+    include_dirs: ["external/squashfs-tools/squashfs-tools"],
+    export_include_dirs: ["."],
+
+    static_libs: [
+        "libcutils",
+    ],
+
+    target: {
+        host: {
+            cflags: ["-Wall", "-Werror", "-D_GNU_SOURCE", "-DSQUASHFS_NO_KLOG"]
+        },
+    },
+
+}
diff --git a/squashfs_utils/Android.mk b/squashfs_utils/Android.mk
index b80da09..bf60cf4 100644
--- a/squashfs_utils/Android.mk
+++ b/squashfs_utils/Android.mk
@@ -3,23 +3,6 @@
 LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := squashfs_utils.c
-LOCAL_STATIC_LIBRARIES := libcutils
-LOCAL_C_INCLUDES := external/squashfs-tools/squashfs-tools
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-LOCAL_MODULE := libsquashfs_utils
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := squashfs_utils.c
-LOCAL_STATIC_LIBRARIES := libcutils
-LOCAL_C_INCLUDES := external/squashfs-tools/squashfs-tools
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-LOCAL_CFLAGS := -Wall -Werror -D_GNU_SOURCE -DSQUASHFS_NO_KLOG
-LOCAL_MODULE := libsquashfs_utils
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
 LOCAL_MODULE := mksquashfsimage.sh
 LOCAL_SRC_FILES := mksquashfsimage.sh
 LOCAL_MODULE_CLASS := EXECUTABLES