summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-04-05 09:49:33 +0800
committerruki <[email protected]>2016-04-05 09:49:33 +0800
commitee1293db712b47706496da86e0564010bafdaaa9 (patch)
tree3d39b3830789da4a4d9e7c9b1abfca71ba27b205
parentfedf748ddd3353f6065dc2502eaec2e396bc2c2a (diff)
adjust global priority
-rwxr-xr-xxmake/actions/global/main.lua64
-rwxr-xr-xxmake/actions/global/xmake.lua47
-rw-r--r--xmake/core/project/config.lua2
-rw-r--r--xmake/core/project/global.lua51
-rw-r--r--xmake/core/sandbox/modules/import/core/project/global.lua10
-rw-r--r--xmake/core/sandbox/modules/import/core/project/task.lua1
6 files changed, 83 insertions, 92 deletions
diff --git a/xmake/actions/global/main.lua b/xmake/actions/global/main.lua
new file mode 100755
index 000000000..9c3434091
--- /dev/null
+++ b/xmake/actions/global/main.lua
@@ -0,0 +1,64 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file main.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.global")
+
+-- main
+function main()
+
+ -- override the option configure
+ --
+ -- priority: option > option_default > config_check > global_cache
+ --
+ for name, value in pairs(option.options()) do
+ if name ~= "verbose" and name ~= "clean" then
+ global.set(name, value)
+ end
+ end
+
+ -- merge the default options
+ for name, value in pairs(option.defaults()) do
+ if name ~= "verbose" and name ~= "clean" and global.get(name) == nil then
+ global.set(name, value)
+ end
+ end
+
+ -- merge the checked configure
+ global.probe()
+
+ -- merge the cached configure
+ if not option.get("clean") then
+ global.load()
+ end
+
+ -- save it
+ global.save()
+
+ -- dump it
+ global.dump()
+
+ -- trace
+ print("configure ok!")
+
+end
diff --git a/xmake/actions/global/xmake.lua b/xmake/actions/global/xmake.lua
index 748866e27..9f5123fb2 100755
--- a/xmake/actions/global/xmake.lua
+++ b/xmake/actions/global/xmake.lua
@@ -27,52 +27,7 @@ task("global")
set_task_category("action")
-- on run
- on_task_run(function ()
-
- -- imports
- import("core.base.option")
- import("core.project.global")
-
- -- load configure
- --
- -- priority: option > config_check > global_cache > option_default
- --
- global.load()
-
- -- clean the cached configure?
- if option.get("clean") then
-
- -- clean it
- global.clean()
- end
-
- -- merge the default options
- for name, value in pairs(option.defaults()) do
- if name ~= "verbose" and name ~= "clean" and global.get(name) == nil then
- global.set(name, value)
- end
- end
-
- -- override the checked configure
- global.probe()
-
- -- override the option configure
- for name, value in pairs(option.options()) do
- if name ~= "verbose" and name ~= "clean" then
- global.set(name, value)
- end
- end
-
- -- save it
- global.save()
-
- -- dump it
- global.dump()
-
- -- trace
- print("configure ok!")
-
- end)
+ on_task_run("main")
-- set menu
set_task_menu({
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index f6e94fda4..761855011 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -36,7 +36,7 @@ local global = require("project/global")
function config._file()
-- get it
- return path.join(config.directory(), "/xmake.conf")
+ return path.join(config.directory(), "xmake.conf")
end
-- get the current given configure
diff --git a/xmake/core/project/global.lua b/xmake/core/project/global.lua
index f4e386c08..cd4682e15 100644
--- a/xmake/core/project/global.lua
+++ b/xmake/core/project/global.lua
@@ -34,17 +34,17 @@ local option = require("base/option")
function global._file()
-- get it
- return path.join(global.directory(), "/xmake.conf")
+ return path.join(global.directory(), "xmake.conf")
end
-- get the current given configure from
function global.get(name)
- -- check
- assert(name and global._CONFIGS)
+ -- get configs
+ local configs = global._CONFIGS or {}
-- the value
- local value = global._CONFIGS[name]
+ local value = configs[name]
if type(value) == "string" and value == "auto" then
value = nil
end
@@ -56,35 +56,15 @@ end
-- set the current given configure
function global.set(name, value)
- -- check
- assert(global._CONFIGS and name)
+ -- get configs
+ local configs = global._CONFIGS or {}
+ global._CONFIGS = configs
-- set it
- global._CONFIGS[name] = value
+ configs[name] = value
end
--- clean the global configure
-function global.clean()
-
- -- check
- assert(global._CONFIGS)
-
- -- clean it
- global._CONFIGS = {}
-
- -- save it
- if os.isfile(global._file()) then
- local ok, errors = os.rm(global._file())
- if not ok then
- return false, errors
- end
- end
-
- -- ok
- return true
-end
-
-- get all options
function global.options()
@@ -118,20 +98,21 @@ function global.load()
if os.isfile(filepath) then
-- load configs
- local configs, errors = io.load(filepath)
+ local results, errors = io.load(filepath)
-- error?
- if not configs and errors then
+ if not results and errors then
utils.error(errors)
end
- -- save configs
- global._CONFIGS = configs
+ -- merge the configure
+ for name, value in pairs(results) do
+ if global.get(name) == nil then
+ global.set(name, value)
+ end
+ end
end
- -- init configs
- global._CONFIGS = global._CONFIGS or {}
-
-- ok
return true
end
diff --git a/xmake/core/sandbox/modules/import/core/project/global.lua b/xmake/core/sandbox/modules/import/core/project/global.lua
index b6f321167..8c2492c62 100644
--- a/xmake/core/sandbox/modules/import/core/project/global.lua
+++ b/xmake/core/sandbox/modules/import/core/project/global.lua
@@ -69,16 +69,6 @@ function sandbox_core_project_global.save()
end
end
--- clean the configure
-function sandbox_core_project_global.clean()
-
- -- clean it
- local ok, errors = global.clean()
- if not ok then
- raise(errors)
- end
-end
-
-- probe the configure
function sandbox_core_project_global.probe()
diff --git a/xmake/core/sandbox/modules/import/core/project/task.lua b/xmake/core/sandbox/modules/import/core/project/task.lua
index cd7161e38..fac132ce9 100644
--- a/xmake/core/sandbox/modules/import/core/project/task.lua
+++ b/xmake/core/sandbox/modules/import/core/project/task.lua
@@ -48,6 +48,7 @@ function sandbox_core_project_task.run(taskname, options, ...)
end
end
+ -- FIXME --verbose no value
-- make command
local cmd = "xmake " .. (taskname or "")
for name, value in pairs(options) do