diff options
| author | ruki <[email protected]> | 2018-09-19 23:17:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-09-19 13:47:18 +0800 |
| commit | 3effabb03faacb09d5b566f8e72a5171bfaaa97e (patch) | |
| tree | 2170cc518e15d2e0eaec190bb125b6ab2b22d52c /xmake/core/platform/environment.lua | |
| parent | dae812d748abf4b10812028acb81d6187fd5e2af (diff) | |
add search directories for prefix
Diffstat (limited to 'xmake/core/platform/environment.lua')
| -rw-r--r-- | xmake/core/platform/environment.lua | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/xmake/core/platform/environment.lua b/xmake/core/platform/environment.lua index aad8318ff..d77ec0d85 100644 --- a/xmake/core/platform/environment.lua +++ b/xmake/core/platform/environment.lua @@ -26,13 +26,42 @@ local environment = environment or {} -- load modules +local os = require("base/os") local platform = require("platform/platform") local sandbox = require("sandbox/sandbox") +local package = require("package/package") + +-- enter the toolchains environment +function environment._enter_toolchains() + + -- save the toolchains environment + environment._PATHES = os.getenv("path") + + -- 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 +end + +-- leave the toolchains environment +function environment._leave_toolchains() + + -- leave the toolchains environment + os.setenv("path", environment._PATHES) +end -- enter the environment for the current platform function environment.enter(name) - -- enter it + -- the maps + local maps = {toolchains = environment._enter_toolchains} + + -- enter the common environment + local func = maps[name] + if func then + func() + end + + -- enter the environment of the given platform local module = platform.get("environment") if module then local ok, errors = sandbox.load(module.enter, name) @@ -48,7 +77,7 @@ end -- leave the environment for the current platform function environment.leave(name) - -- leave it + -- leave the environment of the given platform local module = platform.get("environment") if module then local ok, errors = sandbox.load(module.leave, name) @@ -57,6 +86,15 @@ function environment.leave(name) end end + -- the maps + local maps = {toolchains = environment._leave_toolchains} + + -- leave the common environment + local func = maps[name] + if func then + func() + end + -- ok return true end |
