diff options
| author | ruki <[email protected]> | 2021-10-23 00:34:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-10-23 00:34:32 +0800 |
| commit | 55eaa73edf4b3bace71ec1a71b957c34374442b2 (patch) | |
| tree | 3188a26ef8c1c59ce233ce91c731dfa79cce508d /xmake/modules/core/tools/nim.lua | |
| parent | 62d3e0c681f25cb48560d07461a92738b55a0b6d (diff) | |
fix nim
Diffstat (limited to 'xmake/modules/core/tools/nim.lua')
| -rw-r--r-- | xmake/modules/core/tools/nim.lua | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/nim.lua b/xmake/modules/core/tools/nim.lua index d142e3f0e..0eece46cf 100644 --- a/xmake/modules/core/tools/nim.lua +++ b/xmake/modules/core/tools/nim.lua @@ -98,8 +98,12 @@ function nf_includedir(self, dir) end -- make the link flag -function nf_link(self, lib) - return "--passL:-l" .. lib +function nf_link(self, lib, target) + if target:is_plat("windows") then + return "--passL:" .. lib .. ".lib" + else + return "--passL:-l" .. lib + end end -- make the linkdir flag @@ -126,6 +130,24 @@ function buildargv(self, sourcefiles, targetkind, targetfile, flags) table.insert(flags_extra, "--passC:-DPreMain=PreMain_" .. uniquekey) table.insert(flags_extra, "--passC:-DPreMainInner=PreMainInner_" .. uniquekey) end + if targetkind ~= "static" and is_plat("windows") then + -- fix link flags for windows + -- @see https://github.com/nim-lang/Nim/issues/19033 + local flags_new = {} + local flags_link = {} + for _, flag in ipairs(flags) do + if flag:find("passL:", 1, true) then + table.insert(flags_link, flag) + else + table.insert(flags_new, flag) + end + end + if #flags_link > 0 then + table.insert(flags_new, "--passL:-link") + table.join2(flags_new, flags_link) + end + flags = flags_new + end return self:program(), table.join("c", flags, flags_extra, "-o:" .. targetfile, sourcefiles) end @@ -136,3 +158,4 @@ function build(self, sourcefiles, targetkind, targetfile, flags) os.runv(program, argv, {envs = self:runenvs()}) end + |
