diff options
| author | ruki <[email protected]> | 2021-07-15 00:37:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-07-15 00:37:16 +0800 |
| commit | 528971ff1ad33097e89aa00161d44e8c6dd5fbf1 (patch) | |
| tree | fcac29554051fcbbea0d8973f30bea438fa5ef7b | |
| parent | 609d96e936637ec10278098ceb4e07257db7393b (diff) | |
improve xrepo env
| -rw-r--r-- | xmake/core/base/os.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 24 |
2 files changed, 23 insertions, 2 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 2b8773163..e9f403d92 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -260,7 +260,6 @@ function os._remove_repeat_pathenv(value) return value end - -- match files or directories -- -- @param pattern the search pattern diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index 1db5c4564..2a6d9760d 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -156,6 +156,24 @@ function _enter_project() config.load() end +-- remove repeat environment values +function _remove_repeat_pathenv(value) + if value then + local itemset = {} + local results = {} + for _, item in ipairs(path.splitenv(value)) do + if not itemset[item] then + table.insert(results, item) + itemset[item] = true + end + end + if #results > 0 then + value = path.joinenv(results) + end + end + return value +end + -- add values to environment variable function _addenvs(envs, name, ...) local values = {...} @@ -246,7 +264,11 @@ function _package_getenvs() end end end - return envs + local results = {} + for k, v in pairs(envs) do + results[k] = _remove_repeat_pathenv(v) + end + return results end -- get environment setting script |
