Skip to content

Commit 8ce5d71

Browse files
authored
feat: add debug flag (#102)
1 parent e458c22 commit 8ce5d71

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

ecsact/cli/commands/build.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ constexpr auto USAGE = R"docopt(Ecsact Build Command
3232
3333
Usage:
3434
ecsact build (-h | --help)
35-
ecsact build <files>... --recipe=<name>... --output=<path> [--allow-unresolved-imports] [--format=<type>] [--temp_dir=<path>] [--compiler_config=<path>] [--report_filter=<filter>]
35+
ecsact build <files>... --recipe=<name>... --output=<path> [--allow-unresolved-imports] [--format=<type>] [--temp_dir=<path>] [--compiler_config=<path>] [--report_filter=<filter>] [--debug]
3636
3737
Options:
3838
<files> Ecsact files used to build Ecsact Runtime
@@ -42,6 +42,7 @@ constexpr auto USAGE = R"docopt(Ecsact Build Command
4242
--compiler_config=<path> Optionally specify the compiler by name or path
4343
-f --format=<type> The format used to report progress of the build [default: text]
4444
--report_filter=<filter> Filtering out report logs [default: none]
45+
--debug Compile with debug symbols
4546
)docopt";
4647

4748
// TODO(zaucy): Add this documentation to docopt (msvc regex fails)
@@ -289,6 +290,7 @@ auto ecsact::cli::detail::build_command( //
289290
.files = file_paths,
290291
.work_dir = work_dir,
291292
.output_path = output_path,
293+
.debug = args["--debug"].asBool(),
292294
.additional_plugin_dirs = additional_plugin_dirs,
293295
};
294296
auto runtime_output_path =

ecsact/cli/commands/build/recipe/cook.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ struct compile_options {
344344
fs::path output_path;
345345
std::vector<std::string> imports;
346346
std::vector<std::string> exports;
347+
bool debug;
347348
};
348349

349350
auto clang_gcc_compile(compile_options options) -> int {
@@ -562,6 +563,9 @@ auto cl_compile(compile_options options) -> int {
562563
}
563564

564565
cl_args.push_back("/link");
566+
if(options.debug) {
567+
cl_args.push_back("/DEBUG");
568+
}
565569
cl_args.push_back("/DLL");
566570

567571
for(auto lib_dir : options.compiler.std_lib_paths) {
@@ -769,6 +773,7 @@ auto ecsact::cli::cook_recipe( //
769773
.output_path = output_path,
770774
.imports = as_vec(recipe.imports()),
771775
.exports = as_vec(recipe.exports()),
776+
.debug = recipe_options.debug,
772777
});
773778
} else {
774779
exit_code = clang_gcc_compile({
@@ -780,6 +785,7 @@ auto ecsact::cli::cook_recipe( //
780785
.output_path = output_path,
781786
.imports = as_vec(recipe.imports()),
782787
.exports = as_vec(recipe.exports()),
788+
.debug = recipe_options.debug,
783789
});
784790
}
785791

ecsact/cli/commands/build/recipe/cook.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct cook_recipe_options {
1111
std::vector<std::filesystem::path> files;
1212
std::filesystem::path work_dir;
1313
std::filesystem::path output_path;
14+
bool debug;
1415

1516
/** Other directories to check for codegen plugins */
1617
std::vector<std::filesystem::path> additional_plugin_dirs;

test/build_recipe/test_build_recipe.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ TEST(Build, Success) {
3838
std::format("--recipe={}", test_build_recipe_path),
3939
"--output=test_ecsact_runtime"s,
4040
"--temp_dir=_test_build_recipe_temp"s,
41+
"--debug"s,
4142
});
4243

4344
ASSERT_EQ(exit_code, 0);

0 commit comments

Comments
 (0)