diff options
| author | ruki <[email protected]> | 2015-12-22 19:51:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-12-22 21:05:14 +0800 |
| commit | a1b27b37d0032904adafbeb55f3986af00fdb2e6 (patch) | |
| tree | 434eed35343be2af077602d437bb7670d6242fe6 | |
| parent | b378a1f331cda1f9520b0a3d86feabb498021cb4 (diff) | |
fix setenv and arch for windows
| -rwxr-xr-x | core/src/xmake/machine.c | 4 | ||||
| -rwxr-xr-x | core/src/xmake/os/setenv.c | 12 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/prober.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/tools/link.lua | 2 |
4 files changed, 16 insertions, 4 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index e914297c7..7e5cae462 100755 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -270,9 +270,9 @@ xm_machine_ref_t xm_machine_init() // init architecture #if defined(TB_ARCH_x86) || defined(TB_CONFIG_OS_WINDOWS) - lua_pushstring(impl->lua, "x86"); + lua_pushstring(impl->lua, "i386"); #elif defined(TB_ARCH_x64) - lua_pushstring(impl->lua, "x64"); + lua_pushstring(impl->lua, "x86_64"); #else lua_pushstring(impl->lua, TB_ARCH_STRING); #endif diff --git a/core/src/xmake/os/setenv.c b/core/src/xmake/os/setenv.c index 13fb991e2..7e3661f36 100755 --- a/core/src/xmake/os/setenv.c +++ b/core/src/xmake/os/setenv.c @@ -31,6 +31,9 @@ * includes */ #include "prefix.h" +#ifdef TB_CONFIG_OS_WINDOWS +# include <stdio.h> +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * macros @@ -57,6 +60,14 @@ tb_int_t xm_os_setenv(lua_State* lua) tb_char_t const* value = luaL_checklstring(lua, 2, &value_size); tb_check_return_val(name, 0); +#ifdef TB_CONFIG_OS_WINDOWS + /* @note + * + * we must use setenv for matching the function getenv of luajit, + * because SetEnvironmentVariable and getenv are not compatible. + */ + lua_pushboolean(lua, setenv(name, value)); +#else // find the first separator position tb_char_t const* p = value? tb_strchr(value, XM_OS_ENV_SEP) : tb_null; if (p) @@ -119,6 +130,7 @@ tb_int_t xm_os_setenv(lua_State* lua) // done os.setenv(name, value) lua_pushboolean(lua, tb_environment_set_one(name, value)); } +#endif // ok return 1; diff --git a/xmake/scripts/platform/windows/prober.lua b/xmake/scripts/platform/windows/prober.lua index d0cb51499..40d214efd 100644 --- a/xmake/scripts/platform/windows/prober.lua +++ b/xmake/scripts/platform/windows/prober.lua @@ -44,7 +44,7 @@ function prober._probe_arch(configs) if arch then return true end -- init the default architecture - configs.set("arch", xmake._ARCH) + configs.set("arch", "x86") -- trace utils.printf("checking for the architecture ... %s", configs.get("arch")) diff --git a/xmake/scripts/platform/windows/tools/link.lua b/xmake/scripts/platform/windows/tools/link.lua index 15d0f271e..66476fa41 100644 --- a/xmake/scripts/platform/windows/tools/link.lua +++ b/xmake/scripts/platform/windows/tools/link.lua @@ -42,7 +42,7 @@ function link.init(self, name) -- init flags for architecture local flags_arch = "" if arch == "x86" then flags_arch = "-machine:x86" - elseif arch == "x64" or arch == "amd64" then flags_arch = "-machine:x64" + elseif arch == "x64" or arch == "amd64" or arch == "x86_amd64" then flags_arch = "-machine:x64" end -- init ldflags |
