diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/ninja/Ninja.cpp | 26 |
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 |