From 421cdb9f4b8b8a7be5e29b53065cf3f2e07231ae Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 7 Sep 2022 22:45:55 +0800 Subject: mark as pathenv --- xmake/core/package/package.lua | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index dab537c63..0cebce22e 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -841,11 +841,30 @@ function _instance:_rawenvs() return envs end +-- get path environment keys +function _instance:_pathenvs() + local pathenvs = self._PATHENVS + if pathenvs == nil then + pathenvs = hashset.from { + "PATH", + "LD_LIBRARY_PATH", + "DYLD_LIBRARY_PATH" + } + self._PATHENVS = pathenvs + end + return pathenvs +end + +-- mark as path environments +function _instance:mark_as_pathenv(name) + self:_pathenvs():insert(name) +end + -- get the exported environments function _instance:envs() local envs = {} - for name, values in pairs(instance:_rawenvs()) do - if name == "PATH" or name == "LD_LIBRARY_PATH" or name == "DYLD_LIBRARY_PATH" then + for name, values in pairs(self:_rawenvs()) do + if self:_pathenvs():has(name) then local newvalues = {} for _, value in ipairs(values) do if path.is_absolute(value) then -- cgit v1.3.1