summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-11 21:56:03 +0800
committerruki <[email protected]>2015-06-11 21:56:03 +0800
commitc2e614548b92821c8396e2a2e9f06afeb97cc7bd (patch)
treeea54e043c6f065fce7a778e459440d138a075b54 /xmake/scripts
parent5198147b0b71e43883f4454eaabecfec9b8f9c74 (diff)
optimizate to find tool script
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/compiler.lua6
-rw-r--r--xmake/scripts/base/makefile.lua4
-rw-r--r--xmake/scripts/platform/android/android.lua12
-rw-r--r--xmake/scripts/platform/iphonesimulator/iphonesimulator.lua4
-rw-r--r--xmake/scripts/platform/iphonesimulator/prober.lua2
-rw-r--r--xmake/scripts/tools/make.lua4
-rw-r--r--xmake/scripts/tools/tools.lua31
7 files changed, 45 insertions, 18 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index d9c3a7c5e..53d5a2e5d 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -362,7 +362,7 @@ function compiler.get(srcfile)
-- get the compiler kind
local kind = compiler._kind(srcfile)
if not kind then
- return
+ return nil, string.format("unknown source file: %s", srcfile)
end
-- get compiler from the source file type
@@ -371,11 +371,13 @@ function compiler.get(srcfile)
-- invalid compiler
if not module.command_compile then
- return
+ return nil, string.format("invalid compiler: %s", platform.tool(kind))
end
-- save kind
module._KIND = kind
+ else
+ return nil, string.format("not found compiler: %s", platform.tool(kind))
end
-- ok?
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua
index ba939790a..8be6334a5 100644
--- a/xmake/scripts/base/makefile.lua
+++ b/xmake/scripts/base/makefile.lua
@@ -43,10 +43,10 @@ function makefile._make_object(file, target, srcfile, objfile)
assert(file and target and srcfile and objfile)
-- get the compiler
- local c = compiler.get(srcfile)
+ local c, errors = compiler.get(srcfile)
if not c then
-- error
- utils.error("unknown source file: %s", srcfile)
+ utils.error(errors)
return false
end
diff --git a/xmake/scripts/platform/android/android.lua b/xmake/scripts/platform/android/android.lua
index b8e91a09f..fe1c14cb7 100644
--- a/xmake/scripts/platform/android/android.lua
+++ b/xmake/scripts/platform/android/android.lua
@@ -40,6 +40,18 @@ function android.make(configs)
configs.formats.static = {"lib", ".a"}
configs.formats.object = {"", ".o"}
configs.formats.shared = {"lib", ".so"}
+
+ -- init the toolchains
+ configs.tools = {}
+ configs.tools.make = "make"
+ configs.tools.ccache = config.get("__ccache")
+ configs.tools.cc = config.get("cc") or "arm-linux-androideabi-gcc"
+ configs.tools.cxx = config.get("cxx") or "arm-linux-androideabi-g++"
+ configs.tools.mm = config.get("mm") or configs.tools.cc
+ configs.tools.mxx = config.get("mxx") or configs.tools.cxx
+ configs.tools.ld = config.get("ld") or "arm-linux-androideabi-g++"
+ configs.tools.ar = config.get("ar") or "arm-linux-androideabi-ar"
+ configs.tools.sh = config.get("sh") or "arm-linux-androideabi-g++"
end
diff --git a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
index effab15c3..5189eb9ed 100644
--- a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
+++ b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
@@ -27,10 +27,10 @@ local iphonesimulator = iphonesimulator or {}
local config = require("base/config")
-- init host
-iphonesimulator._HOST = "macosx"
+iphonesimulator._HOST = "macosx"
-- init architectures
-iphonesimulator._ARCHS = {"x86", "x64"}
+iphonesimulator._ARCHS = {"i386"}
-- make configure
function iphonesimulator.make(configs)
diff --git a/xmake/scripts/platform/iphonesimulator/prober.lua b/xmake/scripts/platform/iphonesimulator/prober.lua
index 419becf12..9d48d5f15 100644
--- a/xmake/scripts/platform/iphonesimulator/prober.lua
+++ b/xmake/scripts/platform/iphonesimulator/prober.lua
@@ -42,7 +42,7 @@ function prober._probe_arch(configs)
if arch then return true end
-- init the default architecture
- configs.set("arch", "x86")
+ configs.set("arch", "i386")
-- trace
utils.verbose("checking the architecture ... %s", configs.get("arch"))
diff --git a/xmake/scripts/tools/make.lua b/xmake/scripts/tools/make.lua
index 3927aedb5..9deeebd2f 100644
--- a/xmake/scripts/tools/make.lua
+++ b/xmake/scripts/tools/make.lua
@@ -44,9 +44,9 @@ function make.main(self, mkfile, target)
-- make command
local cmd = nil
if mkfile and os.isfile(mkfile) then
- cmd = string.format("%s -j4 -f %s %s VERBOSE=%s 2> %s", self.name, mkfile, target or "", self._VERBOSE, xmake._NULDEV)
+ cmd = string.format("%s -f %s %s VERBOSE=%s 2> %s", self.name, mkfile, target or "", self._VERBOSE, xmake._NULDEV)
else
- cmd = string.format("%s -j4 %s VERBOSE=%s 2> %s", self.name, target or "", self._VERBOSE, xmake._NULDEV)
+ cmd = string.format("%s %s VERBOSE=%s 2> %s", self.name, target or "", self._VERBOSE, xmake._NULDEV)
end
-- done
diff --git a/xmake/scripts/tools/tools.lua b/xmake/scripts/tools/tools.lua
index 9b5c457e2..9add7310c 100644
--- a/xmake/scripts/tools/tools.lua
+++ b/xmake/scripts/tools/tools.lua
@@ -34,16 +34,16 @@ local platform = require("platform/platform")
function tools._match(name, toolname)
-- match full? ok
- if name == toolname then return true end
+ if name == toolname then return 100 end
- -- match the full word? ok
- if name:find("^" .. toolname .. "$") then return true end
+ -- match the partial word? ok
+ if name:find("%-" .. toolname) then return 60 end
-- contains it? ok
- if name:find(toolname, 1, true) then return true end
+ if name:find(toolname, 1, true) then return 30 end
-- not matched
- return false
+ return 0
end
-- find tool from the given root directory and name
@@ -59,6 +59,8 @@ function tools._find_from(root, name)
name = name:lower()
-- get all tool files
+ local file_ok = nil
+ local score_maxn = 0
local files = os.match(string.format("%s/*.lua", root))
for _, file in ipairs(files) do
@@ -66,11 +68,24 @@ function tools._find_from(root, name)
local toolname = path.basename(file)
-- found it?
- if toolname and toolname ~= "tools" and tools._match(name, toolname:lower()) then
- return file
+ if toolname and toolname ~= "tools" then
+
+ -- match score
+ local score = tools._match(name, toolname:lower())
+
+ -- ok?
+ if score >= 100 then return file end
+
+ -- select the file with the max score
+ if score > score_maxn then
+ file_ok = file
+ score_maxn = score
+ end
end
end
+ -- ok?
+ return file_ok
end
-- probe it's absolute path if exists from the given tool name and root directory
@@ -89,8 +104,6 @@ function tools._probe(root, name)
end
end
-
-
-- find tool from the given name and directory (optional)
function tools.find(name, root)