MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ main()

int main ( int argc,
const char ** argv )

Definition at line 233 of file MayaFluxSignatures.cpp.

234{
235 llvm::cl::OptionCategory category("mayaflux-signatures options");
236 llvm::cl::opt<std::string> root("root",
237 llvm::cl::desc("Repository root holding src/"),
238 llvm::cl::value_desc("dir"), llvm::cl::init("."), llvm::cl::cat(category));
239 llvm::cl::opt<std::string> registry("registry",
240 llvm::cl::desc("Registry header (default: <root>/src/MayaFlux/API/Proxy/Registry.hpp)"),
241 llvm::cl::value_desc("file"), llvm::cl::cat(category));
242 llvm::cl::opt<std::string> output("output",
243 llvm::cl::desc("Directory the generated files are written to (default: <root>/src/MayaFlux/API/Proxy/Generated)"),
244 llvm::cl::value_desc("dir"), llvm::cl::cat(category));
245 llvm::cl::opt<std::string> build_path("p",
246 llvm::cl::desc("Directory holding compile_commands.json"),
247 llvm::cl::value_desc("dir"), llvm::cl::init("build"), llvm::cl::cat(category));
248 llvm::cl::opt<std::string> translation_unit("translation-unit",
249 llvm::cl::desc("Source file whose compile command is borrowed (default: <root>/src/MayaFlux/API/Proxy/Creator.cpp)"),
250 llvm::cl::value_desc("file"), llvm::cl::cat(category));
251 llvm::cl::opt<std::string> resource_dir("resource-dir",
252 llvm::cl::desc("Clang resource directory holding the builtin headers"),
253 llvm::cl::value_desc("dir"), llvm::cl::init(MAYAFLUX_REFLECT_RESOURCE_DIR),
254 llvm::cl::cat(category));
255 llvm::cl::list<std::string> extra_args("extra-arg",
256 llvm::cl::desc("Extra Clang argument added to the scan"),
257 llvm::cl::value_desc("argument"), llvm::cl::cat(category));
258 llvm::cl::opt<bool> check("check",
259 llvm::cl::desc("Write nothing; exit 1 when a generated file is out of date"),
260 llvm::cl::cat(category));
261 llvm::cl::opt<bool> functions("functions",
262 llvm::cl::desc("Write a Name.signatures.hpp sidecar beside each header that holds MF_DESCRIBE_FUNCTION "
263 "requests, instead of the Creator methods. A header with requests must not use its own sidecar"),
264 llvm::cl::cat(category));
265 llvm::cl::opt<bool> no_insert_include("no-insert-include",
266 llvm::cl::desc("With --functions, report a missing sidecar include instead of inserting it"),
267 llvm::cl::cat(category));
268 llvm::cl::opt<bool> build("build",
269 llvm::cl::desc("Build step: write the Creator files and mark them modified, or with --functions the "
270 "sidecar of the one header given, inserting its include when missing. Needs "
271 "--translation-unit (defaulted) with a compile database, or --compile-arg"),
272 llvm::cl::cat(category));
273 llvm::cl::list<std::string> compile_args("compile-arg",
274 llvm::cl::desc("With --build: one argument of the whole compile command, used instead of the database"),
275 llvm::cl::value_desc("argument"), llvm::cl::cat(category));
276 llvm::cl::opt<std::string> depfile("depfile",
277 llvm::cl::desc("With --build: write a depfile of the registry and the headers the scan read"),
278 llvm::cl::value_desc("file"), llvm::cl::cat(category));
279 llvm::cl::opt<std::string> depfile_target("depfile-target",
280 llvm::cl::desc("With --build: the target named in the depfile (default: CreatorIncludes.hpp in the output)"),
281 llvm::cl::value_desc("path"), llvm::cl::cat(category));
282 llvm::cl::list<std::string> paths(llvm::cl::Positional,
283 llvm::cl::desc("<path>... (with --functions: headers or directories searched, default src/MayaFlux)"),
284 llvm::cl::cat(category));
285
286 llvm::cl::HideUnrelatedOptions(category);
287 llvm::cl::ParseCommandLineOptions(argc, argv,
288 "Writes the Creator proxy's methods from the public constructors of the registered classes, or with "
289 "--functions the parameter names of the functions named by MF_DESCRIBE_FUNCTION.\n");
290
291 Config config;
292 config.root = root.getValue();
293 const std::filesystem::path proxy = config.root / "src/MayaFlux/API/Proxy";
294 config.registry = registry.empty() ? proxy / "Registry.hpp" : std::filesystem::path(registry.getValue());
295 config.output = output.empty() ? proxy / "Generated" : std::filesystem::path(output.getValue());
296 config.build_path = build_path.getValue();
297 config.translation_unit = translation_unit.empty() ? proxy / "Creator.cpp" : std::filesystem::path(translation_unit.getValue());
298 config.resource_dir = resource_dir.getValue();
299 config.extra_args.assign(extra_args.begin(), extra_args.end());
300 config.check = check;
301 config.functions = functions;
302 config.insert_includes = !no_insert_include;
303 config.paths.assign(paths.begin(), paths.end());
304
305 if (build && config.functions) {
306 if (config.check || config.paths.size() != 1) {
307 return fail("--functions --build takes exactly one header, and no --check");
308 }
309 FunctionBuildOptions options;
310 options.header = config.paths.front();
311 options.build_path = config.build_path;
312 options.translation_unit = config.translation_unit;
313 options.resource_dir = config.resource_dir;
314 options.extra_args = config.extra_args;
315 options.compile_args.assign(compile_args.begin(), compile_args.end());
316 options.depfile = depfile.getValue();
317 options.depfile_target = depfile_target.getValue();
318 options.insert_includes = config.insert_includes;
319 return run_function_build(options);
320 }
321
322 if (build) {
323 if (config.check || !config.paths.empty()) {
324 return fail("--build writes the Creator files; it takes no --check or paths");
325 }
326 CreatorBuildOptions options;
327 options.root = config.root;
328 options.registry = config.registry;
329 options.output = config.output;
330 options.build_path = config.build_path;
331 options.translation_unit = config.translation_unit;
332 options.resource_dir = config.resource_dir;
333 options.extra_args = config.extra_args;
334 options.compile_args.assign(compile_args.begin(), compile_args.end());
335 options.depfile = depfile.getValue();
336 options.depfile_target = depfile_target.getValue();
337 return run_creator_build(options);
338 }
339
340 return config.functions ? generate_functions(config) : generate(config);
341}
#define MAYAFLUX_REFLECT_RESOURCE_DIR
int run_creator_build(const CreatorBuildOptions &options)
Writes the four Creator files, for a build step.
int run_function_build(const FunctionBuildOptions &options)
Writes the function sidecar of one header, for a build step.
What mayaflux_signatures --build needs to write the Creator files.
What mayaflux_signatures --functions --build needs to describe the functions of one header.

