Add an "--nnbd" flag to build.py.

This treats whether or not to use the forked NNBD SDK as a build flag
similar to mode or architecture. When this flag is passed, it appends
"NNBD" to the main output directory, like xcodebuild/ReleaseX64NNBD.

It also defines a "use_nnbd" flag that is available inside BUILD.gn
files to determine whether or not to use the forked SDK. This flag
currently isn't used. Implementation teams will need to edit their
build steps to take that into account.

In order to use this mode on the bots, we'll need to tweak the bot
scripts to figure out whether the mode is enabled or not. There are a
couple of TODOs in the Python scripts for that. I'm not sure how that
should be specified in dart_sdk.py.

This CL does not remove my previous change to allow building the NNBD
fork next to dart-sdk in the same root output directory. I'll revert
those changes in a different CL once this one lands.

Change-Id: I3bd28f273106ee90caf9474b2fadad120b2c2d0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119602
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
Robert Nystrom 2019-10-03 00:11:32 +00:00 committed by commit-bot@chromium.org
parent d65a60db00
commit e919e89d0b
5 changed files with 68 additions and 20 deletions

View file

@ -130,6 +130,10 @@ declare_args() {
# Compile for Thread Sanitizer to find threading bugs.
is_tsan = false
# Whether to use the NNBD fork of the SDK core libraries.
# TODO(rnystrom): Remove this when the fork has been merged back in.
use_nnbd = false
}
# =============================================================================

View file

