diff options
| author | ruki <[email protected]> | 2019-02-13 00:04:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-02-12 18:27:38 +0800 |
| commit | 51adca823e85369ccbd5db013e1e255a27c8bdf6 (patch) | |
| tree | bdd76936d1e8afaf9830a8fd7b97a18ef0ed2384 | |
| parent | 960c3dc469aaa27746c0a2174f235bd32ce390ff (diff) | |
improve interpreter and restore project.version
| -rw-r--r-- | xmake/core/base/interpreter.lua | 30 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 19 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 5 |
3 files changed, 41 insertions, 13 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 6e8c3bd40..d2052cf00 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -433,7 +433,7 @@ end function interpreter:_filter(values) -- check - assert(self and values) + assert(self and values ~= nil) -- return values directly if no filter local filter = self._PRIVATE._FILTER @@ -511,8 +511,6 @@ function interpreter:_handle(scope, remove_repeat, enable_filter) -- update it results[name] = values end - - -- ok? return results end @@ -530,9 +528,25 @@ function interpreter:_make(scope_kind, remove_repeat, enable_filter) os.raise("the scope %s() is empty!", scope_kind) end - -- make results + -- get the root results of the given scope kind, e.g. root.target local results = {} - if scope_kind then + if scope_kind:startswith("root.") then + + local root_scope = scopes._ROOT[scope_kind:sub(6)] + if root_scope then + results = self:_handle(root_scope, remove_repeat, enable_filter) + end + + -- get the root results without scope kind + elseif scope_kind == "root" or scope_kind == nil then + + local root_scope = scopes._ROOT["__rootkind"] + if root_scope then + results = self:_handle(root_scope, remove_repeat, enable_filter) + end + + -- get the results of the given scope kind + elseif scope_kind then -- not this scope for kind? local scope_for_kind = scopes[scope_kind] @@ -567,13 +581,7 @@ function interpreter:_make(scope_kind, remove_repeat, enable_filter) -- add this scope results[scope_name] = self:_handle(scope_values, remove_repeat, enable_filter) end - else - - -- only uses the root scope kind - results = self:_handle(scopes._ROOT["__rootkind"], remove_repeat, enable_filter) end - - -- ok? return results end diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index f7b499113..a0ea2b064 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -327,8 +327,23 @@ function project._load(force) return false, (errors or "load project file failed!") end - -- load the project info - project._INFO = project._load_scope(nil, true, true) + -- load the root info of the project + local rootinfo, errors = project._load_scope("root", true, true) + if not rootinfo then + return false, errors + end + + -- load the root info of the target + local rootinfo_target, errors = project._load_scope("root.target", true, true) + if not rootinfo_target then + return false, errors + end + + -- save the root info + for name, value in pairs(rootinfo_target) do + rootinfo["target." .. name] = value + end + project._INFO = rootinfo -- leave the project directory oldir, errors = os.cd(oldir) diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 448ab75a1..dee117a99 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -167,6 +167,11 @@ function sandbox_core_project.name() return project.get("project") end +-- get the project version, the root version of the target scope +function sandbox_core_project.version() + return project.get("target.version") +end + -- get the project modes function sandbox_core_project.modes() local modes = project.get("modes") or {} |
