aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-02 00:52:30 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commitc206fd07db07dc6271185dabac822e10d78b4443 (patch)
tree91d3608a7a5abfb39a1e96a3c8926270c40e759f /backend
parent3e401d97546fe407ca72e9766cbdbb9c9212091e (diff)
Add sibs package command
Currently in testing phase. Builds a redistributable binary by statically linking libraries (including standard library).
Diffstat (limited to 'backend')
-rw-r--r--backend/ninja/Ninja.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index 53b1667..943e090 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -316,8 +316,8 @@ namespace backend
vector<PackageListDependency*> pkgConfigDependencies;
for(PackageListDependency *dependency : packageListDependencies)
{
- Result<bool> pkgConfigDependencyValidation = PkgConfig::validatePkgConfigPackageVersionExists(dependency);
- if(pkgConfigDependencyValidation.isOk())
+ // PkgConfig libraries, even the static ones are most likely not built statically against libgcc/libc++, so we don't use them
+ if(!config.packaging && PkgConfig::validatePkgConfigPackageVersionExists(dependency))
{
pkgConfigDependencies.push_back(dependency);
}
@@ -662,6 +662,11 @@ namespace backend
string generatedZigHeaderDirUtf8 = toUtf8(generatedZigHeadersDir);
LibraryType libraryType = getNinjaLibraryType(config.getPackageType());
+ // TODO: Instead of statically linking everything, maybe we should build everything as they prefer to be built
+ // and then copy the files if they are shared libraries to the same directory as the root project executable
+ // so they can be packaged into an archive that can be distributed?
+ if(config.packaging && !config.isMainProject())
+ libraryType = LibraryType::STATIC;
string savePathUtf8 = toUtf8(savePath);
string projectPathUtf8 = toUtf8(config.getProjectPath());
@@ -1077,6 +1082,23 @@ namespace backend
objectNames.emplace_back(move(objectName));
}
+ if(config.packaging)
+ {
+ switch(config.getCompiler())
+ {
+ case Compiler::GCC:
+ {
+ allLinkerFlags += " -static-libgcc -static-libstdc++";
+ break;
+ }
+ case Compiler::MSVC:
+ {
+ // We always statically link using /MT so there is no need to do it here
+ break;
+ }
+ }
+ }
+
// TODO: For now zig projects (zig object files) are built with c/c++ compiler,
// they should be built with zig if project only contains zig files.
// But how to combine object files with zig? build-exe only wants to accept .zig files