Convert more Android.mk files to Android.bp

These modules have their dependencies satisfied, and aren't doing
anything strange.

Change-Id: I72039a15256cbd5e5eee0d79a15d66d74a6c087d
diff --git a/libsparse/Android.bp b/libsparse/Android.bp
new file mode 100644
index 0000000..7a6ae8a
--- /dev/null
+++ b/libsparse/Android.bp
@@ -0,0 +1,78 @@
+// Copyright 2010 The Android Open Source Project
+
+cc_defaults {
+    name: "libsparse_defaults",
+    srcs: [
+        "backed_block.c",
+        "output_file.c",
+        "sparse.c",
+        "sparse_crc32.c",
+        "sparse_err.c",
+        "sparse_read.c",
+    ],
+    cflags: ["-Werror"],
+    local_include_dirs: ["include"],
+    export_include_dirs: ["include"],
+}
+
+cc_library_host_static {
+    name: "libsparse_host",
+    defaults: ["libsparse_defaults"],
+    static_libs: ["libz"],
+    target: {
+        windows: {
+            enabled: true,
+        },
+    },
+}
+
+cc_library_shared {
+    name: "libsparse",
+    defaults: ["libsparse_defaults"],
+    shared_libs: ["libz"],
+}
+
+cc_library_static {
+    name: "libsparse_static",
+    host_supported: true,
+    defaults: ["libsparse_defaults"],
+    static_libs: ["libz"],
+}
+
+cc_binary {
+    name: "simg2img",
+    host_supported: true,
+    srcs: [
+        "simg2img.c",
+        "sparse_crc32.c",
+    ],
+    static_libs: [
+        "libsparse_static",
+        "libz",
+    ],
+
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "img2simg",
+    host_supported: true,
+    srcs: ["img2simg.c"],
+    static_libs: [
+        "libsparse_static",
+        "libz",
+    ],
+
+    cflags: ["-Werror"],
+}
+
+cc_binary_host {
+    name: "append2simg",
+    srcs: ["append2simg.c"],
+    static_libs: [
+        "libsparse_static",
+        "libz",
+    ],
+
+    cflags: ["-Werror"],
+}
diff --git a/libsparse/Android.mk b/libsparse/Android.mk
index c77eba9..05e68bc 100644
--- a/libsparse/Android.mk
+++ b/libsparse/Android.mk
@@ -2,106 +2,6 @@
 
 LOCAL_PATH:= $(call my-dir)
 
-libsparse_src_files := \
-        backed_block.c \
-        output_file.c \
-        sparse.c \
-        sparse_crc32.c \
-        sparse_err.c \
-        sparse_read.c
-
-
-include $(CLEAR_VARS)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_SRC_FILES := $(libsparse_src_files)
-LOCAL_MODULE := libsparse_host
-LOCAL_STATIC_LIBRARIES := libz
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_CFLAGS := -Werror
-LOCAL_MODULE_HOST_OS := darwin linux windows
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_SRC_FILES := $(libsparse_src_files)
-LOCAL_MODULE := libsparse
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
-LOCAL_SHARED_LIBRARIES := \
-    libz
-LOCAL_CFLAGS := -Werror
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_SRC_FILES := $(libsparse_src_files)
-LOCAL_MODULE := libsparse_static
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
-LOCAL_STATIC_LIBRARIES := libz
-LOCAL_CFLAGS := -Werror
-include $(BUILD_STATIC_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := simg2img.c \
-	sparse_crc32.c
-LOCAL_MODULE := simg2img_host
-# Need a unique module name, but exe should still be called simg2img
-LOCAL_MODULE_STEM := simg2img
-LOCAL_STATIC_LIBRARIES := \
-    libsparse_host \
-    libz
-LOCAL_CFLAGS := -Werror
-include $(BUILD_HOST_EXECUTABLE)
-
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := simg2img.c \
-	sparse_crc32.c
-LOCAL_MODULE := simg2img
-LOCAL_STATIC_LIBRARIES := \
-    libsparse_static \
-    libz
-LOCAL_CFLAGS := -Werror
-include $(BUILD_EXECUTABLE)
-
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := img2simg.c
-LOCAL_MODULE := img2simg_host
-# Need a unique module name, but exe should still be called simg2img
-LOCAL_MODULE_STEM := img2simg
-LOCAL_STATIC_LIBRARIES := \
-    libsparse_host \
-    libz
-LOCAL_CFLAGS := -Werror
-include $(BUILD_HOST_EXECUTABLE)
-
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := img2simg.c
-LOCAL_MODULE := img2simg
-LOCAL_STATIC_LIBRARIES := \
-    libsparse_static \
-    libz
-LOCAL_CFLAGS := -Werror
-include $(BUILD_EXECUTABLE)
-
-
-ifneq ($(HOST_OS),windows)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := append2simg.c
-LOCAL_MODULE := append2simg
-LOCAL_STATIC_LIBRARIES := \
-    libsparse_host \
-    libz
-LOCAL_CFLAGS := -Werror
-include $(BUILD_HOST_EXECUTABLE)
-
-endif
-
 include $(CLEAR_VARS)
 LOCAL_MODULE := simg_dump.py
 LOCAL_SRC_FILES := simg_dump.py