1# This file introduces a templates for calling write_cmake_config.py. 2# 3# write_cmake_config behaves like CMake's configure_file(), but runs at build 4# time, not at generator time. See write_cmake_config.py for details. 5# 6# Parameters: 7# 8# input (required) [string] 9# 10# output (required) [string] 11# 12# values (required) [list of strings] 13# Each entry is a '='-separated key-value pair used for substitution. 14# 15# Example use: 16# 17# write_cmake_config("attributes_compat_func_gen") { 18# input = "Version.inc.in" 19# output = "$root_gen_dir/clang/include/clang/Basic/Version.inc", 20# values = [ 21# "CLANG_VERSION=$llvm_version", 22# ] 23# } 24 25template("write_cmake_config") { 26 assert(defined(invoker.input), "must set 'input' in $target_name") 27 assert(defined(invoker.output), "must set 'output' in $target_name") 28 assert(defined(invoker.values), "must set 'values' in $target_name") 29 30 action(target_name) { 31 script = "//llvm/utils/gn/build/write_cmake_config.py" 32 33 sources = [ invoker.input ] 34 outputs = [ invoker.output ] 35 args = [ 36 "-o", 37 rebase_path(outputs[0], root_build_dir), 38 rebase_path(sources[0], root_build_dir), 39 ] + invoker.values 40 41 forward_variables_from(invoker, 42 [ 43 "configs", 44 "deps", 45 "public_configs", 46 "public_deps", 47 "visibility", 48 ]) 49 } 50} 51