summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-06-10 13:26:47 +0800
committerruki <[email protected]>2016-06-10 13:26:47 +0800
commit38c07cd824a33740accf14dda963aad1f2dc9366 (patch)
treef4883f4af6965bbb7ddf27b8d2bfc9b946bf93d9
parentcb9ce25dd0e7669189124a89bf6171190707b13e (diff)
improve mingw and cross toolchains configure
-rwxr-xr-xxmake/actions/config/xmake.lua12
-rw-r--r--xmake/core/project/deprecated/project.lua3
-rw-r--r--xmake/core/project/project.lua3
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/tool.lua4
-rw-r--r--xmake/platforms/checker.lua12
-rw-r--r--xmake/platforms/linux/checker.lua33
-rwxr-xr-xxmake/platforms/linux/xmake.lua14
-rw-r--r--xmake/platforms/mingw/checker.lua26
-rwxr-xr-xxmake/platforms/mingw/xmake.lua8
-rwxr-xr-xxmake/plugins/doxygen/main.lua2
-rw-r--r--xmake/plugins/lua/scripts/lipo.lua2
11 files changed, 91 insertions, 28 deletions
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index 0a02da06c..6fddd1213 100755
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -104,15 +104,21 @@ task("config")
end
, {}
- , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." }
+ , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." }
, {}
, {nil, "cross", "kv", nil, "The cross toolchains prefix"
, ".e.g"
, " - i386-mingw32-"
, " - arm-linux-androideabi-" }
- , {nil, "toolchains", "kv", nil, "The cross toolchains directory" }
-
+ , {nil, "toolchains", "kv", nil, "The cross toolchains directory"
+ , ".e.g"
+ , " - sdk/bin (/arm-linux-gcc ..)" }
+ , {nil, "sdk", "kv", nil, "The cross sdk directory"
+ , ".e.g"
+ , " - sdk/bin (toolchains)"
+ , " - sdk/lib"
+ , " - sdk/include" }
, {}
, {nil, "cc", "kv", nil, "The C Compiler" }
, {nil, "cxx", "kv", nil, "The C++ Compiler" }
diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua
index 89a3891de..6892bae0f 100644
--- a/xmake/core/project/deprecated/project.lua
+++ b/xmake/core/project/deprecated/project.lua
@@ -290,6 +290,9 @@ function deprecated_project.api_register(interp)
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxflags")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "mflags")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "mxflags")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "mxxflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "ldflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "vectorexts")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "defines")
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 2319d2a98..7d8f97df8 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -423,6 +423,9 @@ function project._interpreter()
, "cflags"
, "cxflags"
, "cxxflags"
+ , "mflags"
+ , "mxflags"
+ , "mxxflags"
, "ldflags"
, "vectorexts"
, "defines"
diff --git a/xmake/core/sandbox/modules/import/core/tool/tool.lua b/xmake/core/sandbox/modules/import/core/tool/tool.lua
index ed8c52b39..883789c2c 100644
--- a/xmake/core/sandbox/modules/import/core/tool/tool.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/tool.lua
@@ -52,10 +52,10 @@ function sandbox_core_tool.run(name, ...)
end
-- check the tool and return the absolute path if exists
-function sandbox_core_tool.check(shellname, check)
+function sandbox_core_tool.check(shellname, dirs, check)
-- check it
- return tool.check(shellname, platform.tooldirs(), check)
+ return tool.check(shellname, dirs or platform.tooldirs(), check)
end
-- return module
diff --git a/xmake/platforms/checker.lua b/xmake/platforms/checker.lua
index f31f14963..158156dbc 100644
--- a/xmake/platforms/checker.lua
+++ b/xmake/platforms/checker.lua
@@ -161,7 +161,7 @@ function check_ccache(config)
if ccache == nil then
-- check the ccache path
- local ccache_path = tool.check("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.check("ccache")
-- check ok? update it
if ccache_path then
@@ -204,8 +204,16 @@ function check_toolchain(config, kind, cross, name, description, check)
}
end
+ -- get toolchains
+ local toolchains = config.get("toolchains")
+ if not toolchains then
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ toolchains = path.join(sdkdir, "bin")
+ end
+ end
+
-- attempt to get it from the given cross toolchains
- local toolchains = config.get("toolchains")
if not toolpath and toolchains then
toolpath = tool.check(cross .. name, toolchains)
end
diff --git a/xmake/platforms/linux/checker.lua b/xmake/platforms/linux/checker.lua
index fc2b32137..499a5ef1d 100644
--- a/xmake/platforms/linux/checker.lua
+++ b/xmake/platforms/linux/checker.lua
@@ -42,13 +42,34 @@ end
-- check the toolchains
function _check_toolchains(config)
+ -- get toolchains
+ local toolchains = config.get("toolchains")
+ if not toolchains then
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ toolchains = path.join(sdkdir, "bin")
+ end
+ end
+
+ -- get cross
+ local cross = ""
+ if toolchains then
+ local arpathes = os.match(path.join(toolchains, "*-ar"))
+ for _, arpath in ipairs(arpathes) do
+ local arname = path.basename(arpath)
+ if arname then
+ cross = arname:sub(1, -3)
+ end
+ end
+ end
+
-- done
- checker.check_toolchain(config, "cc", "", "gcc", "the c compiler")
- checker.check_toolchain(config, "cxx", "", "g++", "the c++ compiler")
- checker.check_toolchain(config, "as", "", "gcc", "the assember")
- checker.check_toolchain(config, "ld", "", "g++", "the linker")
- checker.check_toolchain(config, "ar", "", "ar", "the static library linker")
- checker.check_toolchain(config, "sh", "", "g++", "the shared library linker")
+ checker.check_toolchain(config, "cc", cross, "gcc", "the c compiler")
+ checker.check_toolchain(config, "cxx", cross, "g++", "the c++ compiler")
+ checker.check_toolchain(config, "as", cross, "gcc", "the assember")
+ checker.check_toolchain(config, "ld", cross, "g++", "the linker")
+ checker.check_toolchain(config, "ar", cross, "ar", "the static library linker")
+ checker.check_toolchain(config, "sh", cross, "g++", "the shared library linker")
end
-- init it
diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua
index b7f47b15b..e6af941bd 100755
--- a/xmake/platforms/linux/xmake.lua
+++ b/xmake/platforms/linux/xmake.lua
@@ -63,7 +63,18 @@ platform("linux")
_g.tools.sc = config.get("sc")
-- cross toolchains?
- if config.get("cross") then return end
+ if config.get("cross") then
+
+ -- init linkdirs and includedirs
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ _g.includedirs = {path.join(sdkdir, "include")}
+ _g.linkdirs = {path.join(sdkdir, "lib")}
+ end
+
+ -- ok
+ return
+ end
-- init flags for architecture
local archflags = nil
@@ -83,7 +94,6 @@ platform("linux")
-- init linkdirs and includedirs
_g.linkdirs = {"/usr/lib", "/usr/local/lib"}
_g.includedirs = {"/usr/include", "/usr/local/include"}
-
end)
diff --git a/xmake/platforms/mingw/checker.lua b/xmake/platforms/mingw/checker.lua
index 3fdf4653a..b8aaf568d 100644
--- a/xmake/platforms/mingw/checker.lua
+++ b/xmake/platforms/mingw/checker.lua
@@ -27,16 +27,24 @@ import("platforms.checker", {rootdir = os.programdir()})
-- check the toolchains
function _check_toolchains(config)
- -- init the default cross
+ -- get toolchains
+ local toolchains = config.get("toolchains")
+ if not toolchains then
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ toolchains = path.join(sdkdir, "bin")
+ end
+ end
+
+ -- get cross
local cross = ""
- local arch = config.get("arch")
- if arch then
- if os.host() == "macosx" and arch == "i386" then
- cross = "i386-mingw32-"
- elseif arch == "i386" then
- cross = "i686-w64-mingw32-"
- elseif arch == "x86_64" then
- cross = "x86_64-w64-mingw32-"
+ if toolchains then
+ local arpathes = os.match(path.join(toolchains, "*-ar"))
+ for _, arpath in ipairs(arpathes) do
+ local arname = path.basename(arpath)
+ if arname then
+ cross = arname:sub(1, -3)
+ end
end
end
diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua
index a96ea8706..39276f8c7 100755
--- a/xmake/platforms/mingw/xmake.lua
+++ b/xmake/platforms/mingw/xmake.lua
@@ -73,7 +73,11 @@ platform("mingw")
_g.ldflags = { archflags }
_g.shflags = { archflags }
+ -- init linkdirs and includedirs
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ _g.includedirs = {path.join(sdkdir, "include")}
+ _g.linkdirs = {path.join(sdkdir, "lib")}
+ end
end)
-
-
diff --git a/xmake/plugins/doxygen/main.lua b/xmake/plugins/doxygen/main.lua
index 5ac2f1ae4..0b39eaca7 100755
--- a/xmake/plugins/doxygen/main.lua
+++ b/xmake/plugins/doxygen/main.lua
@@ -30,7 +30,7 @@ import("core.project.project")
function main()
-- check the doxygen
- local doxygen = tool.check("doxygen", function (shellname)
+ local doxygen = tool.check("doxygen", nil, function (shellname)
os.run("%s -v", shellname)
end)
assert(doxygen, "doxygen not found!")
diff --git a/xmake/plugins/lua/scripts/lipo.lua b/xmake/plugins/lua/scripts/lipo.lua
index 9092483cf..40395cb98 100644
--- a/xmake/plugins/lua/scripts/lipo.lua
+++ b/xmake/plugins/lua/scripts/lipo.lua
@@ -38,7 +38,7 @@ function main(...)
args = args[1]
-- check the lipo
- local lipo = tool.check("xcrun lipo", function (shellname)
+ local lipo = tool.check("xcrun lipo", nil, function (shellname)
os.run("xcrun -find lipo")
end)
assert(lipo, "lipo not found!")