summaryrefslogtreecommitdiff
path: root/xmake/rules/utils
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-02 23:08:07 +0800
committerruki <[email protected]>2022-03-02 23:08:07 +0800
commit97fc3a089b3aacbb96c36de154f0f024da1e8070 (patch)
tree02688455dfdbae3fd1eda369739a3c6a71a13a1d /xmake/rules/utils
parent952611bf9f388d1f706f44daf557b580a1140c35 (diff)
add export list file
Diffstat (limited to 'xmake/rules/utils')
-rw-r--r--xmake/rules/utils/symbols/export_list/xmake.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/xmake/rules/utils/symbols/export_list/xmake.lua b/xmake/rules/utils/symbols/export_list/xmake.lua
index 874f9425e..b9b642d96 100644
--- a/xmake/rules/utils/symbols/export_list/xmake.lua
+++ b/xmake/rules/utils/symbols/export_list/xmake.lua
@@ -19,12 +19,40 @@
--
-- export the given symbols list
+--
+--@code
+-- target("foo")
+-- set_kind("shared")
+-- add_files("src/foo.c")
+-- add_rules("utils.symbols.export_list", {symbols = {
+-- "add",
+-- "sub"}})
+--
+-- target("foo2")
+-- set_kind("shared")
+-- add_files("src/foo.c")
+-- add_files("src/foo.export.txt")
+-- add_rules("utils.symbols.export_list")
+--
rule("utils.symbols.export_list")
+ set_extensions(".export.txt")
on_config(function (target)
assert(target:is_shared(), 'rule("utils.symbols.export_list"): only for shared target(%s)!', target:name())
local exportfile
local exportkind
local exportsymbols = target:extraconf("rules", "utils.symbols.export_list", "symbols")
+ if not exportsymbols then
+ local sourcebatch = target:sourcebatches()["utils.symbols.export_list"]
+ if sourcebatch then
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ local list = io.readfile(sourcefile)
+ if list then
+ exportsymbols = list:split("\n")
+ end
+ break
+ end
+ end
+ end
assert(exportsymbols and #exportsymbols > 0, 'rule("utils.symbols.export_list"): no exported symbols!')
if target:has_tool("ld", "link") then
exportkind = "def"