@ -45,7 +45,9 @@ class BuildInfo(object):
on several different runtimes.
- builder_tag: A tag indicating a special builder setup.
- cps_ir: Run the compiler with the cps based backend
- use_nnbd: Whether to use the NNBD fork of the SDK.
"""
# TODO: Remove use_nnbd when the fork is merged back in.
def __init__(self,
compiler,
@ -64,7 +66,8 @@ class BuildInfo(object):
dart2js_full=False,
builder_tag=None,
batch=False,
cps_ir=False):
cps_ir=False,
use_nnbd=False):
self.compiler = compiler
self.runtime = runtime
self.mode = mode
@ -81,6 +84,7 @@ class BuildInfo(object):
self.builder_tag = builder_tag
self.batch = batch
self.cps_ir = cps_ir
self.use_nnbd = use_nnbd
if (arch == None):
self.arch = 'ia32'
else:
@ -268,11 +272,20 @@ def RunTestRunner(build_info, path):
"""
Runs the test package's runner on the package at 'path'.
"""
# TODO(38701): Once bots are set up to run NNBD configurations, update
# the various name parsing functions to detect that and pass "use_nnbd" to
# the BuildInfo() constructor.
sdk_bin = os.path.join(
bot_utils.DART_DIR,
utils.GetBuildSdkBin(BUILD_OS, build_info.mode, build_info.arch))
utils.GetBuildSdkBin(BUILD_OS, build_info.mode, build_info.arch,
build_info.use_nnbd))
build_root = utils.GetBuildRoot(BUILD_OS, build_info.mode, build_info.arch)
build_root = utils.GetBuildRoot(
BUILD_OS,
build_info.mode,
build_info.arch,
use_nnbd=build_info.use_nnbd)
dart_name = 'dart.exe' if build_info.system == 'windows' else 'dart'
dart_bin = os.path.join(sdk_bin, dart_name)

View file

@ -63,6 +63,13 @@ def BuildOptions():
help='Target OSs (comma-separated).',
metavar='[all,host,android]',
default='host')
# TODO(38701): Remove this and everything that references it once the
# forked NNBD SDK is merged back in.
result.add_option(
"--nnbd",
help='Use the NNBD fork of the SDK.',
default=False,
action='store_true')
result.add_option(
"-v",
"--verbose",
@ -200,7 +207,7 @@ def GenerateBuildfilesIfNeeded():
return True
def RunGNIfNeeded(out_dir, target_os, mode, arch):
def RunGNIfNeeded(out_dir, target_os, mode, arch, use_nnbd):
if os.path.isfile(os.path.join(out_dir, 'args.gn')):
return
gn_os = 'host' if target_os == HOST_OS else target_os
@ -215,6 +222,9 @@ def RunGNIfNeeded(out_dir, target_os, mode, arch):
gn_os,
'-v',
]
if use_nnbd:
gn_command.append('--nnbd')
process = subprocess.Popen(gn_command)
process.wait()
if process.returncode != 0:
@ -268,12 +278,12 @@ def EnsureGomaStarted(out_dir):
# Returns a tuple (build_config, command to run, whether goma is used)
def BuildOneConfig(options, targets, target_os, mode, arch):
build_config = utils.GetBuildConf(mode, arch, target_os)
out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
build_config = utils.GetBuildConf(mode, arch, target_os, options.nnbd)
out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os, options.nnbd)
using_goma = False
# TODO(zra): Remove auto-run of gn, replace with prompt for user to run
# gn.py manually.
RunGNIfNeeded(out_dir, target_os, mode, arch)
RunGNIfNeeded(out_dir, target_os, mode, arch, options.nnbd)
command = ['ninja', '-C', out_dir]
if options.verbose:
command += ['-v']

View file

@ -66,8 +66,9 @@ def GetGNArgs(args):
return args.split()
def GetOutDir(mode, arch, target_os):
return utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
def GetOutDir(mode, arch, target_os, use_nnbd):
return utils.GetBuildRoot(HOST_OS, mode, arch, target_os, use_nnbd)
def ToCommandLine(gn_args):
@ -166,7 +167,8 @@ def UseSysroot(args, gn_args):
return True
def ToGnArgs(args, mode, arch, target_os):
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
def ToGnArgs(args, mode, arch, target_os, use_nnbd):
gn_args = {}
host_os = HostOsForGn(HOST_OS)
@ -284,6 +286,8 @@ def ToGnArgs(args, mode, arch, target_os):
gn_args['dart_debug_optimization_level'] = args.debug_opt_level
gn_args['debug_optimization_level'] = args.debug_opt_level
gn_args['use_nnbd'] = use_nnbd
return gn_args
@ -385,6 +389,12 @@ def parse_args(args):
help='Target OSs (comma-separated).',
metavar='[all,host,android]',
default='host')
# TODO(38701): Remove this once the forked NNBD SDK is merged back in.
common_group.add_argument(
"--nnbd",
help='Use the NNBD fork of the SDK.',
default=False,
action='store_true')
common_group.add_argument(
"-v",
"--verbose",
@ -533,12 +543,13 @@ def Main(argv):
for target_os in args.os:
for mode in args.mode:
for arch in args.arch:
out_dir = GetOutDir(mode, arch, target_os)
out_dir = GetOutDir(mode, arch, target_os, args.nnbd)
# TODO(infra): Re-enable --check. Many targets fail to use
# public_deps to re-expose header files to their dependents.
# See dartbug.com/32364
command = [gn, 'gen', out_dir]
gn_args = ToCommandLine(ToGnArgs(args, mode, arch, target_os))
gn_args = ToCommandLine(
ToGnArgs(args, mode, arch, target_os, args.nnbd))
gn_args += GetGNArgs(args)
if args.verbose:
print("gn gen --check in %s" % out_dir)

View file

@ -308,32 +308,42 @@ def IsCrossBuild(target_os, arch):
(target_os != GuessOS()))
def GetBuildConf(mode, arch, conf_os=None):
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
def GetBuildConf(mode, arch, conf_os=None, use_nnbd=False):
nnbd = "NNBD" if use_nnbd else ""
if conf_os == 'android':
return '%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper())
return '%s%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper(),
nnbd)
else:
# Ask for a cross build if the host and target architectures don't match.
host_arch = ARCH_GUESS
cross_build = ''
if GetArchFamily(host_arch) != GetArchFamily(arch):
cross_build = 'X'
return '%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper())
return '%s%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper(),
nnbd)
def GetBuildDir(host_os):
return BUILD_ROOT[host_os]
def GetBuildRoot(host_os, mode=None, arch=None, target_os=None):
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
def GetBuildRoot(host_os, mode=None, arch=None, target_os=None, use_nnbd=False):
build_root = GetBuildDir(host_os)
if mode:
build_root = os.path.join(build_root, GetBuildConf(
mode, arch, target_os))
build_root = os.path.join(build_root,
GetBuildConf(mode, arch, target_os, use_nnbd))
return build_root
def GetBuildSdkBin(host_os, mode=None, arch=None, target_os=None):
build_root = GetBuildRoot(host_os, mode, arch, target_os)
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
def GetBuildSdkBin(host_os,
mode=None,
arch=None,
target_os=None,
use_nnbd=False):
build_root = GetBuildRoot(host_os, mode, arch, target_os, use_nnbd)
return os.path.join(build_root, 'dart-sdk', 'bin')