aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-13 19:27:56 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-14 07:38:04 +0000
commit04d46abcf4d0a0a4054372a3da9b8e76c573aee5 (patch)
tree5af4b5ba793673ffa72e0f44414a7a8855371f8a /scripts
parentfcb17112bfbb598954306ee197a842ec8f4e8e64 (diff)
*** 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
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bootstrap/bootstrap.sh32
-rwxr-xr-xscripts/bootstrap/compile.sh2
-rwxr-xr-xscripts/ci/build.sh49
-rw-r--r--scripts/packages/BUILD172
4 files changed, 121 insertions, 134 deletions
diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh
index 3fae3027c4..2fea800680 100755
--- a/scripts/bootstrap/bootstrap.sh
+++ b/scripts/bootstrap/bootstrap.sh
@@ -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[@]}" \
"${@}"
}
@@ -63,6 +51,7 @@ else
${BAZEL} --bazelrc=${BAZELRC} build \
${BAZEL_ARGS-} \
--verbose_failures \
+ --javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
"${EMBED_LABEL_ARG[@]}" \
"${@}"
}
@@ -88,7 +77,7 @@ 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 $?
@@ -96,6 +85,7 @@ function bootstrap_test() {
${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}
@@ -103,7 +93,7 @@ function bootstrap_test() {
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
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 5beb1c7120..3268c83e00 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -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
diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh
index 63f7de705f..df7e794b39 100755
--- a/scripts/ci/build.sh
+++ b/scripts/ci/build.sh
@@ -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
@@ -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
@@ -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
diff --git a/scripts/packages/BUILD b/scripts/packages/BUILD
index 86ca34dfa6..2fba80fed2 100644
--- a/scripts/packages/BUILD
+++ b/scripts/packages/BUILD
@@ -33,13 +33,6 @@ genrule(
)
genrule(
- name = "rename-bazel-bin-jdk7",
- srcs = ["//src:bazel_jdk7"],
- outs = ["jdk7/bazel-real"],
- cmd = "cp $< $@",
-)
-
-genrule(
name = "rename-bazel-sh",
srcs = ["bazel.sh"],
outs = ["bazel"],
@@ -48,49 +41,24 @@ genrule(
load(":self_extract_binary.bzl", "self_extract_binary")
-[
- self_extract_binary(
- name = "install%s.sh" % flavour,
- empty_files = ["tools/defaults/BUILD"],
- flatten_resources = [
- ":bazel-real" + flavour,
- ":bazel",
- "//scripts:bash_completion",
- ],
- launcher = ":launcher_bin.sh",
- )
- for flavour in [
- "",
- "-jdk7",
- ]
-]
-
-load("//tools/build_defs/pkg:pkg.bzl", "pkg_tar", "pkg_deb")
-
-pkg_tar(
- name = "bazel-real-bin",
- files = [
+self_extract_binary(
+ name = "install.sh",
+ empty_files = ["tools/defaults/BUILD"],
+ flatten_resources = [
":bazel-real",
+ ":bazel",
+ "//scripts:bash_completion",
],
- mode = "0755",
- package_dir = "/usr/bin",
- strip_prefix = ".",
+ launcher = ":launcher_bin.sh",
)
-pkg_tar(
- name = "bazel-real-bin-jdk7",
- files = [
- ":bazel-real-jdk7",
- ],
- mode = "0755",
- package_dir = "/usr/bin",
- strip_prefix = "scripts/packages/jdk7/",
-)
+load("//tools/build_defs/pkg:pkg.bzl", "pkg_tar", "pkg_deb")
pkg_tar(
name = "bazel-bin",
files = [
":bazel",
+ ":bazel-real",
],
mode = "0755",
package_dir = "/usr/bin",
@@ -119,71 +87,63 @@ pkg_tar(
strip_prefix = ".",
)
-[
- pkg_tar(
- name = "debian-data" + flavour,
- extension = "tar.gz",
- deps = [
- ":bazel-real-bin" + flavour,
- ":bazel-bin",
- ":bazel-completion",
- ":bazel-rc",
- ],
- )
- for flavour in [
- "",
- "-jdk7",
- ]
-]
+pkg_tar(
+ name = "debian-data",
+ extension = "tar.gz",
+ deps = [
+ ":bazel-bin",
+ ":bazel-completion",
+ ":bazel-rc",
+ ],
+)
-[
- genrule(
- name = "embedded_label" + flavour,
- srcs = [":debian-data"],
- outs = [
- "version%s.txt" % flavour,
- ],
- cmd =
- "find . -name stable-status.txt -exec cat '{}' ';'" +
- " | grep EMBED_LABEL | cut -d ' ' -f 2-" +
- # Debian package manager does not order our rcs correctly, insert a tilde
- # Non RC version number are not matched by the regex, example translations:
- # 0.1.2 0.1.2
- # 0.1.2rc2 0.1.2~rc2
- # 0.1.2rc2-jdk7 0.1.2~rc2-jdk7
- " | sed -E 's/^([0-9\\.]+)([^0-9\\.].*)$$/\\1~\\2/'" +
- " > $@\n",
- stamp = 1,
- )
- for flavour in [
- "",
- "-jdk7",
- ]
-]
+genrule(
+ name = "embedded_label",
+ srcs = [":debian-data"],
+ outs = [
+ "version.txt",
+ ],
+ cmd =
+ "find . -name stable-status.txt -exec cat '{}' ';'" +
+ " | grep EMBED_LABEL | cut -d ' ' -f 2-" +
+ # Debian package manager does not order our rcs correctly, insert a tilde
+ # Non RC version number are not matched by the regex, example translations:
+ # 0.1.2 0.1.2
+ # 0.1.2rc2 0.1.2~rc2
+ # 0.1.2rc2-jdk7 0.1.2~rc2-jdk7
+ " | sed -E 's/^([0-9\\.]+)([^0-9\\.].*)$$/\\1~\\2/'" +
+ " > $@\n",
+ stamp = 1,
+)
-[
- pkg_deb(
- name = "bazel-debian" + flavour,
- architecture = "amd64",
- built_using = "bazel (HEAD)",
- data = ":debian-data" + flavour,
- depends = [
- "java7-jdk | java7-sdk" if (flavour == "-jdk7") else "java8-jdk | java8-sdk",
- "pkg-config",
- "zip",
- "g++",
- "zlib1g-dev",
- "unzip",
- "bash-completion",
+config_setting(
+ name = "jdk7",
+ values = {"define": "JAVA_VERSION=1.7"},
+)
+
+pkg_deb(
+ name = "bazel-debian",
+ architecture = "amd64",
+ built_using = "bazel (HEAD)",
+ data = ":debian-data",
+ depends = select({
+ ":jdk7": [
+ "java7-jdk | java7-sdk",
+ ],
+ "//conditions:default": [
+ "java8-jdk | java8-sdk",
],
- description_file = "debian/description",
- homepage = "http://bazel.io",
- maintainer = "The Bazel Authors <bazel-dev@googlegroups.com>",
- package = "bazel",
- version_file = ":version%s.txt" % flavour,
- )
- for flavour in [
- "",
- "-jdk7",
- ]
-]
+ }) + [
+ "pkg-config",
+ "zip",
+ "g++",
+ "zlib1g-dev",
+ "unzip",
+ "bash-completion",
+ ],
+ description_file = "debian/description",
+ homepage = "http://bazel.io",
+ maintainer = "The Bazel Authors <bazel-dev@googlegroups.com>",
+ package = "bazel",
+ version_file = ":version.txt",
+)