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

Commit4d9a71e

Browse files
authored
[Cleanup] Builder Interface (#218)
1 parent15f2908 commit4d9a71e

File tree

7 files changed

+20
-23
lines changed

7 files changed

+20
-23
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ class Reg::Instance {
8585

8686
template<typename C,typename T,typename... Params>
8787
voidBuild(const C &build_cb, T &builder, Params &&...params) {
88-
constexprbool is_supported_base = std::is_base_of_v<CustomGenerator, T> ||
89-
std::is_base_of_v<BaseTarget, T>;
90-
static_assert(
91-
is_supported_base,
92-
"Build only supports BaseTarget, CustomGenerator and derivatives");
88+
constexprbool is_supported_base =
89+
std::is_base_of_v<internal::BuilderInterface, T>;
90+
static_assert(is_supported_base,
91+
"Build only supports Generator, Target and derivatives");
9392

9493
build_cb(builder, std::forward<Params>(params)...);
9594
tf::Task task =BuildTask(builder);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ template <typename T> class TargetGetter {
7474
// TODO, Add GetPchCommand if required
7575
const std::string &GetCompileCommand(const fs::path &source)const;
7676
const std::string &GetLinkCommand()const;
77-
78-
tf::Taskflow &GetTaskflow();
7977
};
8078

8179
};// namespace buildcc::internal

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include<unordered_map>
2323
#include<vector>
2424

25-
#include"taskflow/taskflow.hpp"
26-
2725
#include"env/command.h"
2826
#include"env/task_state.h"
2927

@@ -125,6 +123,11 @@ class CustomGenerator : public internal::BuilderInterface {
125123
void
126124
AddPatterns(const std::unordered_map<std::string, std::string> &pattern_map);
127125

126+
// TODO, Doc
127+
std::stringParsePattern(const std::string &pattern,
128+
const std::unordered_map<constchar *, std::string>
129+
&arguments = {})const;
130+
128131
/**
129132
* @brief Single Generator task for inputs->generate_cb->outputs
130133
*
@@ -140,6 +143,7 @@ class CustomGenerator : public internal::BuilderInterface {
140143
const GenerateCb &generate_cb,
141144
std::shared_ptr<CustomBlobHandler> blob_handler =nullptr);
142145

146+
// TODO, Doc
143147
voidAddGroup(const std::string &group_id,
144148
std::initializer_list<std::string> ids,
145149
const DependencyCb &dependency_cb = DependencyCb());
@@ -170,7 +174,6 @@ class CustomGenerator : public internal::BuilderInterface {
170174
}
171175
const fs::path &GetRootDir()const {return env_.GetTargetRootDir(); }
172176
const fs::path &GetBuildDir()const {return env_.GetTargetBuildDir(); }
173-
tf::Taskflow &GetTaskflow() {return tf_; }
174177
const std::string &Get(const std::string &file_identifier)const;
175178

176179
private:
@@ -193,11 +196,6 @@ class CustomGenerator : public internal::BuilderInterface {
193196
voidIdUpdated();
194197

195198
protected:
196-
std::stringParsePattern(const std::string &pattern,
197-
const std::unordered_map<constchar *, std::string>
198-
&arguments = {})const {
199-
return command_.Construct(pattern, arguments);
200-
}
201199
const env::Command &ConstCommand()const {return command_; }
202200
env::Command &RefCommand() {return command_; }
203201

@@ -239,7 +237,6 @@ class CustomGenerator : public internal::BuilderInterface {
239237

240238
// Internal
241239
env::Command command_;
242-
tf::Taskflow tf_;
243240

244241
// Callbacks
245242
DependencyCb dependency_cb_;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include<functional>
2222
#include<unordered_set>
2323

24+
#include"taskflow/taskflow.hpp"
25+
2426
#include"env/assert_fatal.h"
2527

2628
#include"target/common/util.h"
@@ -98,6 +100,7 @@ class BuilderInterface {
98100
virtualvoidBuild() = 0;
99101

100102
const std::string &GetUniqueId()const {return unique_id_; }
103+
tf::Taskflow &GetTaskflow() {return tf_; }
101104

102105
protected:
103106
template<typename T>
@@ -154,6 +157,7 @@ class BuilderInterface {
154157
protected:
155158
bool dirty_{false};
156159
std::string unique_id_;
160+
tf::Taskflow tf_;
157161
};
158162

159163
}// namespace buildcc::internal

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ class Target : public internal::BuilderInterface,
136136
//
137137
TargetState state_;
138138
env::Command command_;
139-
tf::Taskflow tf_;
140139

141140
// Task states
142141
tf::Task target_start_task_;

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ const std::string &TargetGetter<T>::GetLinkCommand() const {
9999
return t.link_target_.GetCommand();
100100
}
101101

102-
template<typename T> tf::Taskflow &TargetGetter<T>::GetTaskflow() {
103-
T &t =static_cast<T &>(*this);
104-
105-
return t.tf_;
106-
}
107-
108102
templateclassTargetGetter<BaseTarget>;
109103

110104
}// namespace buildcc::internal

‎buildcc/lib/target/src/custom_generator/custom_generator.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ void CustomGenerator::AddPatterns(
4040
}
4141
}
4242

43+
std::stringCustomGenerator::ParsePattern(
44+
const std::string &pattern,
45+
const std::unordered_map<constchar *, std::string> &arguments)const {
46+
return command_.Construct(pattern, arguments);
47+
}
48+
4349
const std::string &
4450
CustomGenerator::Get(const std::string &file_identifier)const {
4551
return command_.GetDefaultValueByKey(file_identifier);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp