From 12de0a5d9e4ffe14950d90a1aaf05f006dc3af5f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 21 Sep 2018 11:00:01 +0200 Subject: Only define libraries for zig build if running tests --- backend/ninja/Ninja.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index fc1142b..e71b22a 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -863,6 +863,8 @@ namespace backend } } + bool zigTest = (config.zigTestAllFiles || !config.zigTestFiles.empty()); + vector cLanguageVersionFlags = getLanguageVersionFlag(config.getCompiler(), config.getCversion()); compileCCommand.insert(compileCCommand.end(), cLanguageVersionFlags.begin(), cLanguageVersionFlags.end()); @@ -885,8 +887,6 @@ namespace backend // TODO: Find a way to do this more efficiently vector cflagsIncludes = convertCFlagsIncludesToZigIncludes(config.getCompiler(), cflags); - vector zigLibraryFlags = convertCLibrariesToZigLibraries(config.getCompiler(), allLinkerFlags); - vector compileZigArgs = { ninja::NinjaArg::createRaw("zig build-obj"), ninja::NinjaArg::createRaw("$in"), @@ -896,11 +896,16 @@ namespace backend ninja::NinjaArg::createRaw("--library c"), // TODO: Remove this if project does not depend on c libraries or project only has .zig files ninja::NinjaArg::createRaw("$globalIncDirZig") }; - // TODO: Verify if we really need to add all libraries for every object file + compileZigArgs.insert(compileZigArgs.end(), cflagsIncludes.begin(), cflagsIncludes.end()); - compileZigArgs.insert(compileZigArgs.end(), zigLibraryFlags.begin(), zigLibraryFlags.end()); zigTestArgs.insert(zigTestArgs.end(), cflagsIncludes.begin(), cflagsIncludes.end()); - zigTestArgs.insert(zigTestArgs.end(), zigLibraryFlags.begin(), zigLibraryFlags.end()); + + if(zigTest) + { + // TODO: Verify if we really need to add all libraries for every object file + vector zigLibraryFlags = convertCLibrariesToZigLibraries(config.getCompiler(), allLinkerFlags); + zigTestArgs.insert(zigTestArgs.end(), zigLibraryFlags.begin(), zigLibraryFlags.end()); + } if(config.getOptimizationLevel() == sibs::OPT_LEV_RELEASE) { @@ -926,7 +931,6 @@ namespace backend bool usesCFiles = false; bool usesCppFiles = false; - bool zigTest = (config.zigTestAllFiles || !config.zigTestFiles.empty()); vector objectNames; objectNames.reserve(sourceFiles.size()); -- cgit v1.2.3