summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-03-17 22:53:53 +0800
committerruki <[email protected]>2019-03-17 22:54:06 +0800
commit0b5df9fdad06f868d28537746b8b56b3a0bfd18b (patch)
treea90d81070f0f2450d5c577bf083a5bf34be069fa
parentecdb953daa77c74a7475c7486d8df6d96d0d0c4d (diff)
bind package envs to other scipts
-rw-r--r--xmake/actions/build/build.lua12
-rw-r--r--xmake/actions/clean/main.lua12
-rw-r--r--xmake/actions/install/install.lua12
-rw-r--r--xmake/actions/package/main.lua12
-rw-r--r--xmake/actions/uninstall/uninstall.lua12
5 files changed, 60 insertions, 0 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 33bb920dc..03045ec8c 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -71,6 +71,13 @@ end
-- build the given target
function _build_target(target)
+ -- enter the environments of the target packages
+ local oldenvs = {}
+ for name, values in pairs(target:pkgenvs()) do
+ oldenvs[name] = os.getenv(name)
+ os.addenv(name, unpack(values))
+ end
+
-- the target scripts
local scripts =
{
@@ -138,6 +145,11 @@ function _build_target(target)
end
end
+ -- leave the environments of the target packages
+ for name, values in pairs(oldenvs) do
+ os.setenv(name, values)
+ end
+
-- update target index
_g.targetindex = _g.targetindex + 1
end
diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua
index b5c90cd75..7717baf1d 100644
--- a/xmake/actions/clean/main.lua
+++ b/xmake/actions/clean/main.lua
@@ -114,6 +114,13 @@ end
-- clean the given target files
function _clean_target(target)
+ -- enter the environments of the target packages
+ local oldenvs = {}
+ for name, values in pairs(target:pkgenvs()) do
+ oldenvs[name] = os.getenv(name)
+ os.addenv(name, unpack(values))
+ end
+
-- the target scripts
local scripts =
{
@@ -159,6 +166,11 @@ function _clean_target(target)
script(target, {origin = (i == 3 and _do_clean_target or nil)})
end
end
+
+ -- leave the environments of the target packages
+ for name, values in pairs(oldenvs) do
+ os.setenv(name, values)
+ end
end
-- clean the given target and all dependent targets
diff --git a/xmake/actions/install/install.lua b/xmake/actions/install/install.lua
index fc8db342c..db035b3fb 100644
--- a/xmake/actions/install/install.lua
+++ b/xmake/actions/install/install.lua
@@ -157,6 +157,13 @@ function _install_target(target)
-- enter project directory
local oldir = os.cd(project.directory())
+ -- enter the environments of the target packages
+ local oldenvs = {}
+ for name, values in pairs(target:pkgenvs()) do
+ oldenvs[name] = os.getenv(name)
+ os.addenv(name, unpack(values))
+ end
+
-- the target scripts
local scripts =
{
@@ -203,6 +210,11 @@ function _install_target(target)
end
end
+ -- leave the environments of the target packages
+ for name, values in pairs(oldenvs) do
+ os.setenv(name, values)
+ end
+
-- leave project directory
os.cd(oldir)
end
diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua
index f4cd40405..38a7df462 100644
--- a/xmake/actions/package/main.lua
+++ b/xmake/actions/package/main.lua
@@ -168,6 +168,13 @@ function _package(target)
-- enter project directory
local oldir = os.cd(project.directory())
+ -- enter the environments of the target packages
+ local oldenvs = {}
+ for name, values in pairs(target:pkgenvs()) do
+ oldenvs[name] = os.getenv(name)
+ os.addenv(name, unpack(values))
+ end
+
-- the target scripts
local scripts =
{
@@ -200,6 +207,11 @@ function _package(target)
end
end
+ -- leave the environments of the target packages
+ for name, values in pairs(oldenvs) do
+ os.setenv(name, values)
+ end
+
-- leave project directory
os.cd(oldir)
end
diff --git a/xmake/actions/uninstall/uninstall.lua b/xmake/actions/uninstall/uninstall.lua
index f79727947..0d1c07d51 100644
--- a/xmake/actions/uninstall/uninstall.lua
+++ b/xmake/actions/uninstall/uninstall.lua
@@ -134,6 +134,13 @@ function _uninstall_target(target)
-- enter project directory
local oldir = os.cd(project.directory())
+ -- enter the environments of the target packages
+ local oldenvs = {}
+ for name, values in pairs(target:pkgenvs()) do
+ oldenvs[name] = os.getenv(name)
+ os.addenv(name, unpack(values))
+ end
+
-- the target scripts
local scripts =
{
@@ -180,6 +187,11 @@ function _uninstall_target(target)
end
end
+ -- leave the environments of the target packages
+ for name, values in pairs(oldenvs) do
+ os.setenv(name, values)
+ end
+
-- leave project directory
os.cd(oldir)
end