mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[gn build] replace llvm_allow_tardy_revision with llvm_append_vc_rev
Previously, the gn build would create VCSRevision.h / VCSVersion.h files with some LLD_REVISION / LLVM_REVISION / CLANG_REVISION but by default wouldn't add a dependency on .git/logs/HEAD so that the step doesn't rerun after every branch switch or every pull. That's bad for deterministic builds, and having --version print some arbitrarily old revision isn't great either. Instead, move to the model that the cmake build (now) uses fairly consistently: If llvm_append_vc_rev is set, include the revision, else don't. Since the GN build is focused on developers, set llvm_append_vc_rev to false instead of true by default (different from the cmake build), so that things don't rebuild after every branch switch and every pull. While here, also remove some pre-monorepo code. Differential Revision: https://reviews.llvm.org/D72859
This commit is contained in:
parent
6be5d5bda8
commit
02bc480b15
@ -9,11 +9,10 @@
|
|||||||
# Defaults to [ "LLVM" ]
|
# Defaults to [ "LLVM" ]
|
||||||
|
|
||||||
declare_args() {
|
declare_args() {
|
||||||
# If this set to false, VCSRevision.h is updated after every git commit.
|
# If this is set to true, VCSRevision.h is updated after every git commit.
|
||||||
# That's technically correct, but results in rebuilds after every commit.
|
# That's technically correct, but results in rebuilds after every commit.
|
||||||
# If it's true (default), VCSRevision.h will usually be somewhat
|
# If it's false (default), VCSRevision.h will not contain a revision.
|
||||||
# out-of-date, but builds will be faster.
|
llvm_append_vc_rev = false
|
||||||
llvm_allow_tardy_revision = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template("write_vcsrevision") {
|
template("write_vcsrevision") {
|
||||||
@ -29,9 +28,10 @@ template("write_vcsrevision") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = [ rebase_path(header, root_build_dir) ]
|
args = [ rebase_path(header, root_build_dir) ]
|
||||||
if (!llvm_allow_tardy_revision) {
|
if (llvm_append_vc_rev) {
|
||||||
depfile = "$header.d"
|
depfile = "$header.d"
|
||||||
args += [
|
args += [
|
||||||
|
"--write-git-rev",
|
||||||
"-d",
|
"-d",
|
||||||
rebase_path(depfile, root_build_dir),
|
rebase_path(depfile, root_build_dir),
|
||||||
]
|
]
|
||||||
|
@ -29,40 +29,39 @@ def main():
|
|||||||
parser.add_argument('-d', '--depfile',
|
parser.add_argument('-d', '--depfile',
|
||||||
help='if set, writes a depfile that causes this script '
|
help='if set, writes a depfile that causes this script '
|
||||||
'to re-run each time the current revision changes')
|
'to re-run each time the current revision changes')
|
||||||
|
parser.add_argument('--write-git-rev', action='store_true',
|
||||||
|
help='if set, writes git revision, else writes #undef')
|
||||||
parser.add_argument('--name', action='append',
|
parser.add_argument('--name', action='append',
|
||||||
help='if set, writes a depfile that causes this script '
|
help='if set, writes a depfile that causes this script '
|
||||||
'to re-run each time the current revision changes')
|
'to re-run each time the current revision changes')
|
||||||
parser.add_argument('vcs_header', help='path to the output file to write')
|
parser.add_argument('vcs_header', help='path to the output file to write')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if os.path.isdir(os.path.join(LLVM_DIR, '.svn')):
|
|
||||||
print('SVN support not implemented', file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
if os.path.exists(os.path.join(LLVM_DIR, '.git')):
|
|
||||||
print('non-mono-repo git support not implemented', file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
git, use_shell = which('git'), False
|
|
||||||
if not git:
|
|
||||||
git = which('git.exe')
|
|
||||||
if not git:
|
|
||||||
git = which('git.bat')
|
|
||||||
use_shell = True
|
|
||||||
|
|
||||||
git_dir = subprocess.check_output([git, 'rev-parse', '--git-dir'],
|
|
||||||
cwd=LLVM_DIR, shell=use_shell).decode().strip()
|
|
||||||
if not os.path.isdir(git_dir):
|
|
||||||
print('.git dir not found at "%s"' % git_dir, file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
rev = subprocess.check_output([git, 'rev-parse', '--short', 'HEAD'],
|
|
||||||
cwd=git_dir, shell=use_shell).decode().strip()
|
|
||||||
url = subprocess.check_output([git, 'remote', 'get-url', 'origin'],
|
|
||||||
cwd=git_dir, shell=use_shell).decode().strip()
|
|
||||||
vcsrevision_contents = ''
|
vcsrevision_contents = ''
|
||||||
for name in args.name:
|
if args.write_git_rev:
|
||||||
vcsrevision_contents += '#define %s_REVISION "%s"\n' % (name, rev)
|
git, use_shell = which('git'), False
|
||||||
vcsrevision_contents += '#define %s_REPOSITORY "%s"\n' % (name, url)
|
if not git: git = which('git.exe')
|
||||||
|
if not git: git, use_shell = which('git.bat'), True
|
||||||
|
git_dir = subprocess.check_output(
|
||||||
|
[git, 'rev-parse', '--git-dir'],
|
||||||
|
cwd=LLVM_DIR, shell=use_shell).decode().strip()
|
||||||
|
if not os.path.isdir(git_dir):
|
||||||
|
print('.git dir not found at "%s"' % git_dir, file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
rev = subprocess.check_output(
|
||||||
|
[git, 'rev-parse', '--short', 'HEAD'],
|
||||||
|
cwd=git_dir, shell=use_shell).decode().strip()
|
||||||
|
url = subprocess.check_output(
|
||||||
|
[git, 'remote', 'get-url', 'origin'],
|
||||||
|
cwd=git_dir, shell=use_shell).decode().strip()
|
||||||
|
for name in args.name:
|
||||||
|
vcsrevision_contents += '#define %s_REVISION "%s"\n' % (name, rev)
|
||||||
|
vcsrevision_contents += '#define %s_REPOSITORY "%s"\n' % (name, url)
|
||||||
|
else:
|
||||||
|
for name in args.name:
|
||||||
|
vcsrevision_contents += '#undef %s_REVISION\n' % name
|
||||||
|
vcsrevision_contents += '#undef %s_REPOSITORY\n' % name
|
||||||
|
|
||||||
# If the output already exists and is identical to what we'd write,
|
# If the output already exists and is identical to what we'd write,
|
||||||
# return to not perturb the existing file's timestamp.
|
# return to not perturb the existing file's timestamp.
|
||||||
|
Loading…
Reference in New Issue
Block a user