diff --git a/build/rbe/rewrapper_dart.py b/build/rbe/rewrapper_dart.py index e439a5b0ce4..2455ce93c0b 100644 --- a/build/rbe/rewrapper_dart.py +++ b/build/rbe/rewrapper_dart.py @@ -122,23 +122,6 @@ def find_inputs(uris, exec_root, package_config): return inputs -# Rewrite absolute paths in an argument to be relative. -def rewrite_absolute(arg, exec_root, working_directory): - # The file:// schema does not work with relative paths as they are parsed as - # the authority by the dart Uri class. - arg = arg.replace('file:///' + exec_root, '../../') - arg = arg.replace('file://' + exec_root, '../../') - # Replace the absolute exec root by a relative path to the exec root. - arg = arg.replace(exec_root, '../../') - # Simplify paths going to the exec root and back into the out directory. - # Carefully ensure the whole path isn't optimized away. - if arg.endswith(f'../../{working_directory}/'): - arg = arg.replace(f'../../{working_directory}/', '.') - else: - arg = arg.replace(f'../../{working_directory}/', '') - return arg - - # Parse the command line execution to recognize well known programs during the # Dart SDK build, so the inputs and output files can be determined, and the # command can be offloaded to RBE. @@ -858,15 +841,7 @@ def main(argv): command.append('--labels=type=tool') command.append('--inputs=' + ','.join(paths)) command.append('--output_files=' + ','.join(output_files)) - # Absolute paths must not be used with RBE, but since the build currently - # heavily relies on them, work around this issue by rewriting the command - # to instead use relative paths. The Dart SDK build rules needs to be fixed - # rather than doing this, but this is an initial step towards that goal - # which will land in subsequent follow up changes. - command += argv[2:rewrapper_end] + [ - rewrite_absolute(arg, rewrapper.exec_root, working_directory) - for arg in argv[rewrapper_end:] - ] + command += argv[2:] # Finally execute the command remotely. run_command(command, rewrapper.exec_strategy) diff --git a/build/toolchain/mac/mac_toolchain.gni b/build/toolchain/mac/mac_toolchain.gni index 57f71c0e6ab..eee98a0d035 100644 --- a/build/toolchain/mac/mac_toolchain.gni +++ b/build/toolchain/mac/mac_toolchain.gni @@ -171,7 +171,8 @@ template("mac_toolchain") { # to the link step. Which means we can't specify per target # entitlement files - and instead rely on dart_codesign.py script to # match binaries to their entitlement files by name. - signing_script = rebase_path("//runtime/tools/dart_codesign.py") + signing_script = + rebase_path("//runtime/tools/dart_codesign.py", root_build_dir) command += " && $signing_script --identity $codesigning_identity --binary $dylib" } @@ -237,7 +238,8 @@ template("mac_toolchain") { # to the link step. Which means we can't specify per target # entitlement files - and instead rely on dart_codesign.py script to # match binaries to their entitlement files by name. - signing_script = rebase_path("//runtime/tools/dart_codesign.py") + signing_script = + rebase_path("//runtime/tools/dart_codesign.py", root_build_dir) binaries_to_sign = [ "--binary", outfile, diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn index 39749fad158..eca06429bcc 100644 --- a/runtime/vm/BUILD.gn +++ b/runtime/vm/BUILD.gn @@ -168,7 +168,7 @@ template("gen_vm_platform") { invoker.add_implicit_vm_platform_dependency } single_root_scheme = "org-dartlang-sdk" - single_root_base = rebase_path("../../") + single_root_base = rebase_path("../../", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///sdk/lib/libraries.json" outputs = [ "$root_out_dir/vm_platform" + output_postfix + ".dill", diff --git a/tools/build.py b/tools/build.py index 49fd1248788..34d66e8b79d 100755 --- a/tools/build.py +++ b/tools/build.py @@ -198,10 +198,10 @@ def RunOneBuildCommand(build_config, args, env): return 0 -def CheckCleanBuild(build_config, args, env): - args = args + ['-n', '-d', 'explain'] - print(' '.join(args)) - process = subprocess.Popen(args, +def CheckCleanBuild(build_config, args, rbe, env): + explain_args = args + ['-n', '-d', 'explain'] + print(' '.join(explain_args)) + process = subprocess.Popen(explain_args, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -209,10 +209,43 @@ def CheckCleanBuild(build_config, args, env): out, err = process.communicate() process.wait() if process.returncode != 0: - return 1 - if 'ninja: no work to do' not in out.decode('utf-8'): + print(out.decode('utf-8')) print(err.decode('utf-8')) return 1 + if 'ninja: no work to do' not in out.decode('utf-8'): + print(out.decode('utf-8')) + print(err.decode('utf-8')) + return 1 + + if rbe: + list_args = args + ['-t', 'commands'] + print(' '.join(list_args)) + process = subprocess.Popen(list_args, + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + stdin=None) + out, err = process.communicate() + process.wait() + if process.returncode != 0: + print(out.decode('utf-8')) + print(err.decode('utf-8')) + return 1 + bad_commands = [] + working_dir = os.getcwd() + for command in out.decode('utf-8').splitlines(): + if working_dir in command: + bad_commands.append(command) + if len(bad_commands) != 0: + print("""\ + +error: Working directory found in build commands. +Usually this means you forgot to use rebase_path(arg, root_build_dir) when passing arguments to a command. + +bad commands:""") + for command in bad_commands: + print(command) + return 1 return 0 @@ -265,7 +298,7 @@ def Build(configs, env, options): if options.check_clean: for (build_config, args, rbe) in configs: - if CheckCleanBuild(build_config, args, env=env) != 0: + if CheckCleanBuild(build_config, args, rbe, env=env) != 0: return 1 return 0 diff --git a/utils/compiler/BUILD.gn b/utils/compiler/BUILD.gn index 83d0848a510..84cdc39a95e 100644 --- a/utils/compiler/BUILD.gn +++ b/utils/compiler/BUILD.gn @@ -108,7 +108,7 @@ aot_snapshot("dart2js_sdk_aot_product") { compile_platform("compile_dart2js_platform") { single_root_scheme = "org-dartlang-sdk" - single_root_base = rebase_path("$sdk_root/") + single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" outputs = [ @@ -124,7 +124,7 @@ compile_platform("compile_dart2js_platform") { } compile_platform("compile_dart2js_server_platform") { single_root_scheme = "org-dartlang-sdk" - single_root_base = rebase_path("$sdk_root/") + single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" outputs = [ diff --git a/utils/dart2wasm/BUILD.gn b/utils/dart2wasm/BUILD.gn index cb62c899fdc..0edf8ffebaf 100644 --- a/utils/dart2wasm/BUILD.gn +++ b/utils/dart2wasm/BUILD.gn @@ -44,7 +44,7 @@ aot_snapshot("dart2wasm_product_snapshot") { compile_platform("compile_dart2wasm_platform") { single_root_scheme = "org-dartlang-sdk" - single_root_base = rebase_path("$sdk_root/") + single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" outputs = [ @@ -60,7 +60,7 @@ compile_platform("compile_dart2wasm_platform") { compile_platform("compile_dart2wasm_js_compatibility_platform") { single_root_scheme = "org-dartlang-sdk" - single_root_base = rebase_path("$sdk_root/") + single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" outputs = [ @@ -77,7 +77,7 @@ compile_platform("compile_dart2wasm_js_compatibility_platform") { compile_platform("compile_dart2wasm_standalone_platform") { single_root_scheme = "org-dartlang-sdk" - single_root_base = rebase_path("$sdk_root/") + single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" outputs = [ diff --git a/utils/ddc/BUILD.gn b/utils/ddc/BUILD.gn index a4367518243..12b99d3c600 100644 --- a/utils/ddc/BUILD.gn +++ b/utils/ddc/BUILD.gn @@ -409,7 +409,7 @@ ddc_compile("meta_canary_ddc_js") { compile_platform("ddc_platform") { single_root_scheme = "org-dartlang-sdk" - single_root_base = rebase_path("$sdk_root/") + single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" args = [