Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd3ea82

Browse files
authored
Api documentation for Args, Register and Supported Plugin (#185)
1 parent75cecc4 commitfd3ea82

File tree

9 files changed

+273
-32
lines changed

9 files changed

+273
-32
lines changed

‎.github/workflows/linux_gcc_cmake_build.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162

163163
-name:System Packages
164164
run:|
165-
sudo apt-get install ninja-build doxygen graphvizgcovrcppcheck clang-tidy
165+
sudo apt-get install ninja-build doxygen graphviz cppcheck clang-tidy
166166
167167
-name:Install LCOV
168168
run:|
@@ -179,7 +179,6 @@ jobs:
179179
clang --version
180180
ninja --version
181181
doxygen --version
182-
gcovr --version
183182
cppcheck --version
184183
clang-tidy --version
185184

‎TODO.md‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
#Versions
2+
3+
#0.1.1
4+
5+
Complete working proof of concept of the following
6+
7+
- BuildCC library
8+
- BuildCC bootstrap "script" files (Basic)
9+
- BuildExe executable (Standalone)
10+
11+
Contains the following working features
12+
13+
**BuildCC**
14+
- Supported plugin
15+
- Clang Compile Commands
16+
- Toolchain, Generator, TargetInfo and Target interfaces
17+
- Specialized Toolchain for GCC, MSVC and MINGW
18+
- Specialized Target for GCC, MSVC and MINGW
19+
20+
**BuildExe**
21+
- Immediate mode
22+
- Script mode
23+
- Local Package Manager with git
24+
25+
##0.1.2
26+
27+
- Serialization Interface
28+
- Namespace changes
29+
- Remove``buildcc::base``
30+
- Remove``buildcc::env``
31+
- We should only have 3 namespaces``buildcc``,``buildcc::plugin`` and``buildcc::internal``
32+
- Environment updates
33+
- Remove``buildcc::env``
34+
- Refactor free / static functions and variables into classes with static members and variables. For example.``buildcc::env::init`` should become``buildcc::Environment::Init``
35+
- Args and Register module updates
36+
- Pch command from command line
37+
- Make Register functions static.``Register::Build``
38+
- Update``CallbackIf``,``Build`` and``Test`` APIs for the``state`` variable usage
39+
- Unit testing and mocking for BuildExe
40+
41+
##0.1.3
42+
43+
- Make a common interface / internal library which contains all utility functions and libraries
44+
- New generators
45+
- Currently we only have a simple Generator which is similar to our FileIOGenerator (input -> subprocess commands -> outputs)
46+
- Read the``faq`` generators to make more varied and robust generators.
47+
48+
##0.1.4
49+
50+
- Config options updates as per Target requirements
51+
- Update configs to use``fmt::format`` with format specifiers for "{prefix}{value}{suffix}" for customizability. For example:`/D{preprocessor}` for msvc or`-D{preprocessor}` for gcc etc
52+
- Target specialized clang
53+
- Clang behaves differently depending on its backend
54+
- Option 1: Consider adding more options to``ToolchainId`` and different Clang specializations. For example:``Target_gcc_clang`` or``Target_msvc_clang`` or``Target_mingw_clang`` etc
55+
- Option 2: Consider making a``Target_clang`` that changes behaviour as per the``target_triple_architecture`` present in the``toolchain``
56+
- What other flavours of clang are present?
57+
58+
##0.2.x
59+
60+
-`Append*` APIs
61+
-`Add*WithFormat` or`Append*WithFormat` APIs
62+
63+
##Long Term goals
64+
65+
-[Discussion] Supported plugin requirements by users
66+
-[Discussion] Customizability requirements by users
67+
-[Discussion] Target and Generator interfaces for standardization by compilers. (White paper)
68+
-[Community Support] MacOS testing and CI/CD
169

270
#Feature
371

‎buildcc/lib/args/include/args/args.h‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ struct ArgToolchain {
5757
c_compiler(initial_c_compiler), cpp_compiler(initial_cpp_compiler),
5858
archiver(initial_archiver), linker(initial_linker) {}
5959

60+
/**
61+
* @brief Construct a BaseToolchain from the arguments supplied through the
62+
* command line information
63+
*/
6064
BaseToolchainConstructToolchain()const {
6165
BaseToolchaintoolchain(id, name, asm_compiler, c_compiler, cpp_compiler,
6266
archiver, linker);
@@ -88,10 +92,22 @@ class Args {
8892
Args() {Initialize(); }
8993
Args(const Args &) =delete;
9094

95+
/**
96+
* @brief Parse command line information to CLI11
97+
*
98+
* @param argc from int main(int argc, char ** argv)
99+
* @param argv from int main(int argc, char ** argv)
100+
*/
91101
voidParse(int argc,constchar *const *argv);
92102

93-
// TODO, Check if these are necessary
103+
/**
104+
* @brief Modifiable reference to CLI::App (CLI11)
105+
*/
94106
CLI::App &Ref() {return app_; }
107+
108+
/**
109+
* @brief Constant reference to CLI::App (CLI11)
110+
*/
95111
const CLI::App &ConstRef()const {return app_; }
96112

97113
// Setters
@@ -106,8 +122,14 @@ class Args {
106122
ArgToolchain &out,
107123
const ArgToolchain &initial = ArgToolchain());
108124

109-
// NOTE, Incomplete TargetArg
110-
// TODO, Update for pch_compile_command
125+
/**
126+
* @brief Add Target config commands with a unique name and description
127+
*
128+
* @param out Receive the target command information through the CLI
129+
* @param initial Set the default target command information as a fallback
130+
*
131+
* TODO, Update with other options for TargetConfig
132+
*/
111133
voidAddTarget(const std::string &name,const std::string &description,
112134
ArgTarget &out,const ArgTarget &initial = ArgTarget());
113135

‎buildcc/lib/args/include/args/register.h‎

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,20 @@ class Register {
4646
* Can be used to organize code into functional chunks
4747
*/
4848
template<typename C,typename... Params>
49-
voidCallback(const C &build_cb, Params &...params) {
50-
build_cb(std::forward<Params &>(params)...);
49+
voidCallback(const C &build_cb, Params &&...params) {
50+
build_cb(std::forward<Params>(params)...);
51+
}
52+
53+
/**
54+
* @brief Generic register callback that is run when `expression ==
55+
* true`
56+
* Can be used to add Toolchain-Target specific information
57+
*/
58+
template<typename C,typename... Params>
59+
voidCallbackIf(bool expression,const C &build_cb, Params &&...params) {
60+
if (expression) {
61+
Callback(build_cb, std::forward<Params>(params)...);
62+
}
5163
}
5264

5365
/**
@@ -57,35 +69,34 @@ class Register {
5769
*/
5870
template<typename C,typename... Params>
5971
voidCallbackIf(const ArgToolchainState &toolchain_state,const C &build_cb,
60-
Params &...params) {
61-
if (toolchain_state.build) {
62-
Callback(build_cb, std::forward<Params &>(params)...);
63-
}
72+
Params &&...params) {
73+
CallbackIf(toolchain_state.build, build_cb,
74+
std::forward<Params>(params)...);
6475
}
6576

6677
/**
6778
* @brief Register the Target to be built
6879
*/
6980
template<typename C,typename... Params>
7081
voidBuild(const ArgToolchainState &toolchain_state,const C &build_cb,
71-
base::Target &target, Params &...params) {
82+
BaseTarget &target, Params&&...params) {
7283
tf::Task task;
7384
CallbackIf(
7485
toolchain_state,
75-
[&](base::Target &ltarget, Params &...lparams) {
76-
build_cb(ltarget, std::forward<Params &>(lparams)...);
86+
[&](BaseTarget &ltarget, Params&&...lparams) {
87+
build_cb(ltarget, std::forward<Params>(lparams)...);
7788
task =BuildTargetTask(ltarget);
7889
},
79-
target, std::forward<Params &>(params)...);
90+
target, std::forward<Params>(params)...);
8091
BuildStoreTask(target.GetUniqueId(), task);
8192
}
8293

8394
/**
8495
* @brief Register the generator to be built
8596
*/
8697
template<typename C,typename... Params>
87-
voidBuild(const C &build_cb,base::Generator &generator, Params &...params) {
88-
build_cb(generator, std::forward<Params &>(params)...);
98+
voidBuild(const C &build_cb,BaseGenerator &generator, Params&&...params) {
99+
build_cb(generator, std::forward<Params>(params)...);
89100
tf::Task task =BuildGeneratorTask(generator);
90101
BuildStoreTask(generator.GetUniqueId(), task);
91102
}
@@ -102,12 +113,15 @@ class Register {
102113
/**
103114
* @brief Register the Target to be run
104115
* PreReq: Call `Register::Build` before calling `Register::Test`
105-
* PreReq: Requires toolchain_state.build && test to be true
116+
* PreReq: Requires ArgToolchainState::build && ArgToolchainState::test to be
117+
* true
106118
*
107-
* Target is added as the `{executable}` argument
119+
* Target is added as the `{executable}` argument.
120+
* We can add more fmt::format arguments using the TestConfig arguments
121+
* parameter
108122
*/
109123
voidTest(const ArgToolchainState &toolchain_state,
110-
const std::string &command,constbase::Target &target,
124+
const std::string &command,constBaseTarget &target,
111125
const TestConfig &config = TestConfig());
112126

113127
/**
@@ -135,8 +149,8 @@ class Register {
135149
voidEnv();
136150

137151
// BuildTasks
138-
tf::TaskBuildTargetTask(base::Target &target);
139-
tf::TaskBuildGeneratorTask(base::Generator &generator);
152+
tf::TaskBuildTargetTask(BaseTarget &target);
153+
tf::TaskBuildGeneratorTask(BaseGenerator &generator);
140154
voidBuildStoreTask(const std::string &unique_id,const tf::Task &task);
141155

142156
private:

‎buildcc/lib/args/include/args/register/test_info.h‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,21 @@ namespace buildcc {
2626

2727
structTestOutput {
2828
enumclassType {
29-
DefaultBehaviour,// Do not redirect to user or tests, default printed on
30-
// console
31-
TestPrintOnStderr,// Test only redirects stderr and prints
32-
TestPrintOnStdout,// Test only redirects stdout and prints
33-
TestPrintOnStderrAndStdout,// Test redirects both and prints
34-
UserRedirect,// Redirects to user
29+
DefaultBehaviour,///< Do not redirect to user or tests, default printed on
30+
///< console
31+
TestPrintOnStderr,///< Test only redirects stderr and prints
32+
TestPrintOnStdout,///< Test only redirects stdout and prints
33+
TestPrintOnStderrAndStdout,///< Test redirects both and prints
34+
UserRedirect,///< Redirects to user variables
3535
};
3636

37+
/**
38+
* @brief Configure your Register::Test to get test output
39+
*
40+
* @param output_type Select your output type (behaviour)
41+
* @param redirect_stdout User stdout redirection
42+
* @param redirect_stderr User stderr redirection
43+
*/
3744
TestOutput(Type output_type = Type::TestPrintOnStderrAndStdout,
3845
std::vector<std::string> *redirect_stdout =nullptr,
3946
std::vector<std::string> *redirect_stderr =nullptr)
@@ -56,6 +63,13 @@ struct TestOutput {
5663

5764
structTestConfig {
5865
public:
66+
/**
67+
* @brief Configure your Register::Test using TestConfig
68+
*
69+
* @param arguments fmt::format args passed to test commands
70+
* @param working_directory Working directory from which the test runs
71+
* @param output Output from tests
72+
*/
5973
TestConfig(
6074
const std::unordered_map<constchar *, std::string> &arguments = {},
6175
const std::optional<fs::path> &working_directory = {},
@@ -77,6 +91,8 @@ struct TestConfig {
7791
TestOutput output_;
7892
};
7993

94+
// PRIVATE
95+
8096
structTestInfo {
8197
TestInfo(const BaseTarget &target,const std::string &command,
8298
const TestConfig &config = TestConfig())

‎docs/source/user_api/args.rst‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,65 @@ Args
44
args.h
55
-------
66

7+
..doxygenclass::buildcc::Args
8+
:members: Args, Parse, Ref, ConstRef, AddToolchain, Clean, GetLogLevel, GetProjectRootDir, GetProjectBuildDir
9+
10+
..doxygenstruct::buildcc::ArgToolchainState
11+
12+
..doxygenstruct::buildcc::ArgToolchain
13+
14+
Example
15+
---------
16+
17+
..code-block::cpp
18+
:linenos:
19+
20+
int main(int argc, char ** argv) {
21+
Args args;
22+
ArgToolchain arg_gcc_toolchain;
23+
args.AddToolchain("gcc", "Generic GCC toolchain", arg_gcc_toolchain);
24+
25+
// TODO, Add ArgTarget example (Currently incomplete)
26+
args.Parse(argc, argv);
27+
28+
// Root
29+
args.GetProjectRootDir(); // Contains ``root_dir`` value
30+
args.GetProjectBuildDir(); // Contains ``build_dir`` value
31+
args.GetLogLevel(); // Contains ``loglevel`` enum
32+
args.Clean(); // Contains ``clean`` value
33+
34+
// Toolchain
35+
// .build, .test
36+
arg_gcc_toolchain.state;
37+
// .id, .name, .asm_compiler, .c_compiler, .cpp_compiler, .archiver, .linker -> BaseToolchain
38+
BaseToolchain gcc_toolchain = arg_gcc_toolchain.ConstructToolchain();
39+
40+
// Underlying CLI11 library
41+
auto & app = args.Ref();
42+
const auto & app = args.ConstRef();
43+
44+
return 0;
45+
}
46+
47+
..code-block::toml
48+
:linenos:
49+
50+
# Root
51+
root_dir = ""
52+
build_dir = "_build"
53+
loglevel = "trace"
54+
clean = true
55+
56+
# Toolchain
57+
[toolchain.gcc]
58+
build = true
59+
test = true
60+
61+
id = "gcc"
62+
name = "x86_64-linux-gnu"
63+
asm_compiler = "as"
64+
c_compiler = "gcc"
65+
cpp_compiler = "g++"
66+
archiver = "ar"
67+
linker = "ld"
68+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp