summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-27 03:50:01 -0500
committerGitHub <[email protected]>2023-10-27 03:50:01 -0500
commit6af4b8528bfae7536fc77a5e7fb4341b3f11bc9a (patch)
tree45bb260efc422e8692fc664ed80d9ddc9b56cb3c /xmake/modules
parenteeda646a4e32b3d672a8097fe995cbdcf101c7aa (diff)
parent1cb74a5009d8fbcb792aa6cc787943453cc5234a (diff)
Merge pull request #4314 from xmake-io/package
Support linkgroups and linkorders for package
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/core/tools/cl.lua12
-rw-r--r--xmake/modules/core/tools/clang_cl.lua6
-rw-r--r--xmake/modules/core/tools/dmd.lua4
-rw-r--r--xmake/modules/core/tools/gcc.lua28
-rw-r--r--xmake/modules/core/tools/go.lua5
-rw-r--r--xmake/modules/core/tools/ld.lua2
-rw-r--r--xmake/modules/core/tools/ldc2.lua4
-rw-r--r--xmake/modules/core/tools/link.lua6
-rw-r--r--xmake/modules/core/tools/ml.lua2
-rw-r--r--xmake/modules/core/tools/nim.lua6
-rw-r--r--xmake/modules/core/tools/nvcc.lua7
-rw-r--r--xmake/modules/core/tools/zig_cc.lua2
-rw-r--r--xmake/modules/package/manager/xmake/find_package.lua2
-rw-r--r--xmake/modules/private/action/require/impl/register_packages.lua2
14 files changed, 53 insertions, 35 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 607f0f4d9..34927d179 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -88,7 +88,7 @@ function init(self)
end
-- make the symbol flags
-function nf_symbols(self, levels, target)
+function nf_symbols(self, levels, opt)
local flags = nil
local values = hashset.from(levels)
if values:has("debug") then
@@ -103,6 +103,7 @@ function nf_symbols(self, levels, target)
-- generate *.pdb file
local symbolfile = nil
+ local target = opt.target
if target and target.symbolfile and not values:has("embed") then
symbolfile = target:symbolfile()
end
@@ -296,7 +297,8 @@ function nf_includedir(self, dir)
end
-- make the force include flag
-function nf_forceinclude(self, headerfile, target)
+function nf_forceinclude(self, headerfile, opt)
+ local target = opt.target
local sourcekinds = target and target:extraconf("forceincludes", headerfile, "sourcekinds")
if not sourcekinds or table.contains(table.wrap(sourcekinds), self:kind()) then
return {"-FI", headerfile}
@@ -377,8 +379,9 @@ function nf_encoding(self, encoding)
end
-- make the c precompiled header flag
-function nf_pcheader(self, pcheaderfile, target)
+function nf_pcheader(self, pcheaderfile, opt)
if self:kind() == "cc" then
+ local target = opt.target
local objectfiles = target:objectfiles()
if objectfiles then
table.insert(objectfiles, target:pcoutputfile("c") .. ".obj")
@@ -388,8 +391,9 @@ function nf_pcheader(self, pcheaderfile, target)
end
-- make the c++ precompiled header flag
-function nf_pcxxheader(self, pcheaderfile, target)
+function nf_pcxxheader(self, pcheaderfile, opt)
if self:kind() == "cxx" then
+ local target = opt.target
local objectfiles = target:objectfiles()
if objectfiles then
table.insert(objectfiles, target:pcoutputfile("cxx") .. ".obj")
diff --git a/xmake/modules/core/tools/clang_cl.lua b/xmake/modules/core/tools/clang_cl.lua
index ee795e9d7..69459ad3e 100644
--- a/xmake/modules/core/tools/clang_cl.lua
+++ b/xmake/modules/core/tools/clang_cl.lua
@@ -105,7 +105,8 @@ function nf_optimize(self, level)
end
-- make the c precompiled header flag
-function nf_pcheader(self, pcheaderfile, target)
+function nf_pcheader(self, pcheaderfile, opt)
+ local target = opt.target
if self:kind() == "cc" then
local objectfiles = target:objectfiles()
if objectfiles then
@@ -119,7 +120,8 @@ function nf_pcheader(self, pcheaderfile, target)
end
-- make the c++ precompiled header flag
-function nf_pcxxheader(self, pcheaderfile, target)
+function nf_pcxxheader(self, pcheaderfile, opt)
+ local target = opt.target
if self:kind() == "cxx" then
local objectfiles = target:objectfiles()
if objectfiles then
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua
index e02a1ed0a..8be22bf97 100644
--- a/xmake/modules/core/tools/dmd.lua
+++ b/xmake/modules/core/tools/dmd.lua
@@ -72,7 +72,7 @@ function nf_strip(self, level)
end
-- make the symbol flag
-function nf_symbol(self, level, target)
+function nf_symbol(self, level)
local kind = self:kind()
if language.sourcekinds()[kind] then
local maps = _g.symbol_maps
@@ -83,7 +83,7 @@ function nf_symbol(self, level, target)
_g.symbol_maps = maps
end
return maps[level .. '_' .. kind] or maps[level]
- elseif (kind == "dcld" or kind == "dcsh") and target:is_plat("windows") and level == "debug" then
+ elseif (kind == "dcld" or kind == "dcsh") and self:is_plat("windows") and level == "debug" then
return "-g"
end
end
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 6589b6f13..1d4a9e8f9 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -81,7 +81,7 @@ function load(self)
end
-- make the strip flag
-function nf_strip(self, level, target)
+function nf_strip(self, level)
local maps = {
debug = "-Wl,-S"
, all = "-s"
@@ -283,7 +283,8 @@ function nf_sysincludedir(self, dir)
end
-- make the force include flag
-function nf_forceinclude(self, headerfile, target)
+function nf_forceinclude(self, headerfile, opt)
+ local target = opt.target
local sourcekinds = target and target:extraconf("forceincludes", headerfile, "sourcekinds")
if not sourcekinds or table.contains(table.wrap(sourcekinds), self:kind()) then
return {"-include", headerfile}
@@ -307,15 +308,16 @@ function nf_syslink(self, lib)
end
-- make the link group flag
-function nf_linkgroup(self, linkgroup, target)
+function nf_linkgroup(self, linkgroup, opt)
local linkflags = {}
for _, lib in ipairs(linkgroup) do
table.insert(linkflags, nf_link(self, lib))
end
local flags = {}
- if not self:is_plat("macosx", "windows", "mingw") then
- local group = target:extraconf("linkgroups", linkgroup, "group")
- local whole = target:extraconf("linkgroups", linkgroup, "whole")
+ local extra = opt.extra
+ if extra and not self:is_plat("macosx", "windows", "mingw") then
+ local group = extra.group
+ local whole = extra.whole
if group and whole then
-- https://github.com/xmake-io/xmake/issues/4308
table.join2(flags, "-Wl,--whole-archive", "-Wl,--start-group", linkflags, "-Wl,--end-group", "-Wl,--no-whole-archive")
@@ -324,7 +326,7 @@ function nf_linkgroup(self, linkgroup, target)
elseif whole then
table.join2(flags, "-Wl,--whole-archive", linkflags, "-Wl,--no-whole-archive")
end
- local static = target:extraconf("linkgroups", linkgroup, "static")
+ local static = extra.static
if static then
table.join2(flags, "-Wl,-Bstatic", linkflags, "-Wl,-Bdynamic")
end
@@ -416,8 +418,9 @@ function nf_encoding(self, encoding)
end
-- make the c precompiled header flag
-function nf_pcheader(self, pcheaderfile, target)
+function nf_pcheader(self, pcheaderfile, opt)
if self:kind() == "cc" then
+ local target = opt.target
local pcoutputfile = target:pcoutputfile("c")
if self:name() == "clang" then
return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
@@ -428,8 +431,9 @@ function nf_pcheader(self, pcheaderfile, target)
end
-- make the c++ precompiled header flag
-function nf_pcxxheader(self, pcheaderfile, target)
+function nf_pcxxheader(self, pcheaderfile, opt)
if self:kind() == "cxx" then
+ local target = opt.target
local pcoutputfile = target:pcoutputfile("cxx")
if self:name() == "clang" then
return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
@@ -440,8 +444,9 @@ function nf_pcxxheader(self, pcheaderfile, target)
end
-- make the objc precompiled header flag
-function nf_pmheader(self, pcheaderfile, target)
+function nf_pmheader(self, pcheaderfile, opt)
if self:kind() == "mm" then
+ local target = opt.target
local pcoutputfile = target:pcoutputfile("m")
if self:name() == "clang" then
return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
@@ -452,8 +457,9 @@ function nf_pmheader(self, pcheaderfile, target)
end
-- make the objc++ precompiled header flag
-function nf_pmxxheader(self, pcheaderfile, target)
+function nf_pmxxheader(self, pcheaderfile, opt)
if self:kind() == "mxx" then
+ local target = opt.target
local pcoutputfile = target:pcoutputfile("mxx")
if self:name() == "clang" then
return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
diff --git a/xmake/modules/core/tools/go.lua b/xmake/modules/core/tools/go.lua
index 51f5709af..e7d660d75 100644
--- a/xmake/modules/core/tools/go.lua
+++ b/xmake/modules/core/tools/go.lua
@@ -42,8 +42,9 @@ function nf_optimize(self, level)
end
-- make the symbol flag
-function nf_symbol(self, level, target, mapkind)
- if mapkind ~= "object" then
+function nf_symbol(self, level, opt)
+ local targetkind = opt.targetkind
+ if targetkind ~= "object" then
return
end
local maps = {
diff --git a/xmake/modules/core/tools/ld.lua b/xmake/modules/core/tools/ld.lua
index e933a847c..29917f70e 100644
--- a/xmake/modules/core/tools/ld.lua
+++ b/xmake/modules/core/tools/ld.lua
@@ -38,7 +38,7 @@ function init(self)
end
-- make the strip flag
-function nf_strip(self, level, target)
+function nf_strip(self, level)
local maps = {
debug = "-S"
, all = "-s"
diff --git a/xmake/modules/core/tools/ldc2.lua b/xmake/modules/core/tools/ldc2.lua
index 5a9f77026..49a1c451e 100644
--- a/xmake/modules/core/tools/ldc2.lua
+++ b/xmake/modules/core/tools/ldc2.lua
@@ -49,7 +49,7 @@ function nf_optimize(self, level)
end
-- make the symbol flag
-function nf_symbol(self, level, target)
+function nf_symbol(self, level)
local kind = self:kind()
if language.sourcekinds()[kind] then
local maps = _g.symbol_maps
@@ -61,7 +61,7 @@ function nf_symbol(self, level, target)
_g.symbol_maps = maps
end
return maps[level .. '_' .. kind] or maps[level]
- elseif (kind == "dcld" or kind == "dcsh") and target:is_plat("windows") and level == "debug" then
+ elseif (kind == "dcld" or kind == "dcsh") and self:is_plat("windows") and level == "debug" then
return "-g"
end
end
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index ee68cf01f..9c53c2e28 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -58,9 +58,10 @@ function get(self, name)
end
-- make the strip flag
-function nf_strip(self, level, target)
+function nf_strip(self, level, opt)
-- link.exe/arm64 does not support /opt:ref, /opt:icf
+ local target = opt.target
if target and target:is_arch("arm64") then
return
end
@@ -80,10 +81,11 @@ function nf_strip(self, level, target)
end
-- make the symbol flag
-function nf_symbol(self, level, target)
+function nf_symbol(self, level, opt)
-- debug? generate *.pdb file
local flags = nil
+ local target = opt.target
if target then
if target:type() == "target" then
if level == "debug" and (target:is_binary() or target:is_shared()) then
diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua
index 042937ed7..5bb1fb884 100644
--- a/xmake/modules/core/tools/ml.lua
+++ b/xmake/modules/core/tools/ml.lua
@@ -55,7 +55,7 @@ function init(self)
end
-- make the symbol flags
-function nf_symbols(self, levels, target)
+function nf_symbols(self, levels)
local flags = nil
local values = hashset.from(levels)
if values:has("debug") then
diff --git a/xmake/modules/core/tools/nim.lua b/xmake/modules/core/tools/nim.lua
index 13d8fb3d6..b765f01f6 100644
--- a/xmake/modules/core/tools/nim.lua
+++ b/xmake/modules/core/tools/nim.lua
@@ -89,7 +89,7 @@ function nf_symbol(self, level)
end
-- make the strip flag
-function nf_strip(self, level, target)
+function nf_strip(self, level)
if self:is_plat("linux", "macosx", "bsd") then
if level == "debug" or level == "all" then
return "--passL:-s"
@@ -103,7 +103,7 @@ function nf_includedir(self, dir)
end
-- make the link flag
-function nf_link(self, lib, target)
+function nf_link(self, lib)
if self:is_plat("windows") then
return "--passL:" .. lib .. ".lib"
else
@@ -112,7 +112,7 @@ function nf_link(self, lib, target)
end
-- make the linkdir flag
-function nf_linkdir(self, dir, target)
+function nf_linkdir(self, dir)
if self:is_plat("windows") then
return {"--passL:-libpath:" .. path.translate(dir)}
else
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 038e2e75a..7050f86af 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -53,7 +53,7 @@ function init(self)
end
-- make the symbol flag
-function nf_symbol(self, level, target)
+function nf_symbol(self, level, opt)
-- debug? generate *.pdb file
local flags = nil
@@ -62,6 +62,7 @@ function nf_symbol(self, level, target)
if self:is_plat("windows") then
local host_flags = nil
local symbolfile = nil
+ local target = opt.target
if target and target.symbolfile then
symbolfile = target:symbolfile()
end
@@ -259,12 +260,12 @@ function nf_rpathdir(self, dir)
end
-- make the c precompiled header flag
-function nf_pcheader(self, pcheaderfile, target)
+function nf_pcheader(self, pcheaderfile)
return {"-include", pcheaderfile}
end
-- make the c++ precompiled header flag
-function nf_pcxxheader(self, pcheaderfile, target)
+function nf_pcxxheader(self, pcheaderfile)
return {"-include", pcheaderfile}
end
diff --git a/xmake/modules/core/tools/zig_cc.lua b/xmake/modules/core/tools/zig_cc.lua
index 8fefb0f97..205ecddfe 100644
--- a/xmake/modules/core/tools/zig_cc.lua
+++ b/xmake/modules/core/tools/zig_cc.lua
@@ -22,7 +22,7 @@
inherit("gcc")
-- make the strip flag
-function nf_strip(self, level, target)
+function nf_strip(self, level)
local maps = {
debug = "-Wl,-S"
, all = "-s"
diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua
index a1f2dfac2..0d5336fe4 100644
--- a/xmake/modules/package/manager/xmake/find_package.lua
+++ b/xmake/modules/package/manager/xmake/find_package.lua
@@ -245,6 +245,7 @@ function _find_package_from_repo(name, opt)
-- get version and license
result.version = manifest.version or path.filename(path.directory(path.directory(manifest_file)))
result.license = manifest.license
+ result.extras = manifest.extras
return result
end
@@ -352,5 +353,6 @@ function main(name, opt)
if not result and opt.packagedirs then
result = _find_package_from_packagedirs(name, opt)
end
+
return result
end
diff --git a/xmake/modules/private/action/require/impl/register_packages.lua b/xmake/modules/private/action/require/impl/register_packages.lua
index ae66b6e75..621e383d1 100644
--- a/xmake/modules/private/action/require/impl/register_packages.lua
+++ b/xmake/modules/private/action/require/impl/register_packages.lua
@@ -51,7 +51,7 @@ function _register_required_package_libs(instance, required_package, is_deps)
fetchinfo.static = nil
fetchinfo.shared = nil
fetchinfo.installdir = nil
- fetchinfo.extra = nil
+ fetchinfo.extras = nil
fetchinfo.components = nil
end