diff options
| author | ruki <[email protected]> | 2015-06-05 10:18:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-05 10:18:00 +0800 |
| commit | 12ce7dea3c7a74f77e9792236cb85bab4fd001e4 (patch) | |
| tree | a64fd1ef7c1380ae63e5c982472e8712489b3374 | |
| parent | f9cecfd11c958122bb6d619069593b91333bdf6f (diff) | |
add ccache
| -rwxr-xr-x | core/src/xmake/machine.c | 8 | ||||
| -rw-r--r-- | xmake/scripts/_xmake_main.lua | 1 | ||||
| -rw-r--r-- | xmake/scripts/base/main.lua | 18 | ||||
| -rw-r--r-- | xmake/scripts/base/makefile.lua | 29 | ||||
| -rw-r--r-- | xmake/scripts/platform/android/prober.lua | 41 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphoneos/iphoneos.lua | 29 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphoneos/prober.lua | 37 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphonesimulator/iphonesimulator.lua | 29 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphonesimulator/prober.lua | 34 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/linux.lua | 9 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/prober.lua | 41 | ||||
| -rw-r--r-- | xmake/scripts/platform/macosx/macosx.lua | 27 | ||||
| -rw-r--r-- | xmake/scripts/platform/macosx/prober.lua | 37 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/tools/nmake.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/windows.lua | 10 | ||||
| -rw-r--r-- | xmake/scripts/tools/make.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/tools/tools.lua | 45 |
17 files changed, 340 insertions, 63 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index a0c17b0e9..1fbfaaca4 100755 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -287,6 +287,14 @@ xm_machine_ref_t xm_machine_init() #endif lua_setglobal(impl->lua, "_ARCH"); + // init redirect to null +#if defined(TB_CONFIG_OS_WINDOWS) + lua_pushstring(impl->lua, "nul"); +#else + lua_pushstring(impl->lua, "/dev/null"); +#endif + lua_setglobal(impl->lua, "_NULDEV"); + // init namespace: xmake lua_newtable(impl->lua); lua_setglobal(impl->lua, "xmake"); diff --git a/xmake/scripts/_xmake_main.lua b/xmake/scripts/_xmake_main.lua index a81c37511..b897468f6 100644 --- a/xmake/scripts/_xmake_main.lua +++ b/xmake/scripts/_xmake_main.lua @@ -25,6 +25,7 @@ xmake = xmake or {} xmake._ARGV = _ARGV xmake._HOST = _HOST xmake._ARCH = _ARCH +xmake._NULDEV = _NULDEV xmake._VERSION = "XMake v1.0.1" xmake._PROGRAM_DIR = _PROGRAM_DIR xmake._PROJECT_DIR = _PROJECT_DIR diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index 2bd243ac4..96c3eac00 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -182,8 +182,12 @@ local menu = , {'-', "host", "kv", xmake._HOST, "The current host environment." } , {} - , {'o', "buildir", "kv", "build", "Set the build directory" } - , {'k', "packages", "kv", "pkg", "Set the packages directory" } + , {'o', "buildir", "kv", "build", "Set the build directory." } + , {'k', "packages", "kv", "pkg", "Set the packages directory." } + + , {} + , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." + , " --ccache=[y|n]" } , {} , {nil, "cross", "kv", nil, "The cross toolchains prefix" @@ -252,16 +256,18 @@ local menu = -- options , options = { - {'c', "clean", "k", nil, "Clean the cached configure and configure all again." } + {'c', "clean", "k", nil, "Clean the cached configure and configure all again." } + , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." + , " --ccache=[y|n]" } , {} -- the options for all platforms , function () return platform.menu("global") end , {} - , {'v', "verbose", "k", nil, "Print lots of verbose information." } - , {nil, "version", "k", nil, "Print the version number and exit." } - , {'h', "help", "k", nil, "Print this help message and exit." } + , {'v', "verbose", "k", nil, "Print lots of verbose information." } + , {nil, "version", "k", nil, "Print the version number and exit." } + , {'h', "help", "k", nil, "Print this help message and exit." } } } diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua index c3af02d05..275e15d07 100644 --- a/xmake/scripts/base/makefile.lua +++ b/xmake/scripts/base/makefile.lua @@ -34,6 +34,7 @@ local project = require("base/project") local linker = require("base/linker") local compiler = require("base/compiler") local tools = require("tools/tools") +local platform = require("platform/platform") -- make the object to the makefile function makefile._make_object(file, target, srcfile, objfile) @@ -49,6 +50,22 @@ function makefile._make_object(file, target, srcfile, objfile) return false end + -- get mode + local mode = config.get("mode") or "" + if mode == "release" then mode = ".r" + elseif mode == "debug" then mode = ".d" + elseif mode == "profile" then mode = ".p" + else mode = "" end + + -- get ccache + local ccache = platform.tool("ccache") + + -- make command + local cmd = compiler.make(c, target, srcfile, objfile) + if ccache then + cmd = ccache:append(cmd, " ") + end + -- make head file:write(string.format("%s:", objfile)) @@ -56,8 +73,7 @@ function makefile._make_object(file, target, srcfile, objfile) file:write(string.format(" %s\n", srcfile)) -- make body - local cmd = compiler.make(c, target, srcfile, objfile) - file:write(string.format("\t@echo [%s]: compiling %s\n", config.get("mode"), srcfile)) + file:write(string.format("\t@echo %scompiling%s %s\n", utils.ifelse(ccache, "ccache ", ""), mode, srcfile)) file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("%s", "%%20"))) file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile))) file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE)) @@ -130,9 +146,16 @@ function makefile._make_target(file, name, target) -- make dependence end file:write("\n") + -- get mode + local mode = config.get("mode") or "" + if mode == "release" then mode = ".r" + elseif mode == "debug" then mode = ".d" + elseif mode == "profile" then mode = ".p" + else mode = "" end + -- make body local cmd = linker.make(l, target, objfiles, targetfile) - file:write(string.format("\t@echo [%s]: linking %s\n", config.get("mode"), path.filename(targetfile))) + file:write(string.format("\t@echo linking%s %s\n", mode, path.filename(targetfile))) file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("%s", "%%20"))) file:write(string.format("\t@xmake l mkdir %s\n", path.directory(targetfile))) file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE)) diff --git a/xmake/scripts/platform/android/prober.lua b/xmake/scripts/platform/android/prober.lua index 891023387..e04d49c1e 100644 --- a/xmake/scripts/platform/android/prober.lua +++ b/xmake/scripts/platform/android/prober.lua @@ -45,12 +45,53 @@ function prober._probe_arch(configs) return true end +-- probe the ccache +function prober._probe_ccache(configs) + + -- get the ccache mode + local mode = configs.ccache + + -- ok? + if mode and mode == "y" and configs.__ccache then return true end + + -- disable? + if mode and mode == "n" then + configs.__ccache = nil + return true + end + + -- probe the ccache path + local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) + + -- probe ok? update it + if ccache_path then + configs.ccache = "y" + configs.__ccache = ccache_path + else + configs.ccache = "n" + end + + -- ok + return true +end + -- probe the project configure function prober.config(configs) -- probe the architecture if not prober._probe_arch(configs) then return end + -- probe the ccache + if not prober._probe_ccache(configs) then return end + +end + +-- probe the global configure +function prober.global(configs) + + -- probe the ccache + if not prober._probe_ccache(configs) then return end + end -- return module: prober diff --git a/xmake/scripts/platform/iphoneos/iphoneos.lua b/xmake/scripts/platform/iphoneos/iphoneos.lua index 7c6567416..75f8453a3 100644 --- a/xmake/scripts/platform/iphoneos/iphoneos.lua +++ b/xmake/scripts/platform/iphoneos/iphoneos.lua @@ -36,24 +36,25 @@ iphoneos._ARCHS = {"armv7", "armv7s", "arm64"} function iphoneos.make(configs) -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".dylib"} -- init the toolchains - configs.tools = {} - configs.tools.make = "make" - configs.tools.cc = config.get("cc") or "xcrun -sdk iphoneos clang" - configs.tools.cxx = config.get("cxx") or "xcrun -sdk iphoneos clang++" - 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 "xcrun -sdk iphoneos clang++" - configs.tools.ar = config.get("ar") or "xcrun -sdk iphoneos ar" - configs.tools.sh = config.get("sh") or "xcrun -sdk iphoneos clang++" + configs.tools = {} + configs.tools.make = "make" + configs.tools.ccache = config.get("__ccache") + configs.tools.cc = config.get("cc") or "xcrun -sdk iphoneos clang" + configs.tools.cxx = config.get("cxx") or "xcrun -sdk iphoneos clang++" + 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 "xcrun -sdk iphoneos clang++" + configs.tools.ar = config.get("ar") or "xcrun -sdk iphoneos ar" + configs.tools.sh = config.get("sh") or "xcrun -sdk iphoneos clang++" -- init xcode sdk directory - configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" .. config.get("xcode_sdkver") .. ".sdk" + configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" .. config.get("xcode_sdkver") .. ".sdk" end diff --git a/xmake/scripts/platform/iphoneos/prober.lua b/xmake/scripts/platform/iphoneos/prober.lua index d5de4a7c5..33ebe03ad 100644 --- a/xmake/scripts/platform/iphoneos/prober.lua +++ b/xmake/scripts/platform/iphoneos/prober.lua @@ -25,6 +25,7 @@ local os = require("base/os") local path = require("base/path") local utils = require("base/utils") local string = require("base/string") +local tools = require("tools/tools") -- define module: prober local prober = prober or {} @@ -125,6 +126,36 @@ function prober._probe_xcode_sdkver(configs) return true end +-- probe the ccache +function prober._probe_ccache(configs) + + -- get the ccache mode + local mode = configs.ccache + + -- ok? + if mode and mode == "y" and configs.__ccache then return true end + + -- disable? + if mode and mode == "n" then + configs.__ccache = nil + return true + end + + -- probe the ccache path + local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) + + -- probe ok? update it + if ccache_path then + configs.ccache = "y" + configs.__ccache = ccache_path + else + configs.ccache = "n" + end + + -- ok + return true +end + -- probe the project configure function prober.config(configs) @@ -137,6 +168,9 @@ function prober.config(configs) -- probe the xcode sdk version if not prober._probe_xcode_sdkver(configs) then return end + -- probe the ccache + if not prober._probe_ccache(configs) then return end + end -- probe the global configure @@ -145,6 +179,9 @@ function prober.global(configs) -- probe the xcode application directory if not prober._probe_xcode(configs) then return end + -- probe the ccache + if not prober._probe_ccache(configs) then return end + end -- return module: prober diff --git a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua index a7b0a99ff..fb9fd7e3e 100644 --- a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua +++ b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua @@ -36,24 +36,25 @@ iphonesimulator._ARCHS = {"x86", "x64"} function iphonesimulator.make(configs) -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".dylib"} -- init the toolchains - configs.tools = {} - configs.tools.make = "make" - configs.tools.cc = config.get("cc") or "xcrun -sdk iphonesimulator clang" - configs.tools.cxx = config.get("cxx") or "xcrun -sdk iphonesimulator clang++" - 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 "xcrun -sdk iphonesimulator clang++" - configs.tools.ar = config.get("ar") or "xcrun -sdk iphonesimulator ar" - configs.tools.sh = config.get("sh") or "xcrun -sdk iphonesimulator clang++" + configs.tools = {} + configs.tools.make = "make" + configs.tools.ccache = config.get("__ccache") + configs.tools.cc = config.get("cc") or "xcrun -sdk iphonesimulator clang" + configs.tools.cxx = config.get("cxx") or "xcrun -sdk iphonesimulator clang++" + 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 "xcrun -sdk iphonesimulator clang++" + configs.tools.ar = config.get("ar") or "xcrun -sdk iphonesimulator ar" + configs.tools.sh = config.get("sh") or "xcrun -sdk iphonesimulator clang++" -- init xcode sdk directory - configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" .. config.get("xcode_sdkver") .. ".sdk" + configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" .. config.get("xcode_sdkver") .. ".sdk" end diff --git a/xmake/scripts/platform/iphonesimulator/prober.lua b/xmake/scripts/platform/iphonesimulator/prober.lua index 6b81f88f7..6740720bf 100644 --- a/xmake/scripts/platform/iphonesimulator/prober.lua +++ b/xmake/scripts/platform/iphonesimulator/prober.lua @@ -25,6 +25,7 @@ local os = require("base/os") local path = require("base/path") local utils = require("base/utils") local string = require("base/string") +local tools = require("tools/tools") -- define module: prober local prober = prober or {} @@ -125,6 +126,36 @@ function prober._probe_xcode_sdkver(configs) return true end +-- probe the ccache +function prober._probe_ccache(configs) + + -- get the ccache mode + local mode = configs.ccache + + -- ok? + if mode and mode == "y" and configs.__ccache then return true end + + -- disable? + if mode and mode == "n" then + configs.__ccache = nil + return true + end + + -- probe the ccache path + local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) + + -- probe ok? update it + if ccache_path then + configs.ccache = "y" + configs.__ccache = ccache_path + else + configs.ccache = "n" + end + + -- ok + return true +end + -- probe the project configure function prober.config(configs) @@ -145,6 +176,9 @@ function prober.global(configs) -- probe the xcode application directory if not prober._probe_xcode(configs) then return end + -- probe the ccache + if not prober._probe_ccache(configs) then return end + end -- return module: prober diff --git a/xmake/scripts/platform/linux/linux.lua b/xmake/scripts/platform/linux/linux.lua index 3cc436d39..9226ee98a 100644 --- a/xmake/scripts/platform/linux/linux.lua +++ b/xmake/scripts/platform/linux/linux.lua @@ -36,10 +36,11 @@ linux._ARCHS = {"x86", "x64"} function linux.make(configs) -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".so"} + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".so"} + end -- get the option menu for action: xmake config or global diff --git a/xmake/scripts/platform/linux/prober.lua b/xmake/scripts/platform/linux/prober.lua index 5e382e5e4..1a3024df1 100644 --- a/xmake/scripts/platform/linux/prober.lua +++ b/xmake/scripts/platform/linux/prober.lua @@ -45,12 +45,53 @@ function prober._probe_arch(configs) return true end +-- probe the ccache +function prober._probe_ccache(configs) + + -- get the ccache mode + local mode = configs.ccache + + -- ok? + if mode and mode == "y" and configs.__ccache then return true end + + -- disable? + if mode and mode == "n" then + configs.__ccache = nil + return true + end + + -- probe the ccache path + local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) + + -- probe ok? update it + if ccache_path then + configs.ccache = "y" + configs.__ccache = ccache_path + else + configs.ccache = "n" + end + + -- ok + return true +end + -- probe the project configure function prober.config(configs) -- probe the architecture if not prober._probe_arch(configs) then return end + -- probe the ccache + if not prober._probe_ccache(configs) then return end + +end + +-- probe the global configure +function prober.global(configs) + + -- probe the ccache + if not prober._probe_ccache(configs) then return end + end -- return module: prober diff --git a/xmake/scripts/platform/macosx/macosx.lua b/xmake/scripts/platform/macosx/macosx.lua index 9483f2f24..4ccd27951 100644 --- a/xmake/scripts/platform/macosx/macosx.lua +++ b/xmake/scripts/platform/macosx/macosx.lua @@ -36,21 +36,22 @@ macosx._ARCHS = {"x86", "x64"} function macosx.make(configs) -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".dylib"} -- init the toolchains - configs.tools = {} - configs.tools.make = "make" - configs.tools.cc = config.get("cc") or "xcrun -sdk macosx clang" - configs.tools.cxx = config.get("cxx") or "xcrun -sdk macosx clang++" - 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 "xcrun -sdk macosx clang++" - configs.tools.ar = config.get("ar") or "xcrun -sdk macosx ar" - configs.tools.sh = config.get("sh") or "xcrun -sdk macosx clang++" + configs.tools = {} + configs.tools.make = "make" + configs.tools.ccache = config.get("__ccache") + configs.tools.cc = config.get("cc") or "xcrun -sdk macosx clang" + configs.tools.cxx = config.get("cxx") or "xcrun -sdk macosx clang++" + 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 "xcrun -sdk macosx clang++" + configs.tools.ar = config.get("ar") or "xcrun -sdk macosx ar" + configs.tools.sh = config.get("sh") or "xcrun -sdk macosx clang++" -- init xcode sdk directory configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. config.get("xcode_sdkver") .. ".sdk" diff --git a/xmake/scripts/platform/macosx/prober.lua b/xmake/scripts/platform/macosx/prober.lua index 3a3615293..f3077d913 100644 --- a/xmake/scripts/platform/macosx/prober.lua +++ b/xmake/scripts/platform/macosx/prober.lua @@ -25,6 +25,7 @@ local os = require("base/os") local path = require("base/path") local utils = require("base/utils") local string = require("base/string") +local tools = require("tools/tools") -- define module: prober local prober = prober or {} @@ -125,6 +126,36 @@ function prober._probe_xcode_sdkver(configs) return true end +-- probe the ccache +function prober._probe_ccache(configs) + + -- get the ccache mode + local mode = configs.ccache + + -- ok? + if mode and mode == "y" and configs.__ccache then return true end + + -- disable? + if mode and mode == "n" then + configs.__ccache = nil + return true + end + + -- probe the ccache path + local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) + + -- probe ok? update it + if ccache_path then + configs.ccache = "y" + configs.__ccache = ccache_path + else + configs.ccache = "n" + end + + -- ok + return true +end + -- probe the project configure function prober.config(configs) @@ -137,6 +168,9 @@ function prober.config(configs) -- probe the xcode sdk version if not prober._probe_xcode_sdkver(configs) then return end + -- probe the ccache + if not prober._probe_ccache(configs) then return end + end -- probe the global configure @@ -145,6 +179,9 @@ function prober.global(configs) -- probe the xcode application directory if not prober._probe_xcode(configs) then return end + -- probe the ccache + if not prober._probe_ccache(configs) then return end + end -- return module: prober diff --git a/xmake/scripts/platform/windows/tools/nmake.lua b/xmake/scripts/platform/windows/tools/nmake.lua index 6d6b21258..b7fc033c3 100644 --- a/xmake/scripts/platform/windows/tools/nmake.lua +++ b/xmake/scripts/platform/windows/tools/nmake.lua @@ -90,9 +90,9 @@ function nmake.main(mkfile, target) -- make command local cmd = nil if mkfile and os.isfile(mkfile) then - cmd = string.format("%s /f %s %s VERBOSE=%s 2> nul", nmake._NAME, mkfile, target or "", nmake._VERBOSE) + cmd = string.format("%s /f %s %s VERBOSE=%s 2> %s", nmake._NAME, mkfile, target or "", nmake._VERBOSE, xmake._NULDEV) else - cmd = string.format("%s %s VERBOSE=%s 2> nul", nmake._NAME, target or "", nmake._VERBOSE) + cmd = string.format("%s %s VERBOSE=%s 2> %s", nmake._NAME, target or "", nmake._VERBOSE, xmake._NULDEV) end -- done diff --git a/xmake/scripts/platform/windows/windows.lua b/xmake/scripts/platform/windows/windows.lua index 03e30864e..a3d80c49a 100644 --- a/xmake/scripts/platform/windows/windows.lua +++ b/xmake/scripts/platform/windows/windows.lua @@ -36,11 +36,11 @@ windows._ARCHS = {"x86", "x64"} function windows.make(configs) -- init the file formats - configs.formats = {} - configs.formats.static = {"", ".lib"} - configs.formats.object = {"", ".obj"} - configs.formats.shared = {"", ".dll"} - configs.formats.binary = {"", ".exe"} + configs.formats = {} + configs.formats.static = {"", ".lib"} + configs.formats.object = {"", ".obj"} + configs.formats.shared = {"", ".dll"} + configs.formats.binary = {"", ".exe"} -- init the toolchains configs.tools = {} diff --git a/xmake/scripts/tools/make.lua b/xmake/scripts/tools/make.lua index 06a3a92dc..25dd13515 100644 --- a/xmake/scripts/tools/make.lua +++ b/xmake/scripts/tools/make.lua @@ -44,9 +44,9 @@ function make.main(mkfile, target) -- make command local cmd = nil if mkfile and os.isfile(mkfile) then - cmd = string.format("%s -j4 -f %s %s VERBOSE=%s", make.name, mkfile, target or "", make._VERBOSE) + cmd = string.format("%s -j4 -f %s %s VERBOSE=%s 2> %s", make.name, mkfile, target or "", make._VERBOSE, xmake._NULDEV) else - cmd = string.format("%s -j4 %s VERBOSE=%s", make.name, target or "", make._VERBOSE) + cmd = string.format("%s -j4 %s VERBOSE=%s 2> %s", make.name, target or "", make._VERBOSE, xmake._NULDEV) end -- done diff --git a/xmake/scripts/tools/tools.lua b/xmake/scripts/tools/tools.lua index af095618e..abcee4018 100644 --- a/xmake/scripts/tools/tools.lua +++ b/xmake/scripts/tools/tools.lua @@ -73,6 +73,24 @@ function tools._find_from(root, name) end +-- probe it's absolute path if exists from the given tool name and root directory +function tools._probe(root, name) + + -- check + assert(root and name) + + -- make the tool path + local toolpath = string.format("%s/%s", root, name) + toolpath = path.translate(toolpath) + + -- the tool exists? ok + if toolpath and os.isfile(toolpath) then + return toolpath + end +end + + + -- find tool from the given name and directory (optional) function tools.find(name, root) @@ -140,5 +158,32 @@ function tools.get(name) return tools.load(platform.tool(name)) end +-- probe it's absolute path if exists from the given tool name +function tools.probe(name, dirs) + + -- check + assert(name) + + -- attempt to run it directly first + if os.execute(string.format("%s > %s 2>&1", name, xmake._NULDEV)) ~= 0x7f00 then + return name + end + + -- attempt to get it from the given directories + if dirs then + for _, dir in ipairs(dirs) do + + -- probe it + local toolpath = tools._probe(dir, name) + + -- ok? + if toolpath then + return toolpath + end + end + end +end + + -- return module: tools return tools |
