Skip to content

Commit 078f547

Browse files
authored
Merge pull request #2 from ghasemloo/feature
Add bazelrc
2 parents 38b4acf + fbc67bf commit 078f547

File tree

5 files changed

+142
-24
lines changed

5 files changed

+142
-24
lines changed

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cc_library(
1515
],
1616
hdrs = [
1717
"hello_world.h",
18+
"v.h",
1819
],
1920
deps = [
2021
],

WORKSPACE

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Bazel toolchains
22
http_archive(
3-
name = "bazel_toolchains",
4-
urls = [
5-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/r324073.tar.gz",
6-
"https://github.com/bazelbuild/bazel-toolchains/archive/r324073.tar.gz",
7-
],
8-
strip_prefix = "bazel-toolchains-r324073",
9-
sha256 = "71548c0d6cd53eddebbde4fa9962f5395e82645fb9992719e0890505b177f245",
3+
name = "bazel_toolchains",
4+
urls = [
5+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/37acf1841ab1475c98a152cb9e446460c8ae29e1.tar.gz",
6+
"https://github.com/bazelbuild/bazel-toolchains/archive/37acf1841ab1475c98a152cb9e446460c8ae29e1.tar.gz",
7+
],
8+
strip_prefix = "bazel-toolchains-37acf1841ab1475c98a152cb9e446460c8ae29e1",
9+
sha256 = "3b604699685c5c65dd3f6f17425570a4b2f00ddba2f750db15acc72e55bb098b",
1010
)
1111

1212
# GoogleTest/GoogleMock framework. Used by most unit-tests.

bazelrc

Lines changed: 127 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,139 @@
1-
# Based on https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/bazel-0.10.0.bazelrc
1+
# https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/bazel-0.15.0.bazelrc
2+
# Copyright 2016 The Bazel Authors. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
215

16+
# This .bazelrc file contains all of the flags required for the toolchain,
17+
# Remote Build Execution, and the Bazel Build Results UI. Specific flags in
18+
# your Bazel command allow you to use only the remote build, to use only the
19+
# results UI, or to use them both together.
20+
#
21+
# This .bazelrc file also contains all of the flags required for the local
22+
# docker sandboxing.
23+
24+
# Remote Build Execution requires a strong hash function, such as SHA256.
325
startup --host_jvm_args=-Dbazel.DigestFunction=SHA256
426

5-
# Auth
6-
build:remote --auth_enabled=true
7-
build:remote --auth_scope=https://www.googleapis.com/auth/cloud-platform
8-
build:remote --tls_enabled=true
27+
# Depending on how many machines are in the remote execution instance, setting
28+
# this higher can make builds faster by allowing more jobs to run in parallel.
29+
# Setting it too high can result in jobs that timeout, however, while waiting
30+
# for a remote machine to execute them.
31+
build:remote --jobs=50
932

10-
# RBE Toolchains
11-
build:remote --experimental_strict_action_env=true
12-
build:remote --experimental_remote_platform_override='properties:{ name:"container-image" value:"docker://gcr.io/cloud-marketplace/google/rbe-debian8@sha256:d84a7de5175a22505209f56b02f1da20ccec64880da09ee38eaef3670fbd2a56" }'
13-
build:remote --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.3.0/bazel_0.10.0:toolchain
14-
build:remote --host_java_toolchain=@bazel_toolchains//configs/debian8_clang/0.3.0:jdk8
15-
build:remote --host_javabase=@bazel_toolchains//configs/debian8_clang/0.3.0:jdk8
16-
build:remote --javabase=@bazel_toolchains//configs/debian8_clang/0.3.0:jdk8
33+
# Set several flags related to specifying the platform, toolchain and java
34+
# properties.
35+
# These flags are duplicated rather than imported from (for example)
36+
# %workspace%/configs/ubuntu16_04_clang/1.0/toolchain.bazelrc to make this
37+
# bazelrc a standalone file that can be copied more easily.
38+
# These flags should only be used as is for the rbe-ubuntu16-04 container
39+
# and need to be adapted to work with other toolchain containers.
40+
build:remote --host_javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.0:jdk8
41+
build:remote --javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.0:jdk8
42+
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
43+
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
44+
build:remote --crosstool_top=@bazel_toolchains//configs/ubuntu16_04_clang/1.0/bazel_0.15.0/default:toolchain
45+
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
46+
# Platform flags:
47+
# The toolchain container used for execution is defined in the target indicated
48+
# by "extra_execution_platforms", "host_platform" and "platforms".
49+
# If you are using your own toolchain container, you need to create a platform
50+
# target with "constraint_values" that allow for the toolchain specified with
51+
# "extra_toolchains" to be selected (given constraints defined in
52+
# "exec_compatible_with").
53+
# More about platforms: https://docs.bazel.build/versions/master/platforms.html
54+
build:remote --enabled_toolchain_types=@bazel_tools//tools/cpp:toolchain_type
55+
build:remote --extra_toolchains=@bazel_toolchains//configs/ubuntu16_04_clang/1.0/bazel_0.15.0/cpp:cc-toolchain-clang-x86_64-default
56+
build:remote --extra_execution_platforms=@bazel_toolchains//configs/ubuntu16_04_clang/1.0:rbe_ubuntu1604
57+
build:remote --host_platform=@bazel_toolchains//configs/ubuntu16_04_clang/1.0:rbe_ubuntu1604
58+
build:remote --platforms=@bazel_toolchains//configs/ubuntu16_04_clang/1.0:rbe_ubuntu1604
1759

