diff options
| author | ruki <[email protected]> | 2017-09-30 11:37:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-09-30 11:37:32 +0800 |
| commit | 05a3d6aa2a2b94981077e495beefd75b16363f44 (patch) | |
| tree | b907f5d94ea0952d290c92c44553f72304a3edab | |
| parent | b77dcc4cea91854766a718b5d03d49a25de6a180 (diff) | |
fix setenv empty value bug
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | core/src/tbox/src/tbox/platform/libc/environment.c | 5 | ||||
| -rw-r--r-- | xmake/actions/require/action/build.lua | 11 | ||||
| -rw-r--r-- | xmake/actions/require/environment.lua | 27 | ||||
| -rw-r--r-- | xmake/modules/package/manager/install.lua | 2 |
5 files changed, 36 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d4cb8096..8e79493aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ * [#140](https://github.com/tboox/xmake/issues/140): Fix `os.tmpdir()` in fakeroot * [#142](https://github.com/tboox/xmake/issues/142): Fix `os.getenv` charset bug on windows * Fix compile error with spaces path +* Fix setenv empty value bug ## v2.1.6 @@ -393,6 +394,7 @@ * [#140](https://github.com/tboox/xmake/issues/140): 修复`os.tmpdir()`在fakeroot下的冲突问题 * [#142](https://github.com/tboox/xmake/issues/142): 修复`os.getenv` 在windows上的中文编码问题 * 修复在带有空格路径的情况下,编译错误问题 +* 修复setenv空值的崩溃问题 ## v2.1.6 diff --git a/core/src/tbox/src/tbox/platform/libc/environment.c b/core/src/tbox/src/tbox/platform/libc/environment.c index 63e64140c..ae0f622bd 100644 --- a/core/src/tbox/src/tbox/platform/libc/environment.c +++ b/core/src/tbox/src/tbox/platform/libc/environment.c @@ -108,7 +108,10 @@ tb_bool_t tb_environment_save(tb_environment_ref_t environment, tb_char_t const* tb_string_strip(&values, tb_string_size(&values) - 1); // save variable - tb_bool_t ok = !setenv(name, tb_string_cstr(&values), 1); + tb_bool_t ok; + tb_char_t const* value_cstr = tb_string_cstr(&values); + if (value_cstr) ok = !setenv(name, value_cstr, 1); + else ok = !unsetenv(name); // exit values string tb_string_exit(&values); diff --git a/xmake/actions/require/action/build.lua b/xmake/actions/require/action/build.lua index d49f6274f..4ec5772cc 100644 --- a/xmake/actions/require/action/build.lua +++ b/xmake/actions/require/action/build.lua @@ -35,6 +35,11 @@ function _build_for_xmakefile(package, buildfile) local plat = config.plat() local argv = {"f", "-c", "-p", plat, "-a", config.arch(), "-m", config.mode()} + -- verbose? + if option.get("verbose") then + table.insert(argv, "-v") + end + -- init config keys local keys = { @@ -59,7 +64,11 @@ function _build_for_xmakefile(package, buildfile) os.vrunv("xmake", argv) -- build it - os.vrun("xmake") + if option.get("verbose") then + os.vrun("xmake -v") + else + os.vrun("xmake") + end end -- build for makefile diff --git a/xmake/actions/require/environment.lua b/xmake/actions/require/environment.lua index 7c6bdfc68..87c2666c0 100644 --- a/xmake/actions/require/environment.lua +++ b/xmake/actions/require/environment.lua @@ -23,6 +23,7 @@ -- -- imports +import("core.project.config") import("core.platform.environment") import("lib.detect.find_tool") import("package") @@ -43,19 +44,29 @@ function enter() package.install_packages("git") end - -- TODO set toolchains for CC, LD, .. - - -- TODO set flags of toolchains + -- set the environment variables of toolchains + _g.toolenvs = {} + for _, name in ipairs("cc", "cxx", "mm", "mxx", "ld", "ar", "sh") do + local value = config.get(name) + if value then + _g.toolenvs[name] = os.getenv(name:upper()) or "" + os.setenv(name:upper(), value) + end + end end -- leave environment function leave() + -- restore the environment variables of toolchains + for _, name in ipairs("cc", "cxx", "mm", "mxx", "ld", "ar", "sh") do + local value = _g.toolenvs[name] + if value then + print(name, #value) + os.setenv(name:upper(), value) + end + end + -- restore search pathes of toolchains environment.leave("toolchains") - - -- TODO restore toolchains for CC, LD - - -- TODO set flags of toolchains - end diff --git a/xmake/modules/package/manager/install.lua b/xmake/modules/package/manager/install.lua index 175a1cecf..b06f38e22 100644 --- a/xmake/modules/package/manager/install.lua +++ b/xmake/modules/package/manager/install.lua @@ -40,7 +40,7 @@ function main(name, opt) table.insert(scripts, import("yum.install", {anonymous = true})) table.insert(scripts, import("pacman.install", {anonymous = true})) table.insert(scripts, import("brew.install", {anonymous = true})) - elseif host = "windows" then + elseif host == "windows" then table.insert(scripts, import("pacman.install", {anonymous = true})) -- msys/mingw end assert(#scripts > 0, "package manager not found!") |
