From 5986dc7eb718c206848ffaad0ab774b1dc1836cb Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Tue, 21 Feb 2023 17:01:02 +0100 Subject: 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 --- etc/defaults/CC/auto/TARGETS | 1 + 1 file changed, 1 insertion(+) create mode 100644 etc/defaults/CC/auto/TARGETS (limited to 'etc/defaults') diff --git a/etc/defaults/CC/auto/TARGETS b/etc/defaults/CC/auto/TARGETS new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/etc/defaults/CC/auto/TARGETS @@ -0,0 +1 @@ +{} -- cgit v1.2.3