Args#
args.h#
-
class Args#
-
Public Static Functions
-
static void Deinit()#
-
static bool IsInit()#
-
static bool IsParsed()#
-
static bool Clean()#
-
static env::LogLevel GetLogLevel()#
-
static const fs::path &GetProjectRootDir()#
-
static const fs::path &GetProjectBuildDir()#
-
class Instance#
Public Functions
-
Instance &AddToolchain(const std::string &name, const std::string &description, ArgToolchain &out, const ArgToolchain &initial = ArgToolchain())#
Add toolchain with a unique name and description.
- Parameters
out – Receive the toolchain information through the CLI
initial – Set the default toolchain information as a fallback
-
Instance &AddTarget(const std::string &name, const std::string &description, ArgTarget &out, const ArgTarget &initial = ArgTarget())#
Add toolchain with a unique name and description.
- Parameters
out – Receive the toolchain information through the CLI
initial – Set the default toolchain information as a fallback
-
Instance &AddCustomCallback(const std::function<void(CLI::App&)> &add_cb)#
Custom callback for data.
- Parameters
add_cb – Add callback that exposes underlying CLI::App
-
Instance &AddCustomData(ArgCustom &data)#
Add custom data.
- Parameters
data – Derive from
buildcc::ArgCustom
and override theAdd
API
Public Static Functions
-
static void Parse(int argc, const char *const *argv)#
Parse command line information to CLI11.
- Parameters
argc – from int main(int argc, char ** argv)
argv – from int main(int argc, char ** argv)
-
Instance &AddToolchain(const std::string &name, const std::string &description, ArgToolchain &out, const ArgToolchain &initial = ArgToolchain())#
-
struct Internal#
-
static void Deinit()#
-
struct ArgToolchainState#
Toolchain State used to selectively build and test targets.
Public Functions
-
inline ArgToolchainState(bool b = false, bool t = false)#
-
inline ArgToolchainState(bool b = false, bool t = false)#
-
class ArgToolchain#
Toolchain Arg used to receive toolchain information through the command line Bundled with Toolchain State.
Public Functions
-
inline ArgToolchain()#
-
inline ArgToolchain(ToolchainId initial_id, const std::string &initial_name, const ToolchainExecutables &initial_executables, const ToolchainConfig &initial_config)#
Public Members
-
ArgToolchainState state#
-
ToolchainId id#
-
std::string name#
-
ToolchainExecutables executables#
-
ToolchainConfig config#
-
inline ArgToolchain()#
-
struct ArgTarget#
Example#
1using namespace buildcc;
2
3struct CustomData : ArgCustom {
4 void Add(CLI::App & app) override {
5 // setup your app from data1, data2, data3, data...
6 // NOTE: The Add method should not be invoked by the user
7 // NOTE: The Add method is only expected to be invoked once, not multiple times.
8 }
9
10 std::string data1;
11 int data2;
12 float data3;
13 // etc
14};
15
16int main(int argc, char ** argv) {
17 ArgToolchain arg_gcc_toolchain;
18 ArgCustomData custom_data;
19 Args::Init()
20 .AddToolchain("gcc", "Generic GCC toolchain", arg_gcc_toolchain)
21 .AddCustomCallback([](CLI::App &app) {});
22 .AddCustomData(custom_data);
23 .Parse(argc, argv);
24
25 // Root
26 Args::GetProjectRootDir(); // Contains ``root_dir`` value
27 Args::GetProjectBuildDir(); // Contains ``build_dir`` value
28 Args::GetLogLevel(); // Contains ``loglevel`` enum
29 Args::Clean(); // Contains ``clean`` value
30
31 // Toolchain
32 // .build, .test
33 arg_gcc_toolchain.state;
34 // .id, .name, .asm_compiler, .c_compiler, .cpp_compiler, .archiver, .linker -> BaseToolchain
35 auto &gcc_toolchain = arg_gcc_toolchain;
36 gcc_toolchain.SetToolchainInfoFunc(GlobalToolchainInfo::Get(gcc_toolchain.id));
37 return 0;
38}
1# Root
2root_dir = ""
3build_dir = "_build"
4loglevel = "trace"
5clean = true
6
7# Toolchain
8[toolchain.gcc]
9build = true
10test = true
11
12id = "gcc"
13name = "x86_64-linux-gnu"
14asm_compiler = "as"
15c_compiler = "gcc"
16cpp_compiler = "g++"
17archiver = "ar"
18linker = "ld"