Skip to content

[BuildExe] Basic Immediate mode feature #168

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 27 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions .github/workflows/linux_gcc_cmake_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ jobs:
run: |
cmake --build . --target run_buildcc_lib_bootstrap_linux_gcc

- name: BuildExe IM example tiny-process-library
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
run: |
cmake --build . --target run_buildexe_im_tpl_linux_gcc

- name: Install
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_ALL}}
run: |
Expand Down Expand Up @@ -184,6 +189,11 @@ jobs:
run: |
cmake --build . --target run_buildcc_lib_bootstrap_linux_gcc

- name: BuildExe IM example tiny-process-library
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
run: |
cmake --build . --target run_buildexe_im_tpl_linux_gcc

- name: Install
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/win_cmake_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ jobs:
run: |
cmake --build . --config Release --target run_buildcc_lib_bootstrap_win_msvc --parallel 2

- name: BuildExe IM example tiny-process-library
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --target run_buildexe_im_tpl_win_msvc

- name: Install
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ project(BuildCC
)

# User options
option(BUILDCC_INSTALL "Enable Buildcc Installation" ON)
option(BUILDCC_INSTALL "Enable BuildCC Installation" ON)
option(BUILDCC_FLATBUFFERS_FLATC "Build Flatbuffer::Flatc Compiler" ON)

option(BUILDCC_BUILD_AS_SINGLE_LIB "Build all internal libs and modules as part of the buildcc library" ON)
option(BUILDCC_BUILD_AS_INTERFACE "Build all internal libs and modules seperately and link" OFF)

option(BUILDCC_BUILDEXE "Standalone BuildCC buildsystem executable" ON)
option(BUILDCC_BOOTSTRAP_THROUGH_CMAKE "Bootstrap buildcc through CMake" OFF)

# NOTE, Conflict with Clang-Tidy on certain compilers
option(BUILDCC_PRECOMPILE_HEADERS "Enable Buildcc precompile headers" OFF)
option(BUILDCC_EXAMPLES "Enable Buildcc Examples" OFF)
option(BUILDCC_PRECOMPILE_HEADERS "Enable BuildCC precompile headers" OFF)
option(BUILDCC_EXAMPLES "Enable BuildCC Examples" OFF)

# Dev options
option(BUILDCC_TESTING "Enable BuildCC Testing" OFF)
Expand Down Expand Up @@ -115,6 +116,10 @@ if (${BUILDCC_EXAMPLES})
add_subdirectory(example/hybrid/target_info)
endif()

if (${BUILDCC_BUILDEXE})
add_subdirectory(buildexe)
endif()

if (${BUILDCC_BOOTSTRAP_THROUGH_CMAKE})
add_subdirectory(bootstrap)
endif()
6 changes: 6 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BUILDEXE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
Expand All @@ -44,6 +45,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": false,
"BUILDCC_BUILDEXE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
Expand All @@ -68,6 +70,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": false,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BUILDEXE": false,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": false,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": false,
Expand All @@ -92,6 +95,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BUILDEXE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
Expand All @@ -113,6 +117,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": true,
"BUILDCC_BUILDEXE": true,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
Expand All @@ -134,6 +139,7 @@
"BUILDCC_FLATBUFFERS_FLATC": true,
"BUILDCC_BUILD_AS_SINGLE_LIB": true,
"BUILDCC_BUILD_AS_INTERFACE": false,
"BUILDCC_BUILDEXE": false,
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": false,
"BUILDCC_PRECOMPILE_HEADERS": false,
"BUILDCC_EXAMPLES": false,
Expand Down
6 changes: 3 additions & 3 deletions bootstrap/main.buildcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ static void global_flags_cb(TargetInfo &global_info,
const BaseToolchain &toolchain);

static void setup_buildcc_cb(PersistentStorage &storage, Register &reg,
const Args::ToolchainArg &custom_toolchain_arg,
const ArgToolchain &custom_toolchain_arg,
const BaseToolchain &toolchain);

static void hybrid_simple_example_cb(BaseTarget &target,
const BaseTarget &libbuildcc);

