Browse Source

improve vs runtime

ruki 4 years ago
parent
commit
a43151eb99
3 changed files with 18 additions and 3 deletions
  1. 3 2
      .github/workflows/windows.yml
  2. 11 1
      packages/f/fmt/xmake.lua
  3. 4 0
      scripts/test.lua

+ 3 - 2
.github/workflows/windows.yml

@@ -11,6 +11,7 @@ jobs:
         os: [windows-latest]
         kind: [static, shared]
         arch: [x64, x86]
+        vs_runtime: [MT, MD]
 
     runs-on: ${{ matrix.os }}
 
@@ -18,9 +19,9 @@ jobs:
       - uses: actions/checkout@v1
       - uses: xmake-io/github-action-setup-xmake@v1
         with:
-          xmake-version: branch@dev
+          xmake-version: branch@cache
 
       - name: Tests
         run: |
-          xmake l ./scripts/test.lua -D -a ${{ matrix.arch }} -k ${{ matrix.kind }} --vs_sdkver=10.0.19041.0
+          xmake l ./scripts/test.lua -D -a ${{ matrix.arch }} -k ${{ matrix.kind }} --vs_runtime=${{ matrix.vs_runtime }} --vs_sdkver=10.0.19041.0
 

+ 11 - 1
packages/f/fmt/xmake.lua

@@ -30,7 +30,17 @@ package("fmt")
         io.gsub("CMakeLists.txt", "MASTER_PROJECT AND CMAKE_GENERATOR MATCHES \"Visual Studio\"", "0")
         local configs = {"-DFMT_TEST=OFF", "-DFMT_DOC=OFF", "-DFMT_FUZZ=OFF"}
         if package:is_plat("windows") then
-            table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" .. (package:debug() and "Debug" or "") .. (package:config("vs_runtime"):startswith("MT") and "" or "DLL"))
+            -- TODO we will remove it after xmake/2.5.1
+            local vs_runtime = package:config("vs_runtime")
+            if vs_runtime == "MT" then
+                table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded")
+            elseif vs_runtime == "MTd" then
+                table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug")
+            elseif vs_runtime == "MD" then
+                table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL")
+            elseif vs_runtime == "MDd" then
+                table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL")
+            end
         end
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))

+ 4 - 0
scripts/test.lua

@@ -19,6 +19,7 @@ local options =
 ,   {nil, "ndk",        "kv", nil, "Set the android NDK directory."             }
 ,   {nil, "sdk",        "kv", nil, "Set the SDK directory of cross toolchain."  }
 ,   {nil, "vs_sdkver",  "kv", nil, "Set the Windows SDK version."               }
+,   {nil, "vs_runtime", "kv", nil, "Set the VS Runtime library."                }
 ,   {nil, "mingw",      "kv", nil, "Set the MingW directory."                   }
 ,   {nil, "toolchain",  "kv", nil, "Set the toolchain name."                    }
 ,   {nil, "packages",   "vs", nil, "The package list."                          }
@@ -52,6 +53,9 @@ function _require_packages(argv, packages)
     if argv.vs_sdkver then
         table.insert(config_argv, "--vs_sdkver=" .. argv.vs_sdkver)
     end
+    if argv.vs_runtime then
+        table.insert(config_argv, "--vs_runtime=" .. argv.vs_runtime)
+    end
     if argv.mingw then
         table.insert(config_argv, "--mingw=" .. argv.mingw)
     end