Skip to content

Commit

Permalink
Make the embedded JDK targets the default
Browse files Browse the repository at this point in the history
Closes bazelbuild#5403.

PiperOrigin-RevId: 201007405
  • Loading branch information
cushon authored and Copybara-Service committed Jun 18, 2018
1 parent 29a7e05 commit 7c49bd9
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ display "."
log "Building output/bazel"
# We set host and target platform directly since the defaults in @bazel_tools
# have not yet been generated.
bazel_build "src:bazel${EXE_EXT}" \
bazel_build "src:bazel_nojdk${EXE_EXT}" \
--host_platform=@bazel_tools//platforms:host_platform \
--platforms=@bazel_tools//platforms:target_platform \
|| fail "Could not build Bazel"
bazel_bin_path="$(get_bazel_bin_path)/src/bazel${EXE_EXT}"
bazel_bin_path="$(get_bazel_bin_path)/src/bazel_nojdk${EXE_EXT}"
[ -e "$bazel_bin_path" ] \
|| fail "Could not find freshly built Bazel binary at '$bazel_bin_path'"
cp -f "$bazel_bin_path" "output/bazel${EXE_EXT}" \
Expand Down
4 changes: 2 additions & 2 deletions scripts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ genrule(
outs = ["bazel-complete.bash"],
cmd = " ".join([
"$(location :generate_bash_completion.sh)",
"--bazel=$(location //src:bazel_with_jdk)",
"--bazel=$(location //src:bazel)",
"--output=$@",
"--prepend=$(location bazel-complete-template.bash)",
]),
output_to_bindir = 1,
tools = [
":generate_bash_completion.sh",
"//src:bazel_with_jdk",
"//src:bazel",
],
visibility = ["//scripts/packages:__subpackages__"],
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/packages/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ genrule(

genrule(
name = "rename-bazel-bin",
srcs = ["//src:bazel_with_jdk"],
srcs = ["//src:bazel"],
outs = ["with-jdk/bazel-real"],
cmd = "mkdir -p $$(dirname $@); cp $< $@",
)
Expand Down
24 changes: 12 additions & 12 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ filegroup(
}),
) for suffix, embedded_tools_target in {
"": [":embedded_tools"],
"_with_jdk": [":embedded_tools_with_jdk"],
"_nojdk": [":embedded_tools_nojdk"],
"_notools": [],
}.items()]

Expand Down Expand Up @@ -173,13 +173,13 @@ py_binary(
"//conditions:default": [
"//src/tools/singlejar:singlejar",
],
}) + ([":embedded_jdk"] if (suffix == "_with_jdk") else []),
}) + ([":embedded_jdk"] if (suffix == "") else []),
visibility = [
"//src/test:__subpackages__", # For integration tests
],
) for suffix in [
"",
"_with_jdk",
"_nojdk",
]]

filegroup(
Expand Down Expand Up @@ -207,7 +207,7 @@ filegroup(
out = "embedded_tools" + suffix + ".params",
) for suffix in [
"",
"_with_jdk",
"_nojdk",
]]

genrule(
Expand All @@ -222,13 +222,13 @@ genrule(
)

genrule(
name = "embedded_tools_with_jdk",
name = "embedded_tools_nojdk",
srcs = [
":embedded_tools_with_jdk_params",
":embedded_tools_with_jdk_srcs",
":embedded_tools_nojdk_params",
":embedded_tools_nojdk_srcs",
],
outs = ["embedded_tools_with_jdk.zip"],
cmd = "$(location :create_embedded_tools) \"$@\" $(location :embedded_tools_with_jdk_params)",
outs = ["embedded_tools_nojdk.zip"],
cmd = "$(location :create_embedded_tools) \"$@\" $(location :embedded_tools_nojdk_params)",
tools = [":create_embedded_tools"],
)

Expand All @@ -253,7 +253,7 @@ genrule(
) for suffix, embed in [
("", True),
("_notools", False),
("_with_jdk", True),
("_nojdk", True),
]]

[genrule(
Expand All @@ -278,7 +278,7 @@ genrule(
) for suffix in [
"",
"_notools",
"_with_jdk",
"_nojdk",
]]

# Build an executable named `bazel.exe`.
Expand All @@ -299,7 +299,7 @@ genrule(
) for suffix in [
"",
"_notools",
"_with_jdk",
"_nojdk",
]]

