Reland "[build] Use an absolute path for the snapshot"

When constructing the command line for creating the kernel service
snapshot, the variable `abs_output` actually contains a relative
path, which means that copy/pasting the generated command line fails
if not within the root build directory. This CL fixes that.

Previous revert: https://dart-review.googlesource.com/c/sdk/+/200940

Passes `--depfile-output-filename` with the path relative to the output
folder so that the written depfiles do not contain the absolute file
paths.

ninja only accepts paths relative to the build folder in the .d files.

Manually tested that the dependencies now work with running the
build twice:
`tools/build.py --no-start-goma -mrelease create_platform_sdk`

Inspecting the .d file in question that caused the revert:
`cat out/ReleaseX64/gen/kernel-service.dart.snapshot.d`

TEST=SDK build

Change-Id: Id781d2ed94ad7a0041e5899b8fded598de81242b
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200876
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Daco Harkes 2021-05-21 11:52:02 +00:00 committed by commit-bot@chromium.org
parent 4d5055805f
commit 35223586a3
2 changed files with 6 additions and 4 deletions

View file

@ -109,10 +109,10 @@ static void WriteDepsFile(Dart_Isolate isolate) {
Options::depfile());
}
bool success = true;
if (Options::snapshot_filename() != NULL) {
success &= file->Print("%s: ", Options::snapshot_filename());
} else {
if (Options::depfile_output_filename() != NULL) {
success &= file->Print("%s: ", Options::depfile_output_filename());
} else {
success &= file->Print("%s: ", Options::snapshot_filename());
}
if (kernel_isolate_is_running) {
Dart_KernelCompilationResult result = Dart_KernelListDependencies();

View file

@ -145,13 +145,15 @@ template("_application_snapshot") {
dfe = "$_dart_root/pkg/vm/bin/kernel_service.dart"
abs_depfile = rebase_path(depfile)
abs_output = rebase_path(output, root_build_dir)
abs_output = rebase_path(output)
rel_output = rebase_path(output, root_build_dir)
vm_args = [
"--deterministic",
"--packages=$dot_packages",
"--snapshot=$abs_output",
"--snapshot-depfile=$abs_depfile",
"--depfile-output-filename=$rel_output",
] + snapshot_vm_args
if (dart_snapshot_kind == "kernel") {