Template Generator#
> TODO,
File Generator#
> TODO
Custom Generator#
custom_generator.h#
-
class CustomGenerator : public buildcc::internal::BuilderInterface#
Subclassed by buildcc::FileGenerator, buildcc::TemplateGenerator
Public Functions
-
virtual ~CustomGenerator() = default#
-
CustomGenerator(const CustomGenerator&) = delete#
-
void AddPattern(const std::string &identifier, const std::string &pattern)#
-
void AddPatterns(const std::unordered_map<std::string, std::string> &pattern_map)#
-
std::string ParsePattern(const std::string &pattern, const std::unordered_map<const char*, std::string> &arguments = {}) const#
Single Generator task for inputs->generate_cb->outputs.
- Parameters
id – Unique id associated with Generator task
inputs – File inputs
outputs – File outputs
generate_cb – User-defined generate callback to build outputs from the provided inputs
-
virtual void Build() override#
-
inline const std::string &GetName() const#
-
inline const fs::path &GetBinaryPath() const#
-
inline const fs::path &GetRootDir() const#
-
inline const fs::path &GetBuildDir() const#
-
const std::string &Get(const std::string &file_identifier) const#
-
virtual ~CustomGenerator() = default#
Example#
> TODO, Update example
1// Example Setup
2TargetEnv gen_env("gen_root", "gen_build");
3bool parallel{true};
4BaseGenerator generator("unique_name", gen_env, parallel);
5// Adds absolute {gen_root_dir} and {gen_build_dir} paths to internal fmt::format
6
7// We can now do this
8// {gen_root_dir}/my_generator.py -> {my_generator}
9generator.AddInput("{gen_root_dir}/my_generator.py", "my_generator");
10
11// {gen_build_dir}/my_generator.h -> {generated_header}
12// {gen_build_dir}/my_generator.cpp -> {generated_source}
13generator.AddOutput("{gen_build_dir}/generated.h", "generated_header");
14generator.AddOutput("{gen_build_dir}/generated.cpp", "generated_source");
15
16// Example Commands
17// NOTE: If `parallel==true`, both of these commands runs in parallel
18// NOTE: If `parallel==false`, commands will run in the order that they are added.
19generator.AddCommand("{my_generator} --generate header {generated_header}");
20generator.AddCommand("{my_generator} --generate source {generated_source}");
21
22// Setup the tasks
23generator.Build();
24
25// Run the generator
26tf::Executor executor;
27executor.run(generator.GetTaskflow());
28executor.wait_for_all();