summaryrefslogtreecommitdiff
path: root/xmake/modules/core
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-23 22:37:44 +0800
committerGitHub <[email protected]>2020-06-23 22:37:44 +0800
commitc18d15eb89116a0f3ce96bd56f3ccf861849f6ec (patch)
tree52b63db3274349f9a41872414208c7c30058cfd7 /xmake/modules/core
parent53df324acd9c7432336a5894ceef578daa1ce38d (diff)
parent18bded45c229f5580c13fc8b4afc5edb6f18819a (diff)
Merge pull request #857 from xmake-io/toolchain
Improve toolchain to support host and cross toolchains at same time
Diffstat (limited to 'xmake/modules/core')
-rw-r--r--xmake/modules/core/tools/ar.lua3
-rw-r--r--xmake/modules/core/tools/cl.lua3
-rw-r--r--xmake/modules/core/tools/gcc.lua6
-rw-r--r--xmake/modules/core/tools/lib.lua4
-rw-r--r--xmake/modules/core/tools/link.lua16
-rw-r--r--xmake/modules/core/tools/ml.lua27
-rw-r--r--xmake/modules/core/tools/rc.lua3
7 files changed, 29 insertions, 33 deletions
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/cl.lua b/xmake/modules/core/tools/cl.lua
index 9f6421c21..3dfa0bb0f 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -353,7 +353,8 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
end
-- use vstool to compile and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528
- return vstool.iorunv(compargv(self, sourcefile, objectfile, compflags, opt))
+ local program, argv = compargv(self, sourcefile, objectfile, compflags, opt)
+ return vstool.iorunv(program, argv, {envs = self:runenvs()})
end,
catch
{
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 04839ceaf..7896deab6 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -330,7 +330,8 @@ function link(self, objectfiles, targetkind, targetfile, flags)
os.mkdir(path.directory(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
-- has color diagnostics?
@@ -424,7 +425,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/lib.lua b/xmake/modules/core/tools/lib.lua
index 704fe406c..6c07e9d1f 100644
--- a/xmake/modules/core/tools/lib.lua
+++ b/xmake/modules/core/tools/lib.lua
@@ -28,7 +28,7 @@ function extract(self, libraryfile, objectdir)
os.mkdir(objectdir)
-- list object files
- local objectfiles = vstool.iorunv(self:program(), {"-nologo", "-list", libraryfile})
+ local objectfiles = vstool.iorunv(self:program(), {"-nologo", "-list", libraryfile}, {envs = self:runenvs()})
-- extrace all object files
for _, objectfile in ipairs(objectfiles:split('\n')) do
@@ -50,7 +50,7 @@ function extract(self, libraryfile, objectdir)
end
-- extract it
- vstool.runv(self:program(), {"-nologo", "-extract:" .. objectfile, "-out:" .. outputfile, libraryfile})
+ vstool.runv(self:program(), {"-nologo", "-extract:" .. objectfile, "-out:" .. outputfile, libraryfile}, {envs = self:runenvs()})
end
end
end
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index 3bcbb238d..10a242e6d 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -52,7 +52,7 @@ function get(self, name)
local values = self._INFO[name]
if name == "ldflags" or name == "arflags" or name == "shflags" then
-- switch architecture, @note does cache it in init() for generating vs201x project
- values = table.join(values, "-machine:" .. (config.arch() or "x86"))
+ values = table.join(values, "-machine:" .. (self:arch() or "x86"))
end
return values
end
@@ -94,7 +94,16 @@ end
function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
opt = opt or {}
local argv = table.join(flags, "-out:" .. targetfile, objectfiles)
- return self:program(), opt.rawargs and argv or winos.cmdargv(argv)
+ if not opt.rawargs then
+ argv = winos.cmdargv(argv)
+ end
+ -- @note we cannot put -lib/-dll to @args.txt
+ if targetkind == "static" then
+ table.insert(argv, 1, "-lib")
+ elseif targetkind == "shared" then
+ table.insert(argv, 1, "-dll")
+ end
+ return self:program(), argv
end
-- link the target file
@@ -108,7 +117,8 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt)
function ()
-- use vstool to link and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528
- vstool.runv(linkargv(self, objectfiles, targetkind, targetfile, flags, opt))
+ local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
+ vstool.runv(program, argv, {envs = self:runenvs()})
end,
catch
{
diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua
index 4899b46c6..3d6fb7c18 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 = self:runenvs()})
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
-
diff --git a/xmake/modules/core/tools/rc.lua b/xmake/modules/core/tools/rc.lua
index cdaaa6b49..a0379ca57 100644
--- a/xmake/modules/core/tools/rc.lua
+++ b/xmake/modules/core/tools/rc.lua
@@ -59,7 +59,8 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
{
function ()
-- @note we need not uses vstool.iorunv to enable unicode output for rc.exe
- local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, flags))
+ local program, argv = compargv(self, sourcefile, objectfile, flags)
+ local outdata, errdata = os.iorunv(program, argv, {envs = self:runenvs()})
return (outdata or "") .. (errdata or "")
end,
catch