aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/ninja/Ninja.cpp13
-rw-r--r--include/Conf.hpp4
-rw-r--r--src/main.cpp9
3 files changed, 18 insertions, 8 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index d2465b4..54b86d1 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -396,9 +396,10 @@ namespace backend
}
case OPT_LEV_RELEASE:
{
- std::vector<ninja::NinjaArg> result = { ninja::NinjaArg::createRaw("-O3 -g0 -DNDEBUG") };
+ std::vector<ninja::NinjaArg> result = { ninja::NinjaArg::createRaw("-O3 -DNDEBUG") };
if(config.use_lto)
result.push_back(ninja::NinjaArg::createRaw("-flto"));
+ result.push_back(ninja::NinjaArg::createRaw(config.include_debug_symbols_in_release ? "-g3" : "-g0"));
return result;
}
}
@@ -1125,10 +1126,9 @@ namespace backend
if(config.getOptimizationLevel() == sibs::OPT_LEV_RELEASE)
{
// TODO: Specify a way to change these options, either in project.conf or argument to sibs build
- commonZigArgs.insert(commonZigArgs.end(), {
- ninja::NinjaArg::createRaw("--release-safe"),
- ninja::NinjaArg::createRaw("--strip")
- });
+ commonZigArgs.push_back(ninja::NinjaArg::createRaw("--release-safe"));
+ if(!config.include_debug_symbols_in_release)
+ commonZigArgs.push_back(ninja::NinjaArg::createRaw("--strip"));
}
zigTestArgs.insert(zigTestArgs.end(), commonZigArgs.begin(), commonZigArgs.end());
@@ -1356,7 +1356,8 @@ namespace backend
else if(config.getOptimizationLevel() == OPT_LEV_RELEASE)
{
// Strip binary
- buildExeArgs.push_back(ninja::NinjaArg::createRaw("-s"));
+ if(!config.include_debug_symbols_in_release)
+ buildExeArgs.push_back(ninja::NinjaArg::createRaw("-s"));
}
if(config.use_lto)
diff --git a/include/Conf.hpp b/include/Conf.hpp
index cfe0133..a93b44f 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -231,7 +231,8 @@ namespace sibs
packaging(false),
bundling(false),
platform(SYSTEM_PLATFORM),
- use_lto(false)
+ use_lto(false),
+ include_debug_symbols_in_release(false)
{
cmakeDirGlobal = projectPath;
switch(optimizationLevel)
@@ -426,6 +427,7 @@ namespace sibs
PackageVersion version;
Platform platform;
bool use_lto;
+ bool include_debug_symbols_in_release;
std::vector<std::string> includeDirs;
std::vector<std::string> exposeIncludeDirs;
std::vector<std::string> ignoreDirs;
diff --git a/src/main.cpp b/src/main.cpp
index a1136c4..5c3ad8c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -136,7 +136,8 @@ static void usageBuild(bool run)
printf(" --debug|--release Optimization level to build project and dependencies with (if not a system package) - Optional (default: --debug)\n");
printf(" --sanitize Add runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: none)\n");
printf(" --platform The platform to build for - Optional (default: the running platform)\n");
- printf(" --lto Use link-time optimization. May increase compile times - Optional (default: false)\n");
+ printf(" --lto Use link-time optimization. May increase compile times - Optional (default: not used)\n");
+ printf(" --debug-symbols Include debug symbols in release mode - Optional (default: not used)\n");
printf("Examples:\n");
printf(" sibs %s\n", run ? "run" : "build");
if(run)
@@ -492,6 +493,7 @@ static int buildProject(int argc, const _tinydir_char_t **argv, bool run)
Sanitize sanitize = Sanitize::NONE;
FileString platformName;
bool use_lto = false;
+ bool include_debug_symbols_in_release = false;
std::vector<FileString> run_args;
for(int i = 0; i < argc; ++i)
@@ -519,6 +521,10 @@ static int buildProject(int argc, const _tinydir_char_t **argv, bool run)
{
use_lto = true;
}
+ else if(_tinydir_strcmp(arg, TINYDIR_STRING("--debug-symbols")) == 0)
+ {
+ include_debug_symbols_in_release = true;
+ }
else if(_tinydir_strncmp(arg, TINYDIR_STRING("--sanitize="), 11) == 0)
{
sanitize = sanitize_string_to_type(arg + 11);
@@ -627,6 +633,7 @@ static int buildProject(int argc, const _tinydir_char_t **argv, bool run)
sibsConfig.platform = platform;
sibsConfig.setSanitize(sanitize);
sibsConfig.use_lto = use_lto;
+ sibsConfig.include_debug_symbols_in_release = include_debug_symbols_in_release;
return buildProject(projectPath, projectConfFilePath, sibsConfig, run, run_args);
}