Skip to content

Commit

Permalink
Add --no-rbe flag to gn.py to disable RBE. (#4735)
Browse files Browse the repository at this point in the history
This allows Remote Build Execution to be situationally disabled.
Disables RBE for Kokoro builds until RBE is fully supported.

b/384982606
  • Loading branch information
kaidokert authored Jan 22, 2025
2 parents 1e393e2 + 2bf716e commit 052f6b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions cobalt/build/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def get_build_args(build_args_path):
]


def write_build_args(build_args_path, original_lines, dict_settings,
build_type):
def write_build_args(build_args_path, original_lines, dict_settings, build_type,
use_rbe):
""" Write args file, modifying settings for config"""
controlled_args = [
(k, dict_settings[k]) for k in CONTROLLED_ARGS if k in dict_settings
Expand All @@ -85,7 +85,8 @@ def write_build_args(build_args_path, original_lines, dict_settings,
f'The following args cannot be set in configs: {controlled_args}')
gen_comment = '# Set by gn.py'
with open(build_args_path, 'w', encoding='utf-8') as f:
f.write(f'use_remoteexec = true {gen_comment}\n')
if use_rbe:
f.write(f'use_remoteexec = true {gen_comment}\n')
f.write(
f'rbe_cfg_dir = rebase_path("//cobalt/reclient_cfgs") {gen_comment}\n')
f.write(f'build_type = "{build_type}" {gen_comment}\n')
Expand All @@ -95,12 +96,12 @@ def write_build_args(build_args_path, original_lines, dict_settings,
f.write(line)


def main(out_directory: str, platform: str, build_type: str,
def main(out_directory: str, platform: str, build_type: str, use_rbe: bool,
gn_gen_args: List[str]):
Path(out_directory).mkdir(parents=True, exist_ok=True)
platform_path = f'cobalt/build/configs/{platform}'
dst_args_gn_file = os.path.join(out_directory, 'args.gn')
src_args_gn_file = os.path.join(platform_path, 'args.gn')
Path(out_directory).mkdir(parents=True, exist_ok=True)

if os.path.exists(dst_args_gn_file):
# Copy the stale args.gn into stale_args.gn
Expand All @@ -111,7 +112,9 @@ def main(out_directory: str, platform: str, build_type: str,
'In general, if the file exists, you should run'
' `gn args <out_directory>` to edit it instead.')
build_args = get_build_args(src_args_gn_file)
write_build_args(dst_args_gn_file, build_args[0], build_args[1], build_type)
write_build_args(dst_args_gn_file, build_args[0], build_args[1], build_type,
use_rbe)

gn_command = ['gn', 'gen', out_directory] + gn_gen_args
print(' '.join(gn_command))
subprocess.check_call(gn_command)
Expand Down Expand Up @@ -154,6 +157,11 @@ def main(out_directory: str, platform: str, build_type: str,
default=False,
action='store_true',
help='Pass this flag to disable the header dependency gn check.')
parser.add_argument(
'--no-rbe',
default=False,
action='store_true',
help='Pass this flag to disable Remote Build Execution.')
script_args, gen_args = parser.parse_known_args()

if script_args.platform == 'linux':
Expand All @@ -169,4 +177,4 @@ def main(out_directory: str, platform: str, build_type: str,
builds_out_directory = os.path.join(
BUILDS_DIRECTORY, f'{script_args.platform}_{script_args.build_type}')
main(builds_out_directory, script_args.platform, script_args.build_type,
gen_args)
not script_args.no_rbe, gen_args)
2 changes: 1 addition & 1 deletion cobalt/devinfra/kokoro/bin/dind_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pipeline () {
# Run GN and Ninja.
##############################################################################
cd "${gclient_root}/src"
cobalt/build/gn.py -p "${TARGET_PLATFORM}" -C "${CONFIG}"
cobalt/build/gn.py -p "${TARGET_PLATFORM}" -C "${CONFIG}" --no-rbe
autoninja -C "out/${TARGET_PLATFORM}_${CONFIG}" ${TARGET} # TARGET may expand to multiple args

# Build bootloader config if set.
Expand Down

0 comments on commit 052f6b9

Please sign in to comment.