summaryrefslogtreecommitdiff
path: root/xmake/scripts/platform
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-05 10:18:00 +0800
committerruki <[email protected]>2015-06-05 10:18:00 +0800
commit12ce7dea3c7a74f77e9792236cb85bab4fd001e4 (patch)
treea64fd1ef7c1380ae63e5c982472e8712489b3374 /xmake/scripts/platform
parentf9cecfd11c958122bb6d619069593b91333bdf6f (diff)
add ccache
Diffstat (limited to 'xmake/scripts/platform')
-rw-r--r--xmake/scripts/platform/android/prober.lua41
-rw-r--r--xmake/scripts/platform/iphoneos/iphoneos.lua29
-rw-r--r--xmake/scripts/platform/iphoneos/prober.lua37
-rw-r--r--xmake/scripts/platform/iphonesimulator/iphonesimulator.lua29
-rw-r--r--xmake/scripts/platform/iphonesimulator/prober.lua34
-rw-r--r--xmake/scripts/platform/linux/linux.lua9
-rw-r--r--xmake/scripts/platform/linux/prober.lua41
-rw-r--r--xmake/scripts/platform/macosx/macosx.lua27
-rw-r--r--xmake/scripts/platform/macosx/prober.lua37
-rw-r--r--xmake/scripts/platform/windows/tools/nmake.lua4
-rw-r--r--xmake/scripts/platform/windows/windows.lua10
11 files changed, 246 insertions, 52 deletions
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 = {}