diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2023-02-21 17:01:02 +0100 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2023-03-15 14:36:44 +0100 |
commit | 5986dc7eb718c206848ffaad0ab774b1dc1836cb (patch) | |
tree | 01bc6fc1cf5b54b2185c70529735e92bbc283f9d /test/buildtool/crypto/hash_function.test.cpp | |
parent | 838bdc8729429083f1f6e6efb4c5b80a166569d3 (diff) | |
download | justbuild-5986dc7eb718c206848ffaad0ab774b1dc1836cb.tar.gz |
rules: CC/auto: add "config_file" rule to generate a c/c++ header...
...starting from a template (aka configuration file), and using the
variables defined via a ["CC/auto", "config"] target.
For example, to use a CMake configuration file, the targets could be
defined as follows
...
, "foo-header-blueprint":
{ "type": ["@", "rules", "CC/auto", "config_file"]
, "input": ["config.hpp.in"]
, "output": ["config.hpp"]
, "stage": ["foo"]
, "magic_string": ["cmakedefine"]
, "@only": ["true"]
}
, "foo-header":
{ "type": "configure"
, "target": "foo-header-blueprint"
, "config":
{ "type": "let*"
, "bindings":
[ [ "defines"
, [ ["var", "\"string value\""]
, ["FOO_MAJOR_VERSION", "3"]
, ["use_this_feature", true]
]
]
]
, "body": {"type": "env", "vars": ["defines"]}
}
}
...
The file config.hpp.in may look as follows
#ifndef config_cmake
#define config_cmake
#cmakedefine var
#cmakedefine use_this_feature
#cmakedefine01 use_this_feature
#cmakedefine unused
#define FOO_VERSION @FOO_MAJOR_VERSION@
#define DONT_TOUCH_THIS ${FOO_MAJOR_VERSION}
#endif
and the generated configuration file foo/config.hpp is
#ifndef config_cmake
#define config_cmake
#define var "string value"
#define use_this_feature
#define use_this_feature 1
/* #undef unused */
#define FOO_VERSION 3
#define DONT_TOUCH_THIS ${FOO_MAJOR_VERSION}
#endif
Diffstat (limited to 'test/buildtool/crypto/hash_function.test.cpp')
0 files changed, 0 insertions, 0 deletions