3
0
Fork 0
forked from mirrors/nixpkgs

bazel: 0.26.1 -> 0.27.0

- Fixs for newly introduced bin/bash hardcoded reference
- Bazel now references `remote_java_tools_xxx` which contains prebuilt
  binaries. We prefetch them, fix them, and force bazel to use the
  fixed repository.

It also closes #63096
This commit is contained in:
Guillaume Bouchard 2019-06-19 20:11:07 +02:00
parent 216a0f44e6
commit ba327a54b6
2 changed files with 81 additions and 22 deletions

View file

@ -14,14 +14,16 @@
# Always assume all markers valid (don't redownload dependencies).
# Also, don't clean up environment variables.
, enableNixHacks ? false
, gcc-unwrapped
, autoPatchelfHook
}:
let
version = "0.26.1";
version = "0.27.0";
src = fetchurl {
url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
sha256 = "000ny51hwnjyizm1md4w8q7m832jhf3c767pgbvg6nc7h67lzsf0";
sha256 = "0yn662dzgfr8ls4avfl12k5sr4f210bab12wml18bh4sjlxhs263";
};
# Update with `eval $(nix-build -A bazel.updater)`,
@ -40,12 +42,12 @@ let
srcs.bazel_skylib
srcs.io_bazel_rules_sass
(if stdenv.hostPlatform.isDarwin
then srcs.${"java_tools_javac10_darwin-v3.2.zip"}
else srcs.${"java_tools_javac10_linux-v3.2.zip"})
then srcs.${"java_tools_javac11_darwin-v2.0.zip"}
else srcs.${"java_tools_javac11_linux-v2.0.zip"})
srcs.${"coverage_output_generator-v1.0.zip"}
srcs.build_bazel_rules_nodejs
srcs.${"android_tools_pkg-0.2.tar.gz"}
];
srcs.${"android_tools_pkg-0.4.tar.gz"}
];
distDir = runCommand "bazel-deps" {} ''
mkdir -p $out
@ -87,6 +89,36 @@ let
platforms = lib.platforms.linux ++ lib.platforms.darwin;
# This repository is fetched by bazel at runtime
# however it contains prebuilt java binaries, with wrong interpreter
# and libraries path.
# We prefetch it, patch it, and override it in a global bazelrc.
system = if stdenv.hostPlatform.isDarwin
then "darwin" else "linux";
remote_java_tools = stdenv.mkDerivation {
name = "remote_java_tools_${system}";
src = fetchurl {
url = "https://mirror.bazel.build/bazel_java_tools/releases/javac11/v2.0/java_tools_javac11_${system}-v2.0.zip";
sha256 = "074d624fb34441df369afdfd454e75dba821d5d54932fcfee5ba598d17dc1b99";
};
nativeBuildInputs = [ autoPatchelfHook unzip ];
buildInputs = [ gcc-unwrapped ];
sourceRoot = ".";
buildPhase = ''
mkdir $out;
'';
installPhase = ''
cp -Ra * $out/
touch $out/WORKSPACE
'';
};
in
stdenv.mkDerivation rec {
name = "bazel-${version}";
@ -117,6 +149,7 @@ stdenv.mkDerivation rec {
runLocal = name: attrs: script: runCommandCC name ({
preferLocalBuild = true;
meta.platforms = platforms;
buildInputs = [ python3 ];
} // attrs) script;
# bazel wants to extract itself into $install_dir/install every time it runs,
@ -275,6 +308,11 @@ stdenv.mkDerivation rec {
--replace /bin/true ${coreutils}/bin/true
done
# bazel test runner include references to /bin/bash
substituteInPlace tools/build_rules/test_rules.bzl \
--replace /bin/bash ${customBash}/bin/bash
# Fixup scripts that generate scripts. Not fixed up by patchShebangs below.
substituteInPlace scripts/bootstrap/compile.sh \
--replace /bin/bash ${customBash}/bin/bash
@ -323,12 +361,20 @@ stdenv.mkDerivation rec {
mv runfiles.bash.tmp tools/bash/runfiles/runfiles.bash
patchShebangs .
# bazel reads its system bazelrc in /etc
# override this path to a builtin one
substituteInPlace \
src/main/cpp/option_processor.cc \
--replace BAZEL_SYSTEM_BAZELRC_PATH "\"$out/etc/bazelrc\""
'';
in lib.optionalString stdenv.hostPlatform.isDarwin darwinPatches
+ genericPatches;
buildInputs = [
buildJdk
python3 # bazel build requires python3. However we still use python2 for most of the other tasks
# This will have to be refactored later.
];
# when a command cant be found in a bazel build, you might also
@ -375,6 +421,12 @@ stdenv.mkDerivation rec {
wrapProgram "$out/bin/bazel" --add-flags --server_javabase="${runJdk}"
# generates the system bazelrc
# warning: the name of the repository depends on the system, hence
# the reference to .name
mkdir $out/etc
echo "build --override_repository=${remote_java_tools.name}=${remote_java_tools}" > $out/etc/bazelrc
# shell completion files
mkdir -p $out/share/bash-completion/completions $out/share/zsh/site-functions
mv ./bazel_src/output/bazel-complete.bash $out/share/bash-completion/completions/bazel

View file

@ -23,11 +23,11 @@
"https://github.com/bazelbuild/rules_sass/archive/8ccf4f1c351928b55d5dddf3672e3667f6978d60.tar.gz"
]
},
"android_tools_pkg-0.2.tar.gz": {
"name": "android_tools_pkg-0.2.tar.gz",
"sha256": "04f85f2dd049e87805511e3babc5cea3f5e72332b1627e34f3a5461cc38e815f",
"android_tools_pkg-0.4.tar.gz": {
"name": "android_tools_pkg-0.4.tar.gz",
"sha256": "331e7706f2bcae8a68057d8ddd3e3f1574bca26c67c65802fc4a8ac6164fa912",
"urls": [
"https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.2.tar.gz"
"https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.4.tar.gz"
]
},
"bazel_j2objc": {
@ -134,25 +134,25 @@
"https://github.com/bazelbuild/skydoc/archive/2d9566b21fbe405acf5f7bf77eda30df72a4744c.tar.gz"
]
},
"java_tools_javac10_darwin-v3.2.zip": {
"name": "java_tools_javac10_darwin-v3.2.zip",
"sha256": "1437327179b4284f7082cee0bdc3328f040e62fc5cc59c32f6824b8c520e2b7b",
"java_tools_javac11_darwin-v2.0.zip": {
"name": "java_tools_javac11_darwin-v2.0.zip",
"sha256": "0ceb0c9ff91256fe33508306bc9cd9e188dcca38df78e70839d426bdaef67a38",
"urls": [
"https://mirror.bazel.build/bazel_java_tools/releases/javac10/v3.2/java_tools_javac10_darwin-v3.2.zip"
"https://mirror.bazel.build/bazel_java_tools/releases/javac11/v2.0/java_tools_javac11_darwin-v2.0.zip"
]
},
"java_tools_javac10_linux-v3.2.zip": {
"name": "java_tools_javac10_linux-v3.2.zip",
"sha256": "b93e7c556b01815afb6c248aa73f06b7ec912805bde8898eedac1e20d08f2e67",
"java_tools_javac11_linux-v2.0.zip": {
"name": "java_tools_javac11_linux-v2.0.zip",
"sha256": "074d624fb34441df369afdfd454e75dba821d5d54932fcfee5ba598d17dc1b99",
"urls": [
"https://mirror.bazel.build/bazel_java_tools/releases/javac10/v3.2/java_tools_javac10_linux-v3.2.zip"
"https://mirror.bazel.build/bazel_java_tools/releases/javac11/v2.0/java_tools_javac11_linux-v2.0.zip"
]
},
"java_tools_javac10_windows-v3.2.zip": {
"name": "java_tools_javac10_windows-v3.2.zip",
"sha256": "86d3cc7fa0dc91ccb8f78ae3af8440fe459177e22062043ee4b83d55e6b7dfb0",
"java_tools_javac11_windows-v2.0.zip": {
"name": "java_tools_javac11_windows-v2.0.zip",
"sha256": "2c3fc0ce7d30d60e26f4b8a36e2eadcf9e6a9d5a51b667d3d13b78db53b24251",
"urls": [
"https://mirror.bazel.build/bazel_java_tools/releases/javac10/v3.2/java_tools_javac10_windows-v3.2.zip"
"https://mirror.bazel.build/bazel_java_tools/releases/javac11/v2.0/java_tools_javac11_windows-v2.0.zip"
]
},
"java_tools_langtools_javac10": {
@ -162,6 +162,13 @@
"https://mirror.bazel.build/bazel_java_tools/jdk_langtools/langtools_jdk10.zip"
]
},
"java_tools_langtools_javac11": {
"name": "java_tools_langtools_javac11",
"sha256": "128a63f39d3f828a761f6afcfe3c6115279336a72ea77f60d7b3acf1841c9acb",
"urls": [
"https://mirror.bazel.build/bazel_java_tools/jdk_langtools/langtools_jdk11.zip"
]
},
"java_tools_langtools_javac9": {
"name": "java_tools_langtools_javac9",
"sha256": "3b6bbc47256acf2f61883901e2d4e3f9b292f5fe154a6912b928805de24cb864",