Skip to content

Commit

Permalink
Bazel: Clean up configuration options
Browse files Browse the repository at this point in the history
De-duplicate options for local and remote build configurations.
Note, though, that we don't re-use build_shared configuration for
default build configuration, e.g.: build --config=build_shared to
avoid these confusing warnings during the build, when building
non default configurations, e.g.:

$ bazel build --config=java11 java/com/google/gerrit/common:server
[...] WARNING:
option '--java_language_version' was expanded to from both option
'--config=build_shared' (source /home/davido/projects/gerrit2/.bazelrc)
and option '--config=java11' (source command line options)

Also remove unused remote-cache configuration options.

Release-Notes: skip
Change-Id: Ia557c949227b3038cbd62e4a0a3bad0f17d42218
  • Loading branch information
davido authored and avilaplana committed Feb 7, 2024
1 parent 164321e commit 6e51e8d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
34 changes: 20 additions & 14 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@ build --repository_cache=~/.gerritcodereview/bazel-cache/repository
build --action_env=PATH
build --disk_cache=~/.gerritcodereview/bazel-cache/cas

# Define configuration using remotejdk_11, executes using remotejdk_11 or local_jdk
build:build_shared --java_language_version=11
build:build_shared --java_runtime_version=remotejdk_11
build:build_shared --tool_java_language_version=11
build:build_shared --tool_java_runtime_version=remotejdk_11

# Builds using remotejdk_11, executes using remotejdk_11 or local_jdk
# Avoid warnings for non default configurations:
# build --config=build_shared
build --java_language_version=11
build --java_runtime_version=remotejdk_11
build --tool_java_language_version=11
build --tool_java_runtime_version=remotejdk_11

# Builds using remotejdk_17, executes using remotejdk_17 or local_jdk
build:java17 --java_language_version=17
build:java17 --java_runtime_version=remotejdk_17
build:java17 --tool_java_language_version=17
build:java17 --tool_java_runtime_version=remotejdk_17

# Builds and executes on RBE using remotejdk_11
build:remote --java_language_version=11
build:remote --java_runtime_version=remotejdk_11
build:remote --tool_java_language_version=11
build:remote --tool_java_runtime_version=remotejdk_11
build:remote --config=remote_shared
build:remote --config=build_shared

# Define configuration using remotejdk_17, executes using remotejdk_17 or local_jdk
build:build_java17_shared --java_language_version=17
build:build_java17_shared --java_runtime_version=remotejdk_17
build:build_java17_shared --tool_java_language_version=17
build:build_java17_shared --tool_java_runtime_version=remotejdk_17

build:java17 --config=build_java17_shared

# Builds and executes on RBE using remotejdk_17
build:remote17 --java_language_version=17
build:remote17 --java_runtime_version=remotejdk_17
build:remote17 --tool_java_language_version=17
build:remote17 --tool_java_runtime_version=remotejdk_17
build:remote17 --config=remote_shared
build:remote17 --config=build_java11_shared

# Enable strict_action_env flag to. For more information on this feature see
# https://groups.google.com/forum/#!topic/bazel-discuss/_VmRfMyyHBk.
Expand Down
33 changes: 13 additions & 20 deletions tools/remote-bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,34 @@
# this higher can make builds faster by allowing more jobs to run in parallel.
# Setting it too high can result in jobs that timeout, however, while waiting
# for a remote machine to execute them.
build:remote --jobs=200
build:remote --disk_cache=
build:remote_shared --jobs=200
build:remote_shared --disk_cache=

# Set several flags related to specifying the platform, toolchain and java
# properties.
build:remote --crosstool_top=@rbe_jdk11//cc:toolchain
build:remote --extra_toolchains=@rbe_jdk11//config:cc-toolchain
build:remote --extra_execution_platforms=@rbe_jdk11//config:platform
build:remote --host_platform=@rbe_jdk11//config:platform
build:remote --platforms=@rbe_jdk11//config:platform
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build:remote_shared --crosstool_top=@rbe_jdk11//cc:toolchain
build:remote_shared --extra_toolchains=@rbe_jdk11//config:cc-toolchain
build:remote_shared --extra_execution_platforms=@rbe_jdk11//config:platform
build:remote_shared --host_platform=@rbe_jdk11//config:platform
build:remote_shared --platforms=@rbe_jdk11//config:platform
build:remote_shared --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

# Set various strategies so that all actions execute remotely. Mixing remote
# and local execution will lead to errors unless the toolchain and remote
# machine exactly match the host machine.
build:remote --define=EXECUTOR=remote
build:remote_shared --define=EXECUTOR=remote

# Enable the remote cache so action results can be shared across machines,
# developers, and workspaces.
build:remote --remote_cache=remotebuildexecution.googleapis.com
build:remote_shared --remote_cache=remotebuildexecution.googleapis.com

# Enable remote execution so actions are performed on the remote systems.
build:remote --remote_executor=remotebuildexecution.googleapis.com
build:remote_shared --remote_executor=remotebuildexecution.googleapis.com

# Set a higher timeout value, just in case.
build:remote --remote_timeout=3600
build:remote_shared --remote_timeout=3600

# Enable authentication. This will pick up application default credentials by
# default. You can use --auth_credentials=some_file.json to use a service
# account credential instead.
build:remote --google_default_credentials

# The following flags enable the remote cache so action results can be shared
# across machines, developers, and workspaces.
build:remote-cache --remote_cache=remotebuildexecution.googleapis.com
build:remote-cache --tls_enabled=true
build:remote-cache --remote_timeout=3600
build:remote-cache --auth_enabled=true
build:remote_shared --google_default_credentials

0 comments on commit 6e51e8d

Please sign in to comment.