1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00
llvm-mirror/utils/gn/build/write_vcsrevision.gni
Nico Weber 02bc480b15 [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
2020-01-16 19:05:07 -05:00

53 lines
1.3 KiB
Plaintext

# This file introduces a templates for calling write_vcsrevision.py.
#
# Parameters:
#
# header (required) [string]
#
# names (optional) [list of strings]
# Writes "$foo_REVISION" and "$foo_REPOSITORY" for each foo in names.
# Defaults to [ "LLVM" ]
declare_args() {
# 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.
# If it's false (default), VCSRevision.h will not contain a revision.
llvm_append_vc_rev = false
}
template("write_vcsrevision") {
assert(defined(invoker.header), "must set 'header' in $target_name")
action(target_name) {
script = "//llvm/utils/gn/build/write_vcsrevision.py"
header = invoker.header
if (defined(invoker.names)) {
names = invoker.names
} else {
names = [ "LLVM" ]
}
args = [ rebase_path(header, root_build_dir) ]
if (llvm_append_vc_rev) {
depfile = "$header.d"
args += [
"--write-git-rev",
"-d",
rebase_path(depfile, root_build_dir),
]
}
foreach(name, names) {
args += [ "--name=$name" ]
}
outputs = [ header ]
forward_variables_from(invoker,
[
"public_configs",
"visibility",
])
}
}