dart-sdk/sdk_args.gni
Jens Johansen a531b78369 [infra] Make worktrees work (again?)
History:

* Back in (pre June) 2018 worktrees in git just worked.
* https://dart-review.googlesource.com/c/sdk/+/48091 made it not work.
* https://github.com/dart-lang/sdk/issues/33619 was filed.
* https://dart-review.googlesource.com/c/sdk/+/127485 was created to
  work around the problem.

I don't know when it happened, but I can't make the above workaround
work (at least not anymore) --- adding a `default_git_folder` to my
`args.gn` has no effect.

This CL builds on it and automatically sets the correct path based on
a call to `git rev-parse --resolve-git-dir .git` which gives the
correct dir for both worktrees and non-worktrees.

Change-Id: I4dcf0445a44348621752fb88d4dab4c99c6ddd1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190522
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-03-16 08:54:15 +00:00

45 lines
1.8 KiB
Plaintext

# 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() {
# 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.
# The script run here should take care of everything automatically though.
default_git_folder = exec_script("$_dart_root/tools/get_dot_git_folder.py",
[ rebase_path("$_dart_root/.git") ],
"trim string")
# Whether to enable the SDK hash check that will prevent loading a kernel
# into a VM which was built with a different SDK.
verify_sdk_hash = true
}
# The SDK hash to build into VM and kernels.
# The value 0000000000 signifies no hash is set, which will disable the check.
if (verify_sdk_hash) {
sdk_hash = exec_script("$_dart_root/tools/make_version.py",
[ "--format={{GIT_HASH}}" ],
"trim string",
[
"$_dart_root/tools/VERSION",
"$_dart_root/tools/utils.py",
"$default_git_folder/logs/HEAD",
])
} else {
sdk_hash = "0000000000"
}