Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify javabin path resolution #152

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions rules/android_local_test/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = javabase.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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove _runfiles_root_prefix as well but I suspect it will break internal tests if it's being used.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take care of it.

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%": "",
}
Expand Down
6 changes: 3 additions & 3 deletions test/rules/android_local_test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}),
)
6 changes: 3 additions & 3 deletions test/rules/android_local_test/integration_test_stub_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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