filegroup(
Expand Down
2 changes: 1 addition & 1 deletion src/test/py/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ filegroup(
filegroup(
name = "test-deps",
testonly = 1,
srcs = ["//src:bazel_with_jdk"],
srcs = ["//src:bazel"],
data = ["//src/tools/remote:worker"],
)

Expand Down
2 changes: 1 addition & 1 deletion src/test/py/bazel/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def RunBazel(self, args, env_remove=None, env_add=None):
(int, [string], [string]) tuple: exit code, stdout lines, stderr lines
"""
return self.RunProgram([
self.Rlocation('io_bazel/src/bazel_with_jdk'),
self.Rlocation('io_bazel/src/bazel'),
'--bazelrc=/dev/null',
'--nomaster_bazelrc',
] + args, env_remove, env_add)
Expand Down
4 changes: 2 additions & 2 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ filegroup(
"testing_server.py",
":langtools-copy",
"//examples:srcs",
"//src:bazel_with_jdk",
"//src:bazel",
"//src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass:GenClass_deploy.jar",
"//src/java_tools/junitrunner/java/com/google/testing/junit/runner:Runner_deploy.jar",
"//src/main/tools:linux-sandbox",
Expand Down Expand Up @@ -520,7 +520,7 @@ sh_test(
srcs = ["bazel_with_jdk_test.sh"],
data = [
":test-deps",
"//src:bazel_with_jdk",
"//src:bazel",
],
tags = ["no_windows"],
)
Expand Down
4 changes: 2 additions & 2 deletions src/test/shell/bazel/bazel_determinism_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function test_determinism() {
unzip -q "${DISTFILE}"

# Build Bazel once.
bazel --output_base="${TEST_TMPDIR}/out1" build --nostamp //src:bazel_with_jdk
bazel --output_base="${TEST_TMPDIR}/out1" build --nostamp //src:bazel
hash_outputs >"${TEST_TMPDIR}/sum1"

# Build Bazel twice.
bazel-bin/src/bazel_with_jdk --output_base="${TEST_TMPDIR}/out2" build --nostamp //src:bazel_with_jdk
bazel-bin/src/bazel --output_base="${TEST_TMPDIR}/out2" build --nostamp //src:bazel
hash_outputs >"${TEST_TMPDIR}/sum2"

if ! diff -U0 "${TEST_TMPDIR}/sum1" "${TEST_TMPDIR}/sum2" >$TEST_log; then
Expand Down
26 changes: 13 additions & 13 deletions src/test/shell/bazel/bazel_with_jdk_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
source $(rlocation io_bazel/src/test/shell/integration_test_setup.sh) \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }

function bazel_with_jdk() {
$(rlocation io_bazel/src/bazel_with_jdk) --bazelrc=$TEST_TMPDIR/bazelrc "$@"
function bazel() {
$(rlocation io_bazel/src/bazel) --bazelrc=$TEST_TMPDIR/bazelrc "$@"
return $?
}

Expand All @@ -48,32 +48,32 @@ function cleanup() {
}

function test_bazel_uses_bundled_jdk() {
bazel_with_jdk --batch info &> "$TEST_log" || fail "bazel_with_jdk info failed"
install_base="$(bazel_with_jdk --batch info install_base)"
bazel --batch info &> "$TEST_log" || fail "bazel info failed"
install_base="$(bazel --batch info install_base)"

# Case-insensitive match, because Windows paths are case-insensitive.
grep -sqi -- "^java-home: ${install_base}/_embedded_binaries/embedded_tools/jdk" $TEST_log || \
fail "bazel_with_jdk's java-home is not inside the install base"
fail "bazel's java-home is not inside the install base"
}

# Tests that "bazel_with_jdk license" prints the license of the bundled JDK by grepping for
# Tests that "bazel license" prints the license of the bundled JDK by grepping for
# representative strings from those files. If this test breaks after upgrading the version of the
# bundled JDK, the strings may have to be updated.
function test_bazel_license_prints_jdk_license() {
bazel_with_jdk --batch license \
&> "$TEST_log" || fail "running bazel_with_jdk license failed"
bazel --batch license \
&> "$TEST_log" || fail "running bazel license failed"

expect_log "OPENJDK ASSEMBLY EXCEPTION" || \
fail "'bazel_with_jdk license' did not print an expected string from ASSEMBLY_EXCEPTION"
fail "'bazel license' did not print an expected string from ASSEMBLY_EXCEPTION"

expect_log "Provided you have not received the software directly from Azul and have already" || \
fail "'bazel_with_jdk license' did not print an expected string from DISCLAIMER"
fail "'bazel license' did not print an expected string from DISCLAIMER"

expect_log '"CLASSPATH" EXCEPTION TO THE GPL' || \
fail "'bazel_with_jdk license' did not print an expected string from LICENSE"
fail "'bazel license' did not print an expected string from LICENSE"

expect_log "which may be included with JRE [0-9]\+, JDK [0-9]\+, and OpenJDK [0-9]\+" || \
fail "'bazel_with_jdk license' did not print an expected string from THIRD_PARTY_README"
fail "'bazel license' did not print an expected string from THIRD_PARTY_README"
}

run_suite "bazel_with_jdk test suite"
run_suite "bazel test suite"
2 changes: 1 addition & 1 deletion src/test/shell/bin/bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# Wrapper script to run bazel in the tests. Any change to this file will
# affect all our integration tests.
#
exec $(rlocation io_bazel/src/bazel_with_jdk) --bazelrc=$TEST_TMPDIR/bazelrc "$@"
exec $(rlocation io_bazel/src/bazel) --bazelrc=$TEST_TMPDIR/bazelrc "$@"
2 changes: 1 addition & 1 deletion src/test/shell/testenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if is_windows; then
fi

# Make the command "bazel" available for tests.
PATH_TO_BAZEL_BIN=$(rlocation io_bazel/src/bazel_with_jdk)
PATH_TO_BAZEL_BIN=$(rlocation io_bazel/src/bazel)
PATH_TO_BAZEL_WRAPPER="$(dirname $(rlocation io_bazel/src/test/shell/bin/bazel))"
# Convert PATH_TO_BAZEL_WRAPPER to Unix path style on Windows, because it will be
# added into PATH. There's problem if PATH=C:/msys64/usr/bin:/usr/local,
Expand Down

0 comments on commit 7c49bd9

Please sign in to comment.