[lit] Improve lit.Run class
[llvm-complete.git] / utils / gn / build / write_cmake_config.gni
blob6dca02608e157c9912a23f3b26ebb9311259d76e
1 # This file introduces a templates for calling write_cmake_config.py.
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.
6 # Parameters:
8 #   input (required) [string]
10 #   output (required) [string]
12 #   values (required) [list of strings]
13 #       Each entry is a '='-separated key-value pair used for substitution.
15 # Example use:
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 #   }
25 template("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")
30   action(target_name) {
31     script = "//llvm/utils/gn/build/write_cmake_config.py"
33     sources = [
34       invoker.input,
35     ]
36     outputs = [
37       invoker.output,
38     ]
39     args = [
40              "-o",
41              rebase_path(outputs[0], root_build_dir),
42              rebase_path(sources[0], root_build_dir),
43            ] + invoker.values
45     forward_variables_from(invoker,
46                            [
47                              "configs",
48                              "deps",
49                              "public_configs",
50                              "public_deps",
51                              "visibility",
52                            ])
53   }