18-
# RBE
19-
build:remote --remote_timeout=3600
20-
build:remote --remote_local_fallback=false
60+
# Set various strategies so that all actions execute remotely. Mixing remote
61+
# and local execution will lead to errors unless the toolchain and remote
62+
# machine exactly match the host machine.
2163
build:remote --spawn_strategy=remote
2264
build:remote --strategy=Javac=remote
2365
build:remote --strategy=Closure=remote
2466
build:remote --genrule_strategy=remote
2567
build:remote --define=EXECUTOR=remote
2668

27-
# BRUI
28-
build:results --bes_timeout=10s
69+
# Enable the remote cache so action results can be shared across machines,
70+
# developers, and workspaces.
71+
build:remote --remote_cache=remotebuildexecution.googleapis.com
72+
73+
# Enable remote execution so actions are performed on the remote systems.
74+
build:remote --remote_executor=remotebuildexecution.googleapis.com
75+
76+
# Enable encryption.
77+
build:remote --tls_enabled=true
78+
79+
# Enforce stricter environment rules, which eliminates some non-hermetic
80+
# behavior and therefore improves both the remote cache hit rate and the
81+
# correctness and repeatability of the build.
82+
build:remote --experimental_strict_action_env=true
83+
84+
# Set a higher timeout value, just in case.
85+
build:remote --remote_timeout=3600
86+
87+
# Enable authentication. This will pick up application default credentials by
88+
# default. You can use --auth_credentials=some_file.json to use a service
89+
# account credential instead.
90+
build:remote --auth_enabled=true
91+
92+
# Set flags for uploading to BES in order to view results in the Bazel Build
93+
# Results UI.
94+
build:results --bes_backend="buildeventservice.googleapis.com"
95+
build:results --bes_timeout=60s
96+
97+
# If the upload to BES fails, the build will fail.
2998
build:results --bes_best_effort=false
99+
100+
# Output BES results url
101+
build:results --bes_results_url="https://source.cloud.google.com/results/invocations/"
102+
103+
# Set flags for uploading to BES without Remote Build Execution.
104+
build:results-local --bes_backend="buildeventservice.googleapis.com"
105+
build:results-local --bes_timeout=60s
106+
build:results-local --bes_best_effort=false
107+
build:results-local --tls_enabled=true
108+
build:results-local --auth_enabled=true
109+
build:results-local --spawn_strategy=local
110+
build:results-local --experimental_remote_spawn_cache
111+
build:results-local --remote_cache=remotebuildexecution.googleapis.com
112+
build:results-local --remote_timeout=3600
113+
build:results-local --bes_results_url="https://source.cloud.google.com/results/invocations/"
114+
115+
# The following flags are only necessary for local docker sandboxing
116+
# with the rbe-ubuntu16-04 container. Use of these flags is still experimental.
117+
build:docker-sandbox --host_javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.0:jdk8
118+
build:docker-sandbox --javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.0:jdk8
119+
build:docker-sandbox --crosstool_top=@bazel_toolchains//configs/ubuntu16_04_clang/1.0/bazel_0.15.0/default:toolchain
120+
build:docker-sandbox --experimental_docker_image=gcr.io/cloud-marketplace/google/rbe-ubuntu16-04@sha256:59bf0e191a6b5cc1ab62c2224c810681d1326bad5a27b1d36c9f40113e79da7f
121+
build:docker-sandbox --spawn_strategy=docker
122+
build:docker-sandbox --strategy=Javac=docker
123+
build:docker-sandbox --strategy=Closure=docker
124+
build:docker-sandbox --genrule_strategy=docker
125+
build:docker-sandbox --define=EXECUTOR=remote
126+
build:docker-sandbox --experimental_docker_verbose
127+
build:docker-sandbox --experimental_enable_docker_sandbox
128+
129+
# The following flags enable the remote cache so action results can be shared
130+
# across machines, developers, and workspaces.
131+
build:remote-cache --remote_cache=remotebuildexecution.googleapis.com
132+
build:remote-cache --tls_enabled=true
133+
build:remote-cache --experimental_strict_action_env=true
134+
build:remote-cache --remote_timeout=3600
135+
build:remote-cache --auth_enabled=true
136+
build:remote-cache --spawn_strategy=standalone
137+
build:remote-cache --strategy=Javac=standalone
138+
build:remote-cache --strategy=Closure=standalone
139+
build:remote-cache --genrule_strategy=standalone

hello_world.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "hello_world.h"
44

5+
#include "v.h"
6+
57
namespace {
68
const char* message = "Hello World!";
79
}
@@ -14,4 +16,8 @@ std::string HelloWorld::Message() {
1416
return message;
1517
}
1618

19+
int V() {
20+
return v;
21+
}
22+
1723
} // namespace hello_world

v.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const int v = 0;

0 commit comments

Comments
 (0)