diff options
| author | ruki <[email protected]> | 2020-06-23 22:37:44 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-06-23 22:37:44 +0800 |
| commit | c18d15eb89116a0f3ce96bd56f3ccf861849f6ec (patch) | |
| tree | 52b63db3274349f9a41872414208c7c30058cfd7 /xmake/modules/core/tools/link.lua | |
| parent | 53df324acd9c7432336a5894ceef578daa1ce38d (diff) | |
| parent | 18bded45c229f5580c13fc8b4afc5edb6f18819a (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/tools/link.lua')
| -rw-r--r-- | xmake/modules/core/tools/link.lua | 16 |
1 files changed, 13 insertions, 3 deletions
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 { |
