summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-08-17 21:28:53 +0800
committerruki <[email protected]>2019-08-17 21:28:53 +0800
commitadef5373cbd290f0d679c449d06dcb92dbfe3325 (patch)
tree04875f172db651567ebd98beea0756dffc0dc219
parent51dcf34216824a7d5096cad03b5b04964e8ceba8 (diff)
enable vs_unicode_output
-rw-r--r--core/src/xmake/process/close.c1
-rw-r--r--core/src/xmake/process/open.c30
-rw-r--r--core/src/xmake/process/openv.c40
-rw-r--r--core/src/xmake/process/prefix.h3
-rw-r--r--xmake/core/base/os.lua11
-rw-r--r--xmake/modules/core/tools/cl.lua5
-rw-r--r--xmake/modules/core/tools/lib.lua4
-rw-r--r--xmake/modules/core/tools/link.lua5
-rw-r--r--xmake/modules/core/tools/ml.lua3
9 files changed, 77 insertions, 25 deletions
diff --git a/core/src/xmake/process/close.c b/core/src/xmake/process/close.c
index 58373c9cf..94de9b33d 100644
--- a/core/src/xmake/process/close.c
+++ b/core/src/xmake/process/close.c
@@ -64,6 +64,7 @@ tb_int_t xm_process_close(lua_State* lua)
subprocess->errfile = tb_null;
}
+ tb_string_exit(&subprocess->vs_unicode_output);
tb_free(subprocess);
}
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);
diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c
index 7bf97c358..79d99c917 100644
--- a/core/src/xmake/process/openv.c
+++ b/core/src/xmake/process/openv.c
@@ -95,6 +95,7 @@ tb_int_t xm_process_openv(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, 3))
{
// get outpath
@@ -109,6 +110,12 @@ tb_int_t xm_process_openv(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, 3);
+ vs_unicode_output = lua_toboolean(lua, -1);
+ lua_pop(lua, 1);
+
// get environments
lua_pushstring(lua, "envs");
lua_gettable(lua, 3);
@@ -151,22 +158,30 @@ tb_int_t xm_process_openv(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_FILEPATH;
+ 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?
@@ -174,7 +189,9 @@ tb_int_t xm_process_openv(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_FILEPATH;
+ subprocess->errtype = TB_PROCESS_REDIRECT_TYPE_FILE;
+ attr.errfile = subprocess->errfile;
+ attr.errtype = subprocess->errtype;
}
attr.priv = subprocess;
}
@@ -187,7 +204,7 @@ tb_int_t xm_process_openv(lua_State* lua)
// redirect stdout to file
attr.outpath = outpath;
attr.outmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT;
- attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILE;
+ attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH;
}
// redirect stderr?
@@ -196,10 +213,13 @@ tb_int_t xm_process_openv(lua_State* lua)
// redirect stderr to file
attr.errpath = errpath;
attr.errmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT;
- attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILE;
+ attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH;
}
}
+ // set the new environments
+ if (envn > 0) attr.envp = envs;
+
// init process
tb_process_ref_t process = (tb_process_ref_t)tb_process_init(shellname, argv, &attr);
if (process) lua_pushlightuserdata(lua, (tb_pointer_t)process);
diff --git a/core/src/xmake/process/prefix.h b/core/src/xmake/process/prefix.h
index c1391fe19..3ec32f792 100644
--- a/core/src/xmake/process/prefix.h
+++ b/core/src/xmake/process/prefix.h
@@ -57,6 +57,9 @@ typedef struct __xm_subprocess_t
tb_file_ref_t errfile;
};
+ // vs unicode output environment variable
+ tb_string_t vs_unicode_output;
+
}xm_subprocess_t;
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 81d7eb3ec..06ee3a837 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -614,10 +614,12 @@ function os.execv(program, argv, opt)
-- uses the given environments?
local envs = nil
- if opt.envs then
+ if opt.envs or opt.vs_unicode_output then
local envars = os.getenvs()
- for k, v in pairs(opt.envs) do
- envars[k] = v
+ if opt.envs then
+ for k, v in pairs(opt.envs) do
+ envars[k] = v
+ end
end
envs = {}
for k, v in pairs(envars) do
@@ -627,7 +629,7 @@ function os.execv(program, argv, opt)
-- open command
local ok = -1
- local proc = process.openv(filename, argv, {outpath = opt.stdout, errpath = opt.stderr, envs = envs})
+ local proc = process.openv(filename, argv, {outpath = opt.stdout, errpath = opt.stderr, envs = envs, vs_unicode_output = opt.vs_unicode_output})
if proc ~= nil then
-- wait process
@@ -682,6 +684,7 @@ end
-- run command with arguments and return output and error data
function os.iorunv(program, argv, opt)
+ -- init options
opt = opt or {}
-- make temporary output and error file
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 81065f9cf..2d55001e3 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -392,7 +392,10 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
if dependinfo then
compflags = table.join(flags, "-showIncludes")
end
- return os.iorunv(_compargv1(self, sourcefile, objectfile, compflags))
+
+ -- compile and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528
+ local program, argv = _compargv1(self, sourcefile, objectfile, compflags)
+ return os.iorunv(program, argv, {vs_unicode_output = true})
end,
catch
{
diff --git a/xmake/modules/core/tools/lib.lua b/xmake/modules/core/tools/lib.lua
index b8d3812ff..0ae9be7fd 100644
--- a/xmake/modules/core/tools/lib.lua
+++ b/xmake/modules/core/tools/lib.lua
@@ -25,7 +25,7 @@ function extract(self, libraryfile, objectdir)
os.mkdir(objectdir)
-- list object files
- local objectfiles = os.iorunv(self:program(), {"-nologo", "-list", libraryfile})
+ local objectfiles = os.iorunv(self:program(), {"-nologo", "-list", libraryfile}, {vs_unicode_output = true})
-- extrace all object files
for _, objectfile in ipairs(objectfiles:split('\n')) do
@@ -47,7 +47,7 @@ function extract(self, libraryfile, objectdir)
end
-- extract it
- os.runv(self:program(), {"-nologo", "-extract:" .. objectfile, "-out:" .. outputfile, libraryfile})
+ os.runv(self:program(), {"-nologo", "-extract:" .. objectfile, "-out:" .. outputfile, libraryfile}, {vs_unicode_output = true})
end
end
end
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index 9149de17e..73d9c246d 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -112,7 +112,8 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt)
-- ensure the target directory
os.mkdir(path.directory(targetfile))
- -- link it
- os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags, opt))
+ -- link and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528
+ local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
+ os.runv(program, argv, {vs_unicode_output = true})
end
diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua
index 6b4155e29..6eb7c529d 100644
--- a/xmake/modules/core/tools/ml.lua
+++ b/xmake/modules/core/tools/ml.lua
@@ -104,7 +104,8 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
os.mkdir(path.directory(objectfile))
-- compile it
- os.runv(_compargv1(self, sourcefile, objectfile, flags))
+ local program, argv = _compargv1(self, sourcefile, objectfile, flags)
+ os.runv(program, argv, {vs_unicode_output = true})
end
-- make the compile arguments list