summaryrefslogtreecommitdiff
path: root/xmake/core/platform/environment.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-20 23:22:46 +0800
committerruki <[email protected]>2018-09-20 14:16:38 +0800
commit0e997da1878a00b34bda5db168c381d62695d107 (patch)
tree0b04a80d887d1de6c58f957b0e4faf262c1237e7 /xmake/core/platform/environment.lua
parent36cfd6d50340f34526530d10b0c0d0b95b9d14ce (diff)
add run environment
Diffstat (limited to 'xmake/core/platform/environment.lua')
-rw-r--r--xmake/core/platform/environment.lua27
1 files changed, 21 insertions, 6 deletions
diff --git a/xmake/core/platform/environment.lua b/xmake/core/platform/environment.lua
index e78a9aaff..0a549df17 100644
--- a/xmake/core/platform/environment.lua
+++ b/xmake/core/platform/environment.lua
@@ -41,10 +41,6 @@ function environment._enter_toolchains()
-- add search binary pathes of packages
os.addenv("PATH", path.join(package.prefixdir(true), "release", os.host(), os.arch(), "bin")) -- globaldir/release/../bin
os.addenv("PATH", path.join(package.prefixdir(false), "release", os.host(), os.arch(), "bin")) -- localdir/release/../bin
- if os.host() ~= "windows" then
- os.addenv("LD_LIBRARY_PATH", path.join(package.prefixdir(true), "release", os.host(), os.arch(), "lib")) -- globaldir/release/../lib
- os.addenv("LD_LIBRARY_PATH", path.join(package.prefixdir(false), "release", os.host(), os.arch(), "lib")) -- localdir/release/../lib
- end
end
-- leave the toolchains environment
@@ -52,6 +48,25 @@ function environment._leave_toolchains()
-- leave the toolchains environment
os.setenv("PATH", environment._PATH)
+end
+
+-- enter the running environment
+function environment._enter_run()
+
+ -- save the running environment
+ environment._LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH")
+
+ -- add search library pathes of packages
+ if os.host() ~= "windows" then
+ os.addenv("LD_LIBRARY_PATH", path.join(package.prefixdir(true), "release", os.host(), os.arch(), "lib")) -- globaldir/release/../lib
+ os.addenv("LD_LIBRARY_PATH", path.join(package.prefixdir(false), "release", os.host(), os.arch(), "lib")) -- localdir/release/../lib
+ end
+end
+
+-- leave the running environment
+function environment._leave_run()
+
+ -- leave the running environment
os.setenv("LD_LIBRARY_PATH", environment._LD_LIBRARY_PATH)
end
@@ -59,7 +74,7 @@ end
function environment.enter(name)
-- the maps
- local maps = {toolchains = environment._enter_toolchains}
+ local maps = {toolchains = environment._enter_toolchains, run = environment._enter_run}
-- enter the common environment
local func = maps[name]
@@ -93,7 +108,7 @@ function environment.leave(name)
end
-- the maps
- local maps = {toolchains = environment._leave_toolchains}
+ local maps = {toolchains = environment._leave_toolchains, run = environment._enter_run}
-- leave the common environment
local func = maps[name]