summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorstar9029 <[email protected]>2024-11-14 18:33:37 +0800
committerstar9029 <[email protected]>2024-11-14 18:33:37 +0800
commitef7e37c8833d59455a7d30d7b7b244e3e230ea1d (patch)
tree81814b4617c37c687cb616810dde899f86727e4c /xmake/modules
parent2c9034a9c7b6e567ba6f23089323d4908519d547 (diff)
Support custom vc build tools
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index b58e9cb91..b0a085547 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -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
+ local key, value = line:match("set%s+(.-)=(.*)")
+ 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")
+ end
+end
+
-- load vcvarsall environment variables
function _load_vcvarsall(vcvarsall, vsver, arch, opt)
opt = opt or {}