Skip to content

Commit

Permalink
feat: add debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelwan committed May 24, 2024
1 parent e458c22 commit 237fae3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ecsact/cli/commands/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ constexpr auto USAGE = R"docopt(Ecsact Build Command
Usage:
ecsact build (-h | --help)
ecsact build <files>... --recipe=<name>... --output=<path> [--allow-unresolved-imports] [--format=<type>] [--temp_dir=<path>] [--compiler_config=<path>] [--report_filter=<filter>]
ecsact build <files>... --recipe=<name>... --output=<path> [--allow-unresolved-imports] [--format=<type>] [--temp_dir=<path>] [--compiler_config=<path>] [--report_filter=<filter>] [--debug]
Options:
<files> Ecsact files used to build Ecsact Runtime
Expand All @@ -42,6 +42,7 @@ constexpr auto USAGE = R"docopt(Ecsact Build Command
--compiler_config=<path> Optionally specify the compiler by name or path
-f --format=<type> The format used to report progress of the build [default: text]
--report_filter=<filter> Filtering out report logs [default: none]
--debug Compile with debug symbols
)docopt";

// TODO(zaucy): Add this documentation to docopt (msvc regex fails)
Expand Down Expand Up @@ -289,6 +290,7 @@ auto ecsact::cli::detail::build_command( //
.files = file_paths,
.work_dir = work_dir,
.output_path = output_path,
.debug = args["--debug"].asBool(),
.additional_plugin_dirs = additional_plugin_dirs,
};
auto runtime_output_path =
Expand Down
6 changes: 6 additions & 0 deletions ecsact/cli/commands/build/recipe/cook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ struct compile_options {
fs::path output_path;
std::vector<std::string> imports;
std::vector<std::string> exports;
bool debug;
};

auto clang_gcc_compile(compile_options options) -> int {
Expand Down Expand Up @@ -562,6 +563,9 @@ auto cl_compile(compile_options options) -> int {
}

cl_args.push_back("/link");
if(options.debug) {
cl_args.push_back("/DEBUG");
}
cl_args.push_back("/DLL");

for(auto lib_dir : options.compiler.std_lib_paths) {
Expand Down Expand Up @@ -769,6 +773,7 @@ auto ecsact::cli::cook_recipe( //
.output_path = output_path,
.imports = as_vec(recipe.imports()),
.exports = as_vec(recipe.exports()),
.debug = recipe_options.debug,
});
} else {
exit_code = clang_gcc_compile({
Expand All @@ -780,6 +785,7 @@ auto ecsact::cli::cook_recipe( //
.output_path = output_path,
.imports = as_vec(recipe.imports()),
.exports = as_vec(recipe.exports()),
.debug = recipe_options.debug,
});
}

Expand Down
1 change: 1 addition & 0 deletions ecsact/cli/commands/build/recipe/cook.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct cook_recipe_options {
std::vector<std::filesystem::path> files;
std::filesystem::path work_dir;
std::filesystem::path output_path;
bool debug;

/** Other directories to check for codegen plugins */
std::vector<std::filesystem::path> additional_plugin_dirs;
Expand Down
1 change: 1 addition & 0 deletions test/build_recipe/test_build_recipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ TEST(Build, Success) {
std::format("--recipe={}", test_build_recipe_path),
"--output=test_ecsact_runtime"s,
"--temp_dir=_test_build_recipe_temp"s,
"--debug"s,
});

ASSERT_EQ(exit_code, 0);
Expand Down

0 comments on commit 237fae3

Please # to comment.