[infra] Fix not initializing RBE before gn.

Bug: b/296994239
Change-Id: I344f07fa7f389fa5b0f5e65b24168f2d05daacbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355683
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
This commit is contained in:
Jonas Termansen 2024-03-05 13:22:39 +00:00 committed by Commit Queue
parent a4e15669ec
commit a27993d7c9
2 changed files with 27 additions and 18 deletions

View file

@ -161,21 +161,6 @@ def StartRBE(out_dir, use_goma, env):
if not os.path.exists(rbe_dir) or not os.path.isdir(rbe_dir):
print(f'Could not find {rbe} at {rbe_dir}')
return False
RBE_cfg = 'RBE_CFG' if HOST_OS == 'win32' else 'RBE_cfg'
RBE_server_address = ('RBE_SERVER_ADDRESS'
if HOST_OS == 'win32' else 'RBE_server_address')
if not use_goma and not RBE_cfg in env:
env[RBE_cfg] = os.path.join(
os.getcwd(), 'build', 'rbe',
'windows.cfg' if HOST_OS == 'win32' else 'unix.cfg')
if not use_goma and not RBE_server_address in env:
with open(env[RBE_cfg], 'r') as f:
if not any([l.startswith('server_address') for l in f.readlines()]):
schema = 'pipe' if HOST_OS == 'win32' else 'unix'
socket = os.path.join(os.getcwd(), out_dir, 'reproxy.sock')
if HOST_OS == 'win32':
socket = socket.replace('\\', '_').replace(':', '_')
env[RBE_server_address] = f'{schema}://{socket}'
bootstrap = 'goma_ctl.py' if use_goma else 'bootstrap'
bootstrap_path = os.path.join(rbe_dir, bootstrap)
bootstrap_command = [bootstrap_path]
@ -342,7 +327,7 @@ def Main():
env.pop('SDKROOT', None)
# Always run GN before building.
gn_py.RunGnOnConfiguredConfigurations(options)
gn_py.RunGnOnConfiguredConfigurations(options, env)
# Build all targets for each requested configuration.
configs = []

View file

@ -621,6 +621,26 @@ def parse_args(args):
return options
def InitializeRBE(out_dir, env):
RBE_cfg = 'RBE_CFG' if HOST_OS == 'win32' else 'RBE_cfg'
RBE_server_address = ('RBE_SERVER_ADDRESS'
if HOST_OS == 'win32' else 'RBE_server_address')
# Default RBE_cfg to the appropriate configuration file.
if not RBE_cfg in env:
env[RBE_cfg] = os.path.join(
os.getcwd(), 'build', 'rbe',
'windows.cfg' if HOST_OS == 'win32' else 'unix.cfg')
# Default RBE_server_address to inside the build directory.
if not RBE_server_address in env:
with open(env[RBE_cfg], 'r') as f:
if not any([l.startswith('server_address') for l in f.readlines()]):
schema = 'pipe' if HOST_OS == 'win32' else 'unix'
socket = os.path.join(os.getcwd(), out_dir, 'reproxy.sock')
if HOST_OS == 'win32':
socket = socket.replace('\\', '_').replace(':', '_')
env[RBE_server_address] = f'{schema}://{socket}'
def ExecutableName(basename):
if utils.IsWindows():
return f'{basename}.exe'
@ -652,13 +672,17 @@ def BuildGnCommand(args, mode, arch, target_os, sanitizer, out_dir):
return command
def RunGnOnConfiguredConfigurations(args):
def RunGnOnConfiguredConfigurations(args, env={}):
initialized_rbe = False
commands = []
for target_os in args.os:
for mode in args.mode:
for arch in args.arch:
for sanitizer in args.sanitizer:
out_dir = GetOutDir(mode, arch, target_os, sanitizer)
if args.rbe and not initialized_rbe:
InitializeRBE(out_dir, env)
initialized_rbe = True
commands.append(
BuildGnCommand(args, mode, arch, target_os, sanitizer,
out_dir))
@ -674,7 +698,7 @@ def RunGnOnConfiguredConfigurations(args):
for command in commands:
try:
process = subprocess.Popen(command, cwd=DART_ROOT)
process = subprocess.Popen(command, cwd=DART_ROOT, env=env)
active_commands.append([command, process])
except Exception as e:
print('Error: %s' % e)