diff options
| author | ruki <[email protected]> | 2025-01-09 00:52:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-09 00:52:22 +0800 |
| commit | 279b1f07740e235a0a5fddcf46937b829fd160d2 (patch) | |
| tree | 1c6941038d4a4d721ff6d5de9c3f154d3aa68157 | |
| parent | 94918773a3a33398b2ee0dbf23c00199c164a50c (diff) | |
improve to get config
| -rw-r--r-- | xmake/core/project/project.lua | 7 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/get_config.lua | 17 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/has_config.lua | 1 |
3 files changed, 21 insertions, 4 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 2fac8f50b..57655ee0e 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -143,7 +143,12 @@ end -- get config from the given name function project._api_get_config(interp, name) - return config.get(name) + local value = config.get(name) + local namespace = interp:namespace() + if value == nil and namespace then + value = config.get(namespace .. "::" .. name) + end + return value end -- add module directories diff --git a/xmake/core/sandbox/modules/get_config.lua b/xmake/core/sandbox/modules/get_config.lua index 7fbd16a58..fd09c02e3 100644 --- a/xmake/core/sandbox/modules/get_config.lua +++ b/xmake/core/sandbox/modules/get_config.lua @@ -18,6 +18,19 @@ -- @file get_config.lua -- --- return module -return require("project/config").get +local config = require("project/config") +local sandbox = require("sandbox/sandbox") + +return function (name) + local namespace + local instance = sandbox.instance() + if instance then + namespace = instance:namespace() + end + local value = config.get(name) + if value == nil and namespace then + value = config.get(namespace .. "::" .. name) + end + return value +end diff --git a/xmake/core/sandbox/modules/has_config.lua b/xmake/core/sandbox/modules/has_config.lua index e1538a504..468144754 100644 --- a/xmake/core/sandbox/modules/has_config.lua +++ b/xmake/core/sandbox/modules/has_config.lua @@ -18,7 +18,6 @@ -- @file has_config.lua -- --- return module local config = require("project/config") local sandbox = require("sandbox/sandbox") |
