-
-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support custom vc build tools #5823
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -97,6 +97,62 @@ function get_vcvars() | |||
return realvcvars | ||||
end | ||||
|
||||
function load_custom_vcenv(opt) | ||||
opt = opt or {} | ||||
|
||||
if opt.bat and os.isfile(opt.bat) then | ||||
local file = io.readfile(opt.bat) | ||||
if file then | ||||
local variables = {} | ||||
for line in file:gmatch("[^\r\n]+") do | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file:lines() |
||||
local key, value = line:match("set%s+(.-)=(.*)") | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为啥不走运行捕获 envs,至少稳定可靠。
直接语法解析 set,不太稳吧。如果 set 是在 if 分支里呢,怎么判断取到的当前有效值 |
||||
if key and value then | ||||
value = value:gsub("%%%{(.-)%}", variables) | ||||
if value == "%~dp0" then | ||||
value = path.directory(opt.bat) .. "\\" | ||||
else | ||||
for match in value:gmatch("%%(.-)%%") do | ||||
value = value:gsub("%%" .. match .. "%%", variables[match] or "") | ||||
end | ||||
end | ||||
variables[key] = value | ||||
end | ||||
end | ||||
|
||||
for _, name in ipairs(vcvars) do | ||||
if variables[name] and #variables[name]:trim() == 0 then | ||||
variables[name] = nil | ||||
end | ||||
end | ||||
|
||||
local vcvarsall = {} | ||||
if not variables["VCToolsVersion"] then | ||||
variables.VCToolsVersion = path.filename(variables["VCToolsInstallDir"]) | ||||
end | ||||
vcvarsall[variables["VSCMD_ARG_TGT_ARCH"]] = variables | ||||
return vcvarsall | ||||
end | ||||
end | ||||
|
||||
-- TODO: custom search | ||||
local vs_build_tools = opt.vs_build_tools | ||||
if vs_build_tools then | ||||
local VCToolsInstallDir | ||||
local VCToolsInstallDirs = os.dirs(path.join(vs_build_tools, "VC/Tools/MSVC/*")) | ||||
for _, ver in ipairs(VCToolsInstallDirs) do | ||||
if ver == opt.vs_toolset then | ||||
VCToolsInstallDir = ver | ||||
end | ||||
end | ||||
|
||||
if not VCToolsInstallDir and #VCToolsInstallDirs ~= 0 then | ||||
VCToolsInstallDir = VCToolsInstallDirs[1] | ||||
end | ||||
|
||||
local WindowsSDKDir = path.join(vs_build_tools, "Windows Kits/10") | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 没用到的代码 暂时去掉 |
||||
end | ||||
end | ||||
|
||||
-- load vcvarsall environment variables | ||||
function _load_vcvarsall(vcvarsall, vsver, arch, opt) | ||||
opt = opt or {} | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ platform("windows") | |
, " e.g. --vs_sdkver=10.0.15063.0" } | ||
, {nil, "vs_runtime", "kv", nil, "The Runtime library of Visual Studio (deprecated, please use --runtimes)" | ||
, values = {"MT", "MTd", "MD", "MDd"} } | ||
, {nil, "vc_bat", "kv", nil, "The BuildTools bat file" | ||
, " e.g. --vc_bat=C:/BuildTools/devcmd.bat" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 改成 vs_devcmd 。。统一用 vs_ 前缀 |
||
, {category = "Cuda SDK Configuration" } | ||
, {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } | ||
, {category = "Qt SDK Configuration" } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成 opt.devcmd