summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-03 11:56:22 +0800
committerruki <[email protected]>2015-06-03 11:56:22 +0800
commit8f5a561006bb5b0952278075deb908633317c987 (patch)
tree4a57ebf7283fd7c47b88f7c7c0aac4caa67cb607 /xmake/scripts
parent648d0f6875478a5184668996f3948a0e61e862a0 (diff)
clean the cached configure
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/config.lua63
-rw-r--r--xmake/scripts/base/global.lua40
-rw-r--r--xmake/scripts/base/main.lua10
-rw-r--r--xmake/scripts/platform/android/_prober.lua2
-rw-r--r--xmake/scripts/platform/iphoneos/_prober.lua4
-rw-r--r--xmake/scripts/platform/iphonesimulator/_prober.lua4
-rw-r--r--xmake/scripts/platform/linux/_prober.lua2
-rw-r--r--xmake/scripts/platform/macosx/_prober.lua4
-rw-r--r--xmake/scripts/platform/platform.lua4
-rw-r--r--xmake/scripts/platform/windows/_prober.lua2
10 files changed, 89 insertions, 46 deletions
diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua
index 92721fa70..7b6ef01b9 100644
--- a/xmake/scripts/base/config.lua
+++ b/xmake/scripts/base/config.lua
@@ -25,6 +25,7 @@ local config = config or {}
-- load modules
local io = require("base/io")
+local os = require("base/os")
local utils = require("base/utils")
local option = require("base/option")
local global = require("base/global")
@@ -173,6 +174,17 @@ function config._make()
end
end
+-- get the configure file
+function config._file()
+
+ -- the options
+ local options = xmake._OPTIONS
+ assert(options and options.project)
+
+ -- get the configure file
+ return options.project .. "/.xmake.xconf"
+end
+
-- get the current target scope
function config._target()
@@ -234,16 +246,12 @@ end
-- save xmake.xconf
function config.savexconf()
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
-- the configs
local configs = config._CONFIGS
assert(configs)
-- open the configure file
- local path = options.project .. "/.xmake.xconf"
+ local path = config._file()
local file = io.open(path, "w")
if not file then
-- error
@@ -271,7 +279,7 @@ function config.loadxconf()
-- the options
local options = xmake._OPTIONS
- assert(options and options.project)
+ assert(options)
-- check
assert(option._MENU)
@@ -288,27 +296,36 @@ function config.loadxconf()
end
end
- -- load and execute the xmake.xconf
- local path = options.project .. "/.xmake.xconf"
- local newenv = preprocessor.loadfile(path, "config", configures, {"target"})
+ -- does not clean the cached configure?
+ if not options.clean then
- -- exists local configures?
- if newenv then
+ -- load and execute the xmake.xconf
+ local path = config._file()
+ if os.isfile(path) then
+ local newenv, errors = preprocessor.loadfile(path, "config", configures, {"target"})
- -- save configs
- config._CONFIGS = newenv._CONFIGS
+ -- exists local configures?
+ if newenv then
- -- clear configs if the host has been changed
- local target = config._target()
- if target and target.host ~= xmake._HOST then
- -- clear configs
- config._CONFIGS = {}
- end
+ -- save configs
+ config._CONFIGS = newenv._CONFIGS
- -- clear configs if the plat has been changed
- if target and target.plat and options.plat and target.plat ~= options.plat then
- -- clear configs
- config._CONFIGS = {}
+ -- clear configs if the host has been changed
+ local target = config._target()
+ if target and target.host ~= xmake._HOST then
+ -- clear configs
+ config._CONFIGS = {}
+ end
+
+ -- clear configs if the plat has been changed
+ if target and target.plat and options.plat and target.plat ~= options.plat then
+ -- clear configs
+ config._CONFIGS = {}
+ end
+ elseif errors then
+ -- error
+ utils.error(errors)
+ end
end
end
diff --git a/xmake/scripts/base/global.lua b/xmake/scripts/base/global.lua
index 2371445ee..d1faff4b9 100644
--- a/xmake/scripts/base/global.lua
+++ b/xmake/scripts/base/global.lua
@@ -126,6 +126,13 @@ function global._make()
end
end
+-- get the configure file
+function global._file()
+
+ -- get it
+ return path.translate("~/.xmake/xmake.xconf")
+end
+
-- get the given configure from the current
function global.get(name)
@@ -160,10 +167,6 @@ end
-- save xmake.xconf
function global.savexconf()
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
-- the configs
local configs = global._CONFIGS
assert(configs)
@@ -174,7 +177,7 @@ function global.savexconf()
end
-- open the configure file
- local path = path.translate("~/.xmake/xmake.xconf")
+ local path = global._file()
local file = io.open(path, "w")
if not file then
-- error
@@ -219,11 +222,20 @@ function global.loadxconf()
end
end
- -- load and execute the xmake.xconf
- local path = path.translate("~/.xmake/xmake.xconf")
- local newenv = preprocessor.loadfile(path, "global", configures)
- if newenv then
- global._CONFIGS = newenv._CONFIGS
+ -- does not clean the cached configure?
+ if not options.clean then
+
+ -- load and execute the xmake.xconf
+ local path = global._file()
+ if os.isfile(path) then
+ local newenv, errors = preprocessor.loadfile(path, "global", configures)
+ if newenv then
+ global._CONFIGS = newenv._CONFIGS
+ elseif errors then
+ -- error
+ utils.error(errors);
+ end
+ end
end
-- init configs
@@ -273,5 +285,13 @@ function global.dump()
end
+-- clean the current configure
+function global.clean()
+
+ -- remove the configure file
+ os.rm(global._file())
+
+end
+
-- return module: global
return global
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua
index 28e9ca14b..92df2c29c 100644
--- a/xmake/scripts/base/main.lua
+++ b/xmake/scripts/base/main.lua
@@ -144,7 +144,10 @@ local menu =
-- options
, options =
{
- {'p', "plat", "kv", xmake._HOST, "Compile for the given platform."
+ {'c', "clean", "k", nil, "Clean the cached configure and configure all again." }
+
+ , {}
+ , {'p', "plat", "kv", xmake._HOST, "Compile for the given platform."
, function ()
local descriptions = {}
local plats = platform.plats()
@@ -249,8 +252,11 @@ local menu =
-- options
, options =
{
+ {'c', "clean", "k", nil, "Clean the cached configure and configure all again." }
+
+ , {}
-- the options for all platforms
- function () return platform.menu("global") end
+ , function () return platform.menu("global") end
, {}
, {'v', "verbose", "k", nil, "Print lots of verbose information." }
diff --git a/xmake/scripts/platform/android/_prober.lua b/xmake/scripts/platform/android/_prober.lua
index c13b46c01..28ccc3e9f 100644
--- a/xmake/scripts/platform/android/_prober.lua
+++ b/xmake/scripts/platform/android/_prober.lua
@@ -46,7 +46,7 @@ function _prober._probe_arch(configs)
end
-- probe the configure
-function _prober.done(configs)
+function _prober.done(configs, is_global)
-- probe the architecture
if not _prober._probe_arch(configs) then return end
diff --git a/xmake/scripts/platform/iphoneos/_prober.lua b/xmake/scripts/platform/iphoneos/_prober.lua
index f62630583..f28d0a672 100644
--- a/xmake/scripts/platform/iphoneos/_prober.lua
+++ b/xmake/scripts/platform/iphoneos/_prober.lua
@@ -126,7 +126,7 @@ function _prober._probe_xcode_sdkver(configs)
end
-- probe the configure
-function _prober.done(configs)
+function _prober.done(configs, is_global)
-- probe the architecture
if not _prober._probe_arch(configs) then return end
@@ -135,7 +135,7 @@ function _prober.done(configs)
if not _prober._probe_xcode(configs) then return end
-- probe the xcode sdk version
- if not _prober._probe_xcode_sdkver(configs) then return end
+ if not is_global and not _prober._probe_xcode_sdkver(configs) then return end
end
diff --git a/xmake/scripts/platform/iphonesimulator/_prober.lua b/xmake/scripts/platform/iphonesimulator/_prober.lua
index 9e7c85202..eeb485b86 100644
--- a/xmake/scripts/platform/iphonesimulator/_prober.lua
+++ b/xmake/scripts/platform/iphonesimulator/_prober.lua
@@ -126,7 +126,7 @@ function _prober._probe_xcode_sdkver(configs)
end
-- probe the configure
-function _prober.done(configs)
+function _prober.done(configs, is_global)
-- probe the architecture
if not _prober._probe_arch(configs) then return end
@@ -135,7 +135,7 @@ function _prober.done(configs)
if not _prober._probe_xcode(configs) then return end
-- probe the xcode sdk version
- if not _prober._probe_xcode_sdkver(configs) then return end
+ if not is_global and not _prober._probe_xcode_sdkver(configs) then return end
end
diff --git a/xmake/scripts/platform/linux/_prober.lua b/xmake/scripts/platform/linux/_prober.lua
index 13cb0b52f..717bd71fe 100644
--- a/xmake/scripts/platform/linux/_prober.lua
+++ b/xmake/scripts/platform/linux/_prober.lua
@@ -46,7 +46,7 @@ function _prober._probe_arch(configs)
end
-- probe the configure
-function _prober.done(configs)
+function _prober.done(configs, is_global)
-- probe the architecture
if not _prober._probe_arch(configs) then return end
diff --git a/xmake/scripts/platform/macosx/_prober.lua b/xmake/scripts/platform/macosx/_prober.lua
index 81625af9e..9e722d4d0 100644
--- a/xmake/scripts/platform/macosx/_prober.lua
+++ b/xmake/scripts/platform/macosx/_prober.lua
@@ -126,7 +126,7 @@ function _prober._probe_xcode_sdkver(configs)
end
-- probe the configure
-function _prober.done(configs)
+function _prober.done(configs, is_global)
-- probe the architecture
if not _prober._probe_arch(configs) then return end
@@ -135,7 +135,7 @@ function _prober.done(configs)
if not _prober._probe_xcode(configs) then return end
-- probe the xcode sdk version
- if not _prober._probe_xcode_sdkver(configs) then return end
+ if not is_global and not _prober._probe_xcode_sdkver(configs) then return end
end
diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua
index 2858018c2..4361ea42a 100644
--- a/xmake/scripts/platform/platform.lua
+++ b/xmake/scripts/platform/platform.lua
@@ -275,7 +275,7 @@ function platform.probe(configs, is_global)
for _, plat in ipairs(plats) do
local p = platform._load(plat)
if p and p._PROBER and p._PROBER.done and p._HOST and p._HOST == xmake._HOST then
- p._PROBER.done(configs)
+ p._PROBER.done(configs, is_global)
end
end
@@ -284,7 +284,7 @@ function platform.probe(configs, is_global)
-- probe it
local p = platform._load(config.get("plat"))
if p and p._PROBER and p._PROBER.done then
- p._PROBER.done(configs)
+ p._PROBER.done(configs, is_global)
end
end
end
diff --git a/xmake/scripts/platform/windows/_prober.lua b/xmake/scripts/platform/windows/_prober.lua
index 3361e8939..0eb5d0157 100644
--- a/xmake/scripts/platform/windows/_prober.lua
+++ b/xmake/scripts/platform/windows/_prober.lua
@@ -186,7 +186,7 @@ function _prober._probe_vs_path(configs)
end
-- probe the configure
-function _prober.done(configs)
+function _prober.done(configs, is_global)
-- probe the architecture
if not _prober._probe_arch(configs) then return end