diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index 1932df82beb..481fabdc09b 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -2,6 +2,7 @@ # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. +import("../sdk_args.gni") import("configs.gni") import("runtime_args.gni") @@ -257,7 +258,7 @@ action("generate_version_cc_file") { "vm/version_in.cc", ] if (dart_version_git_info) { - inputs += [ "../.git/logs/HEAD" ] + inputs += [ "$default_git_folder/logs/HEAD" ] } output = "$target_gen_dir/version.cc" outputs = [ diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 636abf8cb99..d296c28232a 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -15,6 +15,7 @@ import("../build/dart/copy_tree.gni") import("../runtime/runtime_args.gni") +import("../sdk_args.gni") declare_args() { # Build a SDK with less stuff. It excludes dart2js, ddc, and web libraries. @@ -861,7 +862,7 @@ action("write_version_file") { visibility = [ ":create_common_sdk" ] inputs = [ "../tools/VERSION", - "../.git/logs/HEAD", + "$default_git_folder/logs/HEAD", ] output = "$root_out_dir/dart-sdk/version" outputs = [ @@ -878,7 +879,7 @@ action("write_version_file") { action("write_revision_file") { visibility = [ ":create_common_sdk" ] inputs = [ - "../.git/logs/HEAD", + "$default_git_folder/logs/HEAD", ] output = "$root_out_dir/dart-sdk/revision" outputs = [ @@ -937,7 +938,7 @@ copy("copy_license") { action("write_dartdoc_options") { visibility = [ ":create_common_sdk" ] inputs = [ - "../.git/logs/HEAD", + "$default_git_folder/logs/HEAD", ] output = "$root_out_dir/dart-sdk/dartdoc_options.yaml" outputs = [ diff --git a/sdk_args.gni b/sdk_args.gni index 0a66f18a8e6..7ebca48dc38 100644 --- a/sdk_args.gni +++ b/sdk_args.gni @@ -1,5 +1,26 @@ +# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +_dart_root = get_path_info(".", "abspath") + declare_args() { # Whether to use the NNBD fork of the SDK core libraries. # TODO(#38701): Remove this when the fork has been merged back in. use_nnbd = false + + # Absolute path to the .git folder. + # + # This is used in rules that need to refer to `.git/logs/HEAD` to include + # a hash in the version string. By default the folder is `.git`, but we define + # it as an argument so it can be overriden by users of `git-worktree` (See + # Issue #33619). + # + # When using git-worktree, you can add + # + # default_git_folder = "/path/to/main/git/repo/.git/worktrees/name/" + # + # to out/ReleaseX64/args.gn. The path above can be extracted from the `.git` + # file under the git worktree folder. + default_git_folder = "$_dart_root/.git" } diff --git a/sdk_nnbd/BUILD.gn b/sdk_nnbd/BUILD.gn index 636abf8cb99..d296c28232a 100644 --- a/sdk_nnbd/BUILD.gn +++ b/sdk_nnbd/BUILD.gn @@ -15,6 +15,7 @@ import("../build/dart/copy_tree.gni") import("../runtime/runtime_args.gni") +import("../sdk_args.gni") declare_args() { # Build a SDK with less stuff. It excludes dart2js, ddc, and web libraries. @@ -861,7 +862,7 @@ action("write_version_file") { visibility = [ ":create_common_sdk" ] inputs = [ "../tools/VERSION", - "../.git/logs/HEAD", + "$default_git_folder/logs/HEAD", ] output = "$root_out_dir/dart-sdk/version" outputs = [ @@ -878,7 +879,7 @@ action("write_version_file") { action("write_revision_file") { visibility = [ ":create_common_sdk" ] inputs = [ - "../.git/logs/HEAD", + "$default_git_folder/logs/HEAD", ] output = "$root_out_dir/dart-sdk/revision" outputs = [ @@ -937,7 +938,7 @@ copy("copy_license") { action("write_dartdoc_options") { visibility = [ ":create_common_sdk" ] inputs = [ - "../.git/logs/HEAD", + "$default_git_folder/logs/HEAD", ] output = "$root_out_dir/dart-sdk/dartdoc_options.yaml" outputs = [