From 8a4d7349f8562a3cf5869dfa4a6460c049f44f3b Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 20 Jun 2020 19:14:20 +0800 Subject: fix check options --- xmake/modules/core/tools/ml.lua | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'xmake/modules/core/tools/ml.lua') diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index 4899b46c6..42c10b633 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -91,12 +91,12 @@ function nf_includedir(self, dir) end -- make the compile arguments list -function _compargv1(self, sourcefile, objectfile, flags) +function compargv(self, sourcefile, objectfile, flags) return self:program(), table.join("-c", flags, "-Fo" .. os.args(objectfile), sourcefile) end -- compile the source file -function _compile1(self, sourcefile, objectfile, dependinfo, flags) +function compile(self, sourcefile, objectfile, dependinfo, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) @@ -105,7 +105,8 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) { function () -- @note we need not uses vstool.runv to enable unicode output for ml.exe - os.runv(_compargv1(self, sourcefile, objectfile, flags)) + local program, argv = compargv(self, sourcefile, objectfile, flags) + os.runv(program, argv, {envs = opt.envs}) end, catch { @@ -125,23 +126,3 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) } end --- make the compile arguments list -function compargv(self, sourcefiles, objectfile, flags) - - -- only support single source file now - assert(type(sourcefiles) ~= "table", "'object:sources' not support!") - - -- for only single source file - return _compargv1(self, sourcefiles, objectfile, flags) -end - --- compile the source file -function compile(self, sourcefiles, objectfile, dependinfo, flags) - - -- only support single source file now - assert(type(sourcefiles) ~= "table", "'object:sources' not support!") - - -- for only single source file - _compile1(self, sourcefiles, objectfile, dependinfo, flags) -end - -- cgit v1.3.1 From 98f81666c21be8359f005047f57778aa7905d6f0 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 21 Jun 2020 09:48:44 +0800 Subject: fix ml --- xmake/modules/core/tools/ml.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmake/modules/core/tools/ml.lua') diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index 42c10b633..a6523243d 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -96,7 +96,7 @@ function compargv(self, sourcefile, objectfile, flags) end -- compile the source file -function compile(self, sourcefile, objectfile, dependinfo, flags) +function compile(self, sourcefile, objectfile, dependinfo, flags, opt) -- ensure the object directory os.mkdir(path.directory(objectfile)) -- cgit v1.3.1 From ce6d63d5a4ea3df28fc21db6b4501d4b65480584 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 22 Jun 2020 23:17:06 +0800 Subject: fix mingw/gcc envs --- xmake/modules/core/tools/ar.lua | 3 ++- xmake/modules/core/tools/gcc.lua | 3 ++- xmake/modules/core/tools/ml.lua | 4 ++-- xmake/modules/core/tools/rc.lua | 4 ++-- xmake/modules/detect/tools/gcc/features.lua | 2 +- xmake/modules/detect/tools/gcc/has_flags.lua | 12 +++++------- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'xmake/modules/core/tools/ml.lua') diff --git a/xmake/modules/core/tools/ar.lua b/xmake/modules/core/tools/ar.lua index 576d40695..3e520f887 100644 --- a/xmake/modules/core/tools/ar.lua +++ b/xmake/modules/core/tools/ar.lua @@ -71,7 +71,8 @@ function link(self, objectfiles, targetkind, targetfile, flags) os.tryrm(targetfile) -- link it - os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) + local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags) + os.runv(program, argv, {envs = self:runenvs()}) end -- extract the static library to object directory diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 04839ceaf..4e16875c9 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -424,7 +424,8 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) end -- do compile - return os.iorunv(compargv(self, sourcefile, objectfile, compflags)) + local program, argv = compargv(self, sourcefile, objectfile, compflags) + return os.iorunv(program, argv, {envs = self:runenvs()}) end, catch { diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index a6523243d..3d6fb7c18 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -96,7 +96,7 @@ function compargv(self, sourcefile, objectfile, flags) end -- compile the source file -function compile(self, sourcefile, objectfile, dependinfo, flags, opt) +function compile(self, sourcefile, objectfile, dependinfo, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) @@ -106,7 +106,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) function () -- @note we need not uses vstool.runv to enable unicode output for ml.exe local program, argv = compargv(self, sourcefile, objectfile, flags) - os.runv(program, argv, {envs = opt.envs}) + os.runv(program, argv, {envs = self:runenvs()}) end, catch { diff --git a/xmake/modules/core/tools/rc.lua b/xmake/modules/core/tools/rc.lua index 4d5d79a86..a0379ca57 100644 --- a/xmake/modules/core/tools/rc.lua +++ b/xmake/modules/core/tools/rc.lua @@ -49,7 +49,7 @@ function compargv(self, sourcefile, objectfile, flags) end -- compile the source file -function compile(self, sourcefile, objectfile, dependinfo, flags, opt) +function compile(self, sourcefile, objectfile, dependinfo, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) @@ -60,7 +60,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) function () -- @note we need not uses vstool.iorunv to enable unicode output for rc.exe local program, argv = compargv(self, sourcefile, objectfile, flags) - local outdata, errdata = os.iorunv(program, argv, {envs = opt.envs}) + local outdata, errdata = os.iorunv(program, argv, {envs = self:runenvs()}) return (outdata or "") .. (errdata or "") end, catch diff --git a/xmake/modules/detect/tools/gcc/features.lua b/xmake/modules/detect/tools/gcc/features.lua index 6f339f664..ad4cb3214 100644 --- a/xmake/modules/detect/tools/gcc/features.lua +++ b/xmake/modules/detect/tools/gcc/features.lua @@ -32,7 +32,7 @@ function _get_macro_defines(snippets, extension, opt) -- get defines local results = {} - local defines = try { function () return os.iorunv(opt.program, table.join(opt.flags or {}, {"-dM", "-E", sourcefile})) end } + local defines = try { function () return os.iorunv(opt.program, table.join(opt.flags or {}, {"-dM", "-E", sourcefile}), {envs = opt.envs}) end } if defines then for _, define in ipairs(defines:split("\n")) do local name = define:match("#define%s+(.-)%s+") diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua index 28b4cd254..04956998b 100644 --- a/xmake/modules/detect/tools/gcc/has_flags.lua +++ b/xmake/modules/detect/tools/gcc/has_flags.lua @@ -37,11 +37,9 @@ function _islinker(flags, opt) end -- try running -function _try_running(...) - - local argv = {...} +function _try_running(program, argv, opt) local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(program, argv, opt); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list @@ -67,7 +65,7 @@ function _check_from_arglist(flags, opt, islinker) -- get argument list allflags = {} - local arglist = os.iorunv(opt.program, {"--help"}) + local arglist = os.iorunv(opt.program, {"--help"}, {envs = opt.envs}) if arglist then for arg in arglist:gmatch("%s+(%-[%-%a%d]+)%s+") do allflags[arg] = true @@ -98,12 +96,12 @@ function _check_try_running(flags, opt, islinker) -- check flags for linker if islinker then - return _try_running(opt.program, table.join(flags, "-o", os.tmpfile(), sourcefile)) + return _try_running(opt.program, table.join(flags, "-o", os.tmpfile(), sourcefile), opt) end -- check flags for compiler -- @note we cannot use os.nuldev() as the output file, maybe run failed for some flags, e.g. --coverage - return _try_running(opt.program, table.join(flags, "-S", "-o", os.tmpfile(), sourcefile)) + return _try_running(opt.program, table.join(flags, "-S", "-o", os.tmpfile(), sourcefile), opt) end -- has_flags(flags)? -- cgit v1.3.1