summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-02-02 23:40:58 +0800
committerruki <[email protected]>2018-02-02 16:05:49 +0800
commit45a545b3772bebd9843d991b0223c4e103b036b4 (patch)
tree1a7e90b4d7cc1b0b9f5edd30d6464d570ef9182f
parent7338d6b1e13648f3175555b1f1c4c69301f5bbd0 (diff)
load previous config in menuconf
-rw-r--r--xmake/actions/config/menuconf.lua28
-rw-r--r--xmake/core/project/config.lua6
-rw-r--r--xmake/core/sandbox/modules/import/core/project/config.lua21
-rw-r--r--xmake/core/ui/mconfdialog.lua2
4 files changed, 41 insertions, 16 deletions
diff --git a/xmake/actions/config/menuconf.lua b/xmake/actions/config/menuconf.lua
index 4df099590..4eebf3c39 100644
--- a/xmake/actions/config/menuconf.lua
+++ b/xmake/actions/config/menuconf.lua
@@ -51,7 +51,6 @@ function app:init()
-- insert menu config dialog
self:insert(self:mconfdialog())
- -- TODO
-- load configs
self:load(not option.get("clean"))
end
@@ -119,7 +118,7 @@ function app:_menu_by_category(configs, menus, category)
end
-- make configs by category
-function app:_make_configs_by_category(options_by_category, get_option_info)
+function app:_make_configs_by_category(options_by_category, cache, get_option_info)
-- make configs category
--
@@ -145,7 +144,15 @@ function app:_make_configs_by_category(options_by_category, get_option_info)
-- load value
local value = nil
if cache then
- value = config.get(value)
+ value = config.get(info.name)
+ if value ~= nil and info.kind == "choice" and info.values then
+ for idx, val in ipairs(info.values) do
+ if value == val then
+ value = idx
+ break
+ end
+ end
+ end
end
-- find the menu index in subconfigs
@@ -199,7 +206,7 @@ function app:_basic_configs(cache)
end
-- make configs by category
- self._BASIC_CONFIGS = self:_make_configs_by_category(options_by_category, function (opt)
+ self._BASIC_CONFIGS = self:_make_configs_by_category(options_by_category, cache, function (opt)
-- get default
local default = opt[4]
@@ -266,9 +273,7 @@ function app:_project_configs(cache)
end
-- make configs by category
- self._PROJECT_CONFIGS = self:_make_configs_by_category(options_by_category, function (opt)
-
- -- TODO
+ self._PROJECT_CONFIGS = self:_make_configs_by_category(options_by_category, cache, function (opt)
-- the default value
local default = "auto"
if opt:get("default") ~= nil then
@@ -301,11 +306,20 @@ function app:load(cache)
cache = config.load(option.get("target") or "all")
end
+ -- clear configs first
+ self._BASIC_CONFIGS = nil
+ self._PROJECT_CONFIGS = nil
+
-- load configs
local configs = {}
table.insert(configs, menuconf.menu {description = "Basic Configuration", configs = self:_basic_configs(cache)})
table.insert(configs, menuconf.menu {description = "Project Configuration", configs = self:_project_configs(cache)})
self:mconfdialog():load(configs)
+
+ -- the previous config is only for loading menuconf, so clear config now
+ if cache then
+ config.clear()
+ end
end
-- save configs to options
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index 500ee8933..598212b03 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -231,6 +231,12 @@ function config.read(name, targetname)
return value
end
+-- clear config
+function config.clear()
+ config._MODES = nil
+ config._CONFIGS = nil
+end
+
-- dump the configure
function config.dump()
diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua
index d3f48cb0b..657c37d57 100644
--- a/xmake/core/sandbox/modules/import/core/project/config.lua
+++ b/xmake/core/sandbox/modules/import/core/project/config.lua
@@ -55,7 +55,7 @@ function sandbox_core_project_config.host()
return config.get("host")
end
--- get the configure directory
+-- get the configuration directory
function sandbox_core_project_config.directory()
-- get it
@@ -66,12 +66,12 @@ function sandbox_core_project_config.directory()
return dir
end
--- get the given configure from the current
+-- get the given configuration from the current
function sandbox_core_project_config.get(name)
return config.get(name)
end
--- set the given configure to the current
+-- set the given configuration to the current
--
-- @param name the name
-- @param value the value
@@ -86,12 +86,12 @@ function sandbox_core_project_config.readonly(name)
return config.readonly(name)
end
--- load the configure
+-- load the configuration
function sandbox_core_project_config.load(targetname)
return config.load(targetname)
end
--- save the configure
+-- save the configuration
function sandbox_core_project_config.save(targetname)
-- save it
@@ -101,12 +101,17 @@ function sandbox_core_project_config.save(targetname)
end
end
--- read the value from the configure file directly
+-- read the value from the configuration file directly
function sandbox_core_project_config.read(name, targetname)
return config.read(name, targetname)
end
--- check the configure
+-- clear the configuration
+function sandbox_core_project_config.clear()
+ config.clear()
+end
+
+-- check the configuration
function sandbox_core_project_config.check()
-- get the check script
@@ -116,7 +121,7 @@ function sandbox_core_project_config.check()
end
end
--- dump the configure
+-- dump the configuration
function sandbox_core_project_config.dump()
config.dump()
end
diff --git a/xmake/core/ui/mconfdialog.lua b/xmake/core/ui/mconfdialog.lua
index 41e2947a9..635d8494f 100644
--- a/xmake/core/ui/mconfdialog.lua
+++ b/xmake/core/ui/mconfdialog.lua
@@ -151,7 +151,7 @@ end
-- get choice dialog
function mconfdialog:choicedialog()
if not self._CHOICEDIALOG then
- local dialog_choice = choicedialog:new("mconfdialog.choice", rect {0, 0, math.min(80, self:width()), math.min(16, self:height())}, "input dialog")
+ local dialog_choice = choicedialog:new("mconfdialog.choice", rect {0, 0, math.min(80, self:width()), math.min(20, self:height())}, "input dialog")
dialog_choice:background_set(self:frame():background())
dialog_choice:frame():background_set("cyan")
dialog_choice:box():frame():background_set("cyan")