int main(int argc, char **argv) {
Args args;
Args::ToolchainArg custom_toolchain_arg;
ArgToolchain custom_toolchain_arg;
args.AddToolchain("custom", "Host Toolchain", custom_toolchain_arg);
args.Parse(argc, argv);

Expand Down Expand Up @@ -102,7 +102,7 @@ static void global_flags_cb(TargetInfo &global_info,
}

static void setup_buildcc_cb(PersistentStorage &storage, Register &reg,
const Args::ToolchainArg &custom_toolchain_arg,
const ArgToolchain &custom_toolchain_arg,
const BaseToolchain &toolchain) {

// Flatc Executable
Expand Down
113 changes: 53 additions & 60 deletions buildcc/lib/args/include/args/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,66 +31,59 @@ namespace fs = std::filesystem;

namespace buildcc {

class Args {
public:
/**
* @brief Toolchain State used by the Register module to selectively build or
* test targets
*/
struct ToolchainState {
bool build{false};
bool test{false};
};
/**
* @brief Toolchain State used by the Register module to selectively build or
* test targets
*/
struct ArgToolchainState {
bool build{false};
bool test{false};
};

/**
* @brief Toolchain Arg used to receive toolchain information through the
* command line
* Bundled with Toolchain State
*/
struct ArgToolchain {
ArgToolchain(){};
ArgToolchain(ToolchainId initial_id, const std::string &initial_name,
const std::string &initial_asm_compiler,
const std::string &initial_c_compiler,
const std::string &initial_cpp_compiler,
const std::string &initial_archiver,
const std::string &initial_linker)
: id(initial_id), name(initial_name), asm_compiler(initial_asm_compiler),
c_compiler(initial_c_compiler), cpp_compiler(initial_cpp_compiler),
archiver(initial_archiver), linker(initial_linker) {}

BaseToolchain ConstructToolchain() const {
BaseToolchain toolchain(id, name, asm_compiler, c_compiler, cpp_compiler,
archiver, linker);
return toolchain;
}

ArgToolchainState state;
ToolchainId id{ToolchainId::Undefined};
std::string name{""};
std::string asm_compiler{""};
std::string c_compiler{""};
std::string cpp_compiler{""};
std::string archiver{""};
std::string linker{""};
};

// TODO, Rename to Toolchain
// TODO, Put ToolchainState into Args::Toolchain
// TODO, Add operator() overload and remove ConstructToolchain
// NOTE, Incomplete without pch_compile_command
// TODO, Update this for PCH
struct ArgTarget {
ArgTarget(){};

/**
* @brief Toolchain Arg used to receive toolchain information through the
* command line
* Bundled with Toolchain State
*/
struct ToolchainArg {
ToolchainArg(){};

ToolchainArg(base::Toolchain::Id initial_id,
const std::string &initial_name,
const std::string &initial_asm_compiler,
const std::string &initial_c_compiler,
const std::string &initial_cpp_compiler,
const std::string &initial_archiver,
const std::string &initial_linker)
: id(initial_id), name(initial_name),
asm_compiler(initial_asm_compiler), c_compiler(initial_c_compiler),
cpp_compiler(initial_cpp_compiler), archiver(initial_archiver),
linker(initial_linker) {}

base::Toolchain ConstructToolchain() const {
base::Toolchain toolchain(id, name, asm_compiler, c_compiler,
cpp_compiler, archiver, linker);
return toolchain;
}

ToolchainState state;
base::Toolchain::Id id{base::Toolchain::Id::Undefined};
std::string name{""};
std::string asm_compiler{""};
std::string c_compiler{""};
std::string cpp_compiler{""};
std::string archiver{""};
std::string linker{""};
};

// NOTE, Incomplete without pch_compile_command
// TODO, Update this for PCH
struct TargetArg {
TargetArg(){};

std::string compile_command{""};
std::string link_command{""};
};
std::string compile_command{""};
std::string link_command{""};
};

class Args {
public:
public:
Args() { Initialize(); }
Args(const Args &) = delete;
Expand All @@ -110,13 +103,13 @@ class Args {
* @param initial Set the default toolchain information as a fallback
*/
void AddToolchain(const std::string &name, const std::string &description,
ToolchainArg &out,
const ToolchainArg &initial = ToolchainArg());
ArgToolchain &out,
const ArgToolchain &initial = ArgToolchain());

// NOTE, Incomplete TargetArg
// TODO, Update for pch_compile_command
void AddTarget(const std::string &name, const std::string &description,
TargetArg &out, const TargetArg &initial = TargetArg());
ArgTarget &out, const ArgTarget &initial = ArgTarget());

// Getters
bool Clean() const { return clean_; }
Expand Down
8 changes: 4 additions & 4 deletions buildcc/lib/args/include/args/register.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Register {
* Can be used to add Toolchain-Target specific information
*/
template <typename C, typename... Params>
void CallbackIf(const Args::ToolchainState &toolchain_state,
const C &build_cb, Params &...params) {
void CallbackIf(const ArgToolchainState &toolchain_state, const C &build_cb,
Params &...params) {
if (toolchain_state.build) {
Callback(build_cb, std::forward<Params &>(params)...);
}
Expand All @@ -67,7 +67,7 @@ class Register {
* @brief Register the Target to be built
*/
template <typename C, typename... Params>
void Build(const Args::ToolchainState &toolchain_state, const C &build_cb,
void Build(const ArgToolchainState &toolchain_state, const C &build_cb,
base::Target &target, Params &...params) {
tf::Task task;
CallbackIf(
Expand Down Expand Up @@ -106,7 +106,7 @@ class Register {
*
* Target is added as the `{executable}` argument
*/
void Test(const Args::ToolchainState &toolchain_state,
void Test(const ArgToolchainState &toolchain_state,
const std::string &command, const base::Target &target,
const TestConfig &config = TestConfig());

Expand Down
4 changes: 2 additions & 2 deletions buildcc/lib/args/src/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const std::unordered_map<const char *, buildcc::base::Toolchain::Id>
namespace buildcc {

void Args::AddToolchain(const std::string &name, const std::string &description,
ToolchainArg &out, const ToolchainArg &initial) {
ArgToolchain &out, const ArgToolchain &initial) {
CLI::App *t_user =
toolchain_->add_subcommand(name, description)->group(kToolchainGroup);
t_user->add_flag(kToolchainBuildParam, out.state.build);
Expand All @@ -112,7 +112,7 @@ void Args::AddToolchain(const std::string &name, const std::string &description,
}

void Args::AddTarget(const std::string &name, const std::string &description,
TargetArg &out, const TargetArg &initial) {
ArgTarget &out, const ArgTarget &initial) {
CLI::App *target_user =
target_->add_subcommand(name, description)->group(kTargetGroup);
target_user->add_option(kTargetCompileCommandParam, out.compile_command)
Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/args/src/register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void Register::Dep(const base::BuilderInterface &target,
target_iter->second.succeed(dep_iter->second);
}

void Register::Test(const Args::ToolchainState &toolchain_state,
void Register::Test(const ArgToolchainState &toolchain_state,
const std::string &command, const base::Target &target,
const TestConfig &config) {
if (!(toolchain_state.build && toolchain_state.test)) {
Expand Down
22 changes: 11 additions & 11 deletions buildcc/lib/args/test/test_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST(ArgsTestGroup, Args_CustomToolchain) {
int argc = av.size();

buildcc::Args args;
buildcc::Args::ToolchainArg gcc_toolchain;
buildcc::ArgToolchain gcc_toolchain;
args.AddToolchain("gcc", "Generic gcc toolchain", gcc_toolchain);
args.Parse(argc, av.data());

Expand Down Expand Up @@ -88,8 +88,8 @@ TEST(ArgsTestGroup, Args_MultipleCustomToolchain) {
int argc = av.size();

buildcc::Args args;
buildcc::Args::ToolchainArg gcc_toolchain;
buildcc::Args::ToolchainArg msvc_toolchain;
buildcc::ArgToolchain gcc_toolchain;
buildcc::ArgToolchain msvc_toolchain;
args.AddToolchain("gcc", "Generic gcc toolchain", gcc_toolchain);
args.AddToolchain("msvc", "Generic msvc toolchain", msvc_toolchain);
args.Parse(argc, av.data());
Expand Down Expand Up @@ -126,8 +126,8 @@ TEST(ArgsTestGroup, Args_MultipleCustomToolchain) {

TEST(ArgsTestGroup, Args_DuplicateCustomToolchain) {
buildcc::Args args;
buildcc::Args::ToolchainArg gcc_toolchain;
buildcc::Args::ToolchainArg other_gcc_toolchain;
buildcc::ArgToolchain gcc_toolchain;
buildcc::ArgToolchain other_gcc_toolchain;
args.AddToolchain("gcc", "Generic gcc toolchain", gcc_toolchain);

// CLI11 Throws an exception when multiple toolchains with same name are added
Expand All @@ -151,8 +151,8 @@ TEST(ArgsTestGroup, Args_CustomTarget) {
int argc = av.size();

buildcc::Args args;
buildcc::Args::ToolchainArg gcc_toolchain;
buildcc::Args::TargetArg gcc_target;
buildcc::ArgToolchain gcc_toolchain;
buildcc::ArgTarget gcc_target;
args.AddToolchain("gcc", "Generic gcc toolchain", gcc_toolchain);
args.AddTarget("gcc", "Generic gcc target", gcc_target);
args.Parse(argc, av.data());
Expand Down Expand Up @@ -199,12 +199,12 @@ TEST(ArgsTestGroup, Args_MultipleCustomTarget) {
int argc = av.size();

buildcc::Args args;
buildcc::Args::ToolchainArg gcc_toolchain;
buildcc::Args::TargetArg gcc_target;
buildcc::ArgToolchain gcc_toolchain;
buildcc::ArgTarget gcc_target;
args.AddToolchain("gcc", "Generic gcc toolchain", gcc_toolchain);
args.AddTarget("gcc", "Generic gcc target", gcc_target);
buildcc::Args::ToolchainArg msvc_toolchain;
buildcc::Args::TargetArg msvc_target;
buildcc::ArgToolchain msvc_toolchain;
buildcc::ArgTarget msvc_target;
args.AddToolchain("msvc", "Generic msvc toolchain", msvc_toolchain);
args.AddTarget("msvc", "Generic msvc target", msvc_target);
args.Parse(argc, av.data());
Expand Down
Loading