git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #62336 from groodt/bazel-0.26.0

bazel: 0.24.0 -> 0.26.0

commitcc627366cd7a120ddffb81f613f3ae77263d3d7e authorProfpatsch <philip.patsch@tweag.io> dateWed 12 Jun 2019, 14:55 (7 years ago) parent039983b7bae5c6
4 files changed+131−50
pkgs/development/tools/build-managers/bazel/bash-tools-test.nix+12−11 pkgs/development/tools/build-managers/bazel/default.nix+103−18 pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix+13−18 pkgs/tools/system/xe/default.nix+3−3
pkgs/development/tools/build-managers/bazel/bash-tools-test.nix+12−11
@@ -1,4 +1,4 @@
1−{ stdenv, writeText, runCommandCC, bazel }:
1+{ stdenv, writeText, runCommandCC, bazel, runLocal, bazelTest }:
22
33# Tests that certain executables are available in bazel-executed bash shells.
44
@@ -22,21 +22,22 @@ let
2222 )
2323 '';
2424
25− runLocal = name: script: runCommandCC name { preferLocalBuild = true; } script;
26−
27− workspaceDir = runLocal "our_workspace" ''
25+ workspaceDir = runLocal "our_workspace" {} ''
2826 mkdir $out
2927 cp ${WORKSPACE} $out/WORKSPACE
3028 cp ${fileIn} $out/input.txt
3129 cp ${fileBUILD} $out/BUILD
3230 '';
3331
34− testBazel = runLocal "bazel-test-bash-tools" ''
35− export HOME=$(mktemp -d)
36− cp -r ${workspaceDir} wd && chmod +w wd && cd wd
37− ${bazel}/bin/bazel build :tool_usage
38− cp bazel-genfiles/output.txt $out
39− echo "Testing content" && [ "$(cat $out | wc -l)" == "2" ] && echo "OK"
40− '';
32+ testBazel = bazelTest {
33+ name = "bazel-test-bash-tools";
34+ inherit workspaceDir;
35+
36+ bazelScript = ''
37+ ${bazel}/bin/bazel build :tool_usage
38+ cp bazel-genfiles/output.txt $out
39+ echo "Testing content" && [ "$(cat $out | wc -l)" == "2" ] && echo "OK"
40+ '';
41+ };
4142
4243in testBazel
pkgs/development/tools/build-managers/bazel/default.nix+103−18
@@ -1,5 +1,7 @@
1−{ stdenv, callPackage, lib, fetchurl, fetchpatch, runCommand, makeWrapper
2−, zip, unzip, bash, writeCBin, coreutils
1+{ stdenv, callPackage, lib, fetchurl, fetchpatch, runCommand, runCommandCC, makeWrapper
2+# this package (through the fixpoint glass)
3+, bazel
4+, lr, xe, zip, unzip, bash, writeCBin, coreutils
35, which, python, perl, gawk, gnused, gnutar, gnugrep, gzip, findutils
46# Apple dependencies
57, cctools, clang, libcxx, CoreFoundation, CoreServices, Foundation
@@ -14,14 +16,42 @@
1416
1517let
1618 srcDeps = [
19+ # From: $REPO_ROOT/WORKSPACE
1720 (fetchurl {
1821 url = "https://github.com/google/desugar_jdk_libs/archive/915f566d1dc23bc5a8975320cd2ff71be108eb9c.zip";
1922 sha256 = "0b926df7yxyyyiwm9cmdijy6kplf0sghm23sf163zh8wrk87wfi7";
2023 })
21−
2224 (fetchurl {
23− url = "https://mirror.bazel.build/bazel_java_tools/java_tools_pkg-0.5.1.tar.gz";
24− sha256 = "1ld8m5cj9j0r474f56pixcfi0xvx3w7pzwahxngs8f6ns0yimz5w";
25+ url = "https://mirror.bazel.build/github.com/bazelbuild/skydoc/archive/2d9566b21fbe405acf5f7bf77eda30df72a4744c.tar.gz";
26+ sha256 = "4a1318fed4831697b83ce879b3ab70ae09592b167e5bda8edaff45132d1c3b3f";
27+ })
28+ (fetchurl {
29+ url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/archive/f83cb8dd6f5658bc574ccd873e25197055265d1c.tar.gz";
30+ sha256 = "ba5d15ca230efca96320085d8e4d58da826d1f81b444ef8afccd8b23e0799b52";
31+ })
32+ (fetchurl {
33+ url = "https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/8ccf4f1c351928b55d5dddf3672e3667f6978d60.tar.gz";
34+ sha256 = "d868ce50d592ef4aad7dec4dd32ae68d2151261913450fac8390b3fd474bb898";
35+ })
36+ (fetchurl {
37+ url = "https://mirror.bazel.build/bazel_java_tools/releases/javac10/v3.1/java_tools_javac10_linux-v3.1.zip";
38+ sha256 = "a0cd51f9db1bf05a722ff7f5c60a07fa1c7d27428fff0815c342d32aa6c53576";
39+ })
40+ (fetchurl {
41+ url = "https://mirror.bazel.build/bazel_java_tools/releases/javac10/v3.1/java_tools_javac10_darwin-v3.1.zip";
42+ sha256 = "c646aad8808b8ec5844d6a80a1287fc8e13203375fe40d6af4819eff48b9bbaf";
43+ })
44+ (fetchurl {
45+ url = "https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v1.0.zip";
46+ sha256 = "cc470e529fafb6165b5be3929ff2d99b38429b386ac100878687416603a67889";
47+ })
48+ (fetchurl {
49+ url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.2.zip";
50+ sha256 = "9b72bb0aea72d7cbcfc82a01b1e25bf3d85f791e790ddec16c65e2d906382ee0";
51+ })
52+ (fetchurl {
53+ url = "https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.2.tar.gz";
54+ sha256 = "04f85f2dd049e87805511e3babc5cea3f5e72332b1627e34f3a5461cc38e815f";
2555 })
2656 ];
2757
@@ -63,17 +93,19 @@ let
6393 # Java toolchain used for the build and tests
6494 javaToolchain = "@bazel_tools//tools/jdk:toolchain_host${buildJdkName}";
6595
96+ platforms = lib.platforms.linux ++ lib.platforms.darwin;
97+
6698in
6799stdenv.mkDerivation rec {
68100
69− version = "0.24.0";
101+ version = "0.26.0";
70102
71103 meta = with lib; {
72104 homepage = "https://github.com/bazelbuild/bazel/";
73105 description = "Build tool that builds code quickly and reliably";
74106 license = licenses.asl20;
75107 maintainers = [ maintainers.mboes ];
76− platforms = platforms.linux ++ platforms.darwin;
108+ inherit platforms;
77109 };
78110
79111 # Additional tests that check bazel’s functionality. Execute
@@ -81,16 +113,68 @@ stdenv.mkDerivation rec {
81113 # nix-build . -A bazel.tests
82114 #
83115 # in the nixpkgs checkout root to exercise them locally.
84− passthru.tests = {
85− pythonBinPath = callPackage ./python-bin-path-test.nix {};
86− bashTools = callPackage ./bash-tools-test.nix {};
87− };
116+ passthru.tests =
117+ let
118+ runLocal = name: attrs: script: runCommandCC name ({
119+ preferLocalBuild = true;
120+ meta.platforms = platforms;
121+ } // attrs) script;
122+
123+ # bazel wants to extract itself into $install_dir/install every time it runs,
124+ # so let’s do that only once.
125+ extracted =
126+ let install_dir =
127+ # `install_base` field printed by `bazel info`, minus the hash.
128+ # yes, this path is kinda magic. Sorry.
129+ "$HOME/.cache/bazel/_bazel_nixbld";
130+ in runLocal "bazel-extracted-homedir" { passthru.install_dir = install_dir; } ''
131+ export HOME=$(mktemp -d)
132+ touch WORKSPACE # yeah, everything sucks
133+ install_base="$(${bazel}/bin/bazel info | grep install_base)"
134+ # assert it’s actually below install_dir
135+ [[ "$install_base" =~ ${install_dir} ]] \
136+ || (echo "oh no! $install_base but we are \
137+ trying to copy ${install_dir} to $out instead!"; exit 1)
138+ cp -R ${install_dir} $out
139+ '';
140+
141+ bazelTest = { name, bazelScript, workspaceDir }:
142+ runLocal name {} (
143+ # skip extraction caching on Darwin, because nobody knows how Darwin works
144+ (lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
145+ # set up home with pre-unpacked bazel
146+ export HOME=$(mktemp -d)
147+ mkdir -p ${extracted.install_dir}
148+ cp -R ${extracted}/install ${extracted.install_dir}
149+
150+ # https://stackoverflow.com/questions/47775668/bazel-how-to-skip-corrupt-installation-on-centos6
151+ # Bazel checks whether the mtime of the install dir files
152+ # is >9 years in the future, otherwise it extracts itself again.
153+ # see PosixFileMTime::IsUntampered in src/main/cpp/util
154+ # What the hell bazel.
155+ ${lr}/bin/lr -0 -U ${extracted.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
156+ '')
157+ +
158+ ''
159+ # Note https://github.com/bazelbuild/bazel/issues/5763#issuecomment-456374609
160+ # about why to create a subdir for the workspace.
161+ cp -r ${workspaceDir} wd && chmod u+w wd && cd wd
162+
163+ ${bazelScript}
164+
165+ touch $out
166+ '');
167+
168+ in {
169+ pythonBinPath = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; };
170+ bashTools = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; };
171+ };
88172
89173 name = "bazel-${version}";
90174
91175 src = fetchurl {
92176 url = "https://github.com/bazelbuild/bazel/releases/download/${version}/${name}-dist.zip";
93− sha256 = "11gsc00ghxqkbci8nrflkwq1lcvqawlgkaryj458b24si6bjl7b2";
177+ sha256 = "d26dadf62959255d58e523da3448a6222af768fe1224e321b120c1d5bbe4b4f2";
94178 };
95179
96180 # Necessary for the tests to pass on Darwin with sandbox enabled.
@@ -148,10 +232,6 @@ stdenv.mkDerivation rec {
148232 # https://github.com/NixOS/nixpkgs/pull/41589
149233 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${libcxx}/include/c++/v1"
150234
151− # 10.10 apple_sdk Foundation doesn't have type arguments on classes
152− # Remove this when we update apple_sdk
153− sed -i -e 's/<.*\*>//g' tools/osx/xcode_locator.m
154−
155235 # don't use system installed Xcode to run clang, use Nix clang instead
156236 sed -i -e "s;/usr/bin/xcrun clang;${stdenv.cc}/bin/clang $NIX_CFLAGS_COMPILE $NIX_LDFLAGS -framework CoreFoundation;g" \
157237 scripts/bootstrap/compile.sh \
@@ -159,6 +239,9 @@ stdenv.mkDerivation rec {
159239 src/tools/xcode/stdredirect/BUILD \
160240 tools/osx/BUILD
161241
242+ # nixpkgs's libSystem cannot use pthread headers directly, must import GCD headers instead
243+ sed -i -e "/#include <pthread\/spawn.h>/i #include <dispatch/dispatch.h>" src/main/cpp/blaze_util_darwin.cc
244+
162245 # clang installed from Xcode has a compatibility wrapper that forwards
163246 # invocations of gcc to clang, but vanilla clang doesn't
164247 sed -i -e 's;_find_generic(repository_ctx, "gcc", "CC", overriden_tools);_find_generic(repository_ctx, "clang", "CC", overriden_tools);g' tools/cpp/unix_cc_configure.bzl
@@ -193,7 +276,7 @@ stdenv.mkDerivation rec {
193276
194277 # Fixup scripts that generate scripts. Not fixed up by patchShebangs below.
195278 substituteInPlace scripts/bootstrap/compile.sh \
196− --replace /bin/sh ${customBash}/bin/bash
279+ --replace /bin/bash ${customBash}/bin/bash
197280
198281 # add nix environment vars to .bazelrc
199282 cat >> .bazelrc <<EOF
@@ -297,7 +380,9 @@ stdenv.mkDerivation rec {
297380 cp ./bazel_src/scripts/zsh_completion/_bazel $out/share/zsh/site-functions/
298381 '';
299382
300− doInstallCheck = true;
383+ # Temporarily disabling for now. A new approach is needed for this derivation as Bazel
384+ # accesses the internet during the tests which fails in a sandbox.
385+ doInstallCheck = false;
301386 installCheckPhase = ''
302387 export TEST_TMPDIR=$(pwd)
303388
pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix+13−18
@@ -1,4 +1,4 @@
1−{ stdenv, lib, writeText, runCommandCC, bazel }:
1+{ stdenv, lib, writeText, bazel, bazelTest, runLocal }:
22
33let
44 WORKSPACE = writeText "WORKSPACE" ''
@@ -22,16 +22,14 @@ let
2222 srcs = [ "lib.py" ],
2323 )
2424
25− py_test(
25+ py_binary(
2626 name = "bin",
2727 srcs = [ "bin.py" ],
2828 deps = [ ":lib" ],
2929 )
3030 '';
3131
32− runLocal = name: script: runCommandCC name { preferLocalBuild = true; } script;
33−
34− workspaceDir = runLocal "our_workspace" ''
32+ workspaceDir = runLocal "our_workspace" {} ''
3533 mkdir $out
3634 cp ${WORKSPACE} $out/WORKSPACE
3735 mkdir $out/python
@@ -40,18 +38,15 @@ let
4038 cp ${pythonBUILD} $out/python/BUILD.bazel
4139 '';
4240
43− testBazel = runLocal "bazel-test-builtin-rules" ''
44− export HOME=$(mktemp -d)
45− # Note https://github.com/bazelbuild/bazel/issues/5763#issuecomment-456374609
46− # about why to create a subdir for the workspace.
47− cp -r ${workspaceDir} wd && chmod u+w wd && cd wd
48− ${bazel}/bin/bazel \
49− test \
50− --test_output=errors \
51− --host_javabase='@local_jdk//:jdk' \
52− //...
53−
54− touch $out
55− '';
41+ testBazel = bazelTest {
42+ name = "bazel-test-builtin-rules";
43+ inherit workspaceDir;
44+ bazelScript = ''
45+ ${bazel}/bin/bazel \
46+ run \
47+ --host_javabase='@local_jdk//:jdk' \
48+ //python:bin
49+ '';
50+ };
5651
5752in testBazel
pkgs/tools/system/xe/default.nix+3−3
@@ -3,7 +3,7 @@
33stdenv.mkDerivation rec {
44 name = "xe-${version}";
55 version = "0.11";
6−
6+
77 src = fetchFromGitHub {
88 owner = "chneukirchen";
99 repo = "xe";
@@ -12,12 +12,12 @@ stdenv.mkDerivation rec {
1212 };
1313
1414 makeFlags = "PREFIX=$(out)";
15−
15+
1616 meta = with lib; {
1717 description = "Simple xargs and apply replacement";
1818 homepage = https://github.com/chneukirchen/xe;
1919 license = licenses.publicDomain;
20− platforms = platforms.linux;
20+ platforms = platforms.all;
2121 maintainers = with maintainers; [ cstrahan ndowens ];
2222 };
2323}