mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:13:04 +00:00
[infra] Don't run generate_buildfiles.py during gclient hooks
There is a race with downloading the prebuilt Dart SDK from CIPD
introduced by:
647e1e79eb
If the prebuilt Dart SDK isn't there, then generate_buildfiles.py will
fail. Instead check whether generate_buildfiles.py should be run
right before we try to build.
Change-Id: I1e25e5280075f9d1c7d96877602617ddfb40291e
Reviewed-on: https://dart-review.googlesource.com/77160
Reviewed-by: Jonas Termansen <sortie@google.com>
This commit is contained in:
parent
54f426c273
commit
defd68e431
4
DEPS
4
DEPS
|
@ -475,8 +475,4 @@ hooks = [
|
||||||
'pattern': '.',
|
'pattern': '.',
|
||||||
'action': ['python', 'sdk/build/vs_toolchain.py', 'update'],
|
'action': ['python', 'sdk/build/vs_toolchain.py', 'update'],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"pattern": ".",
|
|
||||||
"action": ["python", Var("dart_root") + "/tools/generate_buildfiles.py"],
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -164,7 +164,26 @@ def NotifyBuildDone(build_config, success, start):
|
||||||
os.system(command)
|
os.system(command)
|
||||||
|
|
||||||
|
|
||||||
def RunGN(target_os, mode, arch):
|
def GenerateBuildfilesIfNeeded():
|
||||||
|
if os.path.exists(utils.GetBuildDir(HOST_OS)):
|
||||||
|
return True
|
||||||
|
command = [
|
||||||
|
'python',
|
||||||
|
os.path.join(DART_ROOT, 'tools', 'generate_buildfiles.py')
|
||||||
|
]
|
||||||
|
print ("Running " + ' '.join(command))
|
||||||
|
process = subprocess.Popen(command)
|
||||||
|
process.wait()
|
||||||
|
if process.returncode != 0:
|
||||||
|
print ("Tried to generate missing buildfiles, but failed. "
|
||||||
|
"Try running manually:\n\t$ " + ' '.join(command))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def RunGNIfNeeded(out_dir, target_os, mode, arch):
|
||||||
|
if os.path.isfile(os.path.join(out_dir, 'args.gn')):
|
||||||
|
return
|
||||||
gn_os = 'host' if target_os == HOST_OS else target_os
|
gn_os = 'host' if target_os == HOST_OS else target_os
|
||||||
gn_command = [
|
gn_command = [
|
||||||
'python',
|
'python',
|
||||||
|
@ -181,11 +200,6 @@ def RunGN(target_os, mode, arch):
|
||||||
' '.join(gn_command))
|
' '.join(gn_command))
|
||||||
|
|
||||||
|
|
||||||
def ShouldRunGN(out_dir):
|
|
||||||
return (not os.path.exists(out_dir) or
|
|
||||||
not os.path.isfile(os.path.join(out_dir, 'args.gn')))
|
|
||||||
|
|
||||||
|
|
||||||
def UseGoma(out_dir):
|
def UseGoma(out_dir):
|
||||||
args_gn = os.path.join(out_dir, 'args.gn')
|
args_gn = os.path.join(out_dir, 'args.gn')
|
||||||
return 'use_goma = true' in open(args_gn, 'r').read()
|
return 'use_goma = true' in open(args_gn, 'r').read()
|
||||||
|
@ -234,8 +248,7 @@ def BuildOneConfig(options, targets, target_os, mode, arch):
|
||||||
using_goma = False
|
using_goma = False
|
||||||
# TODO(zra): Remove auto-run of gn, replace with prompt for user to run
|
# TODO(zra): Remove auto-run of gn, replace with prompt for user to run
|
||||||
# gn.py manually.
|
# gn.py manually.
|
||||||
if ShouldRunGN(out_dir):
|
RunGNIfNeeded(out_dir, target_os, mode, arch)
|
||||||
RunGN(target_os, mode, arch)
|
|
||||||
command = ['ninja', '-C', out_dir]
|
command = ['ninja', '-C', out_dir]
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
command += ['-v']
|
command += ['-v']
|
||||||
|
@ -290,6 +303,9 @@ def Main():
|
||||||
else:
|
else:
|
||||||
targets = args
|
targets = args
|
||||||
|
|
||||||
|
if not GenerateBuildfilesIfNeeded():
|
||||||
|
return 1
|
||||||
|
|
||||||
# Build all targets for each requested configuration.
|
# Build all targets for each requested configuration.
|
||||||
configs = []
|
configs = []
|
||||||
for target_os in options.os:
|
for target_os in options.os:
|
||||||
|
|
Loading…
Reference in a new issue