summaryrefslogtreecommitdiff
path: root/xmake/platforms
diff options
context:
space:
mode:
authorruki <[email protected]>2018-12-19 22:48:13 +0800
committerruki <[email protected]>2018-12-19 10:49:18 +0800
commit1758e5f01e5684bf8da0187bb5b6ee7ac93fd4e6 (patch)
treee5879bdf6d8f98432fd0e34912864b6b57998f6e /xmake/platforms
parent998aedba0b07b6b7605272b99e6dc0d59e5c8ac6 (diff)
improve mingw
Diffstat (limited to 'xmake/platforms')
-rw-r--r--xmake/platforms/cross/check.lua8
-rw-r--r--xmake/platforms/cross/load.lua10
-rw-r--r--xmake/platforms/linux/check.lua4
-rw-r--r--xmake/platforms/linux/load.lua10
-rw-r--r--xmake/platforms/mingw/check.lua52
-rw-r--r--xmake/platforms/mingw/load.lua7
-rw-r--r--xmake/platforms/mingw/xmake.lua14
7 files changed, 61 insertions, 44 deletions
diff --git a/xmake/platforms/cross/check.lua b/xmake/platforms/cross/check.lua
index 0508eae17..90592b3a5 100644
--- a/xmake/platforms/cross/check.lua
+++ b/xmake/platforms/cross/check.lua
@@ -46,17 +46,17 @@ function _toolchains(config)
-- find cross toolchain
local cross = ""
- local toolchain = find_cross_toolchain(config.get("sdk") or config.get("bin"), {bin = config.get("bin"), cross = config.get("cross")})
+ local toolchain = find_cross_toolchain(config.get("sdk") or config.get("bin"), {bindir = config.get("bin"), cross = config.get("cross")})
if toolchain then
-- save toolchain
config.set("cross", toolchain.cross, {readonly = true, force = true})
- config.set("bin", toolchain.bin, {readonly = true, force = true})
+ config.set("bin", toolchain.bindir, {readonly = true, force = true})
cross = toolchain.cross
-- add bin search library for loading some dependent .dll files windows
- if toolchain.bin and is_host("windows") then
- os.addenv("PATH", toolchain.bin)
+ if toolchain.bindir and is_host("windows") then
+ os.addenv("PATH", toolchain.bindir)
end
end
diff --git a/xmake/platforms/cross/load.lua b/xmake/platforms/cross/load.lua
index 576925931..2869541a1 100644
--- a/xmake/platforms/cross/load.lua
+++ b/xmake/platforms/cross/load.lua
@@ -31,8 +31,14 @@ function main(platform)
-- init linkdirs and includedirs
local sdkdir = config.get("sdk")
if sdkdir then
- platform:add("includedirs", path.join(sdkdir, "include"))
- platform:add("linkdirs", path.join(sdkdir, "lib"))
+ local includedir = path.join(sdkdir, "include")
+ if os.isdir(includedir) then
+ platform:add("includedirs", includedir)
+ end
+ local linkdir = path.join(sdkdir, "lib")
+ if os.isdir(linkdir) then
+ platform:add("linkdirs", linkdir)
+ end
end
-- add bin search library for loading some dependent .dll files windows
diff --git a/xmake/platforms/linux/check.lua b/xmake/platforms/linux/check.lua
index 87a225eec..b226ab206 100644
--- a/xmake/platforms/linux/check.lua
+++ b/xmake/platforms/linux/check.lua
@@ -51,10 +51,10 @@ function _toolchains(config)
-- find cross toolchain
local cross = ""
- local toolchain = find_cross_toolchain(config.get("sdk") or config.get("bin"), {bin = config.get("bin"), cross = config.get("cross")})
+ local toolchain = find_cross_toolchain(config.get("sdk") or config.get("bin"), {bindir = config.get("bin"), cross = config.get("cross")})
if toolchain then
config.set("cross", toolchain.cross, {readonly = true, force = true})
- config.set("bin", toolchain.bin, {readonly = true, force = true})
+ config.set("bin", toolchain.bindir, {readonly = true, force = true})
cross = toolchain.cross
end
diff --git a/xmake/platforms/linux/load.lua b/xmake/platforms/linux/load.lua
index e6af9a61a..72e48e096 100644
--- a/xmake/platforms/linux/load.lua
+++ b/xmake/platforms/linux/load.lua
@@ -34,8 +34,14 @@ function main(platform)
-- init linkdirs and includedirs
local sdkdir = config.get("sdk")
if sdkdir then
- platform:add("includedirs", path.join(sdkdir, "include"))
- platform:add("linkdirs", path.join(sdkdir, "lib"))
+ local includedir = path.join(sdkdir, "include")
+ if os.isdir(includedir) then
+ platform:add("includedirs", includedir)
+ end
+ local linkdir = path.join(sdkdir, "lib")
+ if os.isdir(linkdir) then
+ platform:add("linkdirs", linkdir)
+ end
end
-- ok
diff --git a/xmake/platforms/mingw/check.lua b/xmake/platforms/mingw/check.lua
index dfb9fe5d9..b5b6d90bf 100644
--- a/xmake/platforms/mingw/check.lua
+++ b/xmake/platforms/mingw/check.lua
@@ -23,9 +23,25 @@
--
-- imports
-import("detect.sdks.find_cross_toolchain")
+import("detect.sdks.find_mingw")
import("platforms.checker", {rootdir = os.programdir()})
+-- check the mingw toolchain
+function _check_mingw(config)
+ local mingw = find_mingw(config.get("mingw"), {verbose = true, bindir = config.get("bin"), cross = config.get("cross")})
+ if mingw then
+ config.set("mingw", mingw.sdkdir, {force = true, readonly = true}) -- maybe to global
+ config.set("cross", mingw.cross, {readonly = true, force = true})
+ config.set("bin", mingw.bindir, {readonly = true, force = true})
+ else
+ -- failed
+ cprint("${bright red}please run:")
+ cprint("${red} - xmake config --ndk=xxx")
+ cprint("${red}or - xmake global --ndk=xxx")
+ raise()
+ end
+end
+
-- get toolchains
function _toolchains(config)
@@ -34,32 +50,13 @@ function _toolchains(config)
return _g.TOOLCHAINS
end
- -- init arch
- local arch = config.get("arch")
- if not arch or arch == "i386" then
- arch = "i686"
- end
-
- -- get sdk directory, TODO add detect.sdks.find_mingw
- local sdk = config.get("sdk")
- if os.host() == "macosx" and not sdk then
- sdk = "/usr/local/opt/mingw-w64"
- end
-
- -- find cross toolchain
- local cross = ""
- local toolchain = find_cross_toolchain(sdk or config.get("bin"), {bin = config.get("bin"), cross = config.get("cross")})
- if toolchain then
-
- -- save toolchain
- config.set("cross", toolchain.cross, {readonly = true, force = true})
- config.set("bin", toolchain.bin, {readonly = true, force = true})
- cross = toolchain.cross
+ -- get cross
+ local cross = config.get("cross")
- -- add bin search library for loading some dependent .dll files windows
- if toolchain.bin and is_host("windows") then
- os.addenv("PATH", toolchain.bin)
- end
+ -- add bin search library for loading some dependent .dll files windows
+ local bindir = config.get("bin")
+ if bindir and is_host("windows") then
+ os.addenv("PATH", bindir)
end
-- make toolchains
@@ -94,7 +91,8 @@ function main(kind, toolkind)
-- init the check list of config
_g.config =
{
- { checker.check_arch, "i386" }
+ { checker.check_arch, "x86_64" }
+ , _check_mingw
}
-- init the check list of global
diff --git a/xmake/platforms/mingw/load.lua b/xmake/platforms/mingw/load.lua
index d37977143..d419032dc 100644
--- a/xmake/platforms/mingw/load.lua
+++ b/xmake/platforms/mingw/load.lua
@@ -44,13 +44,6 @@ function main(platform)
platform:add("shflags", archflags)
end
- -- init linkdirs and includedirs
- local sdkdir = config.get("sdk")
- if sdkdir then
- platform:add("includedirs", path.join(sdkdir, "include"))
- platform:add("linkdirs", path.join(sdkdir, "lib"))
- end
-
-- add bin search library for loading some dependent .dll files windows
local bindir = config.get("bin")
if bindir and is_host("windows") then
diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua
index da19c2fbb..e1cd53207 100644
--- a/xmake/platforms/mingw/xmake.lua
+++ b/xmake/platforms/mingw/xmake.lua
@@ -43,3 +43,17 @@ platform("mingw")
-- on load
on_load("load")
+ -- set menu
+ set_menu {
+ config =
+ {
+ {category = "MingW Configuration" }
+ , {nil, "mingw", "kv", nil, "The MingW SDK Directory" }
+ }
+
+ , global =
+ {
+ {category = "MingW Configuration" }
+ , {nil, "mingw", "kv", nil, "The MingW SDK Directory" }
+ }
+ }