Skip to content

Commit

Permalink
Rollback of commit 6cb8d82.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breaks ci.bazel.io

While the basics for fixing the build is easy (just a few typos in packages building), fixing the test is a bit more tricky. I see only one solution for fixing the test: use a select statement that would select the good bazel version but that would always pull JavaBuilder as an external dependency when we do test.

Better roll this back then check the JavaBuilder 0.1.0 as a binary in third_party before rolling forward (a similar change is still needed to decouple running the test and building the binary for JDK 7)

*** Original change description ***


Refactor build for JDK 7

Now the JDK 7 tuning happens all in Bazel, removing logic
from the CI script. It uses remote repositories to access
JDK 7 dependencies.

--
MOS_MIGRATED_REVID=119773123
  • Loading branch information
damienmg committed Apr 14, 2016
1 parent fcb1711 commit 04d46ab
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 217 deletions.
16 changes: 0 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ bind(
actual = "//:dummy",
)

# For building for JDK 7
# This is a JDK 7 JavaBuilder from release 0.1.0.
# Do not use the skylark bootstrapped version of JavaBuilder
http_file(
name = "io_bazel_javabuilder_jdk7",
# This was built from Bazel 0.1.0 (after ./compile.sh) and JDK 7.
url = "https://storage.googleapis.com/bazel/0.1.0/JavaBuilder_deploy.jar",
sha256 = "374f07be2f73ec170ef6bdd8057530e6842cb0cbc7a240caccbd7b80be239366",
)

http_file(
name = "io_bazel_javac_jdk7",
url = "https://github.com/bazelbuild/bazel/blob/0.1.0/third_party/java/jdk/langtools/javac.jar?raw=true",
sha256 = "e063cf60cf9a1d24acd043f55dc605da559b913793c6a4e51c5ddbc4f5d494df",
)

# For tools/cpp/test/...
load("//tools/cpp/test:docker_repository.bzl", "docker_repository")
docker_repository()
Expand Down
5 changes: 3 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ if [ $DO_COMPILE ]; then
new_step 'Building Bazel with Bazel'
display "."
log "Building output/bazel"
bazel_build "src:bazel${BAZEL_FLAVOUR}${EXE_EXT}"
cp -f "bazel-bin/src/bazel${BAZEL_FLAVOUR}${EXE_EXT}" "output/bazel${EXE_EXT}"
bazel_build "src:bazel${EXE_EXT}"
cp -f "bazel-bin/src/bazel${EXE_EXT}" "output/bazel${EXE_EXT}"
chmod 0755 "output/bazel${EXE_EXT}"
BAZEL="$(pwd)/output/bazel${EXE_EXT}"
fi
Expand Down Expand Up @@ -155,6 +155,7 @@ if [ $DO_TESTS ]; then
$BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc test \
--test_tag_filters="${BAZEL_TEST_FILTERS-}" \
--build_tests_only \
--nolegacy_bazel_java_test \
${EXTRA_BAZEL_ARGS} \
--javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
-k --test_output=errors //src/... //third_party/ijar/... //scripts/... \
Expand Down
32 changes: 11 additions & 21 deletions scripts/bootstrap/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,21 @@ if [ -n "${EMBED_LABEL}" ]; then
EMBED_LABEL_ARG=(--stamp --embed_label "${EMBED_LABEL}")
fi

