diff options
| author | ruki <[email protected]> | 2021-07-03 00:34:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-07-03 00:34:08 +0800 |
| commit | 9068e48983a41c30a020c302913fbdb4e4c66f9e (patch) | |
| tree | 1ef415646d3b6e2765c51b4393661575ed90c6ee /xmake/modules/package | |
| parent | c44d6060e82fc332e0f7370398bcbbaed7278543 (diff) | |
add os.joinenvs
Diffstat (limited to 'xmake/modules/package')
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/package/tools/gn.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/package/tools/meson.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/package/tools/msbuild.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/package/tools/nmake.lua | 17 |
5 files changed, 28 insertions, 21 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 680d29a9b..f41bf0052 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -71,7 +71,7 @@ end -- get msvc run environments function _get_msvc_runenvs(package) - return _get_msvc(package):runenvs() + return os.joinenvs(_get_msvc(package):runenvs()) end -- get cflags from package deps @@ -491,7 +491,7 @@ function buildenvs(package, opt) local envs = {} local cmake_generator = opt.cmake_generator if cmake_generator and cmake_generator == "Ninja" and package:is_plat("windows") then - table.join2(envs, _get_msvc_runenvs(package)) + envs = _get_msvc_runenvs(package) end -- add environments for cmake/find_packages diff --git a/xmake/modules/package/tools/gn.lua b/xmake/modules/package/tools/gn.lua index 2c5341476..362373c2c 100644 --- a/xmake/modules/package/tools/gn.lua +++ b/xmake/modules/package/tools/gn.lua @@ -39,11 +39,18 @@ function _get_configs(package, configs, opt) return configs end +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + -- get the build environments function buildenvs(package, opt) local envs = {} if package:is_plat("windows") then - table.join2(envs, toolchain.load("msvc"):runenvs()) + envs = os.joinenvs(_get_msvc(package):runenvs()) end return envs end diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index a6bdec48a..6361f2a0e 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -69,7 +69,7 @@ end -- get msvc run environments function _get_msvc_runenvs(package) - return _get_msvc(package):runenvs() + return os.joinenvs(_get_msvc(package):runenvs()) end -- fix libname on windows @@ -89,13 +89,7 @@ function buildenvs(package) envs.CXXFLAGS = table.concat(cxxflags, ' ') envs.ASFLAGS = table.concat(table.wrap(package:config("asflags")), ' ') if package:is_plat("windows") then - for name, values in pairs(_get_msvc_runenvs(package)) do - local oldvalues = os.getenv(name) - if oldvalues then - values = values .. path.envsep() .. oldvalues - end - envs[name] = values - end + envs = os.joinenvs(envs, _get_msvc_runenvs(package)) end else local cflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cflags")) diff --git a/xmake/modules/package/tools/msbuild.lua b/xmake/modules/package/tools/msbuild.lua index 4c322c1f6..b9794a4e3 100644 --- a/xmake/modules/package/tools/msbuild.lua +++ b/xmake/modules/package/tools/msbuild.lua @@ -23,9 +23,16 @@ import("core.base.option") import("core.tool.toolchain") import("lib.detect.find_tool") +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + -- get the build environments function buildenvs(package, opt) - return table.copy(toolchain.load("msvc"):runenvs()) + return os.joinenvs(_get_msvc(package):runenvs()) end -- build package diff --git a/xmake/modules/package/tools/nmake.lua b/xmake/modules/package/tools/nmake.lua index d8c40efca..c618531ce 100644 --- a/xmake/modules/package/tools/nmake.lua +++ b/xmake/modules/package/tools/nmake.lua @@ -24,17 +24,16 @@ import("core.project.config") import("core.tool.toolchain") import("lib.detect.find_tool") +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + -- get the build environments function buildenvs(package, opt) - local envs = {} - for name, values in pairs(toolchain.load("msvc"):runenvs()) do - local oldvalues = os.getenv(name) - if oldvalues then - values = values .. path.envsep() .. oldvalues - end - envs[name] = values - end - return envs + return os.joinenvs(_get_msvc(package):runenvs()) end -- build package |
