summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-06-16 15:45:31 +0800
committerruki <[email protected]>2017-06-16 15:45:31 +0800
commitb3cc1e1c42d8b367f2d0b1a93c236abe1cc94b34 (patch)
tree206f6249f3f61d856ecbfb731661a2514923a91f
parent4ce04f4a25ac9fa21e19ae4c568d7a253959680a (diff)
replace old find compiler scripts and fix string.endswith
-rw-r--r--core/src/demo/xmake.lua2
-rw-r--r--core/src/xmake/machine.c4
-rw-r--r--core/src/xmake/makefile1
-rw-r--r--core/src/xmake/string/endswith.c6
-rw-r--r--core/src/xmake/string/startswith.c2
-rw-r--r--core/src/xmake/string/strcmp.c57
-rw-r--r--xmake/core/_xmake_main.lua5
-rw-r--r--xmake/core/base/interpreter.lua2
-rw-r--r--xmake/core/base/string.lua7
-rw-r--r--xmake/core/project/template.lua8
-rw-r--r--xmake/core/sandbox/modules/import.lua6
-rw-r--r--xmake/core/sandbox/modules/os.lua7
-rw-r--r--xmake/core/sandbox/sandbox.lua2
-rw-r--r--xmake/modules/detect/tool/find_7z.lua5
-rw-r--r--xmake/modules/detect/tool/find_ar.lua2
-rw-r--r--xmake/modules/detect/tool/find_brew.lua5
-rw-r--r--xmake/modules/detect/tool/find_ccache.lua2
-rw-r--r--xmake/modules/detect/tool/find_cl.lua2
-rw-r--r--xmake/modules/detect/tool/find_clang.lua2
-rw-r--r--xmake/modules/detect/tool/find_clangxx.lua2
-rw-r--r--xmake/modules/detect/tool/find_curl.lua5
-rw-r--r--xmake/modules/detect/tool/find_dmd.lua2
-rw-r--r--xmake/modules/detect/tool/find_doxygen.lua5
-rw-r--r--xmake/modules/detect/tool/find_gcc.lua2
-rw-r--r--xmake/modules/detect/tool/find_gccgo.lua2
-rw-r--r--xmake/modules/detect/tool/find_gdb.lua2
-rw-r--r--xmake/modules/detect/tool/find_gdc.lua2
-rw-r--r--xmake/modules/detect/tool/find_git.lua5
-rw-r--r--xmake/modules/detect/tool/find_go.lua2
-rw-r--r--xmake/modules/detect/tool/find_gxx.lua2
-rw-r--r--xmake/modules/detect/tool/find_gzip.lua5
-rw-r--r--xmake/modules/detect/tool/find_ldc2.lua2
-rw-r--r--xmake/modules/detect/tool/find_lib.lua2
-rw-r--r--xmake/modules/detect/tool/find_link.lua2
-rw-r--r--xmake/modules/detect/tool/find_lipo.lua2
-rw-r--r--xmake/modules/detect/tool/find_lldb.lua2
-rw-r--r--xmake/modules/detect/tool/find_ml.lua2
-rw-r--r--xmake/modules/detect/tool/find_ml64.lua59
-rw-r--r--xmake/modules/detect/tool/find_rc.lua58
-rw-r--r--xmake/modules/detect/tool/find_rustc.lua2
-rw-r--r--xmake/modules/detect/tool/find_sudo.lua5
-rw-r--r--xmake/modules/detect/tool/find_swiftc.lua2
-rw-r--r--xmake/modules/detect/tool/find_tar.lua5
-rw-r--r--xmake/modules/detect/tool/find_unzip.lua5
-rw-r--r--xmake/modules/detect/tool/find_wget.lua5
-rw-r--r--xmake/modules/detect/tool/find_zip.lua5
-rw-r--r--xmake/modules/lib/detect/find_tool.lua8
-rw-r--r--xmake/platforms/checker.lua56
-rw-r--r--xmake/platforms/iphoneos/check.lua16
-rw-r--r--xmake/platforms/watchos/check.lua16
-rw-r--r--xmake/platforms/windows/check.lua8
-rwxr-xr-xxmake/scripts/gas-preprocessor.pl (renamed from xmake/tools/utils/gas-preprocessor.pl)0
52 files changed, 220 insertions, 205 deletions
diff --git a/core/src/demo/xmake.lua b/core/src/demo/xmake.lua
index 9f4fd2f0d..40d089f7f 100644
--- a/core/src/demo/xmake.lua
+++ b/core/src/demo/xmake.lua
@@ -36,6 +36,6 @@ target("demo")
-- add the resource files (it will be enabled after publishing new version)
if is_plat("windows") then
--- add_files("*.rc")
+ add_files("*.rc")
end
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index e1638e1ab..7f1acfbd0 100644
--- a/core/src/xmake/machine.c
+++ b/core/src/xmake/machine.c
@@ -99,7 +99,6 @@ tb_int_t xm_winreg_query(lua_State* lua);
#endif
// the string functions
-tb_int_t xm_string_strcmp(lua_State* lua);
tb_int_t xm_string_endswith(lua_State* lua);
tb_int_t xm_string_startswith(lua_State* lua);
@@ -172,8 +171,7 @@ static luaL_Reg const g_path_functions[] =
// the string functions
static luaL_Reg const g_string_functions[] =
{
- { "strcmp", xm_string_strcmp }
-, { "endswith", xm_string_endswith }
+ { "endswith", xm_string_endswith }
, { "startswith", xm_string_startswith }
, { tb_null, tb_null }
};
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index efc32d94d..e9f5badce 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -45,7 +45,6 @@ xmake_C_FILES += \
path/translate \
path/is_absolute \
winreg/query \
- string/strcmp \
string/endswith \
string/startswith \
process/open \
diff --git a/core/src/xmake/string/endswith.c b/core/src/xmake/string/endswith.c
index 241e59254..8de61e2bb 100644
--- a/core/src/xmake/string/endswith.c
+++ b/core/src/xmake/string/endswith.c
@@ -49,9 +49,9 @@ tb_int_t xm_string_endswith(lua_State* lua)
tb_char_t const* suffix = luaL_checklstring(lua, 2, &suffix_size);
tb_check_return_val(string && suffix, 0);
- // done string:endswith(suffix)
- if (string_size >= suffix_size)
- lua_pushboolean(lua, !tb_strcmp(string + string_size - suffix_size, suffix));
+ // string:endswith(suffix)?
+ lua_pushboolean(lua, string_size >= suffix_size && !tb_strcmp(string + string_size - suffix_size, suffix));
+
// ok
return 1;
diff --git a/core/src/xmake/string/startswith.c b/core/src/xmake/string/startswith.c
index 84766e5ca..de039dede 100644
--- a/core/src/xmake/string/startswith.c
+++ b/core/src/xmake/string/startswith.c
@@ -48,7 +48,7 @@ tb_int_t xm_string_startswith(lua_State* lua)
tb_char_t const* prefix = luaL_checklstring(lua, 2, &prefix_size);
tb_check_return_val(string && prefix, 0);
- // done string:startswith(prefix)
+ // string:startswith(prefix)?
lua_pushboolean(lua, !tb_strncmp(string, prefix, (tb_size_t)prefix_size));
// ok
diff --git a/core/src/xmake/string/strcmp.c b/core/src/xmake/string/strcmp.c
deleted file mode 100644
index 2ad06f27d..000000000
--- a/core/src/xmake/string/strcmp.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*!The Make-like Build Utility based on Lua
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Copyright (C) 2015 - 2017, TBOOX Open Source Group.
- *
- * @author ruki
- * @file strcmp.c
- *
- */
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * trace
- */
-#define TB_TRACE_MODULE_NAME "strcmp"
-#define TB_TRACE_MODULE_DEBUG (0)
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * includes
- */
-#include "prefix.h"
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * implementation
- */
-
-// string:strcmp(s1, s2)
-tb_int_t xm_string_strcmp(lua_State* lua)
-{
- // check
- tb_assert_and_check_return_val(lua, 0);
-
- // get the strings
- tb_char_t const* s1 = luaL_checkstring(lua, 1);
- tb_char_t const* s2 = luaL_checkstring(lua, 2);
- tb_check_return_val(s1 && s2, 0);
-
- // compare them
- lua_pushinteger(lua, tb_strcmp(s1, s2));
-
- // ok
- return 1;
-}
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua
index 39bb5f225..58af78d66 100644
--- a/xmake/core/_xmake_main.lua
+++ b/xmake/core/_xmake_main.lua
@@ -33,13 +33,10 @@ xmake._VERSION_SHORT = _VERSION_SHORT
xmake._PROGRAM_DIR = _PROGRAM_DIR
xmake._PROGRAM_FILE = _PROGRAM_FILE
xmake._PROJECT_DIR = _PROJECT_DIR
-xmake._CORE_DIR = _PROGRAM_DIR .. "/core"
-xmake._TOOLS_DIR = _PROGRAM_DIR .. "/tools"
-xmake._TEMPLATES_DIR = _PROGRAM_DIR .. "/templates"
xmake._PROJECT_FILE = "xmake.lua"
-- init package path
-package.path = xmake._CORE_DIR .. "/?.lua;" .. package.path
+package.path = xmake._PROGRAM_DIR .. "/core/?.lua;" .. package.path
-- load modules
local main = require("main")
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 5c51b35e4..c23fa8457 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -700,7 +700,7 @@ function interpreter.new()
instance:api_register(nil, "set_xmakever", interpreter.api_builtin_set_xmakever)
-- load builtin module files
- local builtin_module_files = os.match(path.join(xmake._CORE_DIR, "sandbox/modules/interpreter/*.lua"))
+ local builtin_module_files = os.match(path.join(os.programdir(), "core/sandbox/modules/interpreter/*.lua"))
if builtin_module_files then
for _, builtin_module_file in ipairs(builtin_module_files) do
diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua
index f54f7b1a3..97945851e 100644
--- a/xmake/core/base/string.lua
+++ b/xmake/core/base/string.lua
@@ -131,13 +131,6 @@ function string.join(items, sep)
return str
end
--- less than
-function string:less(other)
-
- -- < ?
- return string.strcmp(self, other) < 0
-end
-
-- try to format
function string.tryformat(format, ...)
diff --git a/xmake/core/project/template.lua b/xmake/core/project/template.lua
index a306bf622..cbc1551a8 100644
--- a/xmake/core/project/template.lua
+++ b/xmake/core/project/template.lua
@@ -90,7 +90,7 @@ function template._replace(macros, macrofiles)
-- make all files
local files = {}
for _, macrofile in ipairs(table.wrap(macrofiles)) do
- local matchfiles = os.match(macrofile)
+ local matchfiles = os.files(macrofile)
if matchfiles then
table.join2(files, matchfiles)
end
@@ -114,7 +114,7 @@ function template.languages()
local list = {}
-- get the language list
- local languages = os.match(xmake._TEMPLATES_DIR .. "/*", true)
+ local languages = os.dirs(path.join(os.programdir(), "templates", "*"))
if languages then
for _, v in ipairs(languages) do
table.insert(list, path.basename(v))
@@ -137,7 +137,7 @@ function template.templates(language)
-- load all templates
local templates = {}
- local templatefiles = os.match(string.format("%s/%s/**/template.lua", xmake._TEMPLATES_DIR, language))
+ local templatefiles = os.files(path.join(os.programdir(), "templates", language, "**", "template.lua"))
if templatefiles then
-- load template
@@ -159,7 +159,7 @@ function template.templates(language)
end
-- sort templates
- table.sort(templates, function(a, b) return a.description:less(b.description) end)
+ table.sort(templates, function(a, b) return a.description < b.description end)
-- ok?
return templates
diff --git a/xmake/core/sandbox/modules/import.lua b/xmake/core/sandbox/modules/import.lua
index 885378750..a18a5231b 100644
--- a/xmake/core/sandbox/modules/import.lua
+++ b/xmake/core/sandbox/modules/import.lua
@@ -300,7 +300,7 @@ function sandbox_import.import(name, args)
assert(rootdir)
-- the sandbox modules directory
- local modules_sandbox_dir = path.join(xmake._CORE_DIR, "sandbox/modules/import")
+ local modules_sandbox_dir = path.join(os.programdir(), "core/sandbox/modules/import")
-- the extension modules directory
local modules_extension_dir = path.join(os.programdir(), "modules")
@@ -313,8 +313,8 @@ function sandbox_import.import(name, args)
{
rootdir -- load module from the given root directory first
, path.join(global.directory(), "modules") -- load module from the user global modules directory
- , path.join(xmake._PROGRAM_DIR, "modules") -- load module from the extension modules directory
- , path.join(xmake._CORE_DIR, "sandbox/modules/import") -- load module from the sandbox core modules directory
+ , path.join(os.programdir(), "modules") -- load module from the extension modules directory
+ , path.join(os.programdir(), "core/sandbox/modules/import") -- load module from the sandbox core modules directory
}
-- load module
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 657364cb2..089f42d7e 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -224,13 +224,6 @@ function sandbox_os.tmpfile()
return tmpfile
end
--- get the tools directory
-function sandbox_os.toolsdir()
-
- -- get it
- return xmake._TOOLS_DIR
-end
-
-- get the script directory
function sandbox_os.scriptdir()
diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua
index 77b7003e2..222312b1c 100644
--- a/xmake/core/sandbox/sandbox.lua
+++ b/xmake/core/sandbox/sandbox.lua
@@ -107,7 +107,7 @@ function sandbox._new()
table.inherit2(instance, sandbox)
-- load builtin module files
- local builtin_module_files = os.match(path.join(xmake._CORE_DIR, "sandbox/modules/*.lua"))
+ local builtin_module_files = os.match(path.join(os.programdir(), "core/sandbox/modules/*.lua"))
if builtin_module_files then
for _, builtin_module_file in ipairs(builtin_module_files) do
diff --git a/xmake/modules/detect/tool/find_7z.lua b/xmake/modules/detect/tool/find_7z.lua
index 58a4ea24e..bc5c3d340 100644
--- a/xmake/modules/detect/tool/find_7z.lua
+++ b/xmake/modules/detect/tool/find_7z.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("7z", {}, "--help")
+ local program = find_program(opt.program or "7z", opt.pathes, opt.check or "--help")
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_ar.lua b/xmake/modules/detect/tool/find_ar.lua
index 2cb78ddff..6bbf840c5 100644
--- a/xmake/modules/detect/tool/find_ar.lua
+++ b/xmake/modules/detect/tool/find_ar.lua
@@ -66,5 +66,5 @@ function main(opt)
opt = opt or {}
-- find program
- return find_program(opt.program or "ar", {}, _check)
+ return find_program(opt.program or "ar", opt.pathes, opt.check or _check)
end
diff --git a/xmake/modules/detect/tool/find_brew.lua b/xmake/modules/detect/tool/find_brew.lua
index 07fb8dae6..e4c07403f 100644
--- a/xmake/modules/detect/tool/find_brew.lua
+++ b/xmake/modules/detect/tool/find_brew.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("brew")
+ local program = find_program(opt.program or "brew", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_ccache.lua b/xmake/modules/detect/tool/find_ccache.lua
index c32bbc4b6..9e4fe4aa6 100644
--- a/xmake/modules/detect/tool/find_ccache.lua
+++ b/xmake/modules/detect/tool/find_ccache.lua
@@ -45,7 +45,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "ccache")
+ local program = find_program(opt.program or "ccache", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_cl.lua b/xmake/modules/detect/tool/find_cl.lua
index 8287120f9..3ab7cf5c1 100644
--- a/xmake/modules/detect/tool/find_cl.lua
+++ b/xmake/modules/detect/tool/find_cl.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "cl.exe", {}, function (program) os.run(program) end)
+ local program = find_program(opt.program or "cl.exe", opt.pathes, opt.check or function (program) os.run(program) end)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_clang.lua b/xmake/modules/detect/tool/find_clang.lua
index 1de30f6a9..5e1dc95d4 100644
--- a/xmake/modules/detect/tool/find_clang.lua
+++ b/xmake/modules/detect/tool/find_clang.lua
@@ -45,7 +45,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "clang")
+ local program = find_program(opt.program or "clang", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_clangxx.lua b/xmake/modules/detect/tool/find_clangxx.lua
index c7d9f45d1..77e80304f 100644
--- a/xmake/modules/detect/tool/find_clangxx.lua
+++ b/xmake/modules/detect/tool/find_clangxx.lua
@@ -45,7 +45,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "clang++")
+ local program = find_program(opt.program or "clang++", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_curl.lua b/xmake/modules/detect/tool/find_curl.lua
index 3b49247ef..a5ba49e20 100644
--- a/xmake/modules/detect/tool/find_curl.lua
+++ b/xmake/modules/detect/tool/find_curl.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("curl")
+ local program = find_program(opt.program or "curl", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_dmd.lua b/xmake/modules/detect/tool/find_dmd.lua
index fe47fc618..f244c0ad0 100644
--- a/xmake/modules/detect/tool/find_dmd.lua
+++ b/xmake/modules/detect/tool/find_dmd.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "dmd")
+ local program = find_program(opt.program or "dmd", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_doxygen.lua b/xmake/modules/detect/tool/find_doxygen.lua
index 3b3a6bee4..5824c574c 100644
--- a/xmake/modules/detect/tool/find_doxygen.lua
+++ b/xmake/modules/detect/tool/find_doxygen.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("doxygen", { "/usr/bin", "/usr/local/bin"})
+ local program = find_program(opt.program or "doxygen", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_gcc.lua b/xmake/modules/detect/tool/find_gcc.lua
index 0076d328f..d7cbce7d2 100644
--- a/xmake/modules/detect/tool/find_gcc.lua
+++ b/xmake/modules/detect/tool/find_gcc.lua
@@ -45,7 +45,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "gcc")
+ local program = find_program(opt.program or "gcc", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_gccgo.lua b/xmake/modules/detect/tool/find_gccgo.lua
index eaff5e3ea..a12be3067 100644
--- a/xmake/modules/detect/tool/find_gccgo.lua
+++ b/xmake/modules/detect/tool/find_gccgo.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "gccgo")
+ local program = find_program(opt.program or "gccgo", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_gdb.lua b/xmake/modules/detect/tool/find_gdb.lua
index ff206288c..3e698022a 100644
--- a/xmake/modules/detect/tool/find_gdb.lua
+++ b/xmake/modules/detect/tool/find_gdb.lua
@@ -46,7 +46,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "gdb")
+ local program = find_program(opt.program or "gdb", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_gdc.lua b/xmake/modules/detect/tool/find_gdc.lua
index a094cf7ee..a2b2b4c9a 100644
--- a/xmake/modules/detect/tool/find_gdc.lua
+++ b/xmake/modules/detect/tool/find_gdc.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "gdc")
+ local program = find_program(opt.program or "gdc", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_git.lua b/xmake/modules/detect/tool/find_git.lua
index 12f08978d..b21455b0c 100644
--- a/xmake/modules/detect/tool/find_git.lua
+++ b/xmake/modules/detect/tool/find_git.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("git")
+ local program = find_program(opt.program or "git", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_go.lua b/xmake/modules/detect/tool/find_go.lua
index 9932f73ba..0b1b9103e 100644
--- a/xmake/modules/detect/tool/find_go.lua
+++ b/xmake/modules/detect/tool/find_go.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "go", {}, "version")
+ local program = find_program(opt.program or "go", opt.pathes, opt.check or "version")
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_gxx.lua b/xmake/modules/detect/tool/find_gxx.lua
index a58cfe75f..5ab35fa44 100644
--- a/xmake/modules/detect/tool/find_gxx.lua
+++ b/xmake/modules/detect/tool/find_gxx.lua
@@ -45,7 +45,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "g++")
+ local program = find_program(opt.program or "g++", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_gzip.lua b/xmake/modules/detect/tool/find_gzip.lua
index d1b286bba..95d364971 100644
--- a/xmake/modules/detect/tool/find_gzip.lua
+++ b/xmake/modules/detect/tool/find_gzip.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("gzip")
+ local program = find_program(opt.program or "gzip", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_ldc2.lua b/xmake/modules/detect/tool/find_ldc2.lua
index 77df85852..8b2f42c5d 100644
--- a/xmake/modules/detect/tool/find_ldc2.lua
+++ b/xmake/modules/detect/tool/find_ldc2.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "ldc2")
+ local program = find_program(opt.program or "ldc2", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_lib.lua b/xmake/modules/detect/tool/find_lib.lua
index 5b6545f40..107c33cbb 100644
--- a/xmake/modules/detect/tool/find_lib.lua
+++ b/xmake/modules/detect/tool/find_lib.lua
@@ -45,7 +45,7 @@ function main(opt)
-- find program
local verinfo = nil
- local program = find_program(opt.program or "lib.exe", {}, function (program)
+ local program = find_program(opt.program or "lib.exe", opt.pathes, opt.check or function (program)
-- make an stub source file
local libraryfile = os.tmpfile() .. ".lib"
diff --git a/xmake/modules/detect/tool/find_link.lua b/xmake/modules/detect/tool/find_link.lua
index 209fa1300..d30fe6fbe 100644
--- a/xmake/modules/detect/tool/find_link.lua
+++ b/xmake/modules/detect/tool/find_link.lua
@@ -45,7 +45,7 @@ function main(opt)
-- find program
local verinfo = nil
- local program = find_program(opt.program or "link.exe", {}, function (program)
+ local program = find_program(opt.program or "link.exe", opt.pathes, opt.check or function (program)
-- make an stub source file
local binaryfile = os.tmpfile() .. ".exe"
diff --git a/xmake/modules/detect/tool/find_lipo.lua b/xmake/modules/detect/tool/find_lipo.lua
index 85d1fba76..27be94c1f 100644
--- a/xmake/modules/detect/tool/find_lipo.lua
+++ b/xmake/modules/detect/tool/find_lipo.lua
@@ -44,5 +44,5 @@ function main(opt)
opt = opt or {}
-- find program
- return find_program(opt.program or "lipo", {}, function (program) os.run("%s -info %s", program, os.programfile()) end)
+ return find_program(opt.program or "lipo", opt.pathes, opt.check or function (program) os.run("%s -info %s", program, os.programfile()) end)
end
diff --git a/xmake/modules/detect/tool/find_lldb.lua b/xmake/modules/detect/tool/find_lldb.lua
index 3c15c2fb1..8a6e86341 100644
--- a/xmake/modules/detect/tool/find_lldb.lua
+++ b/xmake/modules/detect/tool/find_lldb.lua
@@ -46,7 +46,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "lldb")
+ local program = find_program(opt.program or "lldb", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_ml.lua b/xmake/modules/detect/tool/find_ml.lua
index b4407e452..da3f026ac 100644
--- a/xmake/modules/detect/tool/find_ml.lua
+++ b/xmake/modules/detect/tool/find_ml.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "ml.exe", {}, function (program) os.run(program) end)
+ local program = find_program(opt.program or "ml.exe", opt.pathes, opt.check or function (program) os.run(program) end)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_ml64.lua b/xmake/modules/detect/tool/find_ml64.lua
new file mode 100644
index 000000000..d2377c19e
--- /dev/null
+++ b/xmake/modules/detect/tool/find_ml64.lua
@@ -0,0 +1,59 @@
+--!The Make-like Build Utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_ml64.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find ml64
+--
+-- @param opt the argument options, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local ml64 = find_ml64()
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+
+ -- find program
+ local program = find_program(opt.program or "ml64.exe", opt.pathes, opt.check or function (program) os.run(program) end)
+
+ -- find program version
+ local version = nil
+ if program and opt and opt.version then
+ version = find_programver(program, function () local _, info = os.iorun(program); return info end,
+ function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end)
+ end
+
+ -- ok?
+ return program, version
+end
+
diff --git a/xmake/modules/detect/tool/find_rc.lua b/xmake/modules/detect/tool/find_rc.lua
new file mode 100644
index 000000000..cbd24e82a
--- /dev/null
+++ b/xmake/modules/detect/tool/find_rc.lua
@@ -0,0 +1,58 @@
+--!The Make-like Build Utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_rc.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find rc
+--
+-- @param opt the argument options, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local rc = find_rc()
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+
+ -- find program
+ local program = find_program(opt.program or "rc.exe", opt.pathes, "-?")
+
+ -- find program version
+ local version = nil
+ if program and opt and opt.version then
+ version = find_programver(program, "-?", function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end)
+ end
+
+ -- ok?
+ return program, version
+end
+
diff --git a/xmake/modules/detect/tool/find_rustc.lua b/xmake/modules/detect/tool/find_rustc.lua
index 938c6c180..d01380d72 100644
--- a/xmake/modules/detect/tool/find_rustc.lua
+++ b/xmake/modules/detect/tool/find_rustc.lua
@@ -44,7 +44,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "rustc")
+ local program = find_program(opt.program or "rustc", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_sudo.lua b/xmake/modules/detect/tool/find_sudo.lua
index 3d0082b17..3306f2fd3 100644
--- a/xmake/modules/detect/tool/find_sudo.lua
+++ b/xmake/modules/detect/tool/find_sudo.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("sudo", {}, "-h")
+ local program = find_program(opt.program or "sudo", opt.pathes, opt.check or "-h")
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_swiftc.lua b/xmake/modules/detect/tool/find_swiftc.lua
index cc9bdf4d6..cf9373739 100644
--- a/xmake/modules/detect/tool/find_swiftc.lua
+++ b/xmake/modules/detect/tool/find_swiftc.lua
@@ -45,7 +45,7 @@ function main(opt)
opt = opt or {}
-- find program
- local program = find_program(opt.program or "swiftc")
+ local program = find_program(opt.program or "swiftc", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_tar.lua b/xmake/modules/detect/tool/find_tar.lua
index e091d3204..f37843171 100644
--- a/xmake/modules/detect/tool/find_tar.lua
+++ b/xmake/modules/detect/tool/find_tar.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("tar")
+ local program = find_program(opt.program or "tar", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_unzip.lua b/xmake/modules/detect/tool/find_unzip.lua
index 19c30f517..c3533cd54 100644
--- a/xmake/modules/detect/tool/find_unzip.lua
+++ b/xmake/modules/detect/tool/find_unzip.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("unzip", {}, "-v")
+ local program = find_program(opt.program or "unzip", opt.pathes, opt.check or "-v")
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_wget.lua b/xmake/modules/detect/tool/find_wget.lua
index 59a9c7d63..5f8dd7594 100644
--- a/xmake/modules/detect/tool/find_wget.lua
+++ b/xmake/modules/detect/tool/find_wget.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("wget")
+ local program = find_program(opt.program or "wget", opt.pathes, opt.check)
-- find program version
local version = nil
diff --git a/xmake/modules/detect/tool/find_zip.lua b/xmake/modules/detect/tool/find_zip.lua
index b424d6e99..71405d3ff 100644
--- a/xmake/modules/detect/tool/find_zip.lua
+++ b/xmake/modules/detect/tool/find_zip.lua
@@ -40,9 +40,12 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
+
+ -- init options
+ opt = opt or {}
-- find program
- local program = find_program("zip", {}, "-v")
+ local program = find_program(opt.program or "zip", opt.pathes, opt.check or "-v")
-- find program version
local version = nil
diff --git a/xmake/modules/lib/detect/find_tool.lua b/xmake/modules/lib/detect/find_tool.lua
index 74d446bb4..0911bea20 100644
--- a/xmake/modules/lib/detect/find_tool.lua
+++ b/xmake/modules/lib/detect/find_tool.lua
@@ -29,9 +29,17 @@ import("lib.detect.find_programver")
-- find tool from modules
function _find_from_modules(name, opt)
+ -- strip arguments with spaces
+ name = name:split("%s+")[1]
+
-- replace "+" to "x"
name = name:gsub("%+", "x")
+ -- strip suffix on windows
+ if os.host() == "windows" and name:endswith(".exe") then
+ name = name:sub(1, #name - 4)
+ end
+
-- "detect.tool.find_xxx" exists?
if os.isfile(path.join(os.programdir(), "modules", "detect", "tool", "find_" .. name .. ".lua")) then
local find_tool = import("detect.tool.find_" .. name)
diff --git a/xmake/platforms/checker.lua b/xmake/platforms/checker.lua
index 870b51053..c6cb2b581 100644
--- a/xmake/platforms/checker.lua
+++ b/xmake/platforms/checker.lua
@@ -23,10 +23,10 @@
--
-- imports
-import("core.tool.tool")
import("core.base.option")
import("detect.sdk.find_xcode_dir")
import("detect.sdk.find_xcode_sdkvers")
+import("lib.detect.find_tool")
-- find the given tool
function _toolchain_check(config, toolkind, toolinfo)
@@ -39,61 +39,23 @@ function _toolchain_check(config, toolkind, toolinfo)
local name = toolinfo.name
-- get cross
- local cross = config.get("cross") or toolinfo.cross
+ local cross = config.get("cross") or toolinfo.cross or ""
- -- get shell name from the env if not cross-compilation
- if cross and cross:trim() == "" then
- local shellname = os.getenv(toolkind:upper():split('-')[1])
- if shellname and shellname:trim() ~= "" then
- toolpath = tool.check(shellname)
+ -- get program name from the env if not cross-compilation
+ if cross:trim() == "" then
+ local program = os.getenv(toolkind:upper():split('-')[1])
+ if program and program:trim() ~= "" then
+ toolpath = find_tool(name, {program = program})
end
end
- -- check it using the custom script
- if not toolpath and toolinfo.check then
-
- -- check it
- try
- {
- function ()
-
- -- check it
- toolinfo.check(cross .. name)
-
- -- ok
- toolpath = cross .. name
- end
- }
- 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 check it from the given cross toolchains
- if not toolpath and toolchains then
- toolpath = tool.check(cross .. name, toolchains)
- end
-
- -- attempt to check it with cross prefix
+ -- attempt to check it
if not toolpath then
- toolpath = tool.check(cross .. name)
- end
-
- -- attempt to check it without cross prefix
- if not toolpath then
- toolpath = tool.check(name)
+ toolpath = find_tool(name, {program = cross .. name, pathes = config.get("toolchains"), check = toolinfo.check})
end
-- check ok?
if toolpath then
-
- -- update config
config.set(toolkind, toolpath)
end
diff --git a/xmake/platforms/iphoneos/check.lua b/xmake/platforms/iphoneos/check.lua
index b3fa9b728..a12a53801 100644
--- a/xmake/platforms/iphoneos/check.lua
+++ b/xmake/platforms/iphoneos/check.lua
@@ -25,20 +25,6 @@
-- imports
import(".checker")
--- check the as
-function _check_as(shellname)
-
- -- make an empty tmp.S
- local tmpfile = os.tmpfile() .. ".S"
- io.writefile(tmpfile, "")
-
- -- check it
- os.run("%s -arch armv7 -o %s -c %s", shellname, os.nuldev(), tmpfile)
-
- -- remove this tmp.S
- os.rm(tmpfile)
-end
-
-- get toolchains
function _toolchains(config)
@@ -82,7 +68,7 @@ function _toolchains(config)
if simulator then
checker.toolchain_insert(toolchains, "as", cross, "clang", "the assember")
else
- checker.toolchain_insert(toolchains, "as", path.join(os.toolsdir(), "utils/gas-preprocessor.pl " .. cross), "clang", "the assember", _check_as)
+ checker.toolchain_insert(toolchains, "as", path.join(os.programdir(), "scripts", "gas-preprocessor.pl " .. cross), "clang", "the assember")
end
-- save toolchains
diff --git a/xmake/platforms/watchos/check.lua b/xmake/platforms/watchos/check.lua
index c6ce73e21..60a923fa8 100644
--- a/xmake/platforms/watchos/check.lua
+++ b/xmake/platforms/watchos/check.lua
@@ -25,20 +25,6 @@
-- imports
import(".checker")
--- check the as
-function _check_as(shellname)
-
- -- make an empty tmp.S
- local tmpfile = os.tmpfile() .. ".S"
- io.writefile(tmpfile, "")
-
- -- check it
- os.run("%s -arch armv7 -o %s -c %s", shellname, os.nuldev(), tmpfile)
-
- -- remove this tmp.S
- os.rm(tmpfile)
-end
-
-- get toolchains
function _toolchains(config)
@@ -82,7 +68,7 @@ function _toolchains(config)
if simulator then
checker.toolchain_insert(toolchains, "as", cross, "clang", "the assember")
else
- checker.toolchain_insert(toolchains, "as", path.join(os.toolsdir(), "utils/gas-preprocessor.pl " .. cross), "clang", "the assember", _check_as)
+ checker.toolchain_insert(toolchains, "as", path.join(os.programdir(), "scripts", "gas-preprocessor.pl " .. cross), "clang", "the assember")
end
-- save toolchains
diff --git a/xmake/platforms/windows/check.lua b/xmake/platforms/windows/check.lua
index 8218ffd3a..28ad939bc 100644
--- a/xmake/platforms/windows/check.lua
+++ b/xmake/platforms/windows/check.lua
@@ -23,11 +23,11 @@
--
-- imports
-import("core.tool.tool")
-import("core.base.option")
-import("platforms.checker", {rootdir = os.programdir()})
+import(".checker")
import("environment")
+import("core.base.option")
import("detect.sdk.find_vstudio")
+import("lib.detect.find_tool")
-- attempt to check vs environment
function _check_vsenv(config)
@@ -65,7 +65,7 @@ function _check_vsenv(config)
-- check compiler
environment.enter("toolchains")
- local toolpath = tool.check("cl.exe")
+ local toolpath = find_tool("cl.exe")
environment.leave("toolchains")
-- ok?
diff --git a/xmake/tools/utils/gas-preprocessor.pl b/xmake/scripts/gas-preprocessor.pl
index 98dfe4ad9..98dfe4ad9 100755
--- a/xmake/tools/utils/gas-preprocessor.pl
+++ b/xmake/scripts/gas-preprocessor.pl