summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-11-07 20:30:46 +0800
committerruki <[email protected]>2020-11-07 20:30:46 +0800
commitd9de1aa6e08b684646c693dc4530fb5dc0d499a9 (patch)
tree0d985dcd7b115879eddd322f7fd9838b3636bb98
parentba62268d4a1cd7db9e66f52e08a393eb6cc2df90 (diff)
fix package/deps envs
-rw-r--r--xmake/actions/require/install.lua55
-rw-r--r--xmake/core/package/package.lua2
-rw-r--r--xmake/modules/target/action/install/windows.lua4
-rw-r--r--xmake/modules/target/action/uninstall/windows.lua4
4 files changed, 34 insertions, 31 deletions
diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua
index 240129742..4d250293f 100644
--- a/xmake/actions/require/install.lua
+++ b/xmake/actions/require/install.lua
@@ -28,6 +28,30 @@ import("impl.repository")
import("impl.environment")
import("impl.utils.get_requires")
+-- register required package environments
+function _register_required_package_envs(instance, envs)
+ for name, values in pairs(instance:envs()) do
+ if name == "PATH" or name == "LD_LIBRARY_PATH" then
+ for _, value in ipairs(values) do
+ envs[name] = envs[name] or {}
+ if path.is_absolute(value) then
+ table.insert(envs[name], value)
+ else
+ table.insert(envs[name], path.join(instance:installdir(), value))
+ end
+ end
+ else
+ envs[name] = envs[name] or {}
+ table.join2(envs[name], values)
+ end
+ end
+end
+
+-- register required package info
+function _register_required_package_info(instance, requireinfo)
+ requireinfo:add((instance:fetch()))
+end
+
-- register the required local package
function _register_required_package(instance, requireinfo)
@@ -38,39 +62,22 @@ function _register_required_package(instance, requireinfo)
-- clear require info first
requireinfo:clear()
- -- add include and links info
- requireinfo:add(instance:fetch())
+ -- add include, links and envs for all dependent packages
+ local envs = {}
+ _register_required_package_info(instance, requireinfo)
+ _register_required_package_envs(instance, envs)
local orderdeps = instance:orderdeps()
if orderdeps then
local total = #orderdeps
for idx, _ in ipairs(orderdeps) do
local dep = orderdeps[total + 1 - idx]
if dep then
- requireinfo:add((dep:fetch()))
+ _register_required_package_info(dep, requireinfo)
+ _register_required_package_envs(dep, envs)
end
end
end
-
- -- add environments
- local envs = {}
- local hasenvs = false
- local installdir = instance:installdir()
- for name, values in pairs(instance:envs()) do
- if name == "PATH" or name == "LD_LIBRARY_PATH" then
- for _, value in ipairs(values) do
- envs[name] = envs[name] or {}
- if path.is_absolute(value) then
- table.insert(envs[name], value)
- else
- table.insert(envs[name], path.join(installdir, value))
- end
- end
- else
- envs[name] = values
- end
- hasenvs = true
- end
- if hasenvs then
+ if #table.keys(envs) > 0 then
requireinfo:add({envs = envs})
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 52cdc2063..c2f91536b 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -422,7 +422,7 @@ function _instance:envs()
local envs = self._ENVS
if not envs then
envs = {}
- if self:kind() == "binary" or (self:is_plat("windows", "mingw") and self:config("shared")) then
+ if self:kind() == "binary" or self:is_plat("windows", "mingw") then -- bin/*.dll for windows
envs.PATH = {"bin"}
end
-- add LD_LIBRARY_PATH to load *.so directory
diff --git a/xmake/modules/target/action/install/windows.lua b/xmake/modules/target/action/install/windows.lua
index 7e9f6ab0b..0ffb2bd82 100644
--- a/xmake/modules/target/action/install/windows.lua
+++ b/xmake/modules/target/action/install/windows.lua
@@ -55,9 +55,7 @@ function _install_shared_for_packages(target, outputdir)
_g.installed_packages = _g.installed_packages or {}
for _, pkg in ipairs(target:orderpkgs()) do
if not _g.installed_packages[pkg:name()] then
- local extrainfo = pkg:extrainfo() or {}
- local has_shared = extrainfo.configs and extrainfo.configs.shared
- if has_shared and pkg:enabled() and pkg:get("libfiles") then
+ if pkg:enabled() and pkg:get("libfiles") then
_install_shared_for_package(target, pkg, outputdir)
end
_g.installed_packages[pkg:name()] = true
diff --git a/xmake/modules/target/action/uninstall/windows.lua b/xmake/modules/target/action/uninstall/windows.lua
index d4ddf88a2..2d686dacc 100644
--- a/xmake/modules/target/action/uninstall/windows.lua
+++ b/xmake/modules/target/action/uninstall/windows.lua
@@ -41,9 +41,7 @@ function _uninstall_shared_for_packages(target, outputdir)
_g.uninstalled_packages = _g.uninstalled_packages or {}
for _, pkg in ipairs(target:orderpkgs()) do
if not _g.uninstalled_packages[pkg:name()] then
- local extrainfo = pkg:extrainfo() or {}
- local has_shared = extrainfo.configs and extrainfo.configs.shared
- if has_shared and pkg:enabled() and pkg:get("libfiles") then
+ if pkg:enabled() and pkg:get("libfiles") then
_uninstall_shared_for_package(target, pkg, outputdir)
end
_g.uninstalled_packages[pkg:name()] = true