diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 109e3fc4b5a..e5254c77332 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -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 } # ============================================================================= diff --git a/tools/bots/bot.py b/tools/bots/bot.py index e3712398942..4f7b4c56126 100644 --- a/tools/bots/bot.py +++ b/tools/bots/bot.py @@ -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) diff --git a/tools/build.py b/tools/build.py index 904c65608b3..6eef99c1013 100755 --- a/tools/build.py +++ b/tools/build.py @@ -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'] diff --git a/tools/gn.py b/tools/gn.py index 5cdcc3e9c2e..2b023a370b1 100755 --- a/tools/gn.py +++ b/tools/gn.py @@ -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) diff --git a/tools/utils.py b/tools/utils.py index 2eb4289e2a8..085236ae93f 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -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')