summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-14 22:43:43 +0800
committerruki <[email protected]>2020-12-14 22:43:43 +0800
commita6f93e44186006e0ee73450937608ec24fef192e (patch)
tree9bbadaeda9edc14f713c9bd284ddec922b791b05
parent4030bf655cd5bbf3af26b682078f4354eb2cb86c (diff)
add multivs tests
-rw-r--r--tests/apis/toolchain_multivs/.gitignore8
-rw-r--r--tests/apis/toolchain_multivs/src/main.cpp9
-rw-r--r--tests/apis/toolchain_multivs/src/test.asm1
-rw-r--r--tests/apis/toolchain_multivs/src/test.rc0
-rw-r--r--tests/apis/toolchain_multivs/test.lua7
-rw-r--r--tests/apis/toolchain_multivs/xmake.lua18
-rw-r--r--xmake/core/project/target.lua2
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/cache.lua4
-rw-r--r--xmake/core/tool/toolchain.lua7
9 files changed, 46 insertions, 10 deletions
diff --git a/tests/apis/toolchain_multivs/.gitignore b/tests/apis/toolchain_multivs/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/tests/apis/toolchain_multivs/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/tests/apis/toolchain_multivs/src/main.cpp b/tests/apis/toolchain_multivs/src/main.cpp
new file mode 100644
index 000000000..7c435d251
--- /dev/null
+++ b/tests/apis/toolchain_multivs/src/main.cpp
@@ -0,0 +1,9 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "hello world!" << endl;
+ return 0;
+}
diff --git a/tests/apis/toolchain_multivs/src/test.asm b/tests/apis/toolchain_multivs/src/test.asm
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/apis/toolchain_multivs/src/test.asm
@@ -0,0 +1 @@
+
diff --git a/tests/apis/toolchain_multivs/src/test.rc b/tests/apis/toolchain_multivs/src/test.rc
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/apis/toolchain_multivs/src/test.rc
diff --git a/tests/apis/toolchain_multivs/test.lua b/tests/apis/toolchain_multivs/test.lua
new file mode 100644
index 000000000..795df5c95
--- /dev/null
+++ b/tests/apis/toolchain_multivs/test.lua
@@ -0,0 +1,7 @@
+function test_multivs(t)
+ if is_subhost("windows") then
+ t:build()
+ else
+ return t:skip("wrong host platform")
+ end
+end
diff --git a/tests/apis/toolchain_multivs/xmake.lua b/tests/apis/toolchain_multivs/xmake.lua
new file mode 100644
index 000000000..4e61a20a1
--- /dev/null
+++ b/tests/apis/toolchain_multivs/xmake.lua
@@ -0,0 +1,18 @@
+add_rules("mode.debug", "mode.release")
+
+rule("vs2015_x86")
+ before_load(function (target)
+ target:set("arch", "x86")
+ target:set("toolchains", "msvc", {vs = "2015"})
+ end)
+
+target("testvs_vs2015_x86")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.rc")
+ add_rules("vs2015_x86")
+
+target("testvs")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.rc")
+
+
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index dab501131..bb6516767 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1745,7 +1745,7 @@ function _instance:tool(toolkind)
end
-- get tool program
- local key = toolkind .. "_" .. self:plat() .. "_" .. self:arch()
+ local key = self:name() .. "_" .. toolkind .. "_" .. self:plat() .. "_" .. self:arch()
local program, toolname, toolchain_info
local toolinfo = tools[key]
if toolinfo == nil then
diff --git a/xmake/core/sandbox/modules/import/lib/detect/cache.lua b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
index de2468bf9..f4eb7445d 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/cache.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
@@ -34,8 +34,6 @@ local raise = require("sandbox/modules/raise")
-- get detect cache instance
function sandbox_lib_detect_cache._instance()
-
- -- get it
local detectcache = sandbox_lib_detect_cache._INSTANCE or cache(os.isfile(project.rootfile()) and "local.detect" or "memory.detect")
sandbox_lib_detect_cache._INSTANCE = detectcache
return detectcache
@@ -56,8 +54,6 @@ function sandbox_lib_detect_cache.load(name)
cacheinfo = {}
detectcache:set(name, cacheinfo)
end
-
- -- ok?
return cacheinfo
end
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index 8775090a3..adb17c865 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -352,12 +352,9 @@ function _instance:_checktool(toolkind, toolpath)
end
end
- -- init cache key
- local cachekey = "toolchain_" .. self:plat() .. "_" .. self:arch()
-
-- find tool program
local program, toolname
- local tool = find_tool(toolpath, {cachekey = cachekey, program = toolpath, paths = self:bindir(), envs = self:get("runenvs")})
+ local tool = find_tool(toolpath, {cachekey = self:cachekey(), program = toolpath, paths = self:bindir(), envs = self:get("runenvs")})
if tool then
program = tool.program
toolname = tool.name
@@ -406,7 +403,7 @@ end
function toolchain._cachekey(name, opt)
local cachekey = opt.cachekey
if not cachekey then
- cachekey = name
+ cachekey = "toolchain_" .. name
for _, k in ipairs(table.orderkeys(opt)) do
local v = opt[k]
cachekey = cachekey .. "_" .. k .. "_" .. tostring(v)