tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
bazel_7: init at 7.0.0-pre.20230917.3
Guillaume Maudoux
2 years ago
78dd0baf
8cc99ed5
+1110
-467
19 changed files
expand all
collapse all
unified
split
pkgs
development
tools
build-managers
bazel
bash-tools-test.nix
bazel_7
actions_path.patch
bazel-repository-cache.nix
darwin_sleep.patch
default.nix
java_toolchain.patch
no-arc.patch
os_detect.patch
required-hashes.json
serialize_nulls.patch
strict_proto_deps.patch
tmp.patch
trim-last-argument-to-gcc-if-empty.patch
cpp-test.nix
java-test.nix
protobuf-test.nix
python-bin-path-test.nix
shebang-test.nix
top-level
all-packages.nix
+2
-2
pkgs/development/tools/build-managers/bazel/bash-tools-test.nix
···
1
1
-
{ writeText, bazel, runLocal, bazelTest, distDir }:
1
1
+
{ lib, writeText, bazel, runLocal, bazelTest, distDir, extraBazelArgs ? ""}:
2
2
3
3
# Tests that certain executables are available in bazel-executed bash shells.
4
4
···
35
35
inherit workspaceDir;
36
36
37
37
bazelScript = ''
38
38
-
${bazel}/bin/bazel build :tool_usage --distdir=${distDir}
38
38
+
${bazel}/bin/bazel build :tool_usage --distdir=${distDir} ${extraBazelArgs}
39
39
cp bazel-bin/output.txt $out
40
40
echo "Testing content" && [ "$(cat $out | wc -l)" == "2" ] && echo "OK"
41
41
'';
+11
-4
pkgs/development/tools/build-managers/bazel/bazel_7/actions_path.patch
···
1
1
+
commit 595756621dd858cf18033af2c4707d2fe8548350
2
2
+
Author: Guillaume Maudoux <guillaume.maudoux@tweag.io>
3
3
+
Date: Fri Oct 6 15:09:56 2023 +0200
4
4
+
5
5
+
actions_path.patch
6
6
+
1
7
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
2
2
-
index 6fff2af..7e2877e 100644
8
8
+
index 8284eff943..a820037968 100644
3
9
--- a/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
4
10
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
5
11
@@ -47,6 +47,16 @@ public final class PosixLocalEnvProvider implements LocalEnvProvider {
···
19
25
String p = clientEnv.get("TMPDIR");
20
26
if (Strings.isNullOrEmpty(p)) {
21
27
// Do not use `fallbackTmpDir`, use `/tmp` instead. This way if the user didn't export TMPDIR
22
22
-
index 95642767c6..39d3c62461 100644
28
28
+
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java
29
29
+
index 8f230b1b1d..2e4c7d26b7 100644
23
30
--- a/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java
24
31
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java
25
25
-
@@ -74,6 +74,16 @@ public final class XcodeLocalEnvProvider implements LocalEnvProvider {
26
26
-
32
32
+
@@ -75,6 +75,16 @@ public final class XcodeLocalEnvProvider implements LocalEnvProvider {
33
33
+
27
34
ImmutableMap.Builder<String, String> newEnvBuilder = ImmutableMap.builder();
28
35
newEnvBuilder.putAll(Maps.filterKeys(env, k -> !k.equals("TMPDIR")));
29
36
+
+114
pkgs/development/tools/build-managers/bazel/bazel_7/bazel-repository-cache.nix
···
1
1
+
{ lib
2
2
+
, nix
3
3
+
, runCommand
4
4
+
, fetchurl
5
5
+
# The path to the right MODULE.bazel.lock
6
6
+
, lockfile
7
7
+
# The path to a json file containing the list of hashes we should prefetch
8
8
+
, requiredDeps ? null
9
9
+
, extraInputs ? [ ]
10
10
+
}:
11
11
+
let
12
12
+
modules = builtins.fromJSON (builtins.readFile lockfile);
13
13
+
14
14
+
# a foldl' for json values
15
15
+
foldlJSON = op: acc: value:
16
16
+
let
17
17
+
# preorder, visit the current node first
18
18
+
acc' = op acc value;
19
19
+
20
20
+
# then visit child values, ignoring attribute names
21
21
+
children =
22
22
+
if builtins.isList value then
23
23
+
lib.foldl' (foldlJSON op) acc' value
24
24
+
else if builtins.isAttrs value then
25
25
+
lib.foldlAttrs (_acc: _name: foldlJSON op _acc) acc' value
26
26
+
else
27
27
+
acc';
28
28
+
in
29
29
+
# like foldl', force evaluation of intermediate results
30
30
+
builtins.seq acc' children;
31
31
+
32
32
+
extract_source = acc: value:
33
33
+
# We take any "attributes" object that has a "sha256" field. Every value
34
34
+
# under "attributes" is assumed to be an object, and all the "attributes"
35
35
+
# with a "sha256" field are assumed to have either a "urls" or "url" field.
36
36
+
#
37
37
+
# We add them to the `acc`umulator:
38
38
+
#
39
39
+
# acc // {
40
40
+
# "ffad2b06ef2e09d040...fc8e33706bb01634" = fetchurl {
41
41
+
# name = "source";
42
42
+
# sha256 = "ffad2b06ef2e09d040...fc8e33706bb01634";
43
43
+
# urls = [
44
44
+
# "https://mirror.bazel.build/github.com/golang/library.zip",
45
45
+
# "https://github.com/golang/library.zip"
46
46
+
# ];
47
47
+
# };
48
48
+
# }
49
49
+
let
50
50
+
# remove the "--" prefix, abusing undocumented negative substring length
51
51
+
sanitize = builtins.substring 2 (-1);
52
52
+
attrs = value.attributes;
53
53
+
entry = hash: urls: {
54
54
+
${hash} = fetchurl {
55
55
+
name = "source"; # just like fetch*, to get some deduplication
56
56
+
inherit urls;
57
57
+
sha256 = hash;
58
58
+
passthru.sha256 = hash;
59
59
+
};
60
60
+
};
61
61
+
insert = acc: hash: urls: acc // entry (sanitize hash) (map sanitize urls);
62
62
+
in
63
63
+
if builtins.isAttrs value && value ? attributes
64
64
+
&& (attrs ? sha256 || attrs ? integrity)
65
65
+
then
66
66
+
#builtins.trace attrs
67
67
+
(
68
68
+
insert
69
69
+
acc
70
70
+
(attrs.integrity or attrs.sha256)
71
71
+
(attrs.urls or [ attrs.url ])
72
72
+
)
73
73
+
else if builtins.isAttrs value && value ? remote_patches
74
74
+
&& builtins.isAttrs value.remote_patches
75
75
+
then
76
76
+
#builtins.trace value.remote_patches
77
77
+
(
78
78
+
lib.foldlAttrs
79
79
+
(acc: url: hash: insert acc hash [ url ])
80
80
+
acc
81
81
+
value.remote_patches
82
82
+
)
83
83
+
else acc;
84
84
+
85
85
+
inputs = foldlJSON extract_source { } modules;
86
86
+
87
87
+
requiredHashes = builtins.fromJSON (builtins.readFile requiredDeps);
88
88
+
requiredAttrs = lib.genAttrs requiredHashes throw;
89
89
+
90
90
+
requiredInputs =
91
91
+
if requiredDeps == null
92
92
+
then inputs
93
93
+
else builtins.intersectAttrs requiredAttrs (builtins.trace inputs inputs);
94
94
+
95
95
+
command = ''
96
96
+
mkdir -p $out/content_addressable/sha256
97
97
+
cd $out/content_addressable/sha256
98
98
+
'' + lib.concatMapStrings
99
99
+
# TODO: Do not re-hash. Use nix-hash to convert hashes
100
100
+
(drv: ''
101
101
+
filename=$(basename "${lib.head drv.urls}")
102
102
+
echo Caching $filename
103
103
+
hash=$(${nix}/bin/nix-hash --type sha256 --to-base16 ${drv.sha256})
104
104
+
mkdir -p $hash
105
105
+
ln -sfn ${drv} $hash/file
106
106
+
ln -sfn ${drv} $filename
107
107
+
'')
108
108
+
(builtins.attrValues requiredInputs ++ extraInputs)
109
109
+
;
110
110
+
111
111
+
repository_cache = runCommand "bazel-repository-cache" { } command;
112
112
+
113
113
+
in
114
114
+
repository_cache
+56
pkgs/development/tools/build-managers/bazel/bazel_7/darwin_sleep.patch
···
1
1
+
diff --git a/src/main/native/darwin/sleep_prevention_jni.cc b/src/main/native/darwin/sleep_prevention_jni.cc
2
2
+
index 67c35b201e..e50a58320e 100644
3
3
+
--- a/src/main/native/darwin/sleep_prevention_jni.cc
4
4
+
+++ b/src/main/native/darwin/sleep_prevention_jni.cc
5
5
+
@@ -33,31 +33,13 @@ static int g_sleep_state_stack = 0;
6
6
+
static IOPMAssertionID g_sleep_state_assertion = kIOPMNullAssertionID;
7
7
+
8
8
+
int portable_push_disable_sleep() {
9
9
+
- std::lock_guard<std::mutex> lock(g_sleep_state_mutex);
10
10
+
- BAZEL_CHECK_GE(g_sleep_state_stack, 0);
11
11
+
- if (g_sleep_state_stack == 0) {
12
12
+
- BAZEL_CHECK_EQ(g_sleep_state_assertion, kIOPMNullAssertionID);
13
13
+
- CFStringRef reasonForActivity = CFSTR("build.bazel");
14
14
+
- IOReturn success = IOPMAssertionCreateWithName(
15
15
+
- kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity,
16
16
+
- &g_sleep_state_assertion);
17
17
+
- BAZEL_CHECK_EQ(success, kIOReturnSuccess);
18
18
+
- }
19
19
+
- g_sleep_state_stack += 1;
20
20
+
- return 0;
21
21
+
+ // Unreliable, disable for now
22
22
+
+ return -1;
23
23
+
}
24
24
+
25
25
+
int portable_pop_disable_sleep() {
26
26
+
- std::lock_guard<std::mutex> lock(g_sleep_state_mutex);
27
27
+
- BAZEL_CHECK_GT(g_sleep_state_stack, 0);
28
28
+
- g_sleep_state_stack -= 1;
29
29
+
- if (g_sleep_state_stack == 0) {
30
30
+
- BAZEL_CHECK_NE(g_sleep_state_assertion, kIOPMNullAssertionID);
31
31
+
- IOReturn success = IOPMAssertionRelease(g_sleep_state_assertion);
32
32
+
- BAZEL_CHECK_EQ(success, kIOReturnSuccess);
33
33
+
- g_sleep_state_assertion = kIOPMNullAssertionID;
34
34
+
- }
35
35
+
- return 0;
36
36
+
+ // Unreliable, disable for now
37
37
+
+ return -1;
38
38
+
}
39
39
+
40
40
+
} // namespace blaze_jni
41
41
+
diff --git a/src/main/native/darwin/system_suspension_monitor_jni.cc b/src/main/native/darwin/system_suspension_monitor_jni.cc
42
42
+
index 3483aa7935..51782986ec 100644
43
43
+
--- a/src/main/native/darwin/system_suspension_monitor_jni.cc
44
44
+
+++ b/src/main/native/darwin/system_suspension_monitor_jni.cc
45
45
+
@@ -83,10 +83,7 @@ void portable_start_suspend_monitoring() {
46
46
+
// Register to receive system sleep notifications.
47
47
+
// Testing needs to be done manually. Use the logging to verify
48
48
+
// that sleeps are being caught here.
49
49
+
- suspend_state.connect_port = IORegisterForSystemPower(
50
50
+
- &suspend_state, ¬ifyPortRef, SleepCallBack, ¬ifierObject);
51
51
+
- BAZEL_CHECK_NE(suspend_state.connect_port, MACH_PORT_NULL);
52
52
+
- IONotificationPortSetDispatchQueue(notifyPortRef, queue);
53
53
+
+ // XXX: Unreliable, disable for now
54
54
+
55
55
+
// Register to deal with SIGCONT.
56
56
+
// We register for SIGCONT because we can't catch SIGSTOP.
+392
-312
pkgs/development/tools/build-managers/bazel/bazel_7/default.nix
···
1
1
-
{ stdenv, callPackage, lib, fetchurl, fetchpatch, fetchFromGitHub, installShellFiles
2
2
-
, runCommand, runCommandCC, makeWrapper, recurseIntoAttrs
3
3
-
# this package (through the fixpoint glass)
1
1
+
{ stdenv
2
2
+
, callPackage
3
3
+
, lib
4
4
+
, fetchurl
5
5
+
, fetchpatch
6
6
+
, fetchFromGitHub
7
7
+
, installShellFiles
8
8
+
, runCommand
9
9
+
, runCommandCC
10
10
+
, makeWrapper
11
11
+
, recurseIntoAttrs
12
12
+
# this package (through the fixpoint glass)
4
13
, bazel_self
5
5
-
, lr, xe, zip, unzip, bash, writeCBin, coreutils
6
6
-
, which, gawk, gnused, gnutar, gnugrep, gzip, findutils
7
7
-
, diffutils, gnupatch
8
8
-
# updater
9
9
-
, python3, writeScript
10
10
-
# Apple dependencies
11
11
-
, cctools, libcxx, CoreFoundation, CoreServices, Foundation
12
12
-
# Allow to independently override the jdks used to build and run respectively
13
13
-
, buildJdk, runJdk
14
14
+
, lr
15
15
+
, xe
16
16
+
, zip
17
17
+
, unzip
18
18
+
, bash
19
19
+
, writeCBin
20
20
+
, coreutils
21
21
+
, which
22
22
+
, gawk
23
23
+
, gnused
24
24
+
, gnutar
25
25
+
, gnugrep
26
26
+
, gzip
27
27
+
, findutils
28
28
+
, diffutils
29
29
+
, gnupatch
30
30
+
# updater
31
31
+
, python3
32
32
+
, writeScript
33
33
+
# Apple dependencies
34
34
+
, cctools
35
35
+
, libcxx
36
36
+
, CoreFoundation
37
37
+
, CoreServices
38
38
+
, Foundation
39
39
+
, IOKit
40
40
+
# Allow to independently override the jdks used to build and run respectively
41
41
+
, buildJdk
42
42
+
, runJdk
14
43
, runtimeShell
15
15
-
# Downstream packages for tests
44
44
+
# Downstream packages for tests
16
45
, bazel-watcher
17
17
-
# Always assume all markers valid (this is needed because we remove markers; they are non-deterministic).
18
18
-
# Also, don't clean up environment variables (so that NIX_ environment variables are passed to compilers).
46
46
+
# Always assume all markers valid (this is needed because we remove markers; they are non-deterministic).
47
47
+
# Also, don't clean up environment variables (so that NIX_ environment variables are passed to compilers).
19
48
, enableNixHacks ? false
20
49
, gcc-unwrapped
21
50
, autoPatchelfHook
22
51
, file
23
52
, substituteAll
24
53
, writeTextFile
54
54
+
, writeText
55
55
+
, darwin
56
56
+
, jdk11_headless
57
57
+
, jdk17_headless
58
58
+
, openjdk8
59
59
+
, ripgrep
60
60
+
, sigtool
25
61
}:
26
62
27
63
let
28
28
-
version = "6.3.2";
64
64
+
version = "7.0.0-pre.20230917.3";
29
65
sourceRoot = ".";
30
66
31
67
src = fetchurl {
32
68
url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
33
33
-
hash = "sha256-jNf+rFgZO+K8ukUbpmiKRoJNN8pjWf9Y4NROuY8EKUg=";
69
69
+
hash = "sha256-sxITaivcJRrQrL+zZtdZohesNgmDtQysIG3BS8SFZd4=";
34
70
};
35
71
36
36
-
# Update with
37
37
-
# 1. export BAZEL_SELF=$(nix-build -A bazel_6)
38
38
-
# 2. update version and hash for sources above
39
39
-
# 3. `eval $(nix-build -A bazel_6.updater)`
40
40
-
# 4. add new dependencies from the dict in ./src-deps.json if required by failing build
41
41
-
srcDeps = lib.attrsets.attrValues srcDepsSet;
42
42
-
srcDepsSet =
43
43
-
let
44
44
-
srcs = lib.importJSON ./src-deps.json;
45
45
-
toFetchurl = d: lib.attrsets.nameValuePair d.name (fetchurl {
46
46
-
urls = d.urls or [d.url];
47
47
-
sha256 = d.sha256;
48
48
-
});
49
49
-
in builtins.listToAttrs (map toFetchurl [
50
50
-
srcs.desugar_jdk_libs
51
51
-
srcs.io_bazel_skydoc
52
52
-
srcs.bazel_skylib
53
53
-
srcs.bazelci_rules
54
54
-
srcs.io_bazel_rules_sass
55
55
-
srcs.platforms
56
56
-
srcs.remote_java_tools_for_testing
57
57
-
srcs."coverage_output_generator-v2.6.zip"
58
58
-
srcs.build_bazel_rules_nodejs
59
59
-
srcs.android_tools_for_testing
60
60
-
srcs.openjdk_linux_vanilla
61
61
-
srcs.bazel_toolchains
62
62
-
srcs.com_github_grpc_grpc
63
63
-
srcs.upb
64
64
-
srcs.com_google_protobuf
65
65
-
srcs.rules_pkg
66
66
-
srcs.rules_cc
67
67
-
srcs.rules_java
68
68
-
srcs.rules_proto
69
69
-
srcs.rules_nodejs
70
70
-
srcs.rules_license
71
71
-
srcs.com_google_absl
72
72
-
srcs.com_googlesource_code_re2
73
73
-
srcs.com_github_cares_cares
74
74
-
srcs.com_envoyproxy_protoc_gen_validate
75
75
-
srcs.com_google_googleapis
76
76
-
srcs.bazel_gazelle
77
77
-
]);
72
72
+
# Use builtins.fetchurl to avoid IFD, in particular on hydra
73
73
+
lockfile = builtins.fetchurl {
74
74
+
url = "https://raw.githubusercontent.com/bazelbuild/bazel/${version}/MODULE.bazel.lock";
75
75
+
sha256 = "0z6mlz8cn03qa40mqbw6j6kd6qyn4vgb3bb1kyidazgldxjhrz6y";
76
76
+
};
78
77
79
79
-
distDir = runCommand "bazel-deps" {} ''
80
80
-
mkdir -p $out
81
81
-
for i in ${builtins.toString srcDeps}; do cp $i $out/$(stripHash $i); done
82
82
-
'';
78
78
+
# Two-in-one format
79
79
+
distDir = repoCache;
80
80
+
repoCache = callPackage ./bazel-repository-cache.nix {
81
81
+
inherit lockfile;
82
82
+
# TODO: efficiently filter so that all tests find their dependencies
83
83
+
# without downloading 10 jdk versions
84
84
+
# requiredDeps = ./required-hashes.json;
85
85
+
};
83
86
84
87
defaultShellUtils =
85
88
# Keep this list conservative. For more exotic tools, prefer to use
···
130
133
131
134
platforms = lib.platforms.linux ++ lib.platforms.darwin;
132
135
133
133
-
system = if stdenv.hostPlatform.isDarwin then "darwin" else "linux";
136
136
+
inherit (stdenv.hostPlatform) isDarwin isAarch64;
137
137
+
138
138
+
system = if isDarwin then "darwin" else "linux";
134
139
135
140
# on aarch64 Darwin, `uname -m` returns "arm64"
136
141
arch = with stdenv.hostPlatform; if isDarwin && isAarch64 then "arm64" else parsed.cpu.name;
···
138
143
bazelRC = writeTextFile {
139
144
name = "bazel-rc";
140
145
text = ''
141
141
-
startup --server_javabase=${runJdk}
146
146
+
startup --server_javabase=${buildJdk}
142
147
143
143
-
# Can't use 'common'; https://github.com/bazelbuild/bazel/issues/3054
144
144
-
# Most commands inherit from 'build' anyway.
145
145
-
build --distdir=${distDir}
146
146
-
fetch --distdir=${distDir}
147
147
-
query --distdir=${distDir}
148
148
-
149
149
-
build --extra_toolchains=@bazel_tools//tools/jdk:nonprebuilt_toolchain_definition
150
150
-
build --tool_java_runtime_version=local_jdk_11
151
151
-
build --java_runtime_version=local_jdk_11
148
148
+
build --extra_toolchains=@local_jdk//:all
149
149
+
build --tool_java_runtime_version=local_jdk
150
150
+
build --java_runtime_version=local_jdk
151
151
+
build --repo_env=JAVA_HOME=${buildJdk}${if isDarwin then "/zulu-11.jdk/Contents/Home" else "/lib/openjdk"}
152
152
153
153
# load default location for the system wide configuration
154
154
try-import /etc/bazel.bazelrc
155
155
'';
156
156
};
157
157
158
158
+
bazelNixFlagsScript = writeScript "bazel-nix-flags" ''
159
159
+
cat << EOF
160
160
+
common --announce_rc
161
161
+
build --toolchain_resolution_debug=".*"
162
162
+
build --local_ram_resources=HOST_RAM*.5
163
163
+
build --local_cpu_resources=HOST_CPUS*.75
164
164
+
build --copt=$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ / --copt=/g')
165
165
+
build --host_copt=$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ / --host_copt=/g')
166
166
+
build --linkopt=$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ / --linkopt=/g')
167
167
+
build --host_linkopt=$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ / --host_linkopt=/g')
168
168
+
build --linkopt=-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ / --linkopt=-Wl,/g')
169
169
+
build --host_linkopt=-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ / --host_linkopt=-Wl,/g')
170
170
+
build --extra_toolchains=@bazel_tools//tools/jdk:nonprebuilt_toolchain_definition
171
171
+
build --verbose_failures
172
172
+
build --curses=no
173
173
+
build --features=-layering_check
174
174
+
build --experimental_strict_java_deps=off
175
175
+
build --strict_proto_deps=off
176
176
+
build --extra_toolchains=@bazel_tools//tools/jdk:nonprebuilt_toolchain_java11_definition
177
177
+
build --extra_toolchains=@local_jdk//:all
178
178
+
build --tool_java_runtime_version=local_jdk_11
179
179
+
build --java_runtime_version=local_jdk_11
180
180
+
build --repo_env=JAVA_HOME=${buildJdk}${if isDarwin then "/zulu-11.jdk/Contents/Home" else "/lib/openjdk"}
181
181
+
EOF
182
182
+
'';
158
183
in
159
184
stdenv.mkDerivation rec {
160
185
pname = "bazel";
···
165
190
description = "Build tool that builds code quickly and reliably";
166
191
sourceProvenance = with sourceTypes; [
167
192
fromSource
168
168
-
binaryBytecode # source bundles dependencies as jars
193
193
+
binaryBytecode # source bundles dependencies as jars
169
194
];
170
195
license = licenses.asl20;
171
196
maintainers = lib.teams.bazel.members;
···
175
200
inherit src;
176
201
inherit sourceRoot;
177
202
patches = [
178
178
-
# Force usage of the _non_ prebuilt java toolchain.
179
179
-
# the prebuilt one does not work in nix world.
180
180
-
./java_toolchain.patch
203
203
+
# TODO: Make GSON work,
204
204
+
# In particular, our bazel build cannot emit MODULE.bazel.lock
205
205
+
# it only produces an empty json object `{ }`.
206
206
+
./serialize_nulls.patch
207
207
+
208
208
+
./darwin_sleep.patch
181
209
182
210
# On Darwin, the last argument to gcc is coming up as an empty string. i.e: ''
183
211
# This is breaking the build of any C target. This patch removes the last
184
212
# argument if it's found to be an empty string.
185
213
../trim-last-argument-to-gcc-if-empty.patch
186
214
215
215
+
# XXX: This seems merged / not a real problem. See PR.
187
216
# `java_proto_library` ignores `strict_proto_deps`
188
217
# https://github.com/bazelbuild/bazel/pull/16146
189
189
-
./strict_proto_deps.patch
218
218
+
# ./strict_proto_deps.patch
190
219
191
220
# On Darwin, using clang 6 to build fails because of a linker error (see #105573),
192
221
# but using clang 7 fails because libarclite_macosx.a cannot be found when linking
···
226
255
227
256
# Additional tests that check bazel’s functionality. Execute
228
257
#
229
229
-
# nix-build . -A bazel_6.tests
258
258
+
# nix-build . -A bazel_7.tests
230
259
#
231
260
# in the nixpkgs checkout root to exercise them locally.
232
261
passthru.tests =
233
262
let
234
263
runLocal = name: attrs: script:
235
235
-
let
236
236
-
attrs' = removeAttrs attrs [ "buildInputs" ];
237
237
-
buildInputs = attrs.buildInputs or [];
238
238
-
in
239
239
-
runCommandCC name ({
240
240
-
inherit buildInputs;
241
241
-
preferLocalBuild = true;
242
242
-
meta.platforms = platforms;
243
243
-
} // attrs') script;
264
264
+
let
265
265
+
attrs' = removeAttrs attrs [ "buildInputs" ];
266
266
+
buildInputs = attrs.buildInputs or [ ];
267
267
+
in
268
268
+
runCommandCC name
269
269
+
({
270
270
+
inherit buildInputs;
271
271
+
preferLocalBuild = true;
272
272
+
meta.platforms = platforms;
273
273
+
} // attrs')
274
274
+
script;
244
275
245
276
# bazel wants to extract itself into $install_dir/install every time it runs,
246
277
# so let’s do that only once.
247
278
extracted = bazelPkg:
248
248
-
let install_dir =
249
249
-
# `install_base` field printed by `bazel info`, minus the hash.
250
250
-
# yes, this path is kinda magic. Sorry.
251
251
-
"$HOME/.cache/bazel/_bazel_nixbld";
252
252
-
in runLocal "bazel-extracted-homedir" { passthru.install_dir = install_dir; } ''
253
253
-
export HOME=$(mktemp -d)
254
254
-
touch WORKSPACE # yeah, everything sucks
255
255
-
install_base="$(${bazelPkg}/bin/bazel info | grep install_base)"
256
256
-
# assert it’s actually below install_dir
257
257
-
[[ "$install_base" =~ ${install_dir} ]] \
258
258
-
|| (echo "oh no! $install_base but we are \
259
259
-
trying to copy ${install_dir} to $out instead!"; exit 1)
260
260
-
cp -R ${install_dir} $out
261
261
-
'';
279
279
+
let
280
280
+
install_dir =
281
281
+
# `install_base` field printed by `bazel info`, minus the hash.
282
282
+
# yes, this path is kinda magic. Sorry.
283
283
+
"$HOME/.cache/bazel/_bazel_nixbld";
284
284
+
in
285
285
+
runLocal "bazel-extracted-homedir" { passthru.install_dir = install_dir; } ''
286
286
+
export HOME=$(mktemp -d)
287
287
+
touch WORKSPACE # yeah, everything sucks
288
288
+
install_base="$(${bazelPkg}/bin/bazel info install_base)"
289
289
+
# assert it’s actually below install_dir
290
290
+
[[ "$install_base" =~ ${install_dir} ]] \
291
291
+
|| (echo "oh no! $install_base but we are \
292
292
+
trying to copy ${install_dir} to $out instead!"; exit 1)
293
293
+
cp -R ${install_dir} $out
294
294
+
'';
262
295
263
263
-
bazelTest = { name, bazelScript, workspaceDir, bazelPkg, buildInputs ? [] }:
296
296
+
bazelTest = { name, bazelScript, workspaceDir, bazelPkg, buildInputs ? [ ] }:
264
297
let
265
298
be = extracted bazelPkg;
266
266
-
in runLocal name { inherit buildInputs; } (
267
267
-
# skip extraction caching on Darwin, because nobody knows how Darwin works
268
268
-
(lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
269
269
-
# set up home with pre-unpacked bazel
299
299
+
in
300
300
+
runLocal name
301
301
+
{
302
302
+
inherit buildInputs;
303
303
+
# Necessary for the tests to pass on Darwin with sandbox enabled.
304
304
+
__darwinAllowLocalNetworking = true;
305
305
+
}
306
306
+
''
307
307
+
# Bazel needs a real home for self-extraction and internal cache
270
308
export HOME=$(mktemp -d)
271
271
-
mkdir -p ${be.install_dir}
272
272
-
cp -R ${be}/install ${be.install_dir}
309
309
+
export USER=$(basename $HOME)
273
310
274
274
-
# https://stackoverflow.com/questions/47775668/bazel-how-to-skip-corrupt-installation-on-centos6
275
275
-
# Bazel checks whether the mtime of the install dir files
276
276
-
# is >9 years in the future, otherwise it extracts itself again.
277
277
-
# see PosixFileMTime::IsUntampered in src/main/cpp/util
278
278
-
# What the hell bazel.
279
279
-
${lr}/bin/lr -0 -U ${be.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
280
280
-
'')
281
281
-
+
282
282
-
''
283
283
-
# Note https://github.com/bazelbuild/bazel/issues/5763#issuecomment-456374609
284
284
-
# about why to create a subdir for the workspace.
285
285
-
cp -r ${workspaceDir} wd && chmod u+w wd && cd wd
311
311
+
${# Concurrent bazel invocations have the same workspace path.
312
312
+
# On darwin, for some reason, it means they accessing and corrupting the same execroot.
313
313
+
# Having a different workspace path ensures we use different execroots.
314
314
+
lib.optionalString isDarwin ''
315
315
+
# cd $(mktemp --tmpdir=. -d)
316
316
+
''
317
317
+
}
318
318
+
${# Speed-up tests by caching bazel extraction.
319
319
+
# Except on Darwin, because nobody knows how Darwin works.
320
320
+
lib.optionalString (!isDarwin) ''
321
321
+
mkdir -p ${be.install_dir}
322
322
+
cp -R ${be}/install ${be.install_dir}
286
323
287
287
-
${bazelScript}
324
324
+
# https://stackoverflow.com/questions/47775668/bazel-how-to-skip-corrupt-installation-on-centos6
325
325
+
# Bazel checks whether the mtime of the install dir files
326
326
+
# is >9 years in the future, otherwise it extracts itself again.
327
327
+
# see PosixFileMTime::IsUntampered in src/main/cpp/util
328
328
+
# What the hell bazel.
329
329
+
${lr}/bin/lr -0 -U ${be.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
330
330
+
''
331
331
+
}
332
332
+
${# Note https://github.com/bazelbuild/bazel/issues/5763#issuecomment-456374609
333
333
+
# about why to create a subdir for the workspace.
334
334
+
'' cp -r ${workspaceDir} wd && chmod u+w wd && cd wd ''
335
335
+
}
336
336
+
${# run the actual test snippet
337
337
+
bazelScript
338
338
+
}
339
339
+
${# Try to keep darwin clean of our garbage
340
340
+
lib.optionalString isDarwin ''
341
341
+
rm -rf $HOME || true
342
342
+
''
343
343
+
}
288
344
289
345
touch $out
290
290
-
'');
291
291
-
292
292
-
bazelWithNixHacks = bazel_self.override { enableNixHacks = true; };
346
346
+
'';
293
347
294
348
bazel-examples = fetchFromGitHub {
295
349
owner = "bazelbuild";
296
350
repo = "examples";
297
297
-
rev = "4183fc709c26a00366665e2d60d70521dc0b405d";
298
298
-
sha256 = "1mm4awx6sa0myiz9j4hwp71rpr7yh8vihf3zm15n2ii6xb82r31k";
351
351
+
rev = "93564e1f1e7a3c39d6a94acee12b8d7b74de3491";
352
352
+
hash = "sha256-DaPKp7Sn5uvfZRjdDx6grot3g3B7trqCyL0TRIdwg98=";
299
353
};
300
354
301
301
-
in (lib.optionalAttrs (!stdenv.hostPlatform.isDarwin) {
355
355
+
callBazelTest = lib.callPackageWith {
356
356
+
inherit runLocal bazelTest bazel-examples lib writeText darwin runtimeShell stdenv writeScript jdk11_headless openjdk8 fetchFromGitHub fetchurl ripgrep unzip jdk17_headless Foundation;
357
357
+
inherit distDir;
358
358
+
extraBazelArgs = ''
359
359
+
--repository_cache=${repoCache} \
360
360
+
--repo_env=JAVA_HOME=${runJdk}${if isDarwin then "/zulu-17.jdk/Contents/Home" else "/lib/openjdk"} \
361
361
+
'';
362
362
+
bazel = bazel_self;
363
363
+
};
364
364
+
365
365
+
bazelWithNixHacks = bazel_self.override { enableNixHacks = true; };
366
366
+
367
367
+
in
368
368
+
(lib.optionalAttrs (!stdenv.hostPlatform.isDarwin) {
302
369
# `extracted` doesn’t work on darwin
303
303
-
shebang = callPackage ../shebang-test.nix { inherit runLocal extracted bazelTest distDir; bazel = bazel_self;};
370
370
+
shebang = callBazelTest ../shebang-test.nix { inherit extracted; };
304
371
}) // {
305
305
-
bashTools = callPackage ../bash-tools-test.nix { inherit runLocal bazelTest distDir; bazel = bazel_self;};
306
306
-
cpp = callPackage ../cpp-test.nix { inherit runLocal bazelTest bazel-examples distDir; bazel = bazel_self;};
307
307
-
java = callPackage ../java-test.nix { inherit runLocal bazelTest bazel-examples distDir; bazel = bazel_self;};
308
308
-
protobuf = callPackage ../protobuf-test.nix { inherit runLocal bazelTest distDir; bazel = bazel_self; };
309
309
-
pythonBinPath = callPackage ../python-bin-path-test.nix { inherit runLocal bazelTest distDir; bazel = bazel_self;};
372
372
+
bashTools = callBazelTest ../bash-tools-test.nix { };
373
373
+
cpp = callBazelTest ../cpp-test.nix { };
374
374
+
java = callBazelTest ../java-test.nix { };
375
375
+
# TODO: protobuf tests just fail for now.
376
376
+
#protobuf = callBazelTest ../protobuf-test.nix { };
377
377
+
pythonBinPath = callBazelTest ../python-bin-path-test.nix { };
310
378
311
311
-
bashToolsWithNixHacks = callPackage ../bash-tools-test.nix { inherit runLocal bazelTest distDir; bazel = bazelWithNixHacks; };
379
379
+
bashToolsWithNixHacks = callBazelTest ../bash-tools-test.nix { bazel = bazelWithNixHacks; };
312
380
313
313
-
cppWithNixHacks = callPackage ../cpp-test.nix { inherit runLocal bazelTest bazel-examples distDir; bazel = bazelWithNixHacks; };
314
314
-
javaWithNixHacks = callPackage ../java-test.nix { inherit runLocal bazelTest bazel-examples distDir; bazel = bazelWithNixHacks; };
315
315
-
protobufWithNixHacks = callPackage ../protobuf-test.nix { inherit runLocal bazelTest distDir; bazel = bazelWithNixHacks; };
316
316
-
pythonBinPathWithNixHacks = callPackage ../python-bin-path-test.nix { inherit runLocal bazelTest distDir; bazel = bazelWithNixHacks; };
381
381
+
cppWithNixHacks = callBazelTest ../cpp-test.nix { bazel = bazelWithNixHacks; };
382
382
+
javaWithNixHacks = callBazelTest ../java-test.nix { bazel = bazelWithNixHacks; };
383
383
+
#protobufWithNixHacks = callBazelTest ../protobuf-test.nix { bazel = bazelWithNixHacks; };
384
384
+
pythonBinPathWithNixHacks = callBazelTest ../python-bin-path-test.nix { bazel = bazelWithNixHacks; };
317
385
318
386
# downstream packages using buildBazelPackage
319
387
# fixed-output hashes of the fetch phase need to be spot-checked manually
320
320
-
downstream = recurseIntoAttrs ({
321
321
-
inherit bazel-watcher;
322
322
-
});
388
388
+
# TODO
389
389
+
#downstream = recurseIntoAttrs ({
390
390
+
# inherit bazel-watcher;
391
391
+
#});
323
392
};
324
393
325
394
src_for_updater = stdenv.mkDerivation rec {
···
335
404
runHook postInstall
336
405
'';
337
406
};
338
338
-
# update the list of workspace dependencies
339
339
-
passthru.updater = writeScript "update-bazel-deps.sh" ''
340
340
-
#!${runtimeShell}
341
341
-
(cd "${src_for_updater}" &&
342
342
-
BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \
343
343
-
"$BAZEL_SELF"/bin/bazel \
344
344
-
query 'kind(http_archive, //external:*) + kind(http_file, //external:*) + kind(distdir_tar, //external:*) + kind(git_repository, //external:*)' \
345
345
-
--loading_phase_threads=1 \
346
346
-
--output build) \
347
347
-
| "${python3}"/bin/python3 "${./update-srcDeps.py}" \
348
348
-
"${builtins.toString ./src-deps.json}"
349
349
-
'';
350
407
351
351
-
# Necessary for the tests to pass on Darwin with sandbox enabled.
352
408
# Bazel starts a local server and needs to bind a local address.
353
409
__darwinAllowLocalNetworking = true;
410
410
+
# XXX: For IORegisterForSystemPower
411
411
+
# propagatedSandboxProfile = ''
412
412
+
# (allow iokit-open (iokit-user-client-class "RootDomainUserClient"))
413
413
+
# '';
354
414
355
355
-
postPatch = let
415
415
+
postPatch =
416
416
+
let
356
417
357
357
-
darwinPatches = ''
358
358
-
bazelLinkFlags () {
359
359
-
eval set -- "$NIX_LDFLAGS"
360
360
-
local flag
361
361
-
for flag in "$@"; do
362
362
-
printf ' -Wl,%s' "$flag"
363
363
-
done
364
364
-
}
418
418
+
darwinPatches = ''
419
419
+
bazelLinkFlags () {
420
420
+
eval set -- "$NIX_LDFLAGS"
421
421
+
local flag
422
422
+
for flag in "$@"; do
423
423
+
printf ' -Wl,%s' "$flag"
424
424
+
done
425
425
+
}
365
426
366
366
-
# Disable Bazel's Xcode toolchain detection which would configure compilers
367
367
-
# and linkers from Xcode instead of from PATH
368
368
-
export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
427
427
+
# Disable Bazel's Xcode toolchain detection which would configure compilers
428
428
+
# and linkers from Xcode instead of from PATH
429
429
+
export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
369
430
370
370
-
# Explicitly configure gcov since we don't have it on Darwin, so autodetection fails
371
371
-
export GCOV=${coreutils}/bin/false
431
431
+
# Explicitly configure gcov since we don't have it on Darwin, so autodetection fails
432
432
+
export GCOV=${coreutils}/bin/false
372
433
373
373
-
# Framework search paths aren't added by bintools hook
374
374
-
# https://github.com/NixOS/nixpkgs/pull/41914
375
375
-
export NIX_LDFLAGS+=" -F${CoreFoundation}/Library/Frameworks -F${CoreServices}/Library/Frameworks -F${Foundation}/Library/Frameworks"
434
434
+
# Framework search paths aren't added by bintools hook
435
435
+
# https://github.com/NixOS/nixpkgs/pull/41914
436
436
+
export NIX_LDFLAGS+=" -F${CoreFoundation}/Library/Frameworks -F${CoreServices}/Library/Frameworks -F${Foundation}/Library/Frameworks -F${IOKit}/Library/Frameworks"
376
437
377
377
-
# libcxx includes aren't added by libcxx hook
378
378
-
# https://github.com/NixOS/nixpkgs/pull/41589
379
379
-
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${lib.getDev libcxx}/include/c++/v1"
438
438
+
# libcxx includes aren't added by libcxx hook
439
439
+
# https://github.com/NixOS/nixpkgs/pull/41589
440
440
+
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${lib.getDev libcxx}/include/c++/v1"
380
441
381
381
-
# don't use system installed Xcode to run clang, use Nix clang instead
382
382
-
sed -i -E "s;/usr/bin/xcrun (--sdk macosx )?clang;${stdenv.cc}/bin/clang $NIX_CFLAGS_COMPILE $(bazelLinkFlags) -framework CoreFoundation;g" \
383
383
-
scripts/bootstrap/compile.sh \
384
384
-
tools/osx/BUILD
442
442
+
# don't use system installed Xcode to run clang, use Nix clang instead
443
443
+
sed -i -E \
444
444
+
-e "s;/usr/bin/xcrun (--sdk macosx )?clang;${stdenv.cc}/bin/clang $NIX_CFLAGS_COMPILE $(bazelLinkFlags) -framework CoreFoundation;g" \
445
445
+
-e "s;/usr/bin/codesign;CODESIGN_ALLOCATE=${cctools}/bin/${cctools.targetPrefix}codesign_allocate ${sigtool}/bin/codesign;" \
446
446
+
scripts/bootstrap/compile.sh \
447
447
+
tools/osx/BUILD
385
448
386
386
-
substituteInPlace scripts/bootstrap/compile.sh --replace ' -mmacosx-version-min=10.9' ""
449
449
+
substituteInPlace scripts/bootstrap/compile.sh --replace ' -mmacosx-version-min=10.9' ""
387
450
388
388
-
# nixpkgs's libSystem cannot use pthread headers directly, must import GCD headers instead
389
389
-
sed -i -e "/#include <pthread\/spawn.h>/i #include <dispatch/dispatch.h>" src/main/cpp/blaze_util_darwin.cc
451
451
+
# nixpkgs's libSystem cannot use pthread headers directly, must import GCD headers instead
452
452
+
sed -i -e "/#include <pthread\/spawn.h>/i #include <dispatch/dispatch.h>" src/main/cpp/blaze_util_darwin.cc
390
453
391
391
-
# clang installed from Xcode has a compatibility wrapper that forwards
392
392
-
# invocations of gcc to clang, but vanilla clang doesn't
393
393
-
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
454
454
+
# clang installed from Xcode has a compatibility wrapper that forwards
455
455
+
# invocations of gcc to clang, but vanilla clang doesn't
456
456
+
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
394
457
395
395
-
sed -i -e 's;"/usr/bin/libtool";_find_generic(repository_ctx, "libtool", "LIBTOOL", overriden_tools);g' tools/cpp/unix_cc_configure.bzl
396
396
-
wrappers=( tools/cpp/osx_cc_wrapper.sh.tpl )
397
397
-
for wrapper in "''${wrappers[@]}"; do
398
398
-
sed -i -e "s,/usr/bin/gcc,${stdenv.cc}/bin/clang,g" $wrapper
399
399
-
sed -i -e "s,/usr/bin/install_name_tool,${cctools}/bin/install_name_tool,g" $wrapper
400
400
-
sed -i -e "s,/usr/bin/xcrun install_name_tool,${cctools}/bin/install_name_tool,g" $wrapper
401
401
-
done
402
402
-
'';
458
458
+
sed -i -e 's;"/usr/bin/libtool";_find_generic(repository_ctx, "libtool", "LIBTOOL", overriden_tools);g' tools/cpp/unix_cc_configure.bzl
459
459
+
wrappers=( tools/cpp/osx_cc_wrapper.sh.tpl )
460
460
+
for wrapper in "''${wrappers[@]}"; do
461
461
+
sed -i -e "s,/usr/bin/gcc,${stdenv.cc}/bin/clang,g" $wrapper
462
462
+
sed -i -e "s,/usr/bin/install_name_tool,${cctools}/bin/install_name_tool,g" $wrapper
463
463
+
sed -i -e "s,/usr/bin/xcrun install_name_tool,${cctools}/bin/install_name_tool,g" $wrapper
464
464
+
done
465
465
+
'';
403
466
404
404
-
genericPatches = ''
405
405
-
# md5sum is part of coreutils
406
406
-
sed -i 's|/sbin/md5|md5sum|g' \
407
407
-
src/BUILD third_party/ijar/test/testenv.sh tools/objc/libtool.sh
467
467
+
genericPatches = ''
468
468
+
function sedVerbose() {
469
469
+
local path=$1; shift;
470
470
+
sed -i".bak-nix" "$path" "$@"
471
471
+
diff -U0 "$path.bak-nix" "$path" | sed "s/^/ /" || true
472
472
+
rm -f "$path.bak-nix"
473
473
+
}
408
474
409
409
-
# replace initial value of pythonShebang variable in BazelPythonSemantics.java
410
410
-
substituteInPlace src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java \
411
411
-
--replace '"#!/usr/bin/env " + pythonExecutableName' "\"#!${python3}/bin/python\""
475
475
+
# unzip builtins_bzl.zip so the contents get patched
476
476
+
builtins_bzl=src/main/java/com/google/devtools/build/lib/bazel/rules/builtins_bzl
477
477
+
unzip ''${builtins_bzl}.zip -d ''${builtins_bzl}_zip >/dev/null
478
478
+
rm ''${builtins_bzl}.zip
479
479
+
builtins_bzl=''${builtins_bzl}_zip/builtins_bzl
412
480
413
413
-
substituteInPlace src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java \
414
414
-
--replace '"#!/usr/bin/env python3"' "\"#!${python3}/bin/python\""
481
481
+
# md5sum is part of coreutils
482
482
+
sed -i 's|/sbin/md5|md5sum|g' src/BUILD third_party/ijar/test/testenv.sh
415
483
416
416
-
# substituteInPlace is rather slow, so prefilter the files with grep
417
417
-
grep -rlZ /bin/ src/main/java/com/google/devtools | while IFS="" read -r -d "" path; do
418
418
-
# If you add more replacements here, you must change the grep above!
419
419
-
# Only files containing /bin are taken into account.
420
420
-
substituteInPlace "$path" \
421
421
-
--replace /bin/bash ${bash}/bin/bash \
422
422
-
--replace "/usr/bin/env bash" ${bash}/bin/bash \
423
423
-
--replace "/usr/bin/env python" ${python3}/bin/python \
424
424
-
--replace /usr/bin/env ${coreutils}/bin/env \
425
425
-
--replace /bin/true ${coreutils}/bin/true
426
426
-
done
484
484
+
echo
485
485
+
echo "Substituting */bin/* hardcoded paths in src/main/java/com/google/devtools"
486
486
+
# Prefilter the files with grep for speed
487
487
+
grep -rlZ /bin/ \
488
488
+
src/main/java/com/google/devtools \
489
489
+
src/main/starlark/builtins_bzl/common/python \
490
490
+
tools/python \
491
491
+
tools/cpp \
492
492
+
tools/build_rules \
493
493
+
tools/osx/BUILD \
494
494
+
| while IFS="" read -r -d "" path; do
495
495
+
# If you add more replacements here, you must change the grep above!
496
496
+
# Only files containing /bin are taken into account.
497
497
+
sedVerbose "$path" \
498
498
+
-e 's!/usr/local/bin/bash!${bash}/bin/bash!g' \
499
499
+
-e 's!/usr/bin/bash!${bash}/bin/bash!g' \
500
500
+
-e 's!/bin/bash!${bash}/bin/bash!g' \
501
501
+
-e 's!/usr/bin/env bash!${bash}/bin/bash!g' \
502
502
+
-e 's!/usr/bin/env python2!${python3}/bin/python!g' \
503
503
+
-e 's!/usr/bin/env python!${python3}/bin/python!g' \
504
504
+
-e 's!/usr/bin/env!${coreutils}/bin/env!g' \
505
505
+
-e 's!/bin/true!${coreutils}/bin/true!g'
506
506
+
done
427
507
428
428
-
grep -rlZ /bin/ tools/python | while IFS="" read -r -d "" path; do
429
429
-
substituteInPlace "$path" \
430
430
-
--replace "/usr/bin/env python2" ${python3.interpreter} \
431
431
-
--replace "/usr/bin/env python3" ${python3}/bin/python \
432
432
-
--replace /usr/bin/env ${coreutils}/bin/env
433
433
-
done
508
508
+
# Fixup scripts that generate scripts. Not fixed up by patchShebangs below.
509
509
+
sedVerbose scripts/bootstrap/compile.sh \
510
510
+
-e 's!/bin/bash!${bash}/bin/bash!g' \
511
511
+
-e 's!shasum -a 256!sha256sum!g'
434
512
435
435
-
# bazel test runner include references to /bin/bash
436
436
-
substituteInPlace tools/build_rules/test_rules.bzl \
437
437
-
--replace /bin/bash ${bash}/bin/bash
513
513
+
${bazelNixFlagsScript} > .bazelrc.nix
514
514
+
# export BAZELRC=$PWD/.bazelrc.nix
515
515
+
# export BAZEL_BOOTSTRAP_STARTUP_OPTIONS=""
516
516
+
# export DIST_BAZEL_ARGS=
517
517
+
#export EXTRA_BAZEL_ARGS="--rc_source=$PWD/.bazelrc.nix --announce_rc"
438
518
439
439
-
for i in $(find tools/cpp/ -type f)
440
440
-
do
441
441
-
substituteInPlace $i \
442
442
-
--replace /bin/bash ${bash}/bin/bash
443
443
-
done
519
519
+
# Add compile options to command line.
520
520
+
# XXX: It would suit a bazelrc file better, but I found no way to pass it.
521
521
+
# It seems it is always ignored.
522
522
+
# Passing EXTRA_BAZEL_ARGS is tricky due to quoting.
444
523
445
445
-
# Fixup scripts that generate scripts. Not fixed up by patchShebangs below.
446
446
-
substituteInPlace scripts/bootstrap/compile.sh \
447
447
-
--replace /bin/bash ${bash}/bin/bash
524
524
+
#which javac
525
525
+
#printenv JAVA_HOME
526
526
+
#exit 0
448
527
449
449
-
# add nix environment vars to .bazelrc
450
450
-
cat >> .bazelrc <<EOF
451
451
-
# Limit the resources Bazel is allowed to use during the build to 1/2 the
452
452
-
# available RAM and 3/4 the available CPU cores. This should help avoid
453
453
-
# overwhelming the build machine.
454
454
-
build --toolchain_resolution_debug=".*"
455
455
-
build --local_ram_resources=HOST_RAM*.5
456
456
-
build --local_cpu_resources=HOST_CPUS*.75
528
528
+
sedVerbose compile.sh \
529
529
+
-e "/bazel_build /a\ --copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt=\"/g')\" \\\\" \
530
530
+
-e "/bazel_build /a\ --host_copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --host_copt=\"/g')\" \\\\" \
531
531
+
-e "/bazel_build /a\ --linkopt=\"$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ /" --linkopt=\"/g')\" \\\\" \
532
532
+
-e "/bazel_build /a\ --host_linkopt=\"$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ /" --host_linkopt=\"/g')\" \\\\" \
533
533
+
-e "/bazel_build /a\ --linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --linkopt=\"-Wl,/g')\" \\\\" \
534
534
+
-e "/bazel_build /a\ --host_linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --host_linkopt=\"-Wl,/g')\" \\\\" \
535
535
+
-e "/bazel_build /a\ --verbose_failures \\\\" \
536
536
+
-e "/bazel_build /a\ --curses=no \\\\" \
537
537
+
-e "/bazel_build /a\ --features=-layering_check \\\\" \
538
538
+
-e "/bazel_build /a\ --experimental_strict_java_deps=off \\\\" \
539
539
+
-e "/bazel_build /a\ --strict_proto_deps=off \\\\" \
540
540
+
-e "/bazel_build /a\ --tool_java_runtime_version=local_jdk \\\\" \
541
541
+
-e "/bazel_build /a\ --java_runtime_version=local_jdk \\\\" \
542
542
+
-e "/bazel_build /a\ --repo_env=JAVA_HOME=${buildJdk}/${if isDarwin then "/zulu-11.jdk/Contents/Home" else "/lib/openjdk"} \\\\" \
543
543
+
-e "/bazel_build /a\ --extra_toolchains=@local_jdk//:all \\\\" \
544
544
+
-e "/bazel_build /a\ --toolchain_resolution_debug=@bazel_tools//tools/jdk:runtime_toolchain_type \\\\" \
545
545
+
-e "/bazel_build /a\ --sandbox_debug --verbose_failures \\\\" \
546
546
+
${lib.optionalString isDarwin ''
547
547
+
-e "/bazel_build /a\ --cpu=${({aarch64-darwin = "darwin_arm64"; x86_64-darwin = "darwin_x86_64";}.${stdenv.hostPlatform.system})} \\\\" \''
548
548
+
}
457
549
458
458
-
build --distdir=${distDir}
459
459
-
fetch --distdir=${distDir}
460
460
-
build --copt="$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt="/g')"
461
461
-
build --host_copt="$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --host_copt="/g')"
462
462
-
build --linkopt="$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ /" --linkopt="/g')"
463
463
-
build --host_linkopt="$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ /" --host_linkopt="/g')"
464
464
-
build --linkopt="-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --linkopt="-Wl,/g')"
465
465
-
build --host_linkopt="-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --host_linkopt="-Wl,/g')"
466
466
-
build --extra_toolchains=@bazel_tools//tools/jdk:nonprebuilt_toolchain_definition
467
467
-
build --verbose_failures
468
468
-
build --curses=no
469
469
-
build --features=-layering_check
470
470
-
build --experimental_strict_java_deps=off
471
471
-
build --strict_proto_deps=off
472
472
-
EOF
550
550
+
#-e "/bazel_build /a\ --spawn_strategy=standalone \\\\" \
473
551
474
474
-
cat >> third_party/grpc/bazel_1.41.0.patch <<EOF
475
475
-
diff --git a/third_party/grpc/BUILD b/third_party/grpc/BUILD
476
476
-
index 39ee9f97c6..9128d20c85 100644
477
477
-
--- a/third_party/grpc/BUILD
478
478
-
+++ b/third_party/grpc/BUILD
479
479
-
@@ -28,7 +28,6 @@ licenses(["notice"])
480
480
-
package(
481
481
-
default_visibility = ["//visibility:public"],
482
482
-
features = [
483
483
-
- "layering_check",
484
484
-
"-parse_headers",
485
485
-
],
486
486
-
)
487
487
-
EOF
488
552
489
489
-
# add the same environment vars to compile.sh
490
490
-
sed -e "/\$command \\\\$/a --copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt=\"/g')\" \\\\" \
491
491
-
-e "/\$command \\\\$/a --host_copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --host_copt=\"/g')\" \\\\" \
492
492
-
-e "/\$command \\\\$/a --linkopt=\"$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ /" --linkopt=\"/g')\" \\\\" \
493
493
-
-e "/\$command \\\\$/a --host_linkopt=\"$(echo $(< ${stdenv.cc}/nix-support/libcxx-ldflags) | sed -e 's/ /" --host_linkopt=\"/g')\" \\\\" \
494
494
-
-e "/\$command \\\\$/a --linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --linkopt=\"-Wl,/g')\" \\\\" \
495
495
-
-e "/\$command \\\\$/a --host_linkopt=\"-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --host_linkopt=\"-Wl,/g')\" \\\\" \
496
496
-
-e "/\$command \\\\$/a --tool_java_runtime_version=local_jdk_11 \\\\" \
497
497
-
-e "/\$command \\\\$/a --java_runtime_version=local_jdk_11 \\\\" \
498
498
-
-e "/\$command \\\\$/a --verbose_failures \\\\" \
499
499
-
-e "/\$command \\\\$/a --curses=no \\\\" \
500
500
-
-e "/\$command \\\\$/a --features=-layering_check \\\\" \
501
501
-
-e "/\$command \\\\$/a --experimental_strict_java_deps=off \\\\" \
502
502
-
-e "/\$command \\\\$/a --strict_proto_deps=off \\\\" \
503
503
-
-i scripts/bootstrap/compile.sh
553
553
+
# Also build parser_deploy.jar with bootstrap bazel
554
554
+
# TODO: Turn into a proper patch
555
555
+
sedVerbose compile.sh \
556
556
+
-e 's!bazel_build !bazel_build src/tools/execlog:parser_deploy.jar !' \
557
557
+
-e 's!clear_log!cp $(get_bazel_bin_path)/src/tools/execlog/parser_deploy.jar output\nclear_log!'
504
558
505
505
-
# This is necessary to avoid:
506
506
-
# "error: no visible @interface for 'NSDictionary' declares the selector
507
507
-
# 'initWithContentsOfURL:error:'"
508
508
-
# This can be removed when the apple_sdk is upgraded beyond 10.13+
509
509
-
sed -i '/initWithContentsOfURL:versionPlistUrl/ {
510
510
-
N
511
511
-
s/error:nil\];/\];/
512
512
-
}' tools/osx/xcode_locator.m
513
559
514
514
-
# append the PATH with defaultShellPath in tools/bash/runfiles/runfiles.bash
515
515
-
echo "PATH=\$PATH:${defaultShellPath}" >> runfiles.bash.tmp
516
516
-
cat tools/bash/runfiles/runfiles.bash >> runfiles.bash.tmp
517
517
-
mv runfiles.bash.tmp tools/bash/runfiles/runfiles.bash
560
560
+
# This is necessary to avoid:
561
561
+
# "error: no visible @interface for 'NSDictionary' declares the selector
562
562
+
# 'initWithContentsOfURL:error:'"
563
563
+
# This can be removed when the apple_sdk is upgraded beyond 10.13+
564
564
+
sedVerbose tools/osx/xcode_locator.m \
565
565
+
-e '/initWithContentsOfURL:versionPlistUrl/ {
566
566
+
N
567
567
+
s/error:nil\];/\];/
568
568
+
}'
518
569
519
519
-
patchShebangs .
520
520
-
'';
521
521
-
in lib.optionalString stdenv.hostPlatform.isDarwin darwinPatches
522
522
-
+ genericPatches;
570
570
+
# append the PATH with defaultShellPath in tools/bash/runfiles/runfiles.bash
571
571
+
echo "PATH=\$PATH:${defaultShellPath}" >> runfiles.bash.tmp
572
572
+
cat tools/bash/runfiles/runfiles.bash >> runfiles.bash.tmp
573
573
+
mv runfiles.bash.tmp tools/bash/runfiles/runfiles.bash
523
574
524
524
-
buildInputs = [buildJdk] ++ defaultShellUtils;
575
575
+
# reconstruct the now patched builtins_bzl.zip
576
576
+
pushd src/main/java/com/google/devtools/build/lib/bazel/rules/builtins_bzl_zip &>/dev/null
577
577
+
zip ../builtins_bzl.zip $(find builtins_bzl -type f) >/dev/null
578
578
+
rm -rf builtins_bzl
579
579
+
popd &>/dev/null
580
580
+
rmdir src/main/java/com/google/devtools/build/lib/bazel/rules/builtins_bzl_zip
581
581
+
582
582
+
patchShebangs . >/dev/null
583
583
+
'';
584
584
+
in
585
585
+
lib.optionalString stdenv.hostPlatform.isDarwin darwinPatches
586
586
+
+ genericPatches;
587
587
+
588
588
+
buildInputs = [ buildJdk ] ++ defaultShellUtils;
525
589
526
590
# when a command can’t be found in a bazel build, you might also
527
591
# need to add it to `defaultShellPath`.
···
532
596
unzip
533
597
which
534
598
zip
535
535
-
python3.pkgs.absl-py # Needed to build fish completion
536
536
-
] ++ lib.optionals (stdenv.isDarwin) [ cctools libcxx CoreFoundation CoreServices Foundation ];
599
599
+
python3.pkgs.absl-py # Needed to build fish completion
600
600
+
] ++ lib.optionals (stdenv.isDarwin) [
601
601
+
cctools
602
602
+
libcxx
603
603
+
CoreFoundation
604
604
+
CoreServices
605
605
+
Foundation
606
606
+
];
537
607
538
608
# Bazel makes extensive use of symlinks in the WORKSPACE.
539
609
# This causes problems with infinite symlinks if the build output is in the same location as the
540
610
# Bazel WORKSPACE. This is why before executing the build, the source code is moved into a
541
611
# subdirectory.
542
612
# Failing to do this causes "infinite symlink expansion detected"
543
543
-
preBuildPhases = ["preBuildPhase"];
613
613
+
preBuildPhases = [ "preBuildPhase" ];
544
614
preBuildPhase = ''
545
615
mkdir bazel_src
546
616
shopt -s dotglob extglob
···
560
630
# Note that .bazelversion is always correct and is based on bazel-*
561
631
# executable name, version checks should work fine
562
632
export EMBED_LABEL="${version}- (@non-git)"
633
633
+
echo "Stage 1 - Running bazel bootstrap script"
563
634
${bash}/bin/bash ./bazel_src/compile.sh
564
564
-
./bazel_src/scripts/generate_bash_completion.sh \
635
635
+
636
636
+
# XXX: get rid of this, or move it to another stage.
637
637
+
# It is plain annoying when builds fail.
638
638
+
echo "Stage 2 - Generate bazel completions"
639
639
+
${bash}/bin/bash ./bazel_src/scripts/generate_bash_completion.sh \
565
640
--bazel=./bazel_src/output/bazel \
566
641
--output=./bazel_src/output/bazel-complete.bash \
567
642
--prepend=./bazel_src/scripts/bazel-complete-header.bash \
···
570
645
--bazel=./bazel_src/output/bazel \
571
646
--output=./bazel_src/output/bazel-complete.fish
572
647
573
573
-
# need to change directory for bazel to find the workspace
574
574
-
cd ./bazel_src
575
575
-
# build execlog tooling
576
576
-
export HOME=$(mktemp -d)
577
577
-
./output/bazel build src/tools/execlog:parser_deploy.jar
578
578
-
cd -
648
648
+
#echo "Stage 3 - Generate parser_deploy.jar"
649
649
+
# XXX: for now, build in the patched compile.sh script to get all the args right.
650
650
+
## need to change directory for bazel to find the workspace
651
651
+
#cd ./bazel_src
652
652
+
## build execlog tooling
653
653
+
#export HOME=$(mktemp -d)
654
654
+
#./output/bazel build src/tools/execlog:parser_deploy.jar
655
655
+
#cd -
579
656
580
657
runHook postBuild
581
658
'';
···
594
671
mv ./bazel_src/output/bazel $out/bin/bazel-${version}-${system}-${arch}
595
672
596
673
mkdir $out/share
597
597
-
cp ./bazel_src/bazel-bin/src/tools/execlog/parser_deploy.jar $out/share/parser_deploy.jar
674
674
+
cp ./bazel_src/output/parser_deploy.jar $out/share/parser_deploy.jar
598
675
cat <<EOF > $out/bin/bazel-execlog
599
676
#!${runtimeShell} -e
600
677
${runJdk}/bin/java -jar $out/share/parser_deploy.jar \$@
···
615
692
616
693
# Install check fails on `aarch64-darwin`
617
694
# https://github.com/NixOS/nixpkgs/issues/145587
618
618
-
doInstallCheck = stdenv.hostPlatform.system != "aarch64-darwin";
695
695
+
doInstallCheck = false; #stdenv.hostPlatform.system != "aarch64-darwin";
619
696
installCheckPhase = ''
620
697
export TEST_TMPDIR=$(pwd)
621
698
···
672
749
673
750
dontStrip = true;
674
751
dontPatchELF = true;
752
752
+
753
753
+
passthru.repoCache = repoCache;
754
754
+
passthru.distDir = distDir;
675
755
}
+17
-23
pkgs/development/tools/build-managers/bazel/bazel_7/java_toolchain.patch
···
1
1
+
commit ef1f5586d3c7fb426af1df6ba650bbad98a5a78a
2
2
+
Author: Guillaume Maudoux <guillaume.maudoux@tweag.io>
3
3
+
Date: Fri Oct 6 15:03:28 2023 +0200
4
4
+
5
5
+
java_toolchain.patch
6
6
+
1
7
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools
8
8
+
index a8af76e90c..af2540f838 100644
2
9
--- a/tools/jdk/BUILD.tools
3
10
+++ b/tools/jdk/BUILD.tools
4
4
-
@@ -3,6 +3,7 @@ load(
5
5
-
"DEFAULT_TOOLCHAIN_CONFIGURATION",
6
6
-
"PREBUILT_TOOLCHAIN_CONFIGURATION",
7
7
-
"VANILLA_TOOLCHAIN_CONFIGURATION",
8
8
-
+ "NONPREBUILT_TOOLCHAIN_CONFIGURATION",
9
9
-
"bootclasspath",
10
10
-
"default_java_toolchain",
11
11
-
"java_runtime_files",
12
12
-
@@ -321,6 +322,21 @@ alias(
13
13
-
actual = ":toolchain",
11
11
+
@@ -146,6 +146,16 @@ py_test(
12
12
+
],
14
13
)
15
14
16
16
-
+default_java_toolchain(
17
17
-
+ name = "nonprebuilt_toolchain",
18
18
-
+ configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION,
19
19
-
+ java_runtime = "@local_jdk//:jdk",
20
20
-
+)
15
15
+
+load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain", "NONPREBUILT_TOOLCHAIN_CONFIGURATION")
21
16
+
22
17
+default_java_toolchain(
23
23
-
+ name = "nonprebuilt_toolchain_java11",
24
24
-
+ configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION,
25
25
-
+ java_runtime = "@local_jdk//:jdk",
26
26
-
+ source_version = "11",
27
27
-
+ target_version = "11",
18
18
+
+ name = "nonprebuilt_toolchain_java11",
19
19
+
+ configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION,
20
20
+
+ java_runtime = "@local_jdk//:jdk",
21
21
+
+ source_version = "11",
22
22
+
+ target_version = "11",
28
23
+)
29
24
+
30
30
-
+
31
31
-
RELEASES = (8, 9, 10, 11)
25
25
+
#### Aliases to rules_java to keep backward-compatibility (begin) ####
32
26
33
33
-
[
27
27
+
TARGET_NAMES = [
+15
-7
pkgs/development/tools/build-managers/bazel/bazel_7/no-arc.patch
···
1
1
+
commit bb831fbf02535a3372f5c74dc49e668a2507efeb
2
2
+
Author: Guillaume Maudoux <guillaume.maudoux@tweag.io>
3
3
+
Date: Fri Oct 6 15:06:35 2023 +0200
4
4
+
5
5
+
no-arc.patch
6
6
+
1
7
diff --git a/tools/osx/BUILD b/tools/osx/BUILD
2
2
-
index 990afe3e8c..cd5b7b1b7a 100644
8
8
+
index 0358fb0ffe..baae1bf65b 100644
3
9
--- a/tools/osx/BUILD
4
10
+++ b/tools/osx/BUILD
5
5
-
@@ -28,8 +28,8 @@ exports_files([
11
11
+
@@ -27,9 +27,9 @@ exports_files([
6
12
])
7
13
8
14
DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """
9
15
- /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.13 -fobjc-arc -framework CoreServices \
10
16
- -framework Foundation -arch arm64 -arch x86_64 -Wl,-no_adhoc_codesign -Wl,-no_uuid -o $@ $< && \
17
17
+
- env -i codesign --identifier $@ --force --sign - $@
11
18
+ /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.13 -framework CoreServices \
12
12
-
+ -framework Foundation -arch @multiBinPatch@ -Wl,-no_uuid -o $@ $< && \
13
13
-
env -i codesign --identifier $@ --force --sign - $@
19
19
+
+ -framework Foundation -Wl,-no_uuid -o $@ $< && \
20
20
+
+ /usr/bin/env -i /usr/bin/codesign --identifier $@ --force --sign - $@
14
21
"""
15
22
23
23
+
genrule(
16
24
diff --git a/tools/osx/xcode_configure.bzl b/tools/osx/xcode_configure.bzl
17
17
-
index 2b819f07ec..a98ce37673 100644
25
25
+
index a4a712a341..dfbf4869a9 100644
18
26
--- a/tools/osx/xcode_configure.bzl
19
27
+++ b/tools/osx/xcode_configure.bzl
20
20
-
@@ -127,7 +127,6 @@ def run_xcode_locator(repository_ctx, xcode_locator_src_label):
28
28
+
@@ -135,7 +135,6 @@ def run_xcode_locator(repository_ctx, xcode_locator_src_label):
21
29
"macosx",
22
30
"clang",
23
31
"-mmacosx-version-min=10.13",
···
26
34
"CoreServices",
27
35
"-framework",
28
36
diff --git a/tools/osx/xcode_locator.m b/tools/osx/xcode_locator.m
29
29
-
index ed2ef87453..e0ce6dbdd1 100644
37
37
+
index c602b0bb4b..1f7eb64810 100644
30
38
--- a/tools/osx/xcode_locator.m
31
39
+++ b/tools/osx/xcode_locator.m
32
40
@@ -21,10 +21,6 @@
+63
pkgs/development/tools/build-managers/bazel/bazel_7/os_detect.patch
···
1
1
+
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkOS.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkOS.java
2
2
+
index 333ea07801..287760f8b6 100644
3
3
+
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkOS.java
4
4
+
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkOS.java
5
5
+
@@ -64,6 +64,8 @@ final class StarlarkOS implements StarlarkValue {
6
6
+
"A string identifying the architecture Bazel is running on (the value of the \"os.arch\""
7
7
+
+ " Java property converted to lower case).")
8
8
+
public String getArch() {
9
9
+
- return System.getProperty("os.arch").toLowerCase(Locale.ROOT);
10
10
+
+ String arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT);
11
11
+
+ System.out.println("ARCH is " + arch);
12
12
+
+ return arch;
13
13
+
}
14
14
+
}
15
15
+
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
16
16
+
index 56399fb4e3..a0172717b5 100644
17
17
+
--- a/tools/cpp/cc_configure.bzl
18
18
+
+++ b/tools/cpp/cc_configure.bzl
19
19
+
@@ -32,16 +32,20 @@ def cc_autoconf_toolchains_impl(repository_ctx):
20
20
+
# Should we try to find C++ toolchain at all? If not, we don't have to generate toolchains for C++ at all.
21
21
+
should_detect_cpp_toolchain = "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" not in env or env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] != "1"
22
22
+
23
23
+
+ cpu_value = get_cpu_value(repository_ctx)
24
24
+
+ print('cc_autoconf_toolchains_impl', "cpu_value", cpu_value)
25
25
+
if should_detect_cpp_toolchain:
26
26
+
+ print('cc_autoconf_toolchains_impl', repository_ctx.name, "should detect")
27
27
+
paths = resolve_labels(repository_ctx, [
28
28
+
"@bazel_tools//tools/cpp:BUILD.toolchains.tpl",
29
29
+
])
30
30
+
repository_ctx.template(
31
31
+
"BUILD",
32
32
+
paths["@bazel_tools//tools/cpp:BUILD.toolchains.tpl"],
33
33
+
- {"%{name}": get_cpu_value(repository_ctx)},
34
34
+
+ {"%{name}": cpu_value},
35
35
+
)
36
36
+
else:
37
37
+
+ print('cc_autoconf_toolchains_impl', repository_ctx.name, "should NOT detect")
38
38
+
repository_ctx.file("BUILD", "# C++ toolchain autoconfiguration was disabled by BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN env variable.")
39
39
+
40
40
+
cc_autoconf_toolchains = repository_rule(
41
41
+
@@ -62,6 +66,7 @@ def cc_autoconf_impl(repository_ctx, overriden_tools = dict()):
42
42
+
43
43
+
env = repository_ctx.os.environ
44
44
+
cpu_value = get_cpu_value(repository_ctx)
45
45
+
+ print('cc_autoconf_impl', "cpu_value", cpu_value)
46
46
+
if "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" in env and env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] == "1":
47
47
+
paths = resolve_labels(repository_ctx, [
48
48
+
"@bazel_tools//tools/cpp:BUILD.empty.tpl",
49
49
+
@@ -148,12 +153,14 @@ def cc_configure():
50
50
+
cc_autoconf_toolchains(name = "local_config_cc_toolchains")
51
51
+
cc_autoconf(name = "local_config_cc")
52
52
+
native.bind(name = "cc_toolchain", actual = "@local_config_cc//:toolchain")
53
53
+
+ print('cc_configure does register')
54
54
+
native.register_toolchains(
55
55
+
# Use register_toolchain's target pattern expansion to register all toolchains in the package.
56
56
+
"@local_config_cc_toolchains//:all",
57
57
+
)
58
58
+
59
59
+
def _cc_configure_extension_impl(ctx):
60
60
+
+ print('cc_configure_extension does NOT register')
61
61
+
cc_autoconf_toolchains(name = "local_config_cc_toolchains")
62
62
+
cc_autoconf(name = "local_config_cc")
63
63
+
+218
pkgs/development/tools/build-managers/bazel/bazel_7/required-hashes.json
···
1
1
+
[
2
2
+
"0a8003b044294d7840ac7d9d73eef05d6ceb682d7516781a4ec62eeb34702578",
3
3
+
"sha256-CoADsEQpTXhArH2dc+7wXWzraC11FngaTsYu6zRwJXg=",
4
4
+
"0a4c735bb80e342d418c0ef7d2add7793aaf72b91c449bde2769ea81f1869737",
5
5
+
"sha256-CkxzW7gONC1BjA730q3XeTqvcrkcRJveJ2nqgfGGlzc=",
6
6
+
"0d830380ec66bd7e25eee63aa0a5a08578e46ad187fb72d99b44d9ba22827f91",
7
7
+
"sha256-DYMDgOxmvX4l7uY6oKWghXjkatGH+3LZm0TZuiKCf5E=",
8
8
+
"0ea47b5ba23ca1da8eb9146c8fc755c1271414633b1e2be2ce1df764ba0fff2a",
9
9
+
"sha256-DqR7W6I8odqOuRRsj8dVwScUFGM7Hivizh33ZLoP/yo=",
10
10
+
"1b49a7bcbcc595fe1123a5c069816ae31efe6a9625b15dd6fa094f7ff439175e",
11
11
+
"sha256-G0mnvLzFlf4RI6XAaYFq4x7+apYlsV3W+glPf/Q5F14=",
12
12
+
"1dee0481072d19c929b623e155e14d2f6085dc011529a0a0dbefc84cf571d865",
13
13
+
"sha256-He4EgQctGckptiPhVeFNL2CF3AEVKaCg2+/ITPVx2GU=",
14
14
+
"1e490b98005664d149b379a9529a6aa05932b8a11b76b4cd86f3d22d76346f47",
15
15
+
"sha256-HkkLmABWZNFJs3mpUppqoFkyuKEbdrTNhvPSLXY0b0c=",
16
16
+
"1ef5535a8bd41cf3072469f381b9ee6ab28275311a7499f53d6e52adf976fef0",
17
17
+
"sha256-HvVTWovUHPMHJGnzgbnuarKCdTEadJn1PW5Srfl2/vA=",
18
18
+
"1fc4964236b67cf3c5651d7ac1dff668f73b7810c7f1dc0862a0e5bc01608785",
19
19
+
"sha256-H8SWQja2fPPFZR16wd/2aPc7eBDH8dwIYqDlvAFgh4U=",
20
20
+
"2a51593342a2ee4f8f1b946dc48d06b02d0721493238e4ae83d1ad66f8b0c9f4",
21
21
+
"sha256-KlFZM0Ki7k+PG5RtxI0GsC0HIUkyOOSug9GtZviwyfQ=",
22
22
+
"2b70cdfa8c9e997b4007035a266c273c0df341f9c57c9d0b45a680ae3fd882db",
23
23
+
"sha256-K3DN+oyemXtABwNaJmwnPA3zQfnFfJ0LRaaArj/Ygts=",
24
24
+
"2ac5f7fbefa0b73ef783889069344d5515505a14b2303be693c5002c486df2b4",
25
25
+
"sha256-KsX3+++gtz73g4iQaTRNVRVQWhSyMDvmk8UALEht8rQ=",
26
26
+
"2f25841c937e24959a57b630e2c4b8525b3d0f536f2e511c9b2bed30b1651d54",
27
27
+
"sha256-LyWEHJN+JJWaV7Yw4sS4Uls9D1NvLlEcmyvtMLFlHVQ=",
28
28
+
"2fb9007e12f768e9c968f9db292be4ea9cba2ef40fb8d179f3f8746ebdc73c1b",
29
29
+
"sha256-L7kAfhL3aOnJaPnbKSvk6py6LvQPuNF58/h0br3HPBs=",
30
30
+
"3ea995b55a4068be22989b70cc29a4d788c2d328d1d50613a7a9afd13fdd2d0a",
31
31
+
"sha256-PqmVtVpAaL4imJtwzCmk14jC0yjR1QYTp6mv0T/dLQo=",
32
32
+
"3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
33
33
+
"sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=",
34
34
+
"4e5f563ae14ed713381816d582f5fcfd0615aefb29203486cdfb782d8a00a02b",
35
35
+
"sha256-Tl9WOuFO1xM4GBbVgvX8/QYVrvspIDSGzft4LYoAoCs=",
36
36
+
"4ae44dd05b49a1109a463c0d2aaf920c24f76d1e996bb89f29481c4ff75ec526",
37
37
+
"sha256-SuRN0FtJoRCaRjwNKq+SDCT3bR6Za7ifKUgcT/dexSY=",
38
38
+
"5a76c3d401c984999d59868f08df05a15613d1428f7764fed80b722e2a277f6c",
39
39
+
"sha256-WnbD1AHJhJmdWYaPCN8FoVYT0UKPd2T+2AtyLionf2w=",
40
40
+
"4fccff8382aafc589962c4edb262f6aa595e34f1e11e61057d1c6a96e8fc7323",
41
41
+
"sha256-T8z/g4Kq/FiZYsTtsmL2qlleNPHhHmEFfRxqluj8cyM=",
42
42
+
"5a725b777976b77aa122b707d1b6f0f39b6020f66cd427bb111a585599c857b1",
43
43
+
"sha256-WnJbd3l2t3qhIrcH0bbw85tgIPZs1Ce7ERpYVZnIV7E=",
44
44
+
"5bb6b0253ccf64b53d6c7249625a7e3f6c3bc6402abd52d3778bfa48258703a0",
45
45
+
"sha256-W7awJTzPZLU9bHJJYlp+P2w7xkAqvVLTd4v6SCWHA6A=",
46
46
+
"5bc8365613fe2f8ce6cc33959b7667b13b7fe56cb9d16ba740c06e1a7c4242fc",
47
47
+
"sha256-W8g2VhP+L4zmzDOVm3ZnsTt/5Wy50WunQMBuGnxCQvw=",
48
48
+
"5efa9fbb54a58b1a12205a5fac565f6982abfeb0ff45bdbc318748ef5fd3a3ff",
49
49
+
"sha256-Xvqfu1SlixoSIFpfrFZfaYKr/rD/Rb28MYdI71/To/8=",
50
50
+
"6c4e993c28cf2882964cac82a0f96e81a325840043884526565017b2f62c5ba4",
51
51
+
"sha256-bE6ZPCjPKIKWTKyCoPlugaMlhABDiEUmVlAXsvYsW6Q=",
52
52
+
"6ab68b0a3bb3834af44208df058be4631425b56ef95f9b9412aa21df3311e8d3",
53
53
+
"sha256-araLCjuzg0r0QgjfBYvkYxQltW75X5uUEqoh3zMR6NM=",
54
54
+
"6d472ee6d2b60ef3f3e6801e7cd4dbec5fbbef81e883a0de1fbc55e6defe1cb7",
55
55
+
"sha256-bUcu5tK2DvPz5oAefNTb7F+774Hog6DeH7xV5t7+HLc=",
56
56
+
"8a9b54d3506a3b92ee46b217bcee79196b21ca6d52dc2967c686a205fb2f9c15",
57
57
+
"sha256-iptU01BqO5LuRrIXvO55GWshym1S3ClnxoaiBfsvnBU=",
58
58
+
"007c7d9c378df02d390567d0d7ddf542ffddb021b7313dbf502392113ffabb08",
59
59
+
"sha256-AHx9nDeN8C05BWfQ1931Qv/dsCG3MT2/UCOSET/6uwg=",
60
60
+
"8b0862cad85b9549f355fe383c6c63816d2f19529634e033ae06d0107ab110b9",
61
61
+
"sha256-iwhiythblUnzVf44PGxjgW0vGVKWNOAzrgbQEHqxELk=",
62
62
+
"8d784075bec0b7c55042c109a4de8923b3b6d2ebd2e00912d518f07240f9c23a",
63
63
+
"sha256-jXhAdb7At8VQQsEJpN6JI7O20uvS4AkS1RjwckD5wjo=",
64
64
+
"8f9ee2dc10c1ae514ee599a8b42ed99fa262b757058f65ad3c384289ff70c4b8",
65
65
+
"sha256-j57i3BDBrlFO5ZmotC7Zn6Jit1cFj2WtPDhCif9wxLg=",
66
66
+
"21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b",
67
67
+
"sha256-Ia8wySJnvWEiwOC00gzMtmQaN+r5VsZUDsRx1YTmSns=",
68
68
+
"30dba0a651fd5fba8fcae81f92938c590230300f9265ea849f431494f7f92c16",
69
69
+
"sha256-MNugplH9X7qPyugfkpOMWQIwMA+SZeqEn0MUlPf5LBY=",
70
70
+
"50f11b09f877c294d56f24463f47d28f929cf5044f648661c0f0cfbae9a2f49c",
71
71
+
"sha256-UPEbCfh3wpTVbyRGP0fSj5Kc9QRPZIZhwPDPuumi9Jw=",
72
72
+
"54e5be675e5c2ab0958647fcaa35c14bd8f7c08358c634f5ab786e4ed7268576",
73
73
+
"sha256-VOW+Z15cKrCVhkf8qjXBS9j3wINYxjT1q3huTtcmhXY=",
74
74
+
"82ca0e08171846d1768d5ac3f13244d6fe5a54102c14735ef40bf15d57d478e5",
75
75
+
"sha256-gsoOCBcYRtF2jVrD8TJE1v5aVBAsFHNe9AvxXVfUeOU=",
76
76
+
"84ee23b7989d4bf19930b5bd3d03c0f2efb9e73bcee3a0208a9d1b2e1979c049",
77
77
+
"sha256-hO4jt5idS/GZMLW9PQPA8u+55zvO46Agip0bLhl5wEk=",
78
78
+
"91ac87d30cc6d79f9ab974c51874a704de9c2647c40f6932597329a282217ba8",
79
79
+
"sha256-kayH0wzG15+auXTFGHSnBN6cJkfED2kyWXMpooIhe6g=",
80
80
+
"117a1227cdaf813a20a1bba78a9f2d8fb30841000c33e2f2d2a640bd224c9282",
81
81
+
"sha256-EXoSJ82vgTogobunip8tj7MIQQAMM+Ly0qZAvSJMkoI=",
82
82
+
"153fa3cdc153ac3ee25649e8037aeda4438256153d35acf3c27e83e4ee6165a4",
83
83
+
"sha256-FT+jzcFTrD7iVknoA3rtpEOCVhU9Nazzwn6D5O5hZaQ=",
84
84
+
"193edf97aefa28b93c5892bdc598bac34fa4c396588030084f290b1440e8b98a",
85
85
+
"sha256-GT7fl676KLk8WJK9xZi6w0+kw5ZYgDAITykLFEDouYo=",
86
86
+
"211b306cfc44f8f96df3a0a3ddaf75ba8c5289eed77d60d72f889bb855f535e5",
87
87
+
"sha256-IRswbPxE+Plt86Cj3a91uoxSie7XfWDXL4ibuFX1NeU=",
88
88
+
"261be84be30a56994e132d718a85efcd579197a2edb9426b84c5722c56955eca",
89
89
+
"sha256-JhvoS+MKVplOEy1xioXvzVeRl6LtuUJrhMVyLFaVXso=",
90
90
+
"443bb316599fb16e3baeba2fb58881814d7ff0b7af176fe76e38071a6e86f8c0",
91
91
+
"sha256-RDuzFlmfsW47rrovtYiBgU1/8LevF2/nbjgHGm6G+MA=",
92
92
+
"453fe595c3e12b9228b930b845140aaed93a9fb87d1a5d829c55b31d670def9f",
93
93
+
"sha256-RT/llcPhK5IouTC4RRQKrtk6n7h9Gl2CnFWzHWcN758=",
94
94
+
"685de33b53eb313049bbeee7f4b7a80dd09e8e754e96b048a3edab2cebb36442",
95
95
+
"sha256-aF3jO1PrMTBJu+7n9LeoDdCejnVOlrBIo+2rLOuzZEI=",
96
96
+
"725c26b4dd58a1aa782020952ad949bdb607235dd20ee49e5a5875c15456ca86",
97
97
+
"sha256-clwmtN1Yoap4ICCVKtlJvbYHI13SDuSeWlh1wVRWyoY=",
98
98
+
"766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7",
99
99
+
"sha256-dmrSoHg/JoeWLIrXTO7MOKKLn3Ki0IXuQ4t4E+ko0Mc=",
100
100
+
"878fbe521731c072d14d2d65b983b1beae6ad06fda0007b6a8bae81f73f433c4",
101
101
+
"sha256-h4++UhcxwHLRTS1luYOxvq5q0G/aAAe2qLroH3P0M8Q=",
102
102
+
"914ce84508410ee1419514925f93b1855a9f7a7b5b5d02fc07f411d2a45f1bba",
103
103
+
"sha256-kUzoRQhBDuFBlRSSX5OxhVqfentbXQL8B/QR0qRfG7o=",
104
104
+
"990c378168dc6364c6ff569701f4f2f122fffe8998b3e189eba4c4d868ed1084",
105
105
+
"sha256-mQw3gWjcY2TG/1aXAfTy8SL//omYs+GJ66TE2GjtEIQ=",
106
106
+
"2067b788d4c1c96fd621ad861053a5c4d8a801cfafc77fec20d49a6e9340a745",
107
107
+
"sha256-IGe3iNTByW/WIa2GEFOlxNioAc+vx3/sINSabpNAp0U=",
108
108
+
"2220f02fcfc480e3798bab43b2618d158319f9fcb357c9eb04b4a68117699808",
109
109
+
"sha256-IiDwL8/EgON5i6tDsmGNFYMZ+fyzV8nrBLSmgRdpmAg=",
110
110
+
"2744ccc1bbd653c9f65f5764ab211f51cae56aa6c2e2288850a9add9c805be56",
111
111
+
"sha256-J0TMwbvWU8n2X1dkqyEfUcrlaqbC4iiIUKmt2cgFvlY=",
112
112
+
"4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
113
113
+
"sha256-RTHezLkTY5ww5cdRKgVNXYdWmNrrddjPkPKEN1/nw2A=",
114
114
+
"5493a21f5ed3fc502e66fec6b9449c06a551ced63002fa48903c40dfa8de7a4a",
115
115
+
"sha256-VJOiH17T/FAuZv7GuUScBqVRztYwAvpIkDxA36jeeko=",
116
116
+
"6436f19cef264fd949fb7a41e11424e373aa3b1096cad0b7e518f1c81aa60f23",
117
117
+
"sha256-ZDbxnO8mT9lJ+3pB4RQk43OqOxCWytC35RjxyBqmDyM=",
118
118
+
"8923a73ba8a373f7b994906f5902ba9f6bb59d181d4ad01576a6e0c5abb09b67",
119
119
+
"sha256-iSOnO6ijc/e5lJBvWQK6n2u1nRgdStAVdqbgxauwm2c=",
120
120
+
"23722fa366ba017137a68c5e92fc3ee27bbb341c681ac4790f61c6adb7289e26",
121
121
+
"sha256-I3Ivo2a6AXE3poxekvw+4nu7NBxoGsR5D2HGrbconiY=",
122
122
+
"366009a43cfada35015e4cc40a7efc4b7f017c6b8df5cac3f87d2478027b2056",
123
123
+
"sha256-NmAJpDz62jUBXkzECn78S38BfGuN9crD+H0keAJ7IFY=",
124
124
+
"748677bebb1651a313317dfd93e984ed8f8c9e345538fa8b0ab0cbb804631953",
125
125
+
"sha256-dIZ3vrsWUaMTMX39k+mE7Y+MnjRVOPqLCrDLuARjGVM=",
126
126
+
"774165a1c4dbaacb17f9c1ad666b3569a6a59715ae828e7c3d47703f479a53e7",
127
127
+
"sha256-d0FlocTbqssX+cGtZms1aaallxWugo58PUdwP0eaU+c=",
128
128
+
"320366665d19027cda87b2368c03939006a37e0388bfd1091c8d2a96fbc93bd8",
129
129
+
"sha256-MgNmZl0ZAnzah7I2jAOTkAajfgOIv9EJHI0qlvvJO9g=",
130
130
+
"810232374e76a954949f0e2185cd7d9515addb918cf3da3481f77e07c356b49a",
131
131
+
"sha256-gQIyN052qVSUnw4hhc19lRWt25GM89o0gfd+B8NWtJo=",
132
132
+
"a5a78019bc1cd43dbc3c7b7cdd3801912ca26d1f498fb560514fee497864ba96",
133
133
+
"sha256-paeAGbwc1D28PHt83TgBkSyibR9Jj7VgUU/uSXhkupY=",
134
134
+
"2044542933fcdf40ad18441bec37646d150c491871157f288847e29cb81de4cb",
135
135
+
"sha256-IERUKTP830CtGEQb7DdkbRUMSRhxFX8oiEfinLgd5Ms=",
136
136
+
"a136d3dce67168d88751115fa223bec80eae6cc062aa2f8173e8344a98235ec4",
137
137
+
"sha256-oTbT3OZxaNiHURFfoiO+yA6ubMBiqi+Bc+g0SpgjXsQ=",
138
138
+
"a42edc9cab792e39fe39bb94f3fca655ed157ff87a8af78e1d6ba5b07c4a00ab",
139
139
+
"sha256-pC7cnKt5Ljn+ObuU8/ymVe0Vf/h6iveOHWulsHxKAKs=",
140
140
+
"a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26",
141
141
+
"sha256-oXHuTHNN0tqDfksWvp30Zhr6typBra8x64Tf2vk2yiY=",
142
142
+
"aa11ecd5fc0af2769f0f2bdd25e2f4de7c1291ed24326fb23fa69bdd5dcae2b5",
143
143
+
"sha256-qhHs1fwK8nafDyvdJeL03nwSke0kMm+yP6ab3V3K4rU=",
144
144
+
"a827c49183f3a632277d27a0a4673686cb341507447b9d570261094bd748aa68",
145
145
+
"sha256-qCfEkYPzpjInfSegpGc2hss0FQdEe51XAmEJS9dIqmg=",
146
146
+
"aabf9bd23091a4ebfc109c1f3ee7cf3e4b89f6ba2d3f51c5243f16b3cffae011",
147
147
+
"sha256-qr+b0jCRpOv8EJwfPufPPkuJ9rotP1HFJD8Ws8/64BE=",
148
148
+
"ae46b722a8b8e9b62170f83bfb040cbf12adb732144e689985a66b26410a7d6f",
149
149
+
"sha256-rka3Iqi46bYhcPg7+wQMvxKttzIUTmiZhaZrJkEKfW8=",
150
150
+
"ae63be5fe345ffdd5157284d90b783138eb31634e274182a8495242f9ad66a56",
151
151
+
"sha256-rmO+X+NF/91RVyhNkLeDE46zFjTidBgqhJUkL5rWalY=",
152
152
+
"aeb8d7a1361aa3d8f5a191580fa7f8cbc5ceb53137a4a698590f612f791e2c45",
153
153
+
"sha256-rrjXoTYao9j1oZFYD6f4y8XOtTE3pKaYWQ9hL3keLEU=",
154
154
+
"b5ecd1483e041197012786f749968a62063c1964d3ecfbf96ba92a95797bb8f5",
155
155
+
"sha256-tezRSD4EEZcBJ4b3SZaKYgY8GWTT7Pv5a6kqlXl7uPU=",
156
156
+
"b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
157
157
+
"sha256-uKFSeQF3QYCvx5iusoxGNL3M8ZxNmOe90c550f6aqtc=",
158
158
+
"b9d4fe4d71938df38839f0eca42aaaa64cf8b313d678da036f0cb3ca199b47f5",
159
159
+
"sha256-udT+TXGTjfOIOfDspCqqpkz4sxPWeNoDbwyzyhmbR/U=",
160
160
+
"b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99",
161
161
+
"sha256-s3KgN9QjCqV/vv/e8w/WEj+cDC24XQrO0AyRuXTzP5k=",
162
162
+
"ba734e1e84c09d615af6a09d33034b4f0442f8772dec120efb376d86a565ae15",
163
163
+
"sha256-unNOHoTAnWFa9qCdMwNLTwRC+Hct7BIO+zdthqVlrhU=",
164
164
+
"bb529ba133c0256df49139bd403c17835edbf60d2ecd6463549c6a5fe279364d",
165
165
+
"sha256-u1KboTPAJW30kTm9QDwXg17b9g0uzWRjVJxqX+J5Nk0=",
166
166
+
"be4ce53138a238bb522cd781cf91f3ba5ce2f6ca93ec62d46a162a127225e0a6",
167
167
+
"sha256-vkzlMTiiOLtSLNeBz5Hzulzi9sqT7GLUahYqEnIl4KY=",
168
168
+
"c7bec54b7b5588b5967e870341091c5691181d954cf2039f1bf0a6eeb837473b",
169
169
+
"sha256-x77FS3tViLWWfocDQQkcVpEYHZVM8gOfG/Cm7rg3Rzs=",
170
170
+
"c96d60551331a196dac54b745aa642cd078ef89b6f267146b705f2c2cbef052d",
171
171
+
"sha256-yW1gVRMxoZbaxUt0WqZCzQeO+JtvJnFGtwXywsvvBS0=",
172
172
+
"cb852272c1cb0c8449d8b1a70f3e0f2c1efb2063e543183faa43078fb446f540",
173
173
+
"sha256-y4UicsHLDIRJ2LGnDz4PLB77IGPlQxg/qkMHj7RG9UA=",
174
174
+
"cf7f71eaff90b24c1a28b49645a9ff03a9a6c1e7134291ce70901cb63e7364b5",
175
175
+
"sha256-z39x6v+QskwaKLSWRan/A6mmwecTQpHOcJActj5zZLU=",
176
176
+
"d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d",
177
177
+
"sha256-12ua/qYcfAgpCAI/DLwUJ/q5q9LfkVyLij56UJvMvG0=",
178
178
+
"d96cc09045a1341c6d47494352aa263b87b72fb1d2ea9eca161aa73820bfe8bb",
179
179
+
"sha256-2WzAkEWhNBxtR0lDUqomO4e3L7HS6p7KFhqnOCC/6Ls=",
180
180
+
"dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
181
181
+
"sha256-3D+yBqLLNEG0heseQjFlsjEjWh6psDG0Qzz3vB+kYN0=",
182
182
+
"dacf78ce78ab2d29570325db4cd2451ea589639807de95881a0fa7155a9e6b55",
183
183
+
"sha256-2s94znirLSlXAyXbTNJFHqWJY5gH3pWIGg+nFVqea1U=",
184
184
+
"e04ba5195bcd555dc95650f7cc614d151e4bcd52d29a10b8aa2197f3ab89ab9b",
185
185
+
"sha256-4EulGVvNVV3JVlD3zGFNFR5LzVLSmhC4qiGX86uJq5s=",
186
186
+
"de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
187
187
+
"sha256-3mmgnccEF1gKq/IKKGGbs+9g0DhHDHz4RC+vz2J8Ics=",
188
188
+
"e47edfb2ceaf43fc699e20c179ec428b6f3e497cf8e2dcd8e9c936d4b96b1e56",
189
189
+
"sha256-5H7fss6vQ/xpniDBeexCi28+SXz44tzY6ck21LlrHlY=",
190
190
+
"e59770b66e81822e5d111ac4e544d7eb0c543e0a285f52628e53941acd8ed759",
191
191
+
"sha256-5Zdwtm6Bgi5dERrE5UTX6wxUPgooX1JijlOUGs2O11k=",
192
192
+
"ec76c5e79db59762776bece58b69507d095856c37b81fd35bfb0958e74b61d93",
193
193
+
"sha256-7HbF5521l2J3a+zli2lQfQlYVsN7gf01v7CVjnS2HZM=",
194
194
+
"ec92dae810034f4b46dbb16ef4364a4013b0efb24a8c5dd67435cae46a290d8e",
195
195
+
"sha256-7JLa6BADT0tG27Fu9DZKQBOw77JKjF3WdDXK5GopDY4=",
196
196
+
"eede807f0dd5eb1ad74ea1ae1094430631da63fcde00d4dc20eb0cd048bb0ac3",
197
197
+
"sha256-7t6Afw3V6xrXTqGuEJRDBjHaY/zeANTcIOsM0Ei7CsM=",
198
198
+
"eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
199
199
+
"sha256-7KIYhOb2aojDWOWA/WemsUjTCrV7FoD2KpbAD5vGoH4=",
200
200
+
"eeeae917917144a68a741d4c0dff66aa5c5c5fd85593ff217bced3fc8ca783b8",
201
201
+
"sha256-7urpF5FxRKaKdB1MDf9mqlxcX9hVk/8he87T/Iyng7g=",
202
202
+
"f43f29fe2a6ebaf04b2598cdeec32a4e346d49a9404e990f5fc19c19f3a28d0e",
203
203
+
"sha256-9D8p/ipuuvBLJZjN7sMqTjRtSalATpkPX8GcGfOijQ4=",
204
204
+
"f86fd42a809e1871ca0aabe89db0d440451219c3ce46c58da240c7dcdc00125f",
205
205
+
"sha256-+G/UKoCeGHHKCqvonbDUQEUSGcPORsWNokDH3NwAEl8=",
206
206
+
"f87a502f3d257bc41f80bd0b90c19e6b4a48d0600fb26e7b5d6c2c675680fa0e",
207
207
+
"sha256-+HpQLz0le8QfgL0LkMGea0pI0GAPsm57XWwsZ1aA+g4=",
208
208
+
"f195cd6228d3f99fa7e30ff2dee60ad0f2c7923be31399a7dcdc1abd679aa22e",
209
209
+
"sha256-8ZXNYijT+Z+n4w/y3uYK0PLHkjvjE5mn3NwavWeaoi4=",
210
210
+
"fa5469f4c44ee598a2d8f033ab0a9dcbc6498a0c5e0c998dfa0c2adf51358044",
211
211
+
"sha256-+lRp9MRO5Zii2PAzqwqdy8ZJigxeDJmN+gwq31E1gEQ=",
212
212
+
"f1474d47f4b6b001558ad27b952e35eda5cc7146788877fc52938c6eba24b382",
213
213
+
"sha256-8UdNR/S2sAFVitJ7lS417aXMcUZ4iHf8UpOMbroks4I=",
214
214
+
"ff2d59fad74e867630fbc7daab14c432654712ac624dbee468d220677b124dd5",
215
215
+
"sha256-/y1Z+tdOhnYw+8faqxTEMmVHEqxiTb7kaNIgZ3sSTdU=",
216
216
+
"ff5b3cd331ae8a9a804768280da98f50f424fef23dd3c788bb320e08c94ee598",
217
217
+
"sha256-/1s80zGuipqAR2goDamPUPQk/vI908eIuzIOCMlO5Zg="
218
218
+
]
+12
pkgs/development/tools/build-managers/bazel/bazel_7/serialize_nulls.patch
···
1
1
+
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/GsonTypeAdapterUtil.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/GsonTypeAdapterUtil.java
2
2
+
index 05a54e2e05..6e22f10386 100644
3
3
+
--- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/GsonTypeAdapterUtil.java
4
4
+
+++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/GsonTypeAdapterUtil.java
5
5
+
@@ -362,6 +362,7 @@ public final class GsonTypeAdapterUtil {
6
6
+
public static Gson createLockFileGson(Path moduleFilePath) {
7
7
+
return new GsonBuilder()
8
8
+
.setPrettyPrinting()
9
9
+
+ .serializeNulls()
10
10
+
.disableHtmlEscaping()
11
11
+
.enableComplexMapKeySerialization()
12
12
+
.registerTypeAdapterFactory(GenerateTypeAdapter.FACTORY)
+9
-3
pkgs/development/tools/build-managers/bazel/bazel_7/strict_proto_deps.patch
···
1
1
+
commit c5cbdf1fcfb96299aaef7fb9909c2cc30b126568
2
2
+
Author: Guillaume Maudoux <guillaume.maudoux@tweag.io>
3
3
+
Date: Fri Oct 6 15:06:00 2023 +0200
4
4
+
5
5
+
strict_proto_deps.patch
6
6
+
1
7
diff --git a/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl b/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl
2
2
-
index 63f68167e4..f106e64c9b 100644
8
8
+
index e2118aabea..6a33f03472 100644
3
9
--- a/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl
4
10
+++ b/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl
5
5
-
@@ -114,6 +114,7 @@ def java_compile_for_protos(ctx, output_jar_suffix, source_jar = None, deps = []
11
11
+
@@ -117,6 +117,7 @@ def java_compile_for_protos(ctx, output_jar_suffix, source_jar = None, deps = []
12
12
+
deps = deps,
6
13
exports = exports,
7
7
-
output = output_jar,
8
14
output_source_jar = source_jar,
9
15
+ strict_deps = ctx.fragments.proto.strict_proto_deps(),
10
16
injecting_rule_kind = injecting_rule_kind,
+60
pkgs/development/tools/build-managers/bazel/bazel_7/tmp.patch
···
1
1
+
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunction.java
2
2
+
index 958669706c..dc27d3de26 100644
3
3
+
--- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunction.java
4
4
+
+++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunction.java
5
5
+
@@ -52,6 +52,7 @@ import com.google.devtools.build.skyframe.SkyKey;
6
6
+
import com.google.devtools.build.skyframe.SkyValue;
7
7
+
import com.google.errorprone.annotations.FormatMethod;
8
8
+
import java.io.IOException;
9
9
+
+import java.io.*;
10
10
+
import java.net.URISyntaxException;
11
11
+
import java.util.ArrayList;
12
12
+
import java.util.List;
13
13
+
@@ -404,6 +405,7 @@ public class ModuleFileFunction implements SkyFunction {
14
14
+
GetModuleFileResult result = new GetModuleFileResult();
15
15
+
for (Registry registry : registryObjects) {
16
16
+
try {
17
17
+
+ System.out.println("Trying to find module " + key + " in " + registry.getUrl());
18
18
+
Optional<ModuleFile> moduleFile = registry.getModuleFile(key, env.getListener());
19
19
+
if (moduleFile.isEmpty()) {
20
20
+
continue;
21
21
+
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/cache/RepositoryCache.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/cache/RepositoryCache.java
22
22
+
index 07bc071655..0ee990e0f4 100644
23
23
+
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/cache/RepositoryCache.java
24
24
+
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/cache/RepositoryCache.java
25
25
+
@@ -27,6 +27,7 @@ import com.google.devtools.build.lib.vfs.Path;
26
26
+
import java.io.IOException;
27
27
+
import java.io.InputStream;
28
28
+
import java.io.OutputStream;
29
29
+
+import java.io.*;
30
30
+
import java.util.UUID;
31
31
+
import javax.annotation.Nullable;
32
32
+
33
33
+
@@ -166,6 +167,7 @@ public class RepositoryCache {
34
34
+
35
35
+
assertKeyIsValid(cacheKey, keyType);
36
36
+
if (!exists(cacheKey, keyType)) {
37
37
+
+ System.out.println("Cache lookup failed for " + keyType + " key " + cacheKey);
38
38
+
return null;
39
39
+
}
40
40
+
41
41
+
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
42
42
+
index a8e2a08145..fcbe05fcea 100644
43
43
+
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
44
44
+
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
45
45
+
@@ -48,6 +48,7 @@ import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
46
46
+
import com.google.devtools.build.skyframe.SkyKey;
47
47
+
import com.google.devtools.build.skyframe.SkyValue;
48
48
+
import java.io.IOException;
49
49
+
+import java.io.*;
50
50
+
import java.nio.charset.StandardCharsets;
51
51
+
import java.util.Map;
52
52
+
import java.util.Optional;
53
53
+
@@ -345,6 +346,7 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
54
54
+
55
55
+
if (!repoRoot.exists()) {
56
56
+
// The repository isn't on the file system, there is nothing we can do.
57
57
+
+ System.out.println("Failed to find repo " + repositoryName.getNameWithAt());
58
58
+
throw new RepositoryFunctionException(
59
59
+
new IOException(
60
60
+
"to fix, run\n\tbazel fetch //...\nExternal repository "
+23
pkgs/development/tools/build-managers/bazel/bazel_7/trim-last-argument-to-gcc-if-empty.patch
···
1
1
+
commit d2b4b1d748ec4fa302036b514377da4c4618177a
2
2
+
Author: Guillaume Maudoux <guillaume.maudoux@tweag.io>
3
3
+
Date: Fri Oct 6 15:05:20 2023 +0200
4
4
+
5
5
+
trim-last-argument-to-gcc-if-empty.patch
6
6
+
7
7
+
diff --git a/tools/cpp/osx_cc_wrapper.sh.tpl b/tools/cpp/osx_cc_wrapper.sh.tpl
8
8
+
index 8264090c29..b7b9e8537a 100644
9
9
+
--- a/tools/cpp/osx_cc_wrapper.sh.tpl
10
10
+
+++ b/tools/cpp/osx_cc_wrapper.sh.tpl
11
11
+
@@ -64,7 +64,11 @@ done
12
12
+
%{env}
13
13
+
14
14
+
# Call the C++ compiler
15
15
+
-%{cc} "$@"
16
16
+
+if [[ ${*: -1} = "" ]]; then
17
17
+
+ %{cc} "${@:0:$#}"
18
18
+
+else
19
19
+
+ %{cc} "$@"
20
20
+
+fi
21
21
+
22
22
+
function get_library_path() {
23
23
+
for libdir in ${LIB_DIRS}; do
+15
-10
pkgs/development/tools/build-managers/bazel/cpp-test.nix
···
1
1
-
{
2
2
-
bazel
1
1
+
{ bazel
3
2
, bazelTest
4
3
, bazel-examples
5
4
, stdenv
6
5
, darwin
6
6
+
, extraBazelArgs ? ""
7
7
, lib
8
8
, runLocal
9
9
, runtimeShell
10
10
, writeScript
11
11
, writeText
12
12
, distDir
13
13
+
, Foundation
13
14
}:
14
15
15
16
let
···
29
30
exec "$BAZEL_REAL" "$@"
30
31
'';
31
32
32
32
-
workspaceDir = runLocal "our_workspace" {} (''
33
33
+
workspaceDir = runLocal "our_workspace" { } (''
33
34
cp -r ${bazel-examples}/cpp-tutorial/stage3 $out
34
35
find $out -type d -exec chmod 755 {} \;
35
36
''
···
43
44
inherit workspaceDir;
44
45
bazelPkg = bazel;
45
46
bazelScript = ''
46
46
-
${bazel}/bin/bazel \
47
47
-
build --verbose_failures \
47
47
+
${bazel}/bin/bazel info output_base
48
48
+
${bazel}/bin/bazel build //... \
49
49
+
--verbose_failures \
50
50
+
--sandbox_debug \
48
51
--distdir=${distDir} \
49
52
--curses=no \
50
50
-
--sandbox_debug \
51
51
-
//... \
53
53
+
${extraBazelArgs} \
52
54
'' + lib.optionalString (stdenv.isDarwin) ''
53
53
-
--cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
54
54
-
--linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \
55
55
+
--cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
56
56
+
--linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \
57
57
+
--linkopt=-Wl,-F${Foundation}/Library/Frameworks \
58
58
+
--linkopt=-L${darwin.libobjc}/lib \
55
59
'';
56
60
};
57
61
58
58
-
in testBazel
62
62
+
in
63
63
+
testBazel
+17
-9
pkgs/development/tools/build-managers/bazel/java-test.nix
···
1
1
-
{
2
2
-
bazel
1
1
+
{ bazel
3
2
, bazelTest
4
3
, bazel-examples
5
4
, stdenv
6
5
, darwin
6
6
+
, extraBazelArgs ? ""
7
7
, lib
8
8
, openjdk8
9
9
, jdk11_headless
10
10
+
, jdk17_headless
10
11
, runLocal
11
12
, runtimeShell
12
13
, writeScript
···
31
32
exec "$BAZEL_REAL" "$@"
32
33
'';
33
34
34
34
-
workspaceDir = runLocal "our_workspace" {} (''
35
35
+
workspaceDir = runLocal "our_workspace" { } (''
35
36
cp -r ${bazel-examples}/java-tutorial $out
36
37
find $out -type d -exec chmod 755 {} \;
37
38
''
···
44
45
name = "bazel-test-java";
45
46
inherit workspaceDir;
46
47
bazelPkg = bazel;
47
47
-
buildInputs = [ (if lib.strings.versionOlder bazel.version "5.0.0" then openjdk8 else jdk11_headless) ];
48
48
+
buildInputs = [
49
49
+
#(if lib.strings.versionOlder bazel.version "5.0.0" then openjdk8
50
50
+
#else if lib.strings.versionOlder bazel.version "7.0.0" then jdk11_headless
51
51
+
#else jdk17_headless)
52
52
+
jdk17_headless
53
53
+
];
48
54
bazelScript = ''
49
55
${bazel}/bin/bazel \
50
56
run \
57
57
+
--announce_rc \
51
58
--distdir=${distDir} \
52
59
--verbose_failures \
53
60
--curses=no \
···
55
62
--strict_java_deps=off \
56
63
//:ProjectRunner \
57
64
'' + lib.optionalString (lib.strings.versionOlder bazel.version "5.0.0") ''
58
58
-
--host_javabase='@local_jdk//:jdk' \
59
59
-
--java_toolchain='@bazel_tools//tools/jdk:toolchain_hostjdk8' \
60
60
-
--javabase='@local_jdk//:jdk' \
61
61
-
'';
65
65
+
--host_javabase='@local_jdk//:jdk' \
66
66
+
--java_toolchain='@bazel_tools//tools/jdk:toolchain_hostjdk8' \
67
67
+
--javabase='@local_jdk//:jdk' \
68
68
+
'' + extraBazelArgs;
62
69
};
63
70
64
64
-
in testBazel
71
71
+
in
72
72
+
testBazel
65
73
+49
-83
pkgs/development/tools/build-managers/bazel/protobuf-test.nix
···
1
1
-
{
2
2
-
bazel
1
1
+
{ bazel
3
2
, bazelTest
4
3
, fetchFromGitHub
5
4
, fetchurl
6
5
, stdenv
7
6
, darwin
7
7
+
, extraBazelArgs ? ""
8
8
, lib
9
9
, openjdk8
10
10
, jdk11_headless
···
16
16
}:
17
17
18
18
let
19
19
-
com_google_protobuf = fetchFromGitHub {
20
20
-
owner = "protocolbuffers";
21
21
-
repo = "protobuf";
22
22
-
rev = "v3.13.0";
23
23
-
sha256 = "1nqsvi2yfr93kiwlinz8z7c68ilg1j75b2vcpzxzvripxx5h6xhd";
24
24
-
};
25
25
-
26
26
-
bazel_skylib = fetchFromGitHub {
27
27
-
owner = "bazelbuild";
28
28
-
repo = "bazel-skylib";
29
29
-
rev = "2ec2e6d715e993d96ad6222770805b5bd25399ae";
30
30
-
sha256 = "1z2r2vx6kj102zvp3j032djyv99ski1x1sl4i3p6mswnzrzna86s";
31
31
-
};
32
19
33
33
-
rules_python = fetchFromGitHub {
34
34
-
owner = "bazelbuild";
35
35
-
repo = "rules_python";
36
36
-
rev = "c8c79aae9aa1b61d199ad03d5fe06338febd0774";
37
37
-
sha256 = "1zn58wv5wcylpi0xj7riw34i1jjpqahanxx8y9srwrv0v93b6pqz";
38
38
-
};
39
39
-
40
40
-
rules_proto = fetchFromGitHub {
41
41
-
owner = "bazelbuild";
42
42
-
repo = "rules_proto";
43
43
-
rev = "a0761ed101b939e19d83b2da5f59034bffc19c12";
44
44
-
sha256 = "09lqfj5fxm1fywxr5w8pnpqd859gb6751jka9fhxjxjzs33glhqf";
45
45
-
};
46
46
-
47
47
-
net_zlib = fetchurl rec {
48
48
-
url = "https://zlib.net/zlib-1.2.11.tar.gz";
49
49
-
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1";
20
20
+
# Use builtins.fetchurl to avoid IFD, in particular on hydra
21
21
+
lockfile =
22
22
+
let version = "7.0.0-pre.20230917.3";
23
23
+
in builtins.fetchurl {
24
24
+
url = "https://raw.githubusercontent.com/bazelbuild/bazel/${version}/MODULE.bazel.lock";
25
25
+
sha256 = "0z6mlz8cn03qa40mqbw6j6kd6qyn4vgb3bb1kyidazgldxjhrz6y";
26
26
+
};
50
27
51
51
-
passthru.sha256 = sha256;
52
52
-
};
28
28
+
MODULE = writeText "MODULE.bazel" ''
29
29
+
#bazel_dep(name = "bazel_skylib", version = "1.4.1")
30
30
+
#bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
31
31
+
bazel_dep(name = "protobuf", version = "21.7")
32
32
+
#bazel_dep(name = "grpc", version = "1.48.1.bcr.1", repo_name = "com_github_grpc_grpc")
33
33
+
#bazel_dep(name = "platforms", version = "0.0.7")
34
34
+
#bazel_dep(name = "rules_pkg", version = "0.9.1")
35
35
+
#bazel_dep(name = "stardoc", version = "0.5.3", repo_name = "io_bazel_skydoc")
36
36
+
#bazel_dep(name = "zstd-jni", version = "1.5.2-3.bcr.1")
37
37
+
#bazel_dep(name = "blake3", version = "1.3.3.bcr.1")
38
38
+
#bazel_dep(name = "zlib", version = "1.3")
39
39
+
#bazel_dep(name = "rules_cc", version = "0.0.8")
40
40
+
#bazel_dep(name = "rules_java", version = "6.3.1")
41
41
+
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
42
42
+
#bazel_dep(name = "rules_jvm_external", version = "5.2")
43
43
+
#bazel_dep(name = "rules_python", version = "0.24.0")
44
44
+
#bazel_dep(name = "rules_testing", version = "0.0.4")
45
45
+
'';
53
46
54
47
WORKSPACE = writeText "WORKSPACE" ''
55
48
workspace(name = "our_workspace")
56
49
57
57
-
load("//:proto-support.bzl", "protobuf_deps")
58
58
-
protobuf_deps()
59
59
-
load("@rules_proto//proto:repositories.bzl", "rules_proto_toolchains")
60
60
-
rules_proto_toolchains()
61
61
-
'';
62
62
-
63
63
-
protoSupport = writeText "proto-support.bzl" ''
64
64
-
"""Load dependencies needed to compile the protobuf library as a 3rd-party consumer."""
65
65
-
66
50
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
67
51
68
68
-
def protobuf_deps():
69
69
-
"""Loads common dependencies needed to compile the protobuf library."""
70
70
-
71
71
-
if "zlib" not in native.existing_rules():
72
72
-
# proto_library, cc_proto_library, and java_proto_library rules implicitly
73
73
-
# depend on @com_google_protobuf for protoc and proto runtimes.
74
74
-
# This statement defines the @com_google_protobuf repo.
75
75
-
native.local_repository(
76
76
-
name = "com_google_protobuf",
77
77
-
path = "${com_google_protobuf}",
78
78
-
)
79
79
-
native.local_repository(
80
80
-
name = "bazel_skylib",
81
81
-
path = "${bazel_skylib}",
82
82
-
)
83
83
-
native.local_repository(
84
84
-
name = "rules_proto",
85
85
-
path = "${rules_proto}",
86
86
-
)
87
87
-
native.local_repository(
88
88
-
name = "rules_python",
89
89
-
path = "${rules_python}",
90
90
-
)
91
91
-
92
92
-
http_archive(
93
93
-
name = "zlib",
94
94
-
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
95
95
-
sha256 = "${net_zlib.sha256}",
96
96
-
strip_prefix = "zlib-1.2.11",
97
97
-
urls = ["file://${net_zlib}"],
98
98
-
)
52
52
+
http_archive(
53
53
+
name = "rules_proto",
54
54
+
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
55
55
+
strip_prefix = "rules_proto-5.3.0-21.7",
56
56
+
urls = [
57
57
+
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
58
58
+
],
59
59
+
)
60
60
+
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
61
61
+
rules_proto_dependencies()
62
62
+
rules_proto_toolchains()
99
63
'';
100
64
101
65
personProto = writeText "person.proto" ''
···
145
109
exec "$BAZEL_REAL" "$@"
146
110
'';
147
111
148
148
-
workspaceDir = runLocal "our_workspace" {} (''
112
112
+
workspaceDir = runLocal "our_workspace" { } (''
149
113
mkdir $out
114
114
+
cp ${MODULE} $out/MODULE.bazel
115
115
+
cp ${lockfile} $out/MODULE.bazel.lock
150
116
cp ${WORKSPACE} $out/WORKSPACE
151
117
touch $out/BUILD.bazel
152
152
-
cp ${protoSupport} $out/proto-support.bzl
153
118
mkdir $out/person
154
119
cp ${personProto} $out/person/person.proto
155
120
cp ${personBUILD} $out/person/BUILD.bazel
···
167
132
bazelScript = ''
168
133
${bazel}/bin/bazel \
169
134
build \
170
170
-
--distdir=${distDir} \
171
135
--verbose_failures \
172
136
--curses=no \
173
137
--sandbox_debug \
174
138
--strict_java_deps=off \
175
139
--strict_proto_deps=off \
140
140
+
${extraBazelArgs} \
176
141
//... \
177
142
'' + lib.optionalString (lib.strings.versionOlder bazel.version "5.0.0") ''
178
178
-
--host_javabase='@local_jdk//:jdk' \
179
179
-
--java_toolchain='@bazel_tools//tools/jdk:toolchain_hostjdk8' \
180
180
-
--javabase='@local_jdk//:jdk' \
143
143
+
--host_javabase='@local_jdk//:jdk' \
144
144
+
--java_toolchain='@bazel_tools//tools/jdk:toolchain_hostjdk8' \
145
145
+
--javabase='@local_jdk//:jdk' \
181
146
'' + lib.optionalString (stdenv.isDarwin) ''
182
182
-
--cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
183
183
-
--linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \
147
147
+
--cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
148
148
+
--linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \
184
149
'';
185
150
};
186
151
187
187
-
in testBazel
152
152
+
in
153
153
+
testBazel
+3
-1
pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix
···
3
3
, bazelTest
4
4
, stdenv
5
5
, darwin
6
6
+
, extraBazelArgs ? ""
6
7
, lib
7
8
, runLocal
8
9
, runtimeShell
···
76
77
bazelScript = ''
77
78
${bazel}/bin/bazel \
78
79
run \
79
79
-
--distdir=${distDir} \
80
80
+
--repository_cache=${distDir} \
81
81
+
${extraBazelArgs} \
80
82
//python:bin
81
83
'';
82
84
};
+23
-13
pkgs/development/tools/build-managers/bazel/shebang-test.nix
···
1
1
{
2
2
bazel
3
3
, bazelTest
4
4
-
, distDir
5
4
, extracted
5
5
+
, ripgrep
6
6
, runLocal
7
7
, unzip
8
8
+
, ...
8
9
}:
9
10
10
11
# Tests that all shebangs are patched appropriately.
···
21
22
bazelPkg = bazel;
22
23
bazelScript = ''
23
24
set -ueo pipefail
25
25
+
24
26
FAIL=
25
27
check_shebangs() {
26
28
local dir="$1"
27
27
-
{ grep -Re '#!/usr/bin' $dir && FAIL=1; } || true
28
28
-
{ grep -Re '#![^[:space:]]*/bin/env' $dir && FAIL=1; } || true
29
29
+
{ rg -e '#!/usr/bin' -e '#![^[:space:]]*/bin/env' $dir -e && echo && FAIL=1; } || true
29
30
}
30
30
-
BAZEL_EXTRACTED=${extracted bazel}/install
31
31
-
check_shebangs $BAZEL_EXTRACTED
32
32
-
while IFS= read -r -d "" zip; do
33
33
-
unzipped="./$zip/UNPACKED"
34
34
-
mkdir -p "$unzipped"
35
35
-
unzip -qq $zip -d "$unzipped"
36
36
-
check_shebangs "$unzipped"
37
37
-
rm -rf unzipped
38
38
-
done < <(find $BAZEL_EXTRACTED -type f -name '*.zip' -or -name '*.jar' -print0)
31
31
+
extract() {
32
32
+
local dir="$1"
33
33
+
find "$dir" -type f '(' -name '*.zip' -or -name '*.jar' ')' -print0 \
34
34
+
| while IFS="" read -r -d "" zip ; do
35
35
+
echo "Extracting $zip"
36
36
+
local unzipped="$zip-UNPACKED"
37
37
+
mkdir -p "$unzipped"
38
38
+
unzip -qq $zip -d "$unzipped"
39
39
+
extract "$unzipped"
40
40
+
rm -rf "$unzipped" "$zip" || true
41
41
+
done
42
42
+
check_shebangs "$dir"
43
43
+
}
44
44
+
45
45
+
mkdir install_root
46
46
+
cp --no-preserve=all -r ${extracted bazel}/install/*/* install_root/
47
47
+
extract ./install_root
48
48
+
39
49
if [[ $FAIL = 1 ]]; then
40
50
echo "Found files in the bazel distribution with illegal shebangs." >&2
41
51
echo "Replace those by explicit Nix store paths." >&2
···
43
53
exit 1
44
54
fi
45
55
'';
46
46
-
buildInputs = [ unzip ];
56
56
+
buildInputs = [ unzip ripgrep ];
47
57
};
48
58
49
59
in testBazel
+11
pkgs/top-level/all-packages.nix
···
18567
18567
bazel_self = bazel_6;
18568
18568
};
18569
18569
18570
18570
+
bazel_7 = darwin.apple_sdk_11_0.callPackage ../development/tools/build-managers/bazel/bazel_7 {
18571
18571
+
inherit (darwin) cctools sigtool;
18572
18572
+
inherit (darwin.apple_sdk_11_0.frameworks) CoreFoundation CoreServices Foundation IOKit;
18573
18573
+
buildJdk = jdk11_headless;
18574
18574
+
runJdk = jdk17_headless;
18575
18575
+
stdenv = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv
18576
18576
+
else if stdenv.cc.isClang then llvmPackages.stdenv
18577
18577
+
else stdenv;
18578
18578
+
bazel_self = bazel_7;
18579
18579
+
};
18580
18580
+
18570
18581
bazel-buildtools = callPackage ../development/tools/build-managers/bazel/buildtools { };
18571
18582
buildifier = bazel-buildtools;
18572
18583
buildozer = bazel-buildtools;