References MayaFlux::Reflect::Tool::CreatorBuildOptions::build_path, MayaFlux::Reflect::Tool::FunctionBuildOptions::build_path, MayaFlux::Reflect::Tool::CreatorBuildOptions::compile_args, MayaFlux::Reflect::Tool::FunctionBuildOptions::compile_args, MayaFlux::Reflect::Tool::CreatorBuildOptions::depfile, MayaFlux::Reflect::Tool::FunctionBuildOptions::depfile, MayaFlux::Reflect::Tool::CreatorBuildOptions::depfile_target, MayaFlux::Reflect::Tool::FunctionBuildOptions::depfile_target, MayaFlux::Reflect::Tool::CreatorBuildOptions::extra_args, MayaFlux::Reflect::Tool::FunctionBuildOptions::extra_args, MayaFlux::Reflect::Tool::FunctionBuildOptions::header, MayaFlux::Reflect::Tool::FunctionBuildOptions::insert_includes, MAYAFLUX_REFLECT_RESOURCE_DIR, MayaFlux::Reflect::Tool::CreatorBuildOptions::output, MayaFlux::Reflect::Tool::CreatorBuildOptions::registry, MayaFlux::Reflect::Tool::CreatorBuildOptions::resource_dir, MayaFlux::Reflect::Tool::FunctionBuildOptions::resource_dir, MayaFlux::Reflect::Tool::CreatorBuildOptions::root, MayaFlux::Reflect::Tool::run_creator_build(), MayaFlux::Reflect::Tool::run_function_build(), MayaFlux::Reflect::Tool::CreatorBuildOptions::translation_unit, and MayaFlux::Reflect::Tool::FunctionBuildOptions::translation_unit.

Here is the call graph for this function: