diff options
| author | ruki <[email protected]> | 2018-04-28 17:29:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-04-28 17:29:37 +0800 |
| commit | a896aa649265af0f7a73e7c8a1b428fb342fad87 (patch) | |
| tree | b2af34bc470e0a21bae87412323eddf8bf0e6318 | |
| parent | a39107c492d254b4b2c26be69956c61a42e21702 (diff) | |
impl find_wdk
| -rw-r--r-- | xmake/modules/detect/sdks/find_wdk.lua | 37 | ||||
| -rw-r--r-- | xmake/platforms/windows/xmake.lua | 26 |
2 files changed, 45 insertions, 18 deletions
diff --git a/xmake/modules/detect/sdks/find_wdk.lua b/xmake/modules/detect/sdks/find_wdk.lua index c05925946..65c775568 100644 --- a/xmake/modules/detect/sdks/find_wdk.lua +++ b/xmake/modules/detect/sdks/find_wdk.lua @@ -30,30 +30,53 @@ import("core.base.global") import("core.project.config") -- find WDK directory -function _find_sdkdir(sdkdir, sdkver) +function _find_sdkdir(sdkdir) + -- get sdk directory from vsvars + if not sdkdir then + local arch = config.arch() + local vcvarsall = config.get("__vcvarsall") + if vcvarsall then + sdkdir = (vcvarsall[arch] or {}).WindowsSdkDir + end + end + return sdkdir end -- find WDK toolchains function _find_wdk(sdkdir, sdkver) -- find wdk directory - sdkdir = _find_sdkdir(sdkdir, sdkver) + sdkdir = _find_sdkdir(sdkdir) if not sdkdir or not os.isdir(sdkdir) then return nil end + -- get sdk version + if not sdkver then + local vers = {} + for _, dir in ipairs(os.dirs(path.join(sdkdir, "Include", "**", "km"))) do + table.insert(vers, path.filename(path.directory(dir))) + end + for _, ver in ipairs(vers) do + if os.isdir(path.join(sdkdir, "Lib", ver, "km")) and os.isdir(path.join(sdkdir, "Lib", ver, "um")) and os.isdir(path.join(sdkdir, "Include", ver, "um")) then + sdkver = ver + break + end + end + end + if not sdkver then + return nil + end + -- get the bin directory local bindir = path.join(sdkdir, "bin") -- get linkdirs - local linkdirs = {path.join(sdkdir, "lib")} + local linkdirs = {path.join(sdkdir, "Lib", sdkver)} -- get includedirs - local includedirs = {path.join(sdkdir, "include")} - - -- get sdk version - sdkver = sdkver or sdkdir:match("(%d+%.?%d*%.?%d*.-)") + local includedirs = {path.join(sdkdir, "Include", sdkver)} -- get toolchains return {sdkdir = sdkdir, bindir = bindir, linkdirs = linkdirs, includedirs = includedirs, sdkver = sdkver} diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index f17c4ef7e..4d8680e26 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -89,21 +89,25 @@ platform("windows") set_menu { config = { - {category = "Visual Studio SDK Configuration" } - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , {category = "Cuda SDK Configuration" } - , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } - , {category = "Qt SDK Configuration" } - , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } - , {nil, "qt_sdkver","kv", "auto", "The Qt SDK Version" } + {category = "Visual Studio SDK Configuration" } + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } + , {category = "Cuda SDK Configuration" } + , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } + , {category = "Qt SDK Configuration" } + , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } + , {category = "WDK Configuration" } + , {nil, "wdk", "kv", "auto", "The WDK Directory" } + , {nil, "wdk_sdkver","kv", "auto", "The WDK Version" } } , global = { - { } - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } - , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + { } + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } + , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } + , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "wdk", "kv", "auto", "The WDK Directory" } } } |
