diff options
| author | ruki <[email protected]> | 2016-03-16 11:01:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-03-16 11:01:10 +0800 |
| commit | 713413a6f962704fdb5078a38b32c8637eca3d7a (patch) | |
| tree | 68fde05da6780dd76a3150a66d331215b0bc058e | |
| parent | 566d33d6be83884239cce7df0655e60ec00bd836 (diff) | |
save configure
| -rwxr-xr-x | xmake/actions/config/main.lua | 13 | ||||
| -rw-r--r-- | xmake/core/project/config.lua | 14 | ||||
| -rw-r--r-- | xmake/core/project/global.lua | 17 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 33 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/config.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 7 |
6 files changed, 62 insertions, 32 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 89d928a09..b09720be1 100755 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -34,11 +34,14 @@ end -- main function main() + -- the target name + local targetname = option.get("target") + -- load global configure global.load() -- load project configure - config.load(option.get("target")) + config.load(targetname) -- clean the cached configure? if option.get("clean") then @@ -83,6 +86,14 @@ function main() -- load project project.load() + -- check target + if nil == project.target(targetname) then + raise("unknown target: %s", targetname) + end + + -- save the project configure + config.save() + -- TODO -- dump it diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 08b9d72eb..ab4a4c46d 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -189,6 +189,20 @@ function config.load(targetname) return true end +-- save the project configure +function config.save() + + -- the options + local options = config.options() + assert(options) + + -- add version + options.__version = xmake._VERSION + + -- save it + return io.save(config._file(), options) +end + -- dump the configure function config.dump() diff --git a/xmake/core/project/global.lua b/xmake/core/project/global.lua index 410eab08b..7f4ef0b3f 100644 --- a/xmake/core/project/global.lua +++ b/xmake/core/project/global.lua @@ -139,22 +139,15 @@ end -- save the global configure function global.save() - -- check - assert(global._CONFIGS) - - -- remove values with "auto" from the configure - local configs = {} - for name, value in pairs(global._CONFIGS) do - if type(value) ~= "string" or value ~= "auto" then - configs[name] = value - end - end + -- the options + local options = global.options() + assert(options) -- add version - configs.__version = xmake._VERSION + options.__version = xmake._VERSION -- save it - return io.save(global._file(), configs) + return io.save(global._file(), options) end -- dump the configure diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index d8b19081b..c8f0a0fa2 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -862,6 +862,20 @@ function project._make_options(options) end +-- get the given target +function project.target(targetname) + + -- check + assert(targetname and targetname ~= "all") + + -- the targets + local targets = project.targets() + assert(targets) + + -- get it + return targets[targetname] +end + -- get the current configure for targets function project.targets() @@ -965,25 +979,6 @@ function project.makeconf(target_name) return true end --- check target -function project.checktarget(target_name) - - -- the targets - local targets = project.targets() - - -- invalid target? - if target_name and target_name ~= "all" and targets and not targets[target_name] then - utils.error("invalid target: %s!", target_name) - return false - elseif not target_name then - utils.error("no target!") - return false - end - - -- ok - return true -end - -- get the project menu function project.menu() diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua index abebd9bc9..9eb77847c 100644 --- a/xmake/core/sandbox/modules/import/core/project/config.lua +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -98,6 +98,16 @@ function sandbox_core_project_config.load(targetname) end end +-- save the configure +function sandbox_core_project_config.save() + + -- save it + local ok, errors = config.save() + if not ok then + raise(errors) + end +end + -- clean the configure function sandbox_core_project_config.clean() diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 077d1fc27..69c1d0216 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -48,6 +48,13 @@ function sandbox_core_project_project.probe() end end +-- get the given target +function sandbox_core_project_project.target(targetname) + + -- get it + return project.target(targetname) +end + -- get the project directory function sandbox_core_project_project.directory() |
