cake
cake copied to clipboard
how to define macro in cake options?
just like this below: gcc -DUSE_** test.cpp -o test I want to define macro maybe like this: cake --macro=USE_,USE
I check cake source, and found the options supported only this:
`Usage: run.py [options]
Options: -h, --help Show this help message and exit. -v, --version Print the current version of Cake and exit. --args=FILE Path to the args.cake file to use. --config=FILE Path to the config.cake configuration file to use. --debug=KEYWORDS Set features to debug, eg: 'reason,run,script,scan,time'. -s, --silent, --quiet Suppress printing of all Cake messages, warnings and errors. -f, --force Force rebuild of every target. -jJOBCOUNT, --jobs=JOBCOUNT Number of simultaneous jobs to execute. -k, --keep-going Keep building even in the presence of errors. -eCOUNT, --max-errors=COUNT Halt the build after a certain number of errors. -l, --list-targets List named targets in specified build scripts. -p, --projects Create projects instead of building a variant. --clang-install-prefix=PATH Path where clang has been installed. --clang-executable=FILE Name or full-path of clang executable to compile with --libcxx-install-prefix=PATH Path where libc++ has been installed. Defaults to value of --clang-install-prefix --gcc-executable=FILE Name or full-path of g++ executable to compile with`
The typical way to specific a macro on the command line of the compiler is to use the CompilerTool.addDefine()
function.
For example, assuming the tool was configured to be called compiler
in the config.cake, then he following within a Cake script
compiler.addDefine('USE_NAME')
Alternatively, if the option should always apply to all source files for a given variant, then it can be provided in the config.cake
.
You can implement the --macro
argument for a given project, by registering it as a command line in the args.cake
and then handling the option in config.cake
so it passes the arguments to the compiler by using the function mentioned above.
I would recommend that you avoid providing macros that apply to all source files on the command line to Cake. The reason for this is is very wide reaching as it applies to all source files so it will cause everything to rebuild and would make it difficult to have a two builds the same (you would need to remember to use the same --macro
argument again.
If USE_X
only needs to be specific to a sub-set of translation units, it would be better to register an argument like --use
where you can provide a list of things to 'use' which then individual Cake scripts can check for the options it needs.
The typical way to specific a macro on the command line of the compiler is to use the
CompilerTool.addDefine()
function.For example, assuming the tool was configured to be called
compiler
in the config.cake, then he following within a Cake scriptcompiler.addDefine('USE_NAME')
Alternatively, if the option should always apply to all source files for a given variant, then it can be provided in the
config.cake
.You can implement the
--macro
argument for a given project, by registering it as a command line in theargs.cake
and then handling the option inconfig.cake
so it passes the arguments to the compiler by using the function mentioned above.I would recommend that you avoid providing macros that apply to all source files on the command line to Cake. The reason for this is is very wide reaching as it applies to all source files so it will cause everything to rebuild and would make it difficult to have a two builds the same (you would need to remember to use the same
--macro
argument again.If
USE_X
only needs to be specific to a sub-set of translation units, it would be better to register an argument like--use
where you can provide a list of things to 'use' which then individual Cake scripts can check for the options it needs.
thank you very much.