All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kelvin Zhang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs mailing list <linux-erofs@lists.ozlabs.org>,
	Miao Xie <miaoxie@huawei.com>, Fang Wei <fangwei1@huawei.com>
Cc: Kelvin Zhang <zhangkelvin@google.com>
Subject: [PATCH v1 1/2] Add android build target to build erofs as library
Date: Mon, 29 Nov 2021 19:01:54 -0800	[thread overview]
Message-ID: <20211130030155.2804358-2-zhangkelvin@google.com> (raw)
In-Reply-To: <20211130030155.2804358-1-zhangkelvin@google.com>

Signed-off-by: Kelvin Zhang <zhangkelvin@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


  reply	other threads:[~2021-11-30  3:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  3:01 [PATCH v1 0/2] Cosmetic changes to erofs-utils Kelvin Zhang via Linux-erofs
2021-11-30  3:01 ` Kelvin Zhang via Linux-erofs [this message]
2021-11-30  3:01 ` [PATCH v1 2/2] Make erofs-utils more C++ friendly Kelvin Zhang via Linux-erofs
2021-11-30  3:18 ` [PATCH v1 0/2] Cosmetic changes to erofs-utils Gao Xiang
2021-11-30  3:25   ` [PATCH v2 1/2] erofs-utils: Add android build target to build erofs as library Kelvin Zhang via Linux-erofs
2021-11-30  3:25     ` [PATCH v2 2/2] erofs-utils: Make erofs-utils more C++ friendly Kelvin Zhang via Linux-erofs
2021-11-30  5:23       ` Gao Xiang
2021-11-30  5:56   ` [PATCH v3 1/2] erofs-utils: Add android build target to build erofs as library Kelvin Zhang via Linux-erofs
2021-11-30  5:56     ` [PATCH v3 2/2] erofs-utils: Make erofs-utils more C++ friendly Kelvin Zhang via Linux-erofs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211130030155.2804358-2-zhangkelvin@google.com \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=fangwei1@huawei.com \
    --cc=miaoxie@huawei.com \
    --cc=zhangkelvin@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.