COMMON_BAZEL_ARGS="--singlejar_top=//src/java_tools/singlejar:bootstrap_deploy.jar \
--genclass_top=//src/java_tools/buildjar:bootstrap_genclass_deploy.jar \
--ijar_top=//third_party/ijar"
if [[ "${JAVA_VERSION-}" == 1.7 ]]; then
# Set the various arguments when JDK 7 is required (deprecated).
# This setting is here to continue to build binary release of Bazel
# for JDK 7. We will drop this method and JDK 7 support when our
# ci system turn red on this one.
: ${BAZEL_ARGS:=--java_toolchain=//tools/jdk:toolchain7 \
--javabuilder_top=@io_bazel_javabuilder_jdk7//file \
--java_langtools=@io_bazel_javac_jdk7//file \
${COMMON_BAZEL_ARGS} \
"${EXTRA_BAZEL_ARGS:-}"}
: ${BAZEL_FLAVOUR:="-jdk7"}
else
: ${BAZEL_ARGS:=--javabuilder_top=//src/java_tools/buildjar:bootstrap_deploy.jar \
: ${JAVA_VERSION:="1.8"}

: ${BAZEL_ARGS:=--singlejar_top=//src/java_tools/singlejar:bootstrap_deploy.jar \
--javabuilder_top=//src/java_tools/buildjar:bootstrap_deploy.jar \
--genclass_top=//src/java_tools/buildjar:bootstrap_genclass_deploy.jar \
--ijar_top=//third_party/ijar \
--strategy=Javac=worker --worker_quit_after_build \
--genrule_strategy=standalone --spawn_strategy=standalone \
${COMMON_BAZEL_ARGS} \
"${EXTRA_BAZEL_ARGS:-}"}
: ${BAZEL_FLAVOUR:=""}
fi

if [ -z "${BAZEL-}" ]; then
function bazel_build() {
bootstrap_build ${BAZEL_ARGS-} \
--verbose_failures \
--javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
"${EMBED_LABEL_ARG[@]}" \
"${@}"
}
Expand All @@ -63,6 +51,7 @@ else
${BAZEL} --bazelrc=${BAZELRC} build \
${BAZEL_ARGS-} \
--verbose_failures \
--javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
"${EMBED_LABEL_ARG[@]}" \
"${@}"
}
Expand All @@ -88,22 +77,23 @@ function get_outputs_sum() {
function bootstrap_test() {
local BAZEL_BIN=$1
local BAZEL_SUM=$2
local BAZEL_TARGET=${3:-src:bazel${BAZEL_FLAVOUR}}
local BAZEL_TARGET=${3:-src:bazel}
[ -x "${BAZEL_BIN}" ] || fail "syntax: bootstrap bazel-binary"
run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} clean \
--expunge || return $?
run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} build \
${EXTRA_BAZEL_ARGS-} \
--strategy=Javac=worker --worker_quit_after_build \
--fetch --nostamp \
--javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
${BAZEL_TARGET} || return $?
if [ -n "${BAZEL_SUM}" ]; then
cat bazel-genfiles/src/java.version >${BAZEL_SUM}
get_outputs_sum >> ${BAZEL_SUM} || return $?
fi
if [ -z "${BOOTSTRAP:-}" ]; then
tempdir
BOOTSTRAP=${NEW_TMPDIR}/bazel${BAZEL_FLAVOUR}
BOOTSTRAP=${NEW_TMPDIR}/bazel
local FILE=bazel-bin/${BAZEL_TARGET##//}
cp -f ${FILE/:/\/} $BOOTSTRAP
chmod +x $BOOTSTRAP
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Script for building bazel from scratch without bazel

PROTO_FILES=$(ls src/main/protobuf/*.proto)
LIBRARY_JARS=$(find third_party -name '*.jar' | grep -v "javac.jar" | tr "\n" " ")
LIBRARY_JARS=$(find third_party -name '*.jar' | tr "\n" " ")
DIRS=$(echo src/{java_tools/singlejar/java/com/google/devtools/build/zip,main/java,tools/xcode-common/java/com/google/devtools/build/xcode/{common,util}} ${OUTPUT_DIR}/src)
EXCLUDE_FILES=src/main/java/com/google/devtools/build/lib/server/GrpcServer.java

Expand Down
49 changes: 43 additions & 6 deletions scripts/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,45 @@ EOF
fi
}

# Set the various arguments when JDK 7 is required (deprecated).
# This method is here to continue to build binary release of Bazel
# for JDK 7. We will drop this method and JDK 7 support when our
# ci system turn red on this one.
function setup_jdk7() {
# This is a JDK 7 JavaBuilder from release 0.1.0.
local javabuilder_url="https://storage.googleapis.com/bazel/0.1.0/JavaBuilder_deploy.jar"
local javac_url="https://github.com/bazelbuild/bazel/blob/0.1.0/third_party/java/jdk/langtools/javac.jar?raw=true"
sed -i.bak 's/_version = "8"/_version = "7"/' tools/jdk/BUILD
rm -f tools/jdk/BUILD.bak
rm -f third_party/java/jdk/langtools/javac.jar
curl -Ls -o tools/jdk/JavaBuilder_deploy.jar "${javabuilder_url}"
curl -Ls -o third_party/java/jdk/langtools/javac.jar "${javac_url}"
# Do not use the skylark bootstrapped version of JavaBuilder
export BAZEL_ARGS="--singlejar_top=//src/java_tools/singlejar:bootstrap_deploy.jar \
--genclass_top=//src/java_tools/buildjar:bootstrap_genclass_deploy.jar \
--ijar_top=//third_party/ijar"
# Skip building JavaBuilder
export BAZEL_SKIP_TOOL_COMPILATION=tools/jdk/JavaBuilder_deploy.jar
# Ignore JDK8 tests
export BAZEL_TEST_FILTERS="-jdk8"
if ! grep -Fq 'RealJavaBuilder' src/java_tools/buildjar/BUILD; then
# And more ugly hack. Overwrite the BUILD file of JavaBuilder
# so we use the pre-built version in integration tests.
sed -i.bak 's/name = \"JavaBuilder\"/name = \"RealJavaBuilder\"/' \
src/java_tools/buildjar/BUILD
rm -f src/java_tools/buildjar/BUILD.bak
cat >>src/java_tools/buildjar/BUILD <<'EOF'
genrule(
name = "JavaBuilder",
outs = ["JavaBuilder_deploy.jar"],
srcs = ["//tools/jdk:JavaBuilder_deploy.jar"],
cmd = "cp $< $@",
visibility = ["//visibility:public"],
)
EOF
fi
}

# Main entry point for building bazel.
# It sets the embed label to the release name if any, calls the whole
# test suite, compile the various packages, then copy the artifacts
Expand All @@ -112,10 +151,9 @@ function bazel_build() {

if [[ "${JAVA_VERSION-}" =~ ^(1\.)?7$ ]]; then
JAVA_VERSION=1.7
FLAVOUR="-jdk7"
setup_jdk7
release_label="${release_label}-jdk7"
else
FLAVOUR=""
JAVA_VERSION=1.8
fi

Expand All @@ -139,16 +177,15 @@ function bazel_build() {
--workspace_status_command=scripts/ci/build_status_command.sh \
--define JAVA_VERSION=${JAVA_VERSION} \
${ARGS} \
//scripts/packages:install${FLAVOUR}.sh \
//scripts/bazel-debian${FLAVOUR}.deb} || exit $?
//scripts/packages/... || exit $?

if [ -n "${1-}" ]; then
# Copy the results to the output directory
mkdir -p $1/packages
cp output/bazel $1/bazel
cp bazel-bin/scripts/packages/install${FLAVOUR}.sh $1/bazel-${release_label}-installer.sh
cp bazel-bin/scripts/packages/install.sh $1/bazel-${release_label}-installer.sh
if [ "$PLATFORM" = "linux" ]; then
cp bazel-bin/scripts/packages/bazel-debian${FLAVOUR}.deb $1/bazel_${release_label}.deb
cp bazel-bin/scripts/packages/bazel-debian.deb $1/bazel_${release_label}.deb
fi
cp bazel-genfiles/scripts/packages/README.md $1/README.md
fi
Expand Down
Loading

0 comments on commit 04d46ab

Please sign in to comment.