improve msvc (#5827)

* improve msvc

* fix deps

* improve tips
pull/5826/merge
ruki 5 days ago committed by GitHub
parent be2efcfb75
commit 83c421954e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 45
      packages/m/msvc/xmake.lua

@ -31,7 +31,7 @@ package("msvc")
on_load(function (package)
if not package:is_precompiled() then
if is_host("windows") then
package:add("deps", "portablebuildtools")
package:add("deps", "portable_build_tools")
elseif is_host("linux") then
-- TODO use msvc-wine
end
@ -52,22 +52,35 @@ package("msvc")
on_install("@windows", "@msys", function (package)
import("core.base.semver")
local argv = {"accept_license"}
local sdkver = semver.new(package:config("sdkver") or "10.0.26100")
if package:config("preview") then
table.insert(argv, "preview")
end
table.insert(argv, "msvc=" .. package:version_str():replace("+", ".", {plain = true}))
table.insert(argv, "sdk=" .. sdkver:patch())
table.insert(argv, "host=" .. os.arch())
table.insert(argv, "env=none")
table.insert(argv, "path=" .. package:installdir())
table.insert(argv, "target=" .. (package:config("target") or os.arch()))
-- @note It downloads the official binary source
-- https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/
-- https://github.com/Data-Oriented-House/PortableBuildTools/blob/3a2cd42b1de75da63ad30a55982d8dff3c36aa45/source.c#L724
os.vrunv("PortableBuildTools.exe", argv)
-- get confirm result
local result = utils.confirm({description = function ()
cprint("${bright color.warning}note: ${clear}Do you accept the license agreement for installing msvc build toolchain?")
cprint(" https://go.microsoft.com/fwlink/?LinkId=2179911")
end, answer = function ()
cprint("please input: ${bright}y${clear} (y/n)")
io.flush()
return (io.read() or "n"):trim()
end})
if result and result ~= "n" then
local argv = {"accept_license"}
local sdkver = semver.new(package:config("sdkver") or "10.0.26100")
if package:config("preview") then
table.insert(argv, "preview")
end
table.insert(argv, "msvc=" .. package:version_str():replace("+", ".", {plain = true}))
table.insert(argv, "sdk=" .. sdkver:patch())
table.insert(argv, "host=" .. os.arch())
table.insert(argv, "env=none")
table.insert(argv, "path=" .. package:installdir())
table.insert(argv, "target=" .. (package:config("target") or os.arch()))
-- @note It downloads the official binary source
-- https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/
-- https://github.com/Data-Oriented-House/PortableBuildTools/blob/3a2cd42b1de75da63ad30a55982d8dff3c36aa45/source.c#L724
os.vrunv("PortableBuildTools.exe", argv)
end
end)
on_test(function (package)

Loading…
Cancel
Save