@@ -131,7 +131,6 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
131131if constexpr (env::is_win ()) {
132132// TODO, Clang
133133switch (target.GetToolchain ().GetId ()) {
134- case ToolchainId::Gcc:
135134case ToolchainId::MinGW: {
136135 target.AddPreprocessorFlag (" -DFMT_HEADER_ONLY=1" );
137136 target.AddPreprocessorFlag (" -DSPDLOG_FMT_EXTERNAL" );
@@ -147,7 +146,7 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
147146 }
148147 }
149148
150- if constexpr (env::is_linux ()) {
149+ if constexpr (env::is_linux () || env::is_unix () || env::is_clang () ) {
151150// TODO, Clang
152151switch (target.GetToolchain ().GetId ()) {
153152case ToolchainId::Gcc: {
@@ -196,51 +195,41 @@ void BuildBuildCC::Setup(const ArgToolchainState &state) {
196195TargetEnv (env_.GetTargetRootDir () /" third_party" /" flatbuffers" ,
197196 env_.GetTargetBuildDir ()));
198197
199- reg_.CallbackIf (state, global_flags_cb, flatc_exe, toolchain_);
200- reg_.Build (state, build_flatc_exe_cb, flatc_exe);
201-
202198// Schema
203199auto &schema_gen = storage_.Add <BaseGenerator>(
204200kSchemaGenName ,kSchemaGenName ,
205201TargetEnv (env_.GetTargetRootDir () /" buildcc" /" schema" ,
206202 env_.GetTargetBuildDir () / toolchain_.GetName ()));
207- reg_.Build (schema_gen_cb, schema_gen, flatc_exe);
208- reg_.Dep (schema_gen, flatc_exe);
209203
210204// Flatbuffers HO lib
211205auto &flatbuffers_ho_lib = storage_.Add <TargetInfo>(
212206kFlatbuffersHoName , toolchain_,
213207TargetEnv (env_.GetTargetRootDir () /" third_party" /" flatbuffers" ,
214208 env_.GetTargetBuildDir ()));
215- reg_.CallbackIf (state, flatbuffers_ho_cb, flatbuffers_ho_lib);
216209
217210// CLI11 HO lib
218211auto &cli11_ho_lib = storage_.Add <TargetInfo>(
219212kCli11HoName , toolchain_,
220213TargetEnv (env_.GetTargetRootDir () /" third_party" /" CLI11" ,
221214 env_.GetTargetBuildDir ()));
222- reg_.CallbackIf (state, cli11_ho_cb, cli11_ho_lib);
223215
224216// fmt HO lib
225217auto &fmt_ho_lib = storage_.Add <TargetInfo>(
226218kFmtHoName , toolchain_,
227219TargetEnv (env_.GetTargetRootDir () /" third_party" /" fmt" ,
228220 env_.GetTargetBuildDir ()));
229- reg_.CallbackIf (state, fmt_ho_cb, fmt_ho_lib);
230221
231222// spdlog HO lib
232223auto &spdlog_ho_lib = storage_.Add <TargetInfo>(
233224kSpdlogHoName , toolchain_,
234225TargetEnv (env_.GetTargetRootDir () /" third_party" /" spdlog" ,
235226 env_.GetTargetBuildDir ()));
236- reg_.CallbackIf (state, spdlog_ho_cb, spdlog_ho_lib);
237227
238228// taskflow HO lib
239229auto &taskflow_ho_lib = storage_.Add <TargetInfo>(
240230kTaskflowHoName , toolchain_,
241231TargetEnv (env_.GetTargetRootDir () /" third_party" /" taskflow" ,
242232 env_.GetTargetBuildDir ()));
243- reg_.CallbackIf (state, taskflow_ho_cb, taskflow_ho_lib);
244233
245234// Tiny-process-library lib
246235// TODO, Make this a generic selection between StaticTarget and
@@ -250,21 +239,31 @@ void BuildBuildCC::Setup(const ArgToolchainState &state) {
250239TargetEnv (env_.GetTargetRootDir () /" third_party" /
251240" tiny-process-library" ,
252241 env_.GetTargetBuildDir ()));
253- reg_.CallbackIf (state, global_flags_cb, tpl_lib, toolchain_);
254- TplConfig tpl_config;
255- tpl_config.os_id =get_host_os ();
256- reg_.Build (state, tpl_cb, tpl_lib, tpl_config);
257242
243+ // BuildCC lib
258244// TODO, Make this a generic selection between StaticTarget and
259245// DynamicTarget
260246auto &buildcc_lib = storage_.Add <StaticTarget_generic>(
261247kBuildccLibName ,kBuildccLibName , toolchain_,
262248TargetEnv (env_.GetTargetRootDir () /" buildcc" , env_.GetTargetBuildDir ()));
263- reg_.CallbackIf (state, global_flags_cb, buildcc_lib, toolchain_);
264- reg_.Build (state, buildcc_cb, buildcc_lib, schema_gen, flatbuffers_ho_lib,
265- fmt_ho_lib, spdlog_ho_lib, cli11_ho_lib, taskflow_ho_lib, tpl_lib);
266- reg_.Dep (buildcc_lib, schema_gen);
267- reg_.Dep (buildcc_lib, tpl_lib);
249+
250+ Reg::Toolchain (state)
251+ .Func (global_flags_cb, flatc_exe, toolchain_)
252+ .Build (build_flatc_exe_cb, flatc_exe)
253+ .Build (schema_gen_cb, schema_gen, flatc_exe)
254+ .Dep (schema_gen, flatc_exe)
255+ .Func (flatbuffers_ho_cb, flatbuffers_ho_lib)
256+ .Func (cli11_ho_cb, cli11_ho_lib)
257+ .Func (fmt_ho_cb, fmt_ho_lib)
258+ .Func (spdlog_ho_cb, spdlog_ho_lib)
259+ .Func (taskflow_ho_cb, taskflow_ho_lib)
260+ .Func (global_flags_cb, tpl_lib, toolchain_)
261+ .Build (tpl_cb, tpl_lib)
262+ .Func (global_flags_cb, buildcc_lib, toolchain_)
263+ .Build (buildcc_cb, buildcc_lib, schema_gen, flatbuffers_ho_lib,
264+ fmt_ho_lib, spdlog_ho_lib, cli11_ho_lib, taskflow_ho_lib, tpl_lib)
265+ .Dep (buildcc_lib, schema_gen)
266+ .Dep (buildcc_lib, tpl_lib);
268267}
269268
270269}// namespace buildcc