Add baremetal _nostd variant
Note that product_available and vendor_available are dropped from the
existing target because they are irrelevant for a _host target (as per
the change in aosp/2763825).
Add a visibility restriction to the new variant to preserve the
limitation that this crate should not be used in general Android code.
Bug: 303192701
Test: build both variants
Change-Id: I7bceaf8dbb593b1cb9a3ae6071d46870b28f351a
diff --git a/Android.bp b/Android.bp
index 58b77bf..1a07941 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,6 +25,31 @@
cargo_pkg_version: "0.4.3",
srcs: ["src/lib.rs"],
edition: "2018",
+}
+
+rust_library_rlib {
+ name: "libflagset_nostd",
+ crate_name: "flagset",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.4.3",
+ srcs: ["src/lib.rs"],
+ edition: "2018",
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.virt",
+ ],
+ prefer_rlib: true,
+ no_stdlibs: true,
+ stdlibs: [
+ "libcompiler_builtins.rust_sysroot",
+ "libcore.rust_sysroot",
+ ],
product_available: true,
vendor_available: true,
+ visibility: [
+ "//external/rust/crates/der:__subpackages__",
+ "//external/rust/crates/x509-cert:__subpackages__",
+ "//system/keymint:__subpackages__",
+ ]
+ ,
}
diff --git a/cargo2android.json b/cargo2android.json
index 72a9a5a..dcfd6f1 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -4,5 +4,18 @@
"com.android.virt"
],
"run": true,
- "vendor-available": true
+ "vendor-available": true,
+ "variants": [
+ {
+ },
+ {
+ "device": true,
+ "no-host": true,
+ "add-module-block": "cargo2android_viz.bp",
+ "dependency_suffix": "_nostd",
+ "force-rlib": true,
+ "suffix": "_nostd",
+ "no-std": true
+ }
+ ]
}
diff --git a/cargo2android_viz.bp b/cargo2android_viz.bp
new file mode 100644
index 0000000..f527f60
--- /dev/null
+++ b/cargo2android_viz.bp
@@ -0,0 +1,5 @@
+visibility: [
+ "//external/rust/crates/der:__subpackages__",
+ "//external/rust/crates/x509-cert:__subpackages__",
+ "//system/keymint:__subpackages__",
+]