[build] Remove the last absolute paths from RBE builds.
Extend --check-clean (enabled on bots) to verify build commands don't include absolute paths. The non-RBE GCC and MSVC builds still have absolute paths. GCC doesn't have -ffile-compilation-dir so it uses -fdebug-prefix-map, which is not fixable. The MSVC build has absolute path in the toolchain wrappers, which might be fixable. TEST=ci Change-Id: I3b984aaab7aefa7ff527f0a039ca42281224a09d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506505 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
bd304d04bc
commit
7d6c973ed9
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
+40
-7
@@ -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
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
+1
-1
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user