diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/ninja/Ninja.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 6d871fd..530dffe 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -119,26 +119,7 @@ namespace backend } return result; } - - string getCompileWithoutLinkingFlag(Compiler compiler) - { - string result; - switch (compiler) - { - case Compiler::GCC: - { - result = "-c"; - break; - } - case Compiler::MSVC: - { - result = "/c"; - break; - } - } - return result; - } - + string getObjectFileNameFlag(Compiler compiler, const string &objectFileName) { string result; @@ -496,12 +477,15 @@ namespace backend case Compiler::GCC: { result += "rule cpp_COMPILER\n"; + result += " depfile = $out.d\n"; result += " command = ccache c++ $ARGS -c $in -o $out\n\n"; result += "rule cpp_BUILD_EXEC\n"; + result += " depfile = $out.d\n"; result += " command = ccache c++ $ARGS -o $out $in $LINK_ARGS $aliasing\n\n"; result += "rule c_COMPILER\n"; + result += " depfile = $out.d\n"; result += " command = ccache cc $ARGS -c $in -o $out\n\n"; break; } @@ -529,6 +513,7 @@ namespace backend case Compiler::GCC: { result += "rule cpp_COMPILER\n"; + result += " depfile = $out.d\n"; result += " command = ccache c++ $ARGS -c -fPIC $in -o $out\n\n"; result += "rule cpp_BUILD_STATIC\n"; @@ -538,6 +523,7 @@ namespace backend result += " $in\n\n"; result += "rule c_COMPILER\n"; + result += " depfile = $out.d\n"; result += " command = ccache cc $ARGS -c -fPIC $in -o $out\n\n"; break; } @@ -565,13 +551,16 @@ namespace backend case Compiler::GCC: { result += "rule cpp_COMPILER\n"; + result += " depfile = $out.d\n"; result += " command = ccache c++ $ARGS -c -fPIC $in -o $out\n\n"; // --whole-archive result += "rule cpp_BUILD_DYNAMIC\n"; + result += " depfile = $out.d\n"; result += " command = ccache c++ $in -shared -o $out $LINK_ARGS $aliasing\n\n"; result += "rule c_COMPILER\n"; + result += " depfile = $out.d\n"; result += " command = ccache cc $ARGS -c -fPIC $in -o $out\n\n"; break; } @@ -690,7 +679,9 @@ namespace backend case Compiler::GCC: { // -Werror - result += " '-I" + config.getPackageName() + "@exe' " + cflags + " '-I..' -Wall -Wextra -Werror=return-type -fdiagnostics-show-option '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Winvalid-pch' -fstack-protector " + optimizationFlags; + // TODO: Find equivalent -MMD -MP for other compilers than gcc. MMD is used to create "dependency files" -> if headers are modified then source files will be recompiled + // when compiling next time... + result += " -MMD -MP '-I" + config.getPackageName() + "@exe' " + cflags + " '-I..' -Wall -Wextra -Werror=return-type -fdiagnostics-show-option '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Winvalid-pch' -fstack-protector " + optimizationFlags; if(sourceFileLanguage == SourceFileLanguage::CPP) { result += " -fexceptions -Wnon-virtual-dtor"; |