Skip to content

Commit

Permalink
Clean up Android test jars
Browse files Browse the repository at this point in the history
This step is

1) Building files in /tmp which isn't desirable, we should use the
   output dir
2) Dirtying the inputs every time the script runs, causing
   unnecessary rebuilds.
3) Not integrated with the bootstrap which is the expected place
   to run setup steps.

These "prebuilt" test jars are smaller than most C++ sources. Just check
them in and remove this extra step.

After we get the expected "No work to do" from ninja the second time an
Android build is run.
  • Loading branch information
mspang committed Apr 26, 2022
1 parent 6c54ab8 commit 93a2b3a
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 60 deletions.
4 changes: 2 additions & 2 deletions build/chip/java/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ java_library("grandchild_library") {
}

java_prebuilt("java_prebuilt") {
jar_path = "/tmp/chip_java_build_test/prebuilt_jar.jar"
jar_path = "prebuilt_jar.jar"
deps = [ ":child_prebuilt" ]
}

java_prebuilt("child_prebuilt") {
jar_path = "/tmp/chip_java_build_test/child_jar.jar"
jar_path = "child_jar.jar"
}
Binary file added build/chip/java/tests/child_jar.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion build/chip/java/tests/generate_jars_for_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def generateJar(source_file, output_name):
'python3',
chip_root + '/build/chip/java/jar_runner.py',
'cf',
tmp_dir + '/' + output_name,
test_dir + '/' + output_name,
'-C',
tmp_classes_dir,
'.',
Expand Down
Binary file added build/chip/java/tests/prebuilt_jar.jar
Binary file not shown.
5 changes: 1 addition & 4 deletions build/chip/java/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
# limitations under the License.

"""
Test for GN Java build rules. This test should be executed using ninja, and
generate_jars_for_test.py should have been called before running this test.
Test for GN Java build rules. This test should be executed using ninja.
"""

import json
Expand All @@ -33,8 +32,6 @@ class JavaBuildTest(unittest.TestCase):
jars_dir = 'python/lib' + local_test_dir
configs_dir = 'python/gen' + local_test_dir

tmp_dir = '/tmp/chip_java_build_test'

# Target names in the BUILD.gn
targets_to_check = [
'java_library',
Expand Down
1 change: 0 additions & 1 deletion gn_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ for arg; do
done

# Android prebuilt JAR setup
python3 build/chip/java/tests/generate_jars_for_test.py
python3 third_party/android_deps/set_up_android_deps.py

# Android SDK setup
Expand Down
4 changes: 0 additions & 4 deletions scripts/build/builders/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,6 @@ def gradlewBuildExampleAndroid(self):
title='Building Example ' + self.identifier)

def generate(self):
self._Execute([
'python3', 'build/chip/java/tests/generate_jars_for_test.py'
], title='Generating JARs for Java build rules test')

self._Execute([
'python3', 'third_party/android_deps/set_up_android_deps.py'
], title='Setting up Android deps through Gradle')
Expand Down
45 changes: 0 additions & 45 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ bash -c '$AMEBA_PATH/project/realtek_amebaD_va0_example/GCC-RELEASE/build.sh {ro
# Generating ameba-amebad-pigweed
bash -c '$AMEBA_PATH/project/realtek_amebaD_va0_example/GCC-RELEASE/build.sh -r {root} ninja {out}/ameba-amebad-pigweed pigweed-app'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -22,9 +19,6 @@ gn gen --check --fail-on-unused-args {out}/android-androidstudio-arm-chip-tool '
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -34,9 +28,6 @@ gn gen --check --fail-on-unused-args {out}/android-androidstudio-arm64-chip-tool
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -46,9 +37,6 @@ gn gen --check --fail-on-unused-args {out}/android-androidstudio-x64-chip-tool '
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -58,9 +46,6 @@ gn gen --check --fail-on-unused-args {out}/android-androidstudio-x86-chip-tool '
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -70,9 +55,6 @@ gn gen --check --fail-on-unused-args {out}/android-arm-chip-tool '--args=target_
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -82,9 +64,6 @@ gn gen --check --fail-on-unused-args {out}/android-arm-chip-tv-casting-app '--ar
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -94,9 +73,6 @@ gn gen --check --fail-on-unused-args {out}/android-arm-chip-tvserver '--args=tar
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -106,9 +82,6 @@ gn gen --check --fail-on-unused-args {out}/android-arm64-chip-test '--args=targe
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -118,9 +91,6 @@ gn gen --check --fail-on-unused-args {out}/android-arm64-chip-tool '--args=targe
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -130,9 +100,6 @@ gn gen --check --fail-on-unused-args {out}/android-arm64-chip-tv-casting-app '--
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -142,9 +109,6 @@ gn gen --check --fail-on-unused-args {out}/android-arm64-chip-tvserver '--args=t
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -154,9 +118,6 @@ gn gen --check --fail-on-unused-args {out}/android-x64-chip-tool '--args=target_
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -166,9 +127,6 @@ gn gen --check --fail-on-unused-args {out}/android-x64-chip-tvserver '--args=tar
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand All @@ -178,9 +136,6 @@ gn gen --check --fail-on-unused-args {out}/android-x86-chip-tool '--args=target_
# Accepting NDK licenses @ tools
bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null'

# Generating JARs for Java build rules test
python3 build/chip/java/tests/generate_jars_for_test.py

# Setting up Android deps through Gradle
python3 third_party/android_deps/set_up_android_deps.py

Expand Down
1 change: 0 additions & 1 deletion scripts/examples/android_app_ide.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ fi
source scripts/activate.sh

# Set up JARs
python3 build/chip/java/tests/generate_jars_for_test.py
python3 third_party/android_deps/set_up_android_deps.py

# Build CMake for Android Studio
Expand Down
2 changes: 0 additions & 2 deletions scripts/examples/gn_android_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ if [ -z "$TARGET_CPU" ]; then
exit 1
fi

# Set up JARs
python3 "$(dirname "$0")"/../../build/chip/java/tests/generate_jars_for_test.py
python3 "$(dirname "$0")"/../../third_party/android_deps/set_up_android_deps.py

gn gen --check --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="target_os=\"android\" target_cpu=\"$TARGET_CPU\" android_ndk_root=\"$ANDROID_NDK_HOME\" android_sdk_root=\"$ANDROID_HOME\" ${GN_ARGS[*]}"
Expand Down

0 comments on commit 93a2b3a

Please sign in to comment.