summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSineStriker <[email protected]>2025-04-20 23:24:47 +0800
committerruki <[email protected]>2025-04-23 11:30:30 +0800
commit93dda3ce130c3a71a3d8a7bb4776af6e82bcf1c5 (patch)
tree492dfbb42f2c6d0f11e69624ee416ba7bf6e93ce
parent42be9d4228849def30a728b3933209a1cd90638e (diff)
Remove implib API
-rw-r--r--xmake/actions/package/oldpkg/main.lua8
-rw-r--r--xmake/core/project/target.lua17
-rw-r--r--xmake/modules/private/action/build/link_objects.lua10
-rw-r--r--xmake/modules/target/action/clean/main.lua8
-rw-r--r--xmake/modules/target/action/install/main.lua2
-rw-r--r--xmake/plugins/pack/batchcmds.lua11
6 files changed, 35 insertions, 21 deletions
diff --git a/xmake/actions/package/oldpkg/main.lua b/xmake/actions/package/oldpkg/main.lua
index 54a560cb9..394bb7683 100644
--- a/xmake/actions/package/oldpkg/main.lua
+++ b/xmake/actions/package/oldpkg/main.lua
@@ -48,9 +48,11 @@ function _package_library(target)
-- copy *.lib for shared/windows (*.dll) target
-- @see https://github.com/xmake-io/xmake/issues/787
- local target_implib = target:implibfile()
- if target_implib and os.isfile(target_implib) then
- os.vcp(target_implib, format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/", outputdir, targetname))
+ if target:has_implib() then
+ local target_implib = target:artifactfile("lib")
+ if os.isfile(target_implib) then
+ os.vcp(target_implib, format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/", outputdir, targetname))
+ end
end
-- copy headers
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 6e8b93e7b..e0756f6c5 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1643,6 +1643,13 @@ function _instance:artifactdir(type)
end
-- get the build artifact output file
+--
+-- supported artifact types:
+-- 1. bin: executable(.exe, Unix Executables), windows shared library(.dll)
+-- 2. lib: static library(.lib, .a), windows DLL implib(.lib, .dll.a), non-windows shared library(.so, .dylib)
+--
+-- otherwise returns nil
+--
function _instance:artifactfile(type)
if type == "bin" then
-- executable, windows shared library
@@ -1676,14 +1683,7 @@ function _instance:artifactfile(type)
end
-- to be added...
- return nil
-end
--- get the implib file (windows shared library only)
-function _instance:implibfile()
- if self:has_implib() then
- return self:artifactfile("lib")
- end
return nil
end
@@ -2565,7 +2565,8 @@ end
-- has implib artifact file?
--
--- equivalent to "is_windows_shared_library"
+-- returns true if the target is a windows shared library
+--
function _instance:has_implib()
return self:is_shared() and self:is_plat("windows", "mingw")
end
diff --git a/xmake/modules/private/action/build/link_objects.lua b/xmake/modules/private/action/build/link_objects.lua
index 8d3c8e7a1..0ff51e17d 100644
--- a/xmake/modules/private/action/build/link_objects.lua
+++ b/xmake/modules/private/action/build/link_objects.lua
@@ -46,13 +46,19 @@ function _do_link_target(target, opt)
local targetfile = target:targetfile()
local objectfiles = target:objectfiles()
local verbose = option.get("verbose")
+
+ local target_implib = nil
+ if target:has_implib() then
+ target_implib = target:artifactfile("lib")
+ end
+
if verbose then
-- show the full link command with raw arguments, it will expand @xxx.args for msvc/link on windows
- print(linkinst:linkcmd(objectfiles, targetfile, {linkflags = linkflags, implib = target:implibfile(), rawargs = true}))
+ print(linkinst:linkcmd(objectfiles, targetfile, {linkflags = linkflags, implib = target_implib, rawargs = true}))
end
if not dryrun then
- assert(linkinst:link(objectfiles, targetfile, {linkflags = linkflags, implib = target:implibfile()}))
+ assert(linkinst:link(objectfiles, targetfile, {linkflags = linkflags, implib = target_implib}))
end
end, {dependfile = target:dependfile(),
lastmtime = os.mtime(target:targetfile()),
diff --git a/xmake/modules/target/action/clean/main.lua b/xmake/modules/target/action/clean/main.lua
index 8806ed483..b919c4d63 100644
--- a/xmake/modules/target/action/clean/main.lua
+++ b/xmake/modules/target/action/clean/main.lua
@@ -45,9 +45,11 @@ function main(target)
end
end
- local implibfile = target:implibfile()
- if implibfile and os.isfile(implibfile) then
- remove_files(implibfile)
+ if target:has_implib() then
+ local libfile = target:artifactfile("lib")
+ if os.isfile(libfile) then
+ remove_files(libfile)
+ end
end
end
diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua
index 660700c0b..321591ea2 100644
--- a/xmake/modules/target/action/install/main.lua
+++ b/xmake/modules/target/action/install/main.lua
@@ -237,7 +237,7 @@ function _install_shared(target, opt)
-- @see https://github.com/xmake-io/xmake/issues/714
os.vcp(target:targetfile(), bindir)
local libdir = _get_target_libdir(target, opt)
- local target_implib = target:implibfile()
+ local target_implib = target:artifact("lib")
if os.isfile(target_implib) then
os.mkdir(libdir)
os.vcp(target_implib, libdir)
diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua
index 70d8e2f5f..4128a2cd4 100644
--- a/xmake/plugins/pack/batchcmds.lua
+++ b/xmake/plugins/pack/batchcmds.lua
@@ -303,10 +303,13 @@ function _on_target_installcmd_shared(target, batchcmds_, opt)
-- install *.lib for shared/windows (*.dll) target
-- @see https://github.com/xmake-io/xmake/issues/714
- local target_implib = target:implibfile()
- if target_implib and os.isfile(target_implib) then
- batchcmds_:mkdir(libdir)
- batchcmds_:cp(target_implib, path.join(libdir, path.filename(target_implib)))
+
+ if target:has_implib() then
+ local target_implib = target:artifactfile("lib")
+ if os.isfile(target_implib) then
+ batchcmds_:mkdir(libdir)
+ batchcmds_:cp(target_implib, path.join(libdir, path.filename(target_implib)))
+ end
end
_install_target_headers(target, batchcmds_, opt)