From eb526c4b7f7053fcf035ad4fb59afbf8a34e7a04 Mon Sep 17 00:00:00 2001 From: Ben Lee Date: Fri, 29 Sep 2023 14:28:44 -0700 Subject: [PATCH 1/4] Simplify javabin path resolution https://github.com/bazelbuild/rules_android/issues/151 --- rules/android_local_test/impl.bzl | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/rules/android_local_test/impl.bzl b/rules/android_local_test/impl.bzl index 3a6221fd..70fe43dc 100644 --- a/rules/android_local_test/impl.bzl +++ b/rules/android_local_test/impl.bzl @@ -255,21 +255,11 @@ def _process_deploy_jar(ctx, java_package, jvm_ctx, proto_ctx, resources_ctx, ** def _preprocess_stub(ctx, **_unused_sub_ctxs): javabase = ctx.attr._current_java_runtime[java_common.JavaRuntimeInfo] - java_executable = str(javabase.java_executable_runfiles_path) + java_executable = ctx.attr._java_runtime[java_common.JavaRuntimeInfo].java_executable_exec_path java_executable_files = javabase.files - # Absolute java_executable does not require any munging - if java_executable.startswith("/"): - java_executable = "JAVABIN=" + java_executable - - prefix = ctx.attr._runfiles_root_prefix[BuildSettingInfo].value - if not java_executable.startswith(prefix): - java_executable = prefix + java_executable - - java_executable = "JAVABIN=${JAVABIN:-${JAVA_RUNFILES}/" + java_executable + "}" - substitutes = { - "%javabin%": java_executable, + "%javabin%": "JAVABIN=" + java_executable, "%load_lib%": "", "%set_ASAN_OPTIONS%": "", } From 5342693c4b68e6d67b316969794641c7d274e4fb Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Fri, 6 Oct 2023 10:04:41 -0700 Subject: [PATCH 2/4] Fix --- rules/android_local_test/impl.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/android_local_test/impl.bzl b/rules/android_local_test/impl.bzl index 70fe43dc..ca3a47f4 100644 --- a/rules/android_local_test/impl.bzl +++ b/rules/android_local_test/impl.bzl @@ -255,7 +255,7 @@ def _process_deploy_jar(ctx, java_package, jvm_ctx, proto_ctx, resources_ctx, ** def _preprocess_stub(ctx, **_unused_sub_ctxs): javabase = ctx.attr._current_java_runtime[java_common.JavaRuntimeInfo] - java_executable = ctx.attr._java_runtime[java_common.JavaRuntimeInfo].java_executable_exec_path + java_executable = ctx.attr._current_java_runtime[java_common.JavaRuntimeInfo].java_executable_exec_path java_executable_files = javabase.files substitutes = { From 6abc4879fff3e84bc205eef9fe9969418b8b59f2 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Fri, 6 Oct 2023 10:05:41 -0700 Subject: [PATCH 3/4] Simplify --- rules/android_local_test/impl.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/android_local_test/impl.bzl b/rules/android_local_test/impl.bzl index ca3a47f4..7d4c1e9f 100644 --- a/rules/android_local_test/impl.bzl +++ b/rules/android_local_test/impl.bzl @@ -255,7 +255,7 @@ def _process_deploy_jar(ctx, java_package, jvm_ctx, proto_ctx, resources_ctx, ** def _preprocess_stub(ctx, **_unused_sub_ctxs): javabase = ctx.attr._current_java_runtime[java_common.JavaRuntimeInfo] - java_executable = ctx.attr._current_java_runtime[java_common.JavaRuntimeInfo].java_executable_exec_path + java_executable = javabase.java_executable_exec_path java_executable_files = javabase.files substitutes = { From c75235be6df2d760d49c423595663aca165ad49c Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Mon, 9 Oct 2023 17:02:50 -0700 Subject: [PATCH 4/4] Tests --- test/rules/android_local_test/BUILD | 6 +++--- .../android_local_test/integration_test_stub_script.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/rules/android_local_test/BUILD b/test/rules/android_local_test/BUILD index 05850157..9020285d 100644 --- a/test/rules/android_local_test/BUILD +++ b/test/rules/android_local_test/BUILD @@ -88,9 +88,9 @@ android_local_test_launcher_test_suite( android_local_test_launcher_integration_test_suite( name = "android_local_test_launcher_integration_tests", expected_executable = select({ - ":jdk17_linux": "rules_android/../remotejdk17_linux/bin/java", - ":jdk17_macos": "rules_android/../remotejdk17_macos/bin/java", - ":jdk17_macos_aarch64": "rules_android/../remotejdk17_macos_aarch64/bin/java", + ":jdk17_linux": "external/remotejdk17_linux/bin/java", + ":jdk17_macos": "external/remotejdk17_macos/bin/java", + ":jdk17_macos_aarch64": "external/remotejdk17_macos_aarch64/bin/java", "//conditions:default": "rules_android/third_party/java/jdk/jdk-sts-k8/bin/java", }), ) diff --git a/test/rules/android_local_test/integration_test_stub_script.sh b/test/rules/android_local_test/integration_test_stub_script.sh index 9f836f22..0881c9fe 100644 --- a/test/rules/android_local_test/integration_test_stub_script.sh +++ b/test/rules/android_local_test/integration_test_stub_script.sh @@ -14,11 +14,11 @@ # limitations under the License. exit_with_error() { - echo "Expected to find JAVABIN=\${JAVABIN:-\${JAVA_RUNFILES}/%expected_executable% but was" + echo "Expected to find JAVABIN=%expected_executable% but was" echo $reference exit 1 } executable="%executable%" -reference=`grep -o 'JAVABIN=\\${JAVABIN:-\\${JAVA_RUNFILES}/.*}' $executable` -grep -c "JAVABIN:-\${JAVA_RUNFILES}/%expected_executable%" $executable >> /dev/null || exit_with_error +reference=`grep -o '^JAVABIN=.*' $executable` +grep -c "^JAVABIN=%expected_executable%$" $executable >> /dev/null || exit_with_error \ No newline at end of file