diff options
| author | ruki <[email protected]> | 2021-01-24 22:33:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-01-24 22:33:54 +0800 |
| commit | 4e39a9f9da50f54eef30e289078d8794fd5d74ad (patch) | |
| tree | cc42ac436f7a374116e0ff13bb3f6cb21b96ce9a | |
| parent | 80aa72c198b210343c37ecb7db584a700274a783 (diff) | |
remove environment
| -rw-r--r-- | xmake/actions/build/cleaner.lua | 1 | ||||
| -rw-r--r-- | xmake/actions/build/main.lua | 1 | ||||
| -rw-r--r-- | xmake/actions/build/statistics.lua | 7 | ||||
| -rw-r--r-- | xmake/actions/clean/main.lua | 1 | ||||
| -rw-r--r-- | xmake/actions/require/impl/environment.lua | 15 | ||||
| -rw-r--r-- | xmake/actions/run/main.lua | 7 | ||||
| -rw-r--r-- | xmake/core/platform/environment.lua | 44 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/platform/environment.lua | 50 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_7z.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_curl.lua | 6 |
10 files changed, 18 insertions, 120 deletions
diff --git a/xmake/actions/build/cleaner.lua b/xmake/actions/build/cleaner.lua index 97231e819..62bbcf8d4 100644 --- a/xmake/actions/build/cleaner.lua +++ b/xmake/actions/build/cleaner.lua @@ -26,7 +26,6 @@ import("core.project.config") import("core.project.project") import("core.package.package") import("core.platform.platform") -import("core.platform.environment") -- clean up temporary files once a day function cleanup() diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index ac703d79b..864f88185 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -26,7 +26,6 @@ import("core.project.rule") import("core.project.config") import("core.project.project") import("core.platform.platform") -import("core.platform.environment") import("core.theme.theme") import("private.utils.progress") import("build") diff --git a/xmake/actions/build/statistics.lua b/xmake/actions/build/statistics.lua index 3ad6de99e..c98684cd6 100644 --- a/xmake/actions/build/statistics.lua +++ b/xmake/actions/build/statistics.lua @@ -23,7 +23,6 @@ import("core.base.option") import("core.base.process") import("core.project.config") import("core.platform.platform") -import("core.platform.environment") import("private.action.update.fetch_version") import("private.action.require.packagenv") @@ -111,9 +110,6 @@ function main() -- load platform platform.load(config.plat()) - -- enter environment - environment.enter("toolchains") - -- enter the environments of git packagenv.enter("git") @@ -144,7 +140,4 @@ function main() -- leave the environments of git packagenv.leave("git") - - -- leave environment - environment.leave("toolchains") end diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua index a8b8016e4..c72f82a6f 100644 --- a/xmake/actions/clean/main.lua +++ b/xmake/actions/clean/main.lua @@ -26,7 +26,6 @@ import("core.project.config") import("core.base.global") import("core.project.project") import("core.platform.platform") -import("core.platform.environment") import("private.action.clean.remove_files") import("target.action.clean", {alias = "_do_clean_target"}) diff --git a/xmake/actions/require/impl/environment.lua b/xmake/actions/require/impl/environment.lua index 1d163df63..89034fabf 100644 --- a/xmake/actions/require/impl/environment.lua +++ b/xmake/actions/require/impl/environment.lua @@ -20,7 +20,6 @@ -- imports import("core.project.config") -import("core.platform.environment") import("core.package.package", {alias = "core_package"}) import("lib.detect.find_tool") import("private.action.require.packagenv") @@ -34,16 +33,13 @@ import("package") -- function enter() - -- set search paths of toolchains - environment.enter("toolchains") - -- unzip or 7zip is necessary if not find_tool("unzip") and not find_tool("7z") then raise("unzip or 7zip not found! we need install it first") end - -- enter the environments of git and 7z - packagenv.enter("git", "7z") + -- enter the environments of git + packagenv.enter("git") -- git not found? install it first local packages = {} @@ -72,9 +68,6 @@ function leave() end _g._PACKAGES = nil - -- leave the environments of git and 7z - packagenv.leave("7z", "git") - - -- restore search paths of toolchains - environment.leave("toolchains") + -- leave the environments of git + packagenv.leave("git") end diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 88156f5b5..7690ea331 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -25,7 +25,6 @@ import("core.project.config") import("core.base.global") import("core.project.project") import("core.platform.platform") -import("core.platform.environment") import("devel.debugger") import("private.action.run.make_runenvs") @@ -214,9 +213,6 @@ function main() -- enter project directory local oldir = os.cd(project.directory()) - -- enter the running environment - environment.enter("run") - -- run the given target? if targetname then _run(project.target(targetname)) @@ -230,9 +226,6 @@ function main() end end - -- leave the running environment - environment.leave("run") - -- leave project directory os.cd(oldir) end diff --git a/xmake/core/platform/environment.lua b/xmake/core/platform/environment.lua index cec1cf980..721507c6e 100644 --- a/xmake/core/platform/environment.lua +++ b/xmake/core/platform/environment.lua @@ -25,57 +25,17 @@ local environment = environment or {} local os = require("base/os") local table = require("base/table") local global = require("base/global") -local platform_core = require("platform/platform") local sandbox = require("sandbox/sandbox") local package = require("package/package") local import = require("sandbox/modules/import") -- enter the toolchains environment function environment._enter_toolchains() - - -- get the current platform - local platform, errors = platform_core.load() - if not platform then - return false, errors - end - - -- add $programdir/winenv/bin to $path - local oldenvs = {} - oldenvs.PATH = os.getenv("PATH") - if os.host() == "windows" then - os.addenv("PATH", path.join(os.programdir(), "winenv", "bin")) - end - environment._OLDENVS_TOOLCHAINS = oldenvs return true end -- leave the toolchains environment function environment._leave_toolchains() - local oldenvs = environment._OLDENVS_TOOLCHAINS - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end - return true -end - --- enter the running environment -function environment._enter_run() - local oldenvs = {} - oldenvs.PATH = os.getenv("PATH") - oldenvs.LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH") - if os.host() == "macosx" then - oldenvs.DYLD_LIBRARY_PATH = os.getenv("DYLD_LIBRARY_PATH") - end - environment._OLDENVS_RUN = oldenvs - return true -end - --- leave the running environment -function environment._leave_run() - local oldenvs = environment._OLDENVS_RUN - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end return true end @@ -93,7 +53,7 @@ function environment.enter(name) end -- do enter - local maps = {toolchains = environment._enter_toolchains, run = environment._enter_run} + local maps = {toolchains = environment._enter_toolchains} local func = maps[name] if func then local ok, errors = func() @@ -119,7 +79,7 @@ function environment.leave(name) end -- do leave - local maps = {toolchains = environment._leave_toolchains, run = environment._leave_run} + local maps = {toolchains = environment._leave_toolchains} local func = maps[name] if func then local ok, errors = func() diff --git a/xmake/core/sandbox/modules/import/core/platform/environment.lua b/xmake/core/sandbox/modules/import/core/platform/environment.lua deleted file mode 100644 index 362952950..000000000 --- a/xmake/core/sandbox/modules/import/core/platform/environment.lua +++ /dev/null @@ -1,50 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file environment.lua --- - --- define module -local sandbox_core_platform_environment = sandbox_core_platform_environment or {} - --- load modules -local platform = require("platform/platform") -local environment = require("platform/environment") -local raise = require("sandbox/modules/raise") - --- enter the given environment -function sandbox_core_platform_environment.enter(name) - - -- enter it - local ok, errors = environment.enter(name) - if not ok then - raise(errors) - end -end - --- leave the given environment -function sandbox_core_platform_environment.leave(name) - - -- enter it - local ok, errors = environment.leave(name) - if not ok then - raise(errors) - end -end - --- return module -return sandbox_core_platform_environment diff --git a/xmake/modules/detect/tools/find_7z.lua b/xmake/modules/detect/tools/find_7z.lua index 08c0d172b..a53ba4dc1 100644 --- a/xmake/modules/detect/tools/find_7z.lua +++ b/xmake/modules/detect/tools/find_7z.lua @@ -43,6 +43,12 @@ function main(opt) opt.command = opt.command or "--help" opt.parse = "(%d+%.?%d*)%s" + -- find 7z from builtin xmake/winenv + if is_host("windows") then + opt.paths = opt.paths or {} + table.insert(opt.paths, path.join(os.programdir(), "winenv", "bin")) + end + -- find program local program = find_program(opt.program or "7z", opt) if not program and not opt.program then diff --git a/xmake/modules/detect/tools/find_curl.lua b/xmake/modules/detect/tools/find_curl.lua index 7807a65a3..493264684 100644 --- a/xmake/modules/detect/tools/find_curl.lua +++ b/xmake/modules/detect/tools/find_curl.lua @@ -40,6 +40,12 @@ function main(opt) -- init options opt = opt or {} + -- find curl from builtin xmake/winenv + if is_host("windows") then + opt.paths = opt.paths or {} + table.insert(opt.paths, path.join(os.programdir(), "winenv", "bin")) + end + -- find program local program = find_program(opt.program or "curl", opt) |
