Skip to content

Updated bootstrap and buildexe #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 65 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d8e2392
Updated tpl cb with TplConfig
coder137 Jan 5, 2022
5993275
Update main.buildcc.cpp
coder137 Jan 5, 2022
c7a1191
Update build_buildcc.cpp
coder137 Jan 5, 2022
20317f0
Update build_cli11.cpp
coder137 Jan 5, 2022
d4082fb
Update build_flatbuffers.cpp
coder137 Jan 5, 2022
789026d
Update build_taskflow.cpp
coder137 Jan 5, 2022
560b47f
Update host_os.h
coder137 Jan 5, 2022
333ac93
Updated toolchain files to toolchain.host
coder137 Jan 5, 2022
2407184
Update main.buildcc.cpp
coder137 Jan 5, 2022
1fab57d
Update buildexe.cpp
coder137 Jan 5, 2022
7b22566
Update target_generic.h
coder137 Jan 5, 2022
d5ecc72
Update target_generic.h
coder137 Jan 5, 2022
701fea5
Updated Target_generic for Mingw
coder137 Jan 5, 2022
5e0a981
Update toolchain_win_gcc.toml
coder137 Jan 5, 2022
cbe4370
Update args.cpp
coder137 Jan 5, 2022
0c8dafe
Update include_api.cpp
coder137 Jan 5, 2022
f2da211
Update build_taskflow.cpp
coder137 Jan 5, 2022
65008e2
Updated compiler with path
coder137 Jan 5, 2022
127974b
Update buildexe.cpp
coder137 Jan 5, 2022
108eeda
Update toc.rst
coder137 Jan 5, 2022
bf8dd26
Update toc.rst
coder137 Jan 5, 2022
6ecec2c
Update toc.rst
coder137 Jan 5, 2022
423e14c
Create setup.rst
coder137 Jan 6, 2022
76d6790
Update toc.rst
coder137 Jan 6, 2022
6e9497f
Update setup.rst
coder137 Jan 6, 2022
17d7d43
Update build_buildcc.cpp
coder137 Jan 6, 2022
262368b
Segregated args for buildexe to args_setup.h/.cpp
coder137 Jan 6, 2022
ea7fa20
Update args_setup.cpp
coder137 Jan 6, 2022
801d78f
Segregated buildexe toolchain to toolchain_setup.h/.cpp
coder137 Jan 6, 2022
8004e5a
Shifted buildexe_mode to args_setup.h/.cpp
coder137 Jan 6, 2022
2fb53ee
Update buildexe.cpp
coder137 Jan 6, 2022
58169be
Added find_toolchain_verify
coder137 Jan 6, 2022
77117b0
Update buildexe.cpp
coder137 Jan 6, 2022
82dc2d6
Added ifdefs
coder137 Jan 6, 2022
153abc2
Added buildcc_setup.h
coder137 Jan 6, 2022
12a4176
Renamed buildcc_setup to build_env_setup.h/.cpp
coder137 Jan 6, 2022
a26aa07
Updated BuildEnvSetup
coder137 Jan 6, 2022
65e829f
Added RunUserTarget API
coder137 Jan 7, 2022
9aab820
Update persistent_storage.h
coder137 Jan 7, 2022
e778d15
Update build.cpp
coder137 Jan 7, 2022
5899026
Update setup.rst
coder137 Jan 7, 2022
6f0279d
Added usage_buildexe.rst
coder137 Jan 7, 2022
6f2e08f
Update build.cpp
coder137 Jan 7, 2022
f233ac5
Update usage_buildexe.rst
coder137 Jan 8, 2022
bd4e769
Renamed file
coder137 Jan 8, 2022
b85e1a5
Update buildexe_getting_started.rst
coder137 Jan 8, 2022
1de0baa
Update toc.rst
coder137 Jan 8, 2022
5b36ef6
Added all_compile_options and all_build_options
coder137 Jan 8, 2022
f830500
Update args.cpp
coder137 Jan 8, 2022
d978a56
Update args_setup.cpp
coder137 Jan 8, 2022
27da98e
Update buildexe.cpp
coder137 Jan 8, 2022
d2f2c14
Update all_compile_options.rst
coder137 Jan 8, 2022
b546394
Update buildexe_getting_started.rst
coder137 Jan 8, 2022
21f0f70
Update all_compile_options.rst
coder137 Jan 8, 2022
51458ba
Updated all_default_build_options
coder137 Jan 8, 2022
30349a7
Updated heading naming
coder137 Jan 8, 2022
425ec4e
Renamed file
coder137 Jan 8, 2022
0f2146e
Renamed file
coder137 Jan 8, 2022
a9708fb
Added buildexe_immediate_example file
coder137 Jan 8, 2022
a49aa49
Update toc.rst
coder137 Jan 8, 2022
fc6d20c
Update buildexe_script_example.rst
coder137 Jan 8, 2022
5b4fc75
Update buildexe_script_example.rst
coder137 Jan 8, 2022
3885ae7
Update buildexe_immediate_example.rst
coder137 Jan 8, 2022
ee946df
Update buildexe_immediate_example.rst
coder137 Jan 8, 2022
deabae4
Added walkthroughs
coder137 Jan 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstrap/config/toolchain_linux_gcc.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain.custom]
[toolchain.host]
build = true
test = true

