[PATCH v2 1/2] erofs-utils: Add android build target to build erofs as library

Kelvin Zhang zhangkelvin at google.com
Tue Nov 30 14:25:45 AEDT 2021


Change-Id: I648ae5707ec94b0b5a13781dc22e2c47d488cb83
Signed-off-by: Kelvin Zhang <zhangkelvin at google.com>
---
 Android.bp | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/Android.bp b/Android.bp
index fc84e6e..7973555 100644
--- a/Android.bp
+++ b/Android.bp
@@ -52,7 +52,7 @@ genrule {
 }
 
 cc_defaults {
-    name: "erofs-utils_defaults",
+    name: "erofs-utils_export_defaults",
 
     cflags: [
         "-Wall",
@@ -60,7 +60,7 @@ cc_defaults {
         "-Wno-ignored-qualifiers",
         "-Wno-pointer-arith",
         "-Wno-unused-parameter",
-        "-include erofs-utils-version.h",
+        "-Wno-unused-function",
         "-DHAVE_FALLOCATE",
         "-DHAVE_LINUX_TYPES_H",
         "-DHAVE_LIBSELINUX",
@@ -69,6 +69,15 @@ cc_defaults {
         "-DLZ4HC_ENABLED",
         "-DWITH_ANDROID",
     ],
+}
+
+cc_defaults {
+    name: "erofs-utils_defaults",
+    defaults: ["erofs-utils_export_defaults"],
+
+    cflags: [
+        "-include erofs-utils-version.h",
+    ],
     local_include_dirs: [
         "include",
     ],
@@ -86,6 +95,22 @@ cc_defaults {
     ],
 }
 
+cc_library {
+    host_supported: true,
+    name: "liberofs",
+    defaults: ["erofs-utils_defaults"],
+    srcs: [
+        "lib/*.c",
+    ],
+    export_include_dirs: ["include"],
+
+    target: {
+        darwin: {
+            enabled: false,
+        },
+    },
+}
+
 cc_defaults {
     name: "mkfs-erofs_defaults",
 
@@ -95,6 +120,9 @@ cc_defaults {
         "lib/*.c",
         "mkfs/*.c",
     ],
+    static_libs: [
+        "liberofs",
+    ],
 
     target: {
         darwin: {
@@ -122,6 +150,9 @@ cc_binary_host {
         "lib/*.c",
         "dump/*.c",
     ],
+    static_libs: [
+        "liberofs",
+    ],
     target: {
         darwin: {
             enabled: false,
@@ -136,6 +167,9 @@ cc_binary_host {
         "lib/*.c",
         "fsck/*.c",
     ],
+    static_libs: [
+        "liberofs",
+    ],
     target: {
         darwin: {
             enabled: false,
-- 
2.34.0.rc2.393.gf8c9666880-goog



More information about the Linux-erofs mailing list