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

Commitc9c2cd8

Browse files
authored
Toolchain config (#194)
Instead of having all configurations on the Target level, we have common parameters on the Toolchain level (which can be used by the corresponding targets).- TargetInfo now requires Toolchain- Some TargetConfig parameters are shifted to ToolchainConfig
1 parent2dedb35 commitc9c2cd8

File tree

42 files changed

+420
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+420
-313
lines changed

‎.github/workflows/msvc-analysis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
jobs:
2626
analyze:
2727
name:Analyze
28-
runs-on:windows-latest
28+
runs-on:windows-2019
2929

3030
steps:
3131
-name:Checkout repository

‎bootstrap/src/build_buildcc.cpp‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
6262

6363
// TOOLCHAIN
6464
target.GlobSources("lib/toolchain/src/api");
65+
target.GlobSources("lib/toolchain/src/common");
6566
target.AddIncludeDir("lib/toolchain/include");
6667
target.GlobHeaders("lib/toolchain/include/toolchain");
6768
target.GlobHeaders("lib/toolchain/include/toolchain/api");
69+
target.GlobHeaders("lib/toolchain/include/toolchain/common");
6870

6971
// TARGET
7072
target.GlobSources("lib/target/src/common");
@@ -205,33 +207,35 @@ void BuildBuildCC::Setup(const ArgToolchainState &state) {
205207

206208
// Flatbuffers HO lib
207209
auto &flatbuffers_ho_lib = storage_.Add<TargetInfo>(
208-
kFlatbuffersHoName,
210+
kFlatbuffersHoName, toolchain_,
209211
TargetEnv(env_.GetTargetRootDir() /"third_party" /"flatbuffers",
210212
env_.GetTargetBuildDir()));
211213
reg_.CallbackIf(state, flatbuffers_ho_cb, flatbuffers_ho_lib);
212214

213215
// CLI11 HO lib
214216
auto &cli11_ho_lib = storage_.Add<TargetInfo>(
215-
kCli11HoName,TargetEnv(env_.GetTargetRootDir() /"third_party" /"CLI11",
216-
env_.GetTargetBuildDir()));
217+
kCli11HoName, toolchain_,
218+
TargetEnv(env_.GetTargetRootDir() /"third_party" /"CLI11",
219+
env_.GetTargetBuildDir()));
217220
reg_.CallbackIf(state, cli11_ho_cb, cli11_ho_lib);
218221

219222
// fmt HO lib
220223
auto &fmt_ho_lib = storage_.Add<TargetInfo>(
221-
kFmtHoName,TargetEnv(env_.GetTargetRootDir() /"third_party" /"fmt",
222-
env_.GetTargetBuildDir()));
224+
kFmtHoName, toolchain_,
225+
TargetEnv(env_.GetTargetRootDir() /"third_party" /"fmt",
226+
env_.GetTargetBuildDir()));
223227
reg_.CallbackIf(state, fmt_ho_cb, fmt_ho_lib);
224228

225229
// spdlog HO lib
226230
auto &spdlog_ho_lib = storage_.Add<TargetInfo>(
227-
kSpdlogHoName,
231+
kSpdlogHoName, toolchain_,
228232
TargetEnv(env_.GetTargetRootDir() /"third_party" /"spdlog",
229233
env_.GetTargetBuildDir()));
230234
reg_.CallbackIf(state, spdlog_ho_cb, spdlog_ho_lib);
231235

232236
// taskflow HO lib
233237
auto &taskflow_ho_lib = storage_.Add<TargetInfo>(
234-
kTaskflowHoName,
238+
kTaskflowHoName, toolchain_,
235239
TargetEnv(env_.GetTargetRootDir() /"third_party" /"taskflow",
236240
env_.GetTargetBuildDir()));
237241
reg_.CallbackIf(state, taskflow_ho_cb, taskflow_ho_lib);

