Skip to content

Commit d3eef06

Browse files
committed
Integrate with Buildbuddy
1 parent b4359c0 commit d3eef06

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed

projects/bzl4/.bazelrc

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,39 @@ build --host_platform=@io_tweag_rules_nixpkgs//nixpkgs/platforms:host
44
# Enable platforms for cc_rules
55
build --incompatible_enable_cc_toolchain_resolution
66

7-
build:gcc9 --//build/cc:compiler=gcc9
7+
build --experimental_platform_in_output_dir
8+
9+
# Build with gcc9 by default
10+
build --//build/cc:compiler=gcc9
11+
# Config for gcc11
812
build:gcc11 --//build/cc:compiler=gcc11
13+
# Config for cuda
14+
build:cuda --//hello_world:gpu=cuda
15+
16+
# config for BES
17+
build:bes --bes_results_url=https://buildbuddy.1e100.one/invocation/
18+
build:bes --bes_backend=grpcs://buildbuddy-grpc.1e100.one
19+
build:bes --noslim_profile
20+
build:bes --experimental_profile_include_target_label
21+
build:bes --experimental_profile_include_primary_output
22+
build:bes --build_metadata=USER=dev
23+
24+
# Config for remote cache, also uses BES
25+
build:cache --config=bes
26+
build:cache --remote_cache=grpcs://buildbuddy-grpc.1e100.one
27+
build:cache --remote_timeout=3600
28+
29+
# Config for remote execution, also uses remote cache and BES
30+
build:remote --config=cache
31+
build:remote --experimental_repo_remote_exec
32+
build:remote --remote_executor=grpcs://buildbuddy-grpc.1e100.one
33+
build:remote --extra_execution_platforms=@buildbuddy_toolchain//:platform
34+
build:remote --crosstool_top=@buildbuddy_toolchain//:toolchain
35+
build:remote --extra_toolchains=@buildbuddy_toolchain//:cc_toolchain
36+
build:remote --javabase=@buildbuddy_toolchain//:javabase_jdk8
37+
build:remote --host_javabase=@buildbuddy_toolchain//:javabase_jdk8
38+
build:remote --java_toolchain=@buildbuddy_toolchain//:toolchain_jdk8
39+
build:remote --host_java_toolchain=@buildbuddy_toolchain//:toolchain_jdk8
40+
build:remote --define=EXECUTOR=remote
41+
42+
try-import %workspace%/user.bazelrc

projects/bzl4/WORKSPACE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ http_archive(
2727
urls = ["https://github.com/tweag/rules_nixpkgs/archive/d542df716db422f6a7fab180202d03e1f1cc03f6.tar.gz"],
2828
)
2929

30+
http_archive(
31+
name = "io_buildbuddy_buildbuddy_toolchain",
32+
sha256 = "a2a5cccec251211e2221b1587af2ce43c36d32a42f5d881737db3b546a536510",
33+
strip_prefix = "buildbuddy-toolchain-829c8a574f706de5c96c54ca310f139f4acda7dd",
34+
urls = ["https://github.com/buildbuddy-io/buildbuddy-toolchain/archive/829c8a574f706de5c96c54ca310f139f4acda7dd.tar.gz"],
35+
)
36+
37+
load("@io_buildbuddy_buildbuddy_toolchain//:deps.bzl", "buildbuddy_deps")
38+
39+
buildbuddy_deps()
40+
41+
load("@io_buildbuddy_buildbuddy_toolchain//:rules.bzl", "buildbuddy")
42+
43+
buildbuddy(name = "buildbuddy_toolchain")
44+
3045
load("@io_tweag_rules_nixpkgs//nixpkgs:repositories.bzl", "rules_nixpkgs_dependencies")
3146
rules_nixpkgs_dependencies()
3247

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" Hello world app """
22

33
load("@rules_cc//cc:defs.bzl", "cc_binary")
4+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
45

56
cc_binary(
67
name = "main",
@@ -9,5 +10,36 @@ cc_binary(
910
]),
1011
deps = [
1112
"//third_party/xz"
12-
]
13+
],
14+
defines = select({
15+
":cuda_build": ["WITH_CUDA"],
16+
"//conditions:default": [],
17+
})
1318
)
19+
20+
string_flag(
21+
name = "gpu",
22+
build_setting_default = "none",
23+
values = [
24+
"none",
25+
"cuda"
26+
],
27+
)
28+
29+
30+
config_setting(
31+
name = "cuda_build",
32+
flag_values = {
33+
":gpu": "cuda",
34+
},
35+
visibility = ["//visibility:public"],
36+
)
37+
38+
39+
# Legacy way for configurable build attributes
40+
# config_setting(
41+
# name = "cuda_build",
42+
# values = {
43+
# "define": "with_cuda=1",
44+
# },
45+
# )

projects/bzl4/hello_world/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include <lzma.h>
33

44
int main() {
5-
std::cout << "Hello World!";
5+
std::cout << "Hey there!\n";
6+
#ifndef WITH_CUDA
7+
std::cout << "I'm missing my cuda\n";
8+
#endif
69
return 0;
710
}

projects/bzl4/user.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build --remote_header=x-buildbuddy-api-key=iVJirZ6U1ZlWGtmBUu25

0 commit comments

Comments
 (0)