From d128790d6b9aa7809461eecd3d3e05cc1744742b Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 31 Dec 2017 08:16:41 +0100 Subject: Add static linking for msvc --- backend/ninja/Ninja.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'backend/ninja') diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index b6314f0..db7394a 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -484,15 +484,31 @@ namespace backend } case LibraryType::STATIC: { - // TODO: Write equivalent code for msvc - result += "rule cpp_COMPILER\n"; - result += " command = ccache c++ $ARGS -c -fPIC $in -o $out\n\n"; - - result += "rule cpp_BUILD_STATIC\n"; - result += " command = ar rcs lib"; - result += config.getPackageName(); - result += ".a"; - result += " $in\n\n"; + switch (config.getCompiler()) + { + case Compiler::GCC: + { + result += "rule cpp_COMPILER\n"; + result += " command = ccache c++ $ARGS -c -fPIC $in -o $out\n\n"; + + result += "rule cpp_BUILD_STATIC\n"; + result += " command = ar rcs lib"; + result += config.getPackageName(); + result += ".a"; + result += " $in\n\n"; + break; + } + case Compiler::MSVC: + { + result += "rule cpp_COMPILER\n"; + result += " command = cl.exe $ARGS /c $in /Fo$out\n\n"; + + result += "rule cpp_BUILD_STATIC\n"; + result += " command = lib.exe /OUT:$out $in\n\n"; + break; + } + } + buildJob = "cpp_BUILD_STATIC"; break; } -- cgit v1.2.3