diff options
| author | ruki <[email protected]> | 2019-08-17 21:28:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-08-17 21:28:53 +0800 |
| commit | adef5373cbd290f0d679c449d06dcb92dbfe3325 (patch) | |
| tree | 04875f172db651567ebd98beea0756dffc0dc219 /core/src/xmake/process/open.c | |
| parent | 51dcf34216824a7d5096cad03b5b04964e8ceba8 (diff) | |
enable vs_unicode_output
Diffstat (limited to 'core/src/xmake/process/open.c')
| -rw-r--r-- | core/src/xmake/process/open.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c index 676d0241f..8cd63d966 100644 --- a/core/src/xmake/process/open.c +++ b/core/src/xmake/process/open.c @@ -53,6 +53,7 @@ tb_int_t xm_process_open(lua_State* lua) tb_char_t const* envs[256] = {0}; tb_char_t const* outpath = tb_null; tb_char_t const* errpath = tb_null; + tb_bool_t vs_unicode_output = tb_false; if (lua_istable(lua, 2)) { // get outpath @@ -67,6 +68,12 @@ tb_int_t xm_process_open(lua_State* lua) errpath = lua_tostring(lua, -1); lua_pop(lua, 1); + // enable vs_unicode_output? + lua_pushstring(lua, "vs_unicode_output"); + lua_gettable(lua, 2); + vs_unicode_output = lua_toboolean(lua, -1); + lua_pop(lua, 1); + // get environments lua_pushstring(lua, "envs"); lua_gettable(lua, 2); @@ -110,21 +117,29 @@ tb_int_t xm_process_open(lua_State* lua) lua_pop(lua, 1); } - // set the new environments - if (envn > 0) attr.envp = envs; - - // TODO - if (1) + // enable vs_unicode_output? @see https://github.com/xmake-io/xmake/issues/528 + if (vs_unicode_output) { xm_subprocess_t* subprocess = tb_malloc0_type(xm_subprocess_t); if (subprocess) { + // init vs_unicode_output + tb_string_init(&subprocess->vs_unicode_output); + // redirect stdout? if (outpath) { // redirect stdout to file subprocess->outfile = tb_file_init(outpath, TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT); subprocess->outtype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.outfile = subprocess->outfile; + attr.outtype = subprocess->outtype; + +#ifdef TB_CONFIG_OS_WINDOWS + // add environment value of vs_unicode_output + if (envn + 1 < tb_arrayn(envs)) + envs[envn++] = tb_string_cstrfcpy(&subprocess->vs_unicode_output, "VS_UNICODE_OUTPUT=%zu", (tb_size_t)subprocess->outfile); +#endif } // redirect stderr? @@ -133,6 +148,8 @@ tb_int_t xm_process_open(lua_State* lua) // redirect stderr to file subprocess->errfile = tb_file_init(errpath, TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT); subprocess->errtype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.errfile = subprocess->errfile; + attr.errtype = subprocess->errtype; } attr.priv = subprocess; } @@ -158,6 +175,9 @@ tb_int_t xm_process_open(lua_State* lua) } } + // set the new environments + if (envn > 0) attr.envp = envs; + // init process tb_process_ref_t process = (tb_process_ref_t)tb_process_init_cmd(command, &attr); if (process) lua_pushlightuserdata(lua, (tb_pointer_t)process); |
