aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Mayle <fmayle@google.com>2022-04-16 01:23:34 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-16 01:23:34 +0000
commit90032986e5407450c69e2116f271a684b509206d (patch)
tree7c4f13116f1e65927321fcebaab6de4b0b9c79bb
parent1a7a791dce1d1a59524116f0a5ed5c9a45bde665 (diff)
parent963301122e2177682ce2aab69914b285a5462c0f (diff)
downloadcrosvm-90032986e5407450c69e2116f271a684b509206d.tar.gz
Merge "all2android.sh enhancements" am: cb5b9fdccb am: 8a267bd6aa am: cb0516a22f am: 963301122e
Original change: https://android-review.googlesource.com/c/platform/external/crosvm/+/2064639 Change-Id: I9edb2c9899357e875a16a71b172d2e5b9a1d028e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rwxr-xr-xall2android.sh53
-rw-r--r--crosvm-fuzz/cargo2android.json1
-rw-r--r--integration_tests/cargo2android.json1
-rwxr-xr-xrun_c2a.sh40
-rw-r--r--rutabaga_gfx/src/rutabaga_gralloc/cargo2android.json1
5 files changed, 45 insertions, 51 deletions
diff --git a/all2android.sh b/all2android.sh
index 004d27229..229086f99 100755
--- a/all2android.sh
+++ b/all2android.sh
@@ -1,56 +1,7 @@
#!/bin/bash
-# Convenience script to run cargo2android.py with the appropriate arguments in the crosvm directory
-# and all subdirectories with Cargo.toml files.
+# Run cargo2android.py for every crate in crosvm.
set -e
-if ! [ -x "$(command -v bpfmt)" ]; then
- echo 'Error: bpfmt not found.' >&2
- exit 1
-fi
-
-cargo2android() {
- local C2A=${C2A:-cargo2android.py}
- echo "Using $C2A to run this script."
-
- # Some crates need special options to cargo2android.py, if there's a config file then use it.
- if [[ -f "cargo2android.json" ]]; then
- $C2A --config cargo2android.json
- else
- $C2A --run --device --tests $@
- fi
- bpfmt -w Android.bp || /bin/true
- rm -f cargo.out
- rm -rf target.tmp || /bin/true
-}
-
-# Run in the main crosvm directory.
-cargo2android --no-subdir
-
-initial_dir=`pwd`
-for dir in */src common/*/src third_party/*/src
-do
- base=`dirname $dir`
- echo "$base"
- cd "$base"
- # If the subdirectory has more subdirectories with crates, then pass --no-subdir and run it in
- # each of them too.
- if compgen -G "*/Cargo.toml" > /dev/null
- then
- cargo2android --global_defaults=crosvm_defaults --add_workspace --no-subdir
-
- for dir in */Cargo.toml
- do
- sub_base=`dirname $dir`
- echo "$base/$sub_base"
- cd "$sub_base"
- cargo2android --global_defaults=crosvm_defaults --add_workspace
- cd ..
- done
- else
- cargo2android --global_defaults=crosvm_defaults --add_workspace
- fi
-
- cd "$initial_dir"
-done
+find . -type f -name Cargo.toml | xargs dirname | sort | xargs -L1 ./run_c2a.sh
diff --git a/crosvm-fuzz/cargo2android.json b/crosvm-fuzz/cargo2android.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/crosvm-fuzz/cargo2android.json
@@ -0,0 +1 @@
+{}
diff --git a/integration_tests/cargo2android.json b/integration_tests/cargo2android.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/integration_tests/cargo2android.json
@@ -0,0 +1 @@
+{}
diff --git a/run_c2a.sh b/run_c2a.sh
new file mode 100755
index 000000000..5140545d9
--- /dev/null
+++ b/run_c2a.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Run cargo2android.py with the appropriate arguments for the crate in the
+# supplied directory.
+
+set -e
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: $0 CRATE_DIRECTORY"
+ exit 1
+fi
+cd $1
+
+if ! [ -x "$(command -v bpfmt)" ]; then
+ echo 'Error: bpfmt not found.' >&2
+ exit 1
+fi
+
+C2A_ARGS=""
+if [[ -f "cargo2android.json" ]]; then
+ # If the crate has a cargo2android config, let it handle all the flags.
+ C2A_ARGS+=" --config cargo2android.json"
+else
+ # Otherwise, set common flags.
+ C2A_ARGS+=" --run --device --tests --global_defaults=crosvm_defaults --add_workspace"
+ # If there are subdirectories with crates, then pass --no-subdir.
+ if [ -n "$(find . -mindepth 2 -name "Cargo.toml")" ]; then
+ C2A_ARGS+=" --no-subdir"
+ fi
+fi
+
+C2A=${C2A:-cargo2android.py}
+echo "Using $C2A to run this script."
+$C2A $C2A_ARGS
+rm -f cargo.out
+rm -rf target.tmp || /bin/true
+
+if [[ -f "Android.bp" ]]; then
+ bpfmt -w Android.bp || /bin/true
+fi
diff --git a/rutabaga_gfx/src/rutabaga_gralloc/cargo2android.json b/rutabaga_gfx/src/rutabaga_gralloc/cargo2android.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/rutabaga_gfx/src/rutabaga_gralloc/cargo2android.json
@@ -0,0 +1 @@
+{}