‎buildcc/lib/target/cmake/common_target_src.cmake‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ set(COMMON_TARGET_SRCS
77
src/common/target_state.cpp
88
include/target/common/target_config.h
99
include/target/common/target_state.h
10-
include/target/common/target_file_ext.h
1110
include/target/common/target_env.h
1211

1312
src/common/util.cpp

‎buildcc/lib/target/cmake/mock_target.cmake‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ target_link_options(mock_target PUBLIC ${TEST_LINK_FLAGS} ${BUILD_LINK_FLAGS})
2121
target_link_libraries(mock_targetPUBLIC
2222
Taskflow
2323

24-
mock_schema
2524
mock_toolchain
2625

2726
CppUTest

‎buildcc/lib/target/cmake/target.cmake‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ if(${BUILDCC_BUILD_AS_INTERFACE})
2828
$<INSTALL_INTERFACE:${BUILDCC_INSTALL_HEADER_PREFIX}>
2929
)
3030
target_link_libraries(targetPUBLIC
31-
schema
3231
toolchain
3332
Taskflow
3433
)

‎buildcc/lib/target/include/target/common/target_config.h‎

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -21,86 +21,20 @@
2121
#include<string>
2222
#include<unordered_set>
2323

24-
#include"target/common/target_file_ext.h"
25-
2624
namespacefs= std::filesystem;
2725

2826
namespacebuildcc {
2927

3028
structTargetConfig {
3129
TargetConfig() =default;
3230

33-
/**
34-
* @brief Get the valid file extension from a path
35-
*
36-
* See TargetConfig::valid_c_ext, TargetConfig::valid_cpp_ext,
37-
* TargetConfig::valid_asm_ext, TargetConfig::valid_header_ext
38-
*
39-
* @param filepath Absolute / Relative path of the file
40-
* @return TargetFileExt File path detected as per TargetConfig::valid_*
41-
* variables
42-
*/
43-
TargetFileExtGetFileExt(const fs::path &filepath)const;
44-
45-
/**
46-
* @brief Checks for C/C++ source file validity.
47-
*
48-
* See TargetConfig::valid_c_ext, TargetConfig::valid_cpp_ext,
49-
* TargetConfig::valid_asm_ext
50-
*
51-
* @param filepath Absolute / Relative path of file
52-
* @return true If file extension belongs to the above valid_* list
53-
* @return false If file extension does not belong to the above valid_* list
54-
*/
55-
boolIsValidSource(const fs::path &filepath)const;
56-
57-
/**
58-
* @brief Checks for Header file validity
59-
*
60-
* See TargetConfig::valid_header_ext
61-
*
62-
* @param filepath Absolute / Relative path of file
63-
* @return true If file extension belongs to above valid_* list
64-
* @return false If file extension does not belong to above valid_* list
65-
*/
66-
boolIsValidHeader(const fs::path &filepath)const;
67-
68-
/**
69-
* @brief Expects Source file validity
70-
*
71-
* env::assert_fatal if not a valid source
72-
*
73-
* @param filepath Absolute / Relative path of file
74-
*/
75-
voidExpectsValidSource(const fs::path &filepath)const;
76-
77-
/**
78-
* @brief Expects header file validity
79-
*
80-
* env::assert_fatal if not a valid header
81-
*
82-
* @param filepath Absolute / Relative path of file
83-
*/
84-
voidExpectsValidHeader(const fs::path &filepath)const;
85-
8631
std::string target_ext{""};
87-
std::string obj_ext{".o"};
88-
std::string pch_header_ext{".h"};
89-
std::string pch_compile_ext{".gch"};
90-
91-
std::string prefix_include_dir{"-I"};
92-
std::string prefix_lib_dir{"-L"};
9332

9433
// clang-format off
9534
std::string pch_command{"{compiler} {preprocessor_flags} {include_dirs} {common_compile_flags} {pch_compile_flags} {compile_flags} -o {output} -c {input}"};
9635
std::string compile_command{"{compiler} {preprocessor_flags} {include_dirs} {common_compile_flags} {pch_object_flags} {compile_flags} -o {output} -c {input}"};
9736
std::string link_command{"{cpp_compiler} {link_flags} {compiled_sources} -o {output} {lib_dirs} {lib_deps}"};
9837
// clang-format on
99-
100-
std::unordered_set<std::string> valid_c_ext{".c"};
101-
std::unordered_set<std::string> valid_cpp_ext{".cpp",".cxx",".cc"};
102-
std::unordered_set<std::string> valid_asm_ext{".s",".S",".asm"};
103-
std::unordered_set<std::string> valid_header_ext{".h",".hpp"};
10438
};
10539

10640
}// namespace buildcc

‎buildcc/lib/target/include/target/common/target_state.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef TARGET_COMMON_TARGET_STATE_H_
1818
#defineTARGET_COMMON_TARGET_STATE_H_
1919

20-
#include"target/common/target_file_ext.h"
20+
#include"toolchain/common/file_ext.h"
2121

2222
namespacebuildcc {
2323

@@ -27,7 +27,7 @@ namespace buildcc {
2727
// TargetInfo does not have a `Build` method, it is only meant to hold
2828
// information
2929
structTargetState {
30-
voidSetSourceState(TargetFileExt file_extension);
30+
voidSetSourceState(FileExt file_extension);
3131
voidSetPch();
3232
voidSetLock();
3333

‎buildcc/lib/target/include/target/target.h‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ class Target : public internal::BuilderInterface,
7070
const Toolchain &toolchain,const TargetEnv &env,
7171
const TargetConfig &config = TargetConfig())
7272
: TargetInfo(
73+
toolchain,
7374
TargetEnv(env.GetTargetRootDir(),
7475
env.GetTargetBuildDir() / toolchain.GetName() / name),
7576
config),
76-
name_(name), type_(type), toolchain_(toolchain),
77+
name_(name), type_(type),
78+
// toolchain_(toolchain),
7779
// loader_(name, env_.GetTargetBuildDir()),
7880
serialization_(env_.GetTargetBuildDir() / fmt::format("{}.bin", name)),
7981
compile_pch_(*this), compile_object_(*this), link_target_(*this) {
@@ -99,8 +101,8 @@ class Target : public internal::BuilderInterface,
99101
voidInitialize();
100102

101103
//
102-
std::optional<std::string>SelectCompileFlags(TargetFileExt ext)const;
103-
std::optional<std::string>SelectCompiler(TargetFileExt ext)const;
104+
std::optional<std::string>SelectCompileFlags(FileExt ext)const;
105+
std::optional<std::string>SelectCompiler(FileExt ext)const;
104106

105107
// Recompilation checks
106108
voidRecheckPaths(const internal::path_unordered_set &previous_path,
@@ -139,7 +141,7 @@ class Target : public internal::BuilderInterface,
139141
private:
140142
std::string name_;
141143
TargetType type_;
142-
const Toolchain &toolchain_;
144+
//const Toolchain &toolchain_;
143145
internal::TargetSerialization serialization_;
144146

145147
// Friend classes

‎buildcc/lib/target/include/target/target_info.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include<string>
2121

22+
#include"toolchain/toolchain.h"
23+
2224
#include"target/common/target_config.h"
2325
#include"target/common/target_env.h"
2426
#include"target/common/target_state.h"
@@ -60,8 +62,9 @@ class TargetInfo : public internal::SourceApi<TargetInfo>,
6062
public internal::SyncApi<TargetInfo>,
6163
public internal::TargetInfoGetter<TargetInfo> {
6264
public:
63-
TargetInfo(const TargetEnv &env,const TargetConfig &config = TargetConfig())
64-
: env_(env), config_(config) {}
65+
TargetInfo(const BaseToolchain &toolchain,const TargetEnv &env,
66+
const TargetConfig &config = TargetConfig())
67+
: toolchain_(toolchain), env_(env), config_(config) {}
6568

6669
private:
6770
// Inputs
@@ -79,6 +82,7 @@ class TargetInfo : public internal::SourceApi<TargetInfo>,
7982
friendclassinternal::TargetInfoGetter<TargetInfo>;
8083

8184
protected:
85+
const BaseToolchain &toolchain_;
8286
TargetEnv env_;
8387
TargetConfig config_;
8488

‎buildcc/lib/target/src/api/include_api.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void IncludeApi<T>::AddHeaderAbsolute(const fs::path &absolute_filepath) {
2525
T &t =static_cast<T &>(*this);
2626

2727
t.state_.ExpectsUnlock();
28-
t.config_.ExpectsValidHeader(absolute_filepath);
28+
t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);
2929
t.user_.headers.insert(absolute_filepath);
3030
}
3131

@@ -53,7 +53,7 @@ void IncludeApi<T>::GlobHeadersAbsolute(const fs::path &absolute_path) {
5353
T &t =static_cast<T &>(*this);
5454

5555
for (constauto &p :fs::directory_iterator(absolute_path)) {
56-
if (t.config_.IsValidHeader(p.path())) {
56+
if (t.toolchain_.GetConfig().IsValidHeader(p.path())) {
5757
AddHeaderAbsolute(p.path());
5858
}
5959
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp