Skip to content

feat: add debug flag #102

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 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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