Generate rules.mk for libc via cargo_embargo
Update cargo_embargo.json to also generate Trusty rules.mk for use
in the Trusty kernel. patches/rules.mk.diff also updated to obtain
the desired makefile rules.
Test: cargo_embargo generate cargo_embargo.json
Change-Id: I8516b3d7edfe9e89d416c8a26168a951f4b7e424
diff --git a/crates/libc/cargo_embargo.json b/crates/libc/cargo_embargo.json
index fde4fff..a7537e1 100644
--- a/crates/libc/cargo_embargo.json
+++ b/crates/libc/cargo_embargo.json
@@ -5,5 +5,25 @@
"std"
],
"min_sdk_version": "29",
- "tests": true
+ "tests": true,
+ "package": {
+ "libc": {
+ "rulesmk_patch": "patches/rules.mk.diff"
+ }
+ },
+ "variants": [
+ {},
+ {
+ "package": {
+ "libc": {
+ "no_std": true
+ }
+ },
+ "features": [],
+ "tests": false,
+ "generate_androidbp": false,
+ "generate_rulesmk": true,
+ "run_cargo": false
+ }
+ ]
}
diff --git a/crates/libc/patches/rules.mk.diff b/crates/libc/patches/rules.mk.diff
index e9ebe30..4370994 100644
--- a/crates/libc/patches/rules.mk.diff
+++ b/crates/libc/patches/rules.mk.diff
@@ -1,17 +1,32 @@
-diff --git a/rules.mk b/rules.mk
-index b2ae04d7..0cd09394 100644
+diff --git a/rules.mk b/rules.desired.mk
+index 4ca7b4d..e2f63f2 100644
--- a/rules.mk
-+++ b/rules.mk
-@@ -24,5 +24,21 @@ MODULE_RUSTFLAGS += \
- --cfg 'libc_ptr_addr_of' \
- --cfg 'libc_underscore_const_names' \
- --cfg 'libc_union' \
++++ b/rules.desired.mk
+@@ -10,8 +10,36 @@ MODULE_RUST_CRATE_TYPES := rlib
+ MODULE_SRCS := $(LOCAL_DIR)/src/lib.rs
+ MODULE_ADD_IMPLICIT_DEPS := false
+ MODULE_RUST_EDITION := 2015
++MODULE_RUSTFLAGS += \
++ --cfg 'freebsd11' \
++ --cfg 'libc_align' \
++ --cfg 'libc_cfg_target_vendor' \
++ --cfg 'libc_const_extern_fn' \
++ --cfg 'libc_const_size_of' \
++ --cfg 'libc_core_cvoid' \
++ --cfg 'libc_int128' \
++ --cfg 'libc_long_array' \
++ --cfg 'libc_non_exhaustive' \
++ --cfg 'libc_packedN' \
++ --cfg 'libc_priv_mod_use' \
++ --cfg 'libc_ptr_addr_of' \
++ --cfg 'libc_underscore_const_names' \
++ --cfg 'libc_union' \
+ -A unknown-lints \
+
-+MODULE_LIBRARY_DEPS := \
-+ trusty/user/base/lib/libcompiler_builtins-rust \
-+ trusty/user/base/lib/libcore-rust \
-+
+ MODULE_LIBRARY_DEPS := \
+ trusty/user/base/lib/libcompiler_builtins-rust \
+ trusty/user/base/lib/libcore-rust
+
+ifeq ($(call TOBOOL,$(TRUSTY_USERSPACE)),true)
+
+MODULE_RUSTFLAGS += \
@@ -22,5 +37,5 @@
+ trusty/user/base/lib/trusty-sys \
+
+endif
-
++
include make/library.mk
diff --git a/crates/libc/rules.mk b/crates/libc/rules.mk
index 0cd0939..e2f63f2 100644
--- a/crates/libc/rules.mk
+++ b/crates/libc/rules.mk
@@ -1,12 +1,13 @@
-# This file is generated by cargo2rulesmk.py --run --config cargo2rulesmk.json.
-# Do not modify this file as changes will be overridden on upgrade.
+# This file is generated by cargo_embargo.
+# Do not modify this file after the LOCAL_DIR line
+# because the changes will be overridden on upgrade.
+# Content before the first line starting with LOCAL_DIR is preserved.
LOCAL_DIR := $(GET_LOCAL_DIR)
MODULE := $(LOCAL_DIR)
MODULE_CRATE_NAME := libc
-MODULE_SRCS := \
- $(LOCAL_DIR)/src/lib.rs \
-
+MODULE_RUST_CRATE_TYPES := rlib
+MODULE_SRCS := $(LOCAL_DIR)/src/lib.rs
MODULE_ADD_IMPLICIT_DEPS := false
MODULE_RUST_EDITION := 2015
MODULE_RUSTFLAGS += \
@@ -28,7 +29,7 @@
MODULE_LIBRARY_DEPS := \
trusty/user/base/lib/libcompiler_builtins-rust \
- trusty/user/base/lib/libcore-rust \
+ trusty/user/base/lib/libcore-rust
ifeq ($(call TOBOOL,$(TRUSTY_USERSPACE)),true)