summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/link.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-23 22:49:40 +0800
committerruki <[email protected]>2025-04-23 11:30:31 +0800
commit81c8589d494d42bfc64393955b2d62ae22c90039 (patch)
tree208c0f093e92ad29ac4be924a5e22967fd231d32 /xmake/modules/core/tools/link.lua
parenta0d18574febebd378cfa481ec733581f01c2a41e (diff)
improve implib
Diffstat (limited to 'xmake/modules/core/tools/link.lua')
-rw-r--r--xmake/modules/core/tools/link.lua25
1 files changed, 17 insertions, 8 deletions
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index 12bad4a0d..70266c4c7 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -22,6 +22,14 @@
import("core.project.config")
import("private.tools.vstool")
+-- get implib file
+function _get_implibfile(self, opt)
+ local target = opt and opt.target
+ if target and target:type() == "target" then
+ return target:artifactfile("implib")
+ end
+end
+
-- init it
function init(self)
@@ -137,8 +145,9 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
table.insert(argv, 1, "-lib")
elseif targetkind == "shared" then
table.insert(argv, 1, "-dll")
- if opt.implib then
- table.insert(argv, "/IMPLIB:" .. opt.implib)
+ local implibfile = _get_implibfile(self, opt)
+ if implibfile then
+ table.insert(argv, "/implib:" .. implibfile)
end
end
return self:program(), argv
@@ -146,13 +155,13 @@ end
-- link the target file
function link(self, objectfiles, targetkind, targetfile, flags, opt)
+ opt = opt or {}
- -- ensure the target directory
+ -- ensure the target file directory exists
os.mkdir(path.directory(targetfile))
-
- -- ensure the implib directory
- if opt and opt.implib then
- os.mkdir(path.directory(opt.implib))
+ local implibfile = _get_implibfile(self, opt)
+ if implibfile then
+ os.mkdir(path.directory(implibfile))
end
try
@@ -161,6 +170,7 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt)
local toolchain = self:toolchain()
local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
+
if toolchain and toolchain:name() == "masm32" then
os.iorunv(program, argv, {envs = self:runenvs()})
else
@@ -185,4 +195,3 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt)
}
}
end
-