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 | 4cb044433c177868d7e35957f76ce29fa9aaeb47 (patch) | |
tree | 43622dc86a2f7bff8972a44b033c87c80993c809 /etc/json-format.py | |
parent | 3b08fc29eff1fa61c3fd317ca5321d47cddd9c69 (diff) | |
download | rules-cc-4cb044433c177868d7e35957f76ce29fa9aaeb47.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 'etc/json-format.py')
0 files changed, 0 insertions, 0 deletions