1# This file introduces a templates for calling write_vcsrevision.py. 2# 3# Parameters: 4# 5# header (required) [string] 6# 7# names (optional) [list of strings] 8# Writes "$foo_REVISION" and "$foo_REPOSITORY" for each foo in names. 9# Defaults to [ "LLVM" ] 10 11declare_args() { 12 # If this is set to true, VCSRevision.h is updated after every git commit. 13 # That's technically correct, but results in rebuilds after every commit. 14 # If it's false (default), VCSRevision.h will not contain a revision. 15 llvm_append_vc_rev = false 16} 17 18template("write_vcsrevision") { 19 assert(defined(invoker.header), "must set 'header' in $target_name") 20 21 action(target_name) { 22 script = "//llvm/utils/gn/build/write_vcsrevision.py" 23 header = invoker.header 24 if (defined(invoker.names)) { 25 names = invoker.names 26 } else { 27 names = [ "LLVM" ] 28 } 29 30 args = [ rebase_path(header, root_build_dir) ] 31 if (llvm_append_vc_rev) { 32 depfile = "$header.d" 33 args += [ 34 "--write-git-rev", 35 "-d", 36 rebase_path(depfile, root_build_dir), 37 ] 38 } 39 40 foreach(name, names) { 41 args += [ "--name=$name" ] 42 } 43 44 outputs = [ header ] 45 46 forward_variables_from(invoker, 47 [ 48 "public_configs", 49 "visibility", 50 ]) 51 } 52} 53