summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-12 23:21:08 +0800
committerruki <[email protected]>2024-03-12 23:21:08 +0800
commit1448c9aeefe9ab76c6e17a348e5bf69e7676e3b1 (patch)
tree6060d18f943bd88bf91599a61e285cadc8e15147
parentf35a5e08721df2c61905e4258a5fb4a2f7295356 (diff)
fix trybuild/msbuild
-rw-r--r--xmake/modules/private/action/trybuild/msbuild.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/xmake/modules/private/action/trybuild/msbuild.lua b/xmake/modules/private/action/trybuild/msbuild.lua
index 245c3b6b3..c09a178af 100644
--- a/xmake/modules/private/action/trybuild/msbuild.lua
+++ b/xmake/modules/private/action/trybuild/msbuild.lua
@@ -25,18 +25,24 @@ import("core.tool.toolchain")
import("lib.detect.find_file")
import("lib.detect.find_tool")
+-- find project file
+function _find_projectfile()
+ return find_file("*.sln", os.curdir())
+end
+
-- detect build-system and configuration file
function detect()
if is_subhost("windows") then
- return find_file("*.sln", os.curdir())
+ return _find_projectfile()
end
end
-- do clean
function clean()
+ local projectfile = _find_projectfile()
local runenvs = toolchain.load("msvc"):runenvs()
local msbuild = find_tool("msbuild", {envs = runenvs})
- os.vexecv(msbuild.program, {configfile, "-nologo", "-t:Clean", "-p:Configuration=Release", "-p:Platform=" .. (is_arch("x64") and "x64" or "Win32")}, {envs = runenvs})
+ os.vexecv(msbuild.program, {projectfile, "-nologo", "-t:Clean", "-p:Configuration=Release", "-p:Platform=" .. (is_arch("x64") and "x64" or "Win32")}, {envs = runenvs})
end
-- do build
@@ -46,9 +52,9 @@ function build()
assert(is_subhost(config.plat()), "msbuild: %s not supported!", config.plat())
-- do build
- local configfile = find_file("*.sln", os.curdir())
+ local projectfile = _find_projectfile()
local runenvs = toolchain.load("msvc"):runenvs()
local msbuild = find_tool("msbuild", {envs = runenvs})
- os.vexecv(msbuild.program, {configfile, "-nologo", "-t:Build", "-p:Configuration=Release", "-p:Platform=" .. (is_arch("x64") and "x64" or "Win32")}, {envs = runenvs})
+ os.vexecv(msbuild.program, {projectfile, "-nologo", "-t:Build", "-p:Configuration=Release", "-p:Platform=" .. (is_arch("x64") and "x64" or "Win32")}, {envs = runenvs})
cprint("${color.success}build ok!")
end