Expand Down
4 changes: 2 additions & 2 deletions bootstrap/config/toolchain_win_gcc.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[toolchain.custom]
[toolchain.host]
build = true
test = true

id = "gcc"
id = "mingw"
name = "x86_64-w64-mingw32"
asm_compiler = "as"
c_compiler = "gcc"
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/config/toolchain_win_msvc.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain.custom]
[toolchain.host]
build = true
test = true

Expand Down
8 changes: 7 additions & 1 deletion bootstrap/include/bootstrap/build_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@

namespace buildcc {

void tpl_cb(BaseTarget &target);
struct TplConfig {
TplConfig() = default;

OsId os_id{OsId::Linux};
};

void tpl_cb(BaseTarget &target, const TplConfig &config = TplConfig());

} // namespace buildcc

Expand Down
3 changes: 1 addition & 2 deletions bootstrap/main.buildcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ static void hybrid_simple_example_cb(BaseTarget &target,
int main(int argc, char **argv) {
Args args;
ArgToolchain custom_toolchain_arg;
args.AddToolchain("custom", "Host Toolchain", custom_toolchain_arg);
args.AddToolchain("host", "Host Toolchain", custom_toolchain_arg);
args.Parse(argc, argv);

Register reg(args);
reg.Clean(clean_cb);

BaseToolchain toolchain = custom_toolchain_arg.ConstructToolchain();

PersistentStorage storage;
BuildBuildCC buildcc(
reg, toolchain,
TargetEnv(env::get_project_root_dir(), env::get_project_build_dir()));
Expand Down
6 changes: 5 additions & 1 deletion bootstrap/src/build_buildcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,
target.GlobHeaders("lib/env/include/env");

// TOOLCHAIN
target.GlobSources("lib/toolchain/src/api");
target.AddIncludeDir("lib/toolchain/include");
target.GlobHeaders("lib/toolchain/include/toolchain");
target.GlobHeaders("lib/toolchain/include/toolchain/api");

// TARGET
target.GlobSources("lib/target/src/common");
Expand Down Expand Up @@ -238,7 +240,9 @@ void BuildBuildCC::Setup(const ArgToolchainState &state) {
"tiny-process-library",
env_.GetTargetBuildDir()));
reg_.CallbackIf(state, global_flags_cb, tpl_lib, toolchain_);
reg_.Build(state, tpl_cb, tpl_lib);
TplConfig tpl_config;
tpl_config.os_id = get_host_os();
reg_.Build(state, tpl_cb, tpl_lib, tpl_config);

// TODO, Make this a generic selection between StaticTarget and
// DynamicTarget
Expand Down
1 change: 0 additions & 1 deletion bootstrap/src/build_cli11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace buildcc {
void cli11_ho_cb(TargetInfo &info) {
info.AddIncludeDir("include");
info.GlobHeaders("include/CLI");
// TODO, Add PCH
}

} // namespace buildcc
47 changes: 16 additions & 31 deletions bootstrap/src/build_flatbuffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,45 +82,30 @@ void build_flatc_exe_cb(BaseTarget &target) {
kFlatcPreprocessorFlags.cend(),
[&](const auto &f) { target.AddPreprocessorFlag(f); });

if constexpr (env::is_win()) {
switch (target.GetToolchain().GetId()) {
case ToolchainId::Gcc:
case ToolchainId::MinGW:
std::for_each(kFlatcGccCppCompileFlags.cbegin(),
kFlatcGccCppCompileFlags.cend(),
[&](const auto &f) { target.AddCppCompileFlag(f); });
break;
case ToolchainId::Msvc:
std::for_each(kFlatcMsvcCppCompileFlags.cbegin(),
kFlatcMsvcCppCompileFlags.cend(),
[&](const auto &f) { target.AddCppCompileFlag(f); });
break;
default:
break;
}
switch (target.GetToolchain().GetId()) {
case ToolchainId::Gcc:
case ToolchainId::MinGW:
std::for_each(kFlatcGccCppCompileFlags.cbegin(),
kFlatcGccCppCompileFlags.cend(),
[&](const auto &f) { target.AddCppCompileFlag(f); });
break;
case ToolchainId::Msvc:
std::for_each(kFlatcMsvcCppCompileFlags.cbegin(),
kFlatcMsvcCppCompileFlags.cend(),
[&](const auto &f) { target.AddCppCompileFlag(f); });
break;
case ToolchainId::Clang:
break;
default:
break;
}

if constexpr (env::is_linux()) {
switch (target.GetToolchain().GetId()) {
case ToolchainId::Gcc:
std::for_each(kFlatcGccCppCompileFlags.cbegin(),
kFlatcGccCppCompileFlags.cend(),
[&](const auto &f) { target.AddCppCompileFlag(f); });
break;
default:
break;
}
}

// TODO, Add PCH

target.Build();
}

void flatbuffers_ho_cb(TargetInfo &info) {
info.AddIncludeDir("include");
info.GlobHeaders("include/flatbuffers");
// TODO, Add PCH
}

} // namespace buildcc
7 changes: 6 additions & 1 deletion bootstrap/src/build_taskflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ void taskflow_ho_cb(TargetInfo &info) {
info.GlobHeaders("taskflow");
info.GlobHeaders("taskflow/core");
info.GlobHeaders("taskflow/core/algorithm");
// TODO, Track more header files
info.GlobHeaders("taskflow/cuda");
info.GlobHeaders("taskflow/cuda/cuda_algorithm");
info.GlobHeaders("taskflow/dsl");
info.GlobHeaders("taskflow/sycl");
info.GlobHeaders("taskflow/sycl/sycl_algorithm");
info.GlobHeaders("taskflow/utility");
}

} // namespace buildcc
13 changes: 10 additions & 3 deletions bootstrap/src/build_tpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@

