[PATCH v1 1/2] Add android build target to build erofs as library
Kelvin Zhang
zhangkelvin at google.com
Tue Nov 30 14:01:54 AEDT 2021
Signed-off-by: Kelvin Zhang <zhangkelvin at google.com>
---
Android.bp | 38 ++++++++++++++++++++++++++++++++++++--
include/erofs/defs.h | 5 +++++
2 files changed, 41 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,
diff --git a/include/erofs/defs.h b/include/erofs/defs.h
index 6398cbb..1ba920d 100644
--- a/include/erofs/defs.h
+++ b/include/erofs/defs.h
@@ -82,11 +82,16 @@ typedef int64_t s64;
#endif
#endif
+#ifdef __cplusplus
+#define BUILD_BUG_ON(condition) static_assert(!(condition))
+#else
+
#ifndef __OPTIMIZE__
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))
#else
#define BUILD_BUG_ON(condition) assert(!(condition))
#endif
+#endif
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
--
2.34.0.rc2.393.gf8c9666880-goog
More information about the Linux-erofs
mailing list