aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2020-10-30 16:11:02 -0700
committerChih-Hung Hsieh <chh@google.com>2020-11-02 02:54:49 -0800
commitb89665d2df35118bea9db3455fac8d3d68d6dd2c (patch)
tree02a80a842c7d0c33635a82bd78c39c22bf2b4d34
parent821d8c6ee13a8767e5f216418d7a7bd5780a1f6e (diff)
downloadunicode-xid-b89665d2df35118bea9db3455fac8d3d68d6dd2c.tar.gz
Use cargo2android.py with a patch file.
* No need to manually fix the .bp file after a version upgrade. * Clean up post_update.sh * Add the missing patch for src/lib.rs. * Fix a rustc warning with the patch in src/lib.rs. Bug: 172093078 Test: make and regenerate .bp Change-Id: Ifa32265fa0e69dcef206be6b59d656793b12f7ec
-rw-r--r--Android.bp15
-rw-r--r--patches/Android.bp.patch24
-rw-r--r--patches/std.diff16
-rwxr-xr-xpost_update.sh2
-rw-r--r--src/lib.rs2
5 files changed, 45 insertions, 14 deletions
diff --git a/Android.bp b/Android.bp
index 721b163..97a1490 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,4 @@
-// This file is generated by cargo2android.py --run --device --tests --dependencies.
-// For test converage, override some properties in device test modules.
+// This file is generated by cargo2android.py --run --device --tests --dependencies --patch=patches/Android.bp.patch.
rust_library {
name: "libunicode_xid",
@@ -7,9 +6,7 @@ rust_library {
crate_name: "unicode_xid",
srcs: ["src/lib.rs"],
edition: "2015",
- features: [
- "default",
- ],
+ features: ["default"],
}
rust_defaults {
@@ -19,9 +16,7 @@ rust_defaults {
test_suites: ["general-tests"],
auto_gen_config: true,
edition: "2015",
- features: [
- "default",
- ],
+ features: ["default"],
}
rust_test_host {
@@ -45,9 +40,7 @@ rust_defaults {
test_suites: ["general-tests"],
auto_gen_config: true,
edition: "2015",
- features: [
- "default",
- ],
+ features: ["default"],
rustlibs: [
"libunicode_xid",
],
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
new file mode 100644
index 0000000..d214303
--- /dev/null
+++ b/patches/Android.bp.patch
@@ -0,0 +1,24 @@
+diff --git b/Android.bp a/Android.bp
+index b2cef8e..721b163 100644
+--- b/Android.bp
++++ a/Android.bp
+@@ -29,6 +29,10 @@ rust_test_host {
+ rust_test {
+ name: "unicode-xid_device_test_src_lib",
+ defaults: ["unicode-xid_defaults"],
++ // override the following properties to work with coverage tests
++ test_suites: ["device-tests"],
++ auto_gen_config: false,
++ test_config: "AndroidTest.xml",
+ }
+
+ rust_defaults {
+@@ -53,4 +57,8 @@ rust_test_host {
+ rust_test {
+ name: "unicode-xid_device_test_tests_exhaustive_tests",
+ defaults: ["unicode-xid_defaults_exhaustive_tests"],
++ // override the following properties to work with coverage tests
++ test_suites: ["device-tests"],
++ auto_gen_config: false,
++ test_config: "AndroidTest_exhaustive_tests.xml",
+ }
diff --git a/patches/std.diff b/patches/std.diff
new file mode 100644
index 0000000..73141c0
--- /dev/null
+++ b/patches/std.diff
@@ -0,0 +1,16 @@
+diff --git a/src/lib.rs b/src/lib.rs
+index 01c81e2..927fc9a 100644
+--- a/src/lib.rs
++++ b/src/lib.rs
+@@ -37,8 +37,9 @@
+ #![no_std]
+ #![cfg_attr(feature = "bench", feature(test, unicode_internals))]
+
+-#[cfg(test)]
+-#[macro_use]
++// #[cfg(test)]
++// ANDROID: Unconditionally use std to allow building as a dylib.
++// #[macro_use]
+ extern crate std;
+
+ #[cfg(feature = "bench")]
diff --git a/post_update.sh b/post_update.sh
index c007670..3a3ae24 100755
--- a/post_update.sh
+++ b/post_update.sh
@@ -8,5 +8,3 @@ set -e
# copy old test xml config files.
cp -a -n $2/AndroidTest*.xml $1/
-
-# TODO: fix up Android.bp
diff --git a/src/lib.rs b/src/lib.rs
index 9820a6f..927fc9a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,7 +39,7 @@
// #[cfg(test)]
// ANDROID: Unconditionally use std to allow building as a dylib.
-#[macro_use]
+// #[macro_use]
extern crate std;
#[cfg(feature = "bench")]