namespace buildcc {

void tpl_cb(BaseTarget &target) {
void tpl_cb(BaseTarget &target, const TplConfig &config) {
target.AddSource("process.cpp");
target.AddIncludeDir("");
target.AddHeader("process.hpp");

if constexpr (env::is_win()) {
switch (config.os_id) {
case OsId::Win:
target.AddSource("process_win.cpp");
} else {
break;
case OsId::Linux:
case OsId::Unix:
case OsId::Mac:
target.AddSource("process_unix.cpp");
break;
default:
break;
}

target.Build();
Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/args/include/args/persistent_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PersistentStorage {
metadata.ptr = (void *)ptr;
metadata.typeid_name = typeid(T).name();
metadata.destructor = [this, identifier, ptr]() {
env::log_info("Cleaning", identifier);
env::log_trace("Cleaning", identifier);
Remove<T>(ptr);
};
ptrs_.emplace(identifier, metadata);
Expand Down
29 changes: 14 additions & 15 deletions buildcc/lib/args/src/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ const std::unordered_map<const char *, buildcc::env::LogLevel> kLogLevelMap{

const std::unordered_map<const char *, buildcc::base::Toolchain::Id>
kToolchainIdMap{
{"gcc", buildcc::base::Toolchain::Id::Gcc},
{"msvc", buildcc::base::Toolchain::Id::Msvc},
{"clang", buildcc::base::Toolchain::Id::Clang},
{"custom", buildcc::base::Toolchain::Id::Custom},
{"undefined", buildcc::base::Toolchain::Id::Undefined},
{"gcc", buildcc::ToolchainId::Gcc},
{"msvc", buildcc::ToolchainId::Msvc},
{"mingw", buildcc::ToolchainId::MinGW},
{"clang", buildcc::ToolchainId::Clang},
{"custom", buildcc::ToolchainId::Custom},
{"undefined", buildcc::ToolchainId::Undefined},
};

} // namespace
Expand Down Expand Up @@ -136,19 +137,17 @@ void Args::RootArgs() {
->expected(kMinFiles, kMaxFiles);

// Root flags
auto *root_group = app_.add_option_group(kRootGroup);

app_.add_flag(kCleanParam, clean_, kCleanDesc)->group(kRootGroup);
app_.add_option(kLoglevelParam, loglevel_, kLoglevelDesc)
->transform(CLI::CheckedTransformer(kLogLevelMap, CLI::ignore_case))
->group(kRootGroup);
root_group->add_flag(kCleanParam, clean_, kCleanDesc);
root_group->add_option(kLoglevelParam, loglevel_, kLoglevelDesc)
->transform(CLI::CheckedTransformer(kLogLevelMap, CLI::ignore_case));

// Dir flags
app_.add_option(kRootDirParam, project_root_dir_, kRootDirDesc)
->required()
->group(kRootGroup);
app_.add_option(kBuildDirParam, project_build_dir_, kBuildDirDesc)
->required()
->group(kRootGroup);
root_group->add_option(kRootDirParam, project_root_dir_, kRootDirDesc)
->required();
root_group->add_option(kBuildDirParam, project_build_dir_, kBuildDirDesc)
->required();
}

} // namespace buildcc
33 changes: 33 additions & 0 deletions buildcc/lib/env/include/env/host_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,37 @@ inline constexpr bool is_unix() {

} // namespace buildcc::env

namespace buildcc {

enum class OsId {
Linux,
Win,
Mac,
Unix,
Undefined,
};

inline constexpr OsId get_host_os() {
OsId os_id = OsId::Undefined;
if constexpr (env::is_linux()) {
os_id = OsId::Linux;
}

if constexpr (env::is_unix()) {
os_id = OsId::Unix;
}

if constexpr (env::is_win()) {
os_id = OsId::Win;
}

if constexpr (env::is_mac()) {
os_id = OsId::Mac;
}

return os_id;
}

} // namespace buildcc

#endif
1 change: 0 additions & 1 deletion buildcc/lib/target/src/api/include_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ void IncludeApi<T>::GlobHeadersAbsolute(const fs::path &absolute_path) {

for (const auto &p : fs::directory_iterator(absolute_path)) {
if (t.config_.IsValidHeader(p.path())) {
env::log_trace(__FUNCTION__, fmt::format("Added header {}", p.path()));
AddHeaderAbsolute(p.path());
}
}
Expand Down
10 changes: 5 additions & 5 deletions buildcc/lib/target/src/target/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ void Target::Build() {
{kLinkFlags, internal::aggregate(GetLinkFlags())},

// Toolchain executables here
{kAsmCompiler, toolchain_.GetAsmCompiler()},
{kCCompiler, toolchain_.GetCCompiler()},
{kCppCompiler, toolchain_.GetCppCompiler()},
{kArchiver, toolchain_.GetArchiver()},
{kLinker, toolchain_.GetLinker()},
{kAsmCompiler, fmt::format("{}", fs::path(toolchain_.GetAsmCompiler()))},
{kCCompiler, fmt::format("{}", fs::path(toolchain_.GetCCompiler()))},
{kCppCompiler, fmt::format("{}", fs::path(toolchain_.GetCppCompiler()))},
{kArchiver, fmt::format("{}", fs::path(toolchain_.GetArchiver()))},
{kLinker, fmt::format("{}", fs::path(toolchain_.GetLinker()))},
});

// Load the serialized file
Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/src/target/friend/compile_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void CompileObject::CacheCompileCommands() {
const std::string selected_aggregated_compile_flags =
target_.SelectCompileFlags(type).value_or("");
const std::string selected_compiler =
target_.SelectCompiler(type).value_or("");
fmt::format("{}", fs::path(target_.SelectCompiler(type).value_or("")));
object_iter.second.command = target_.command_.Construct(
target_.GetConfig().compile_command,
{
Expand Down
7 changes: 4 additions & 3 deletions buildcc/lib/target/src/target/friend/compile_pch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ fs::path CompilePch::ConstructObjectPath() const {
}

std::string CompilePch::ConstructCompileCommand() const {
const std::string compiler = target_.GetState().contains_cpp
? target_.GetToolchain().GetCppCompiler()
: target_.GetToolchain().GetCCompiler();
std::string compiler = target_.GetState().contains_cpp
? target_.GetToolchain().GetCppCompiler()
: target_.GetToolchain().GetCCompiler();
compiler = fmt::format("{}", fs::path(compiler));
const TargetFileExt file_ext_type =
target_.GetState().contains_cpp ? TargetFileExt::Cpp : TargetFileExt::C;
const std::string compile_flags =
Expand Down
Loading