diff options
| author | ruki <[email protected]> | 2024-04-03 00:57:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-04-03 00:57:04 +0800 |
| commit | efbf92709a0be6e2fba38efe3e10a2684d4e3836 (patch) | |
| tree | d135001bc3f1fbeb0887a05058b7aa7a45d5211d /core | |
| parent | 1cb62a5d466173ce4e8690eb320c44d5ddd6e1e2 (diff) | |
add xmake.arch
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/xmake/engine.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index cbe1ed4fc..827d46d2e 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -933,11 +933,39 @@ static tb_void_t xm_engine_init_host(xm_engine_t* engine) lua_setglobal(engine->lua, "_SUBHOST"); } +static __tb_inline__ tb_char_t const* xm_engine_xmake_arch() +{ + tb_char_t const* arch = tb_null; +#if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX) +# if defined(TB_ARCH_x64) + arch = "x64"; +# elif defined(TB_ARCH_ARM64) + arch = "arm64"; +# elif defined(TB_ARCH_ARM) + arch = "arm"; +# else + arch = "x86"; +# endif +#elif defined(TB_ARCH_x64) + arch = "x86_64"; +#elif defined(TB_ARCH_x86) + arch = "i386"; +#else + arch = TB_ARCH_STRING; +#endif + return arch; +} + static tb_void_t xm_engine_init_arch(xm_engine_t* engine) { // check tb_assert_and_check_return(engine && engine->lua); + // init xmake arch + tb_char_t const* xmakearch = xm_engine_xmake_arch(); + lua_pushstring(engine->lua, xmakearch); + lua_setglobal(engine->lua, "_XMAKE_ARCH"); + // init system architecture tb_char_t const* sysarch = tb_null; #if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX) @@ -972,27 +1000,8 @@ static tb_void_t xm_engine_init_arch(xm_engine_t* engine) default: break; } - - // get arch from compiler - if (!sysarch) - { -# if defined(TB_ARCH_x64) - sysarch = "x64"; -# elif defined(TB_ARCH_ARM64) - sysarch = "arm64"; -# elif defined(TB_ARCH_ARM) - sysarch = "arm"; -# else - sysarch = "x86"; -# endif - } -#elif defined(TB_ARCH_x64) - sysarch = "x86_64"; -#elif defined(TB_ARCH_x86) - sysarch = "i386"; -#else - sysarch = TB_ARCH_STRING; #endif + if (!sysarch) sysarch = xmakearch; lua_pushstring(engine->lua, sysarch); lua_setglobal(engine->lua, "_ARCH"); |
