Skip to content

Commit

Permalink
fix trybuild/msbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Mar 12, 2024
1 parent f35a5e0 commit 1448c9a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions xmake/modules/private/action/trybuild/msbuild.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 1448c9a

Please sign in to comment.