diff options
| author | ruki <[email protected]> | 2023-10-24 22:53:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-10-24 22:53:05 +0800 |
| commit | 66b43560f7cf25b20ecb78a85dc17fe1f975bb48 (patch) | |
| tree | 52e461ab60c8c76d6b5a8ae8a379121991573df9 /xmake/modules/core/tools/gcc.lua | |
| parent | 645d407a01aa69d35d5340c66f5e109583e4c427 (diff) | |
pass extras to tools
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 7d55c4fdc..ecc4eed98 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,24 @@ 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 target and not self:is_plat("macosx", "windows", "mingw") then - local group = target:extraconf("linkgroups", linkgroup, "group") - local whole = target:extraconf("linkgroups", linkgroup, "whole") + local target = opt.target + local extras = opt.extras or target:extraconf("linkgroups") + if extras then + if type(linkgroup) == "table" then + extras = extras[table.concat(linkgroup, "_")] + else + extras = extras[linkgroup] + end + end + if extras and not self:is_plat("macosx", "windows", "mingw") then + local group = extras.group + local whole = extras.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 +334,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 = extras.static if static then table.join2(flags, "-Wl,-Bstatic", linkflags, "-Wl,-Bdynamic") end @@ -416,8 +426,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 +439,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 +452,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 +465,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} |
