diff options
| author | ruki <[email protected]> | 2022-03-02 23:08:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-03-02 23:08:07 +0800 |
| commit | 97fc3a089b3aacbb96c36de154f0f024da1e8070 (patch) | |
| tree | 02688455dfdbae3fd1eda369739a3c6a71a13a1d | |
| parent | 952611bf9f388d1f706f44daf557b580a1140c35 (diff) | |
add export list file
| -rw-r--r-- | tests/projects/c/shared_library_export_list/src/foo.export.txt | 2 | ||||
| -rw-r--r-- | tests/projects/c/shared_library_export_list/xmake.lua | 6 | ||||
| -rw-r--r-- | xmake/rules/utils/symbols/export_list/xmake.lua | 28 |
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/projects/c/shared_library_export_list/src/foo.export.txt b/tests/projects/c/shared_library_export_list/src/foo.export.txt new file mode 100644 index 000000000..f8c70f59e --- /dev/null +++ b/tests/projects/c/shared_library_export_list/src/foo.export.txt @@ -0,0 +1,2 @@ +add +sub diff --git a/tests/projects/c/shared_library_export_list/xmake.lua b/tests/projects/c/shared_library_export_list/xmake.lua index 7e856130f..b48e131c2 100644 --- a/tests/projects/c/shared_library_export_list/xmake.lua +++ b/tests/projects/c/shared_library_export_list/xmake.lua @@ -7,6 +7,12 @@ target("foo") "add", "sub"}}) +target("foo2") + set_kind("shared") + add_files("src/foo.c") + add_files("src/foo.export.txt") + add_rules("utils.symbols.export_list") + target("test") set_kind("binary") add_deps("foo") 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" |
