diff options
| author | ruki <[email protected]> | 2018-11-08 22:51:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-11-08 11:11:44 +0800 |
| commit | da5ba0608b0db673077d30951b7227ed42a69dca (patch) | |
| tree | 8b0968bf8cf6cd33db6704c615fd2c1db18abb7e | |
| parent | a1c8f03dc30ad086a2116458ae58ec6e2eddce1b (diff) | |
add syslinks api
26 files changed, 157 insertions, 22 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 124b2dfde..66489da69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * [#233](https://github.com/tboox/xmake/issues/233): Support windres for mingw platform * [#239](https://github.com/tboox/xmake/issues/239): Add cparser compiler support * Add plugin manager `xmake plugin --help` +* Add `add_syslinks` api to add system libraries dependence ### Changes @@ -507,6 +508,7 @@ * [#233](https://github.com/tboox/xmake/issues/233): 对mingw平台增加windres的支持 * [#239](https://github.com/tboox/xmake/issues/239): 添加cparser编译器支持 * 添加插件管理器,`xmake plugin --help` +* 添加`add_syslinks`接口去设置系统库依赖,分离与`add_links`添加的库依赖之间的链接顺序 ### 改进 diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index ac2f5a3b3..5daf18f94 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -141,13 +141,13 @@ function builder:_inherit_from_targetdeps(results, target, flagname) local targetkind = target:get("kind") local depconfig = table.wrap(target:depconfig(dep:name())) if (depkind == "static" or depkind == "shared") and (depconfig.inherit == nil or depconfig.inherit) then - if flagname == "links" and (targetkind == "binary" or targetkind == "shared") then + if (flagname == "links" or flagname == "syslinks") and (targetkind == "binary" or targetkind == "shared") then -- add dependent link table.insert(results, dep:basename()) -- inherit links from the depdent target - self:_inherit_from_target(results, dep, "links") + self:_inherit_from_target(results, dep, flagname) elseif flagname == "linkdirs" and (targetkind == "binary" or targetkind == "shared") then @@ -155,7 +155,7 @@ function builder:_inherit_from_targetdeps(results, target, flagname) table.insert(results, path.directory(dep:targetfile())) -- inherit linkdirs from the depdent target - self:_inherit_from_target(results, dep, "linkdirs") + self:_inherit_from_target(results, dep, flagname) elseif flagname == "rpathdirs" and (targetkind == "binary" or targetkind == "shared") then @@ -293,7 +293,7 @@ function builder:_addflags_from_language(flags, target, getters) if target:type() == "target" then -- link? add includes and links of all dependent targets first - if name == "links" or name == "linkdirs" or name == "rpathdirs" or name == "includedirs" then + if name == "links" or name == "syslinks" or name == "linkdirs" or name == "rpathdirs" or name == "includedirs" then self:_inherit_from_targetdeps(results, target, name) end diff --git a/xmake/languages/asm/api.lua b/xmake/languages/asm/api.lua index 79a512ad5..79ab3693b 100644 --- a/xmake/languages/asm/api.lua +++ b/xmake/languages/asm/api.lua @@ -30,6 +30,7 @@ function apis() { -- target.add_xxx "target.add_links" + , "target.add_syslinks" , "target.add_asflags" , "target.add_ldflags" , "target.add_arflags" @@ -38,6 +39,7 @@ function apis() , "target.add_undefines" -- option.add_xxx , "option.add_links" + , "option.add_syslinks" , "option.add_asflags" , "option.add_ldflags" , "option.add_arflags" diff --git a/xmake/languages/asm/xmake.lua b/xmake/languages/asm/xmake.lua index a368375f3..74c099001 100644 --- a/xmake/languages/asm/xmake.lua +++ b/xmake/languages/asm/xmake.lua @@ -106,6 +106,10 @@ language("asm") , "target.links" , "option.links" , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , static = { @@ -136,6 +140,7 @@ language("asm") , {category = "Cross Complation Configuration/Builin Flags Configuration" } , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "syslinks", "kv", nil, "The System Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } , {nil, "includedirs","kv", nil, "The Include Search Directories" } } diff --git a/xmake/languages/c++/api.lua b/xmake/languages/c++/api.lua index 0fc5bc06b..12fa78b92 100644 --- a/xmake/languages/c++/api.lua +++ b/xmake/languages/c++/api.lua @@ -167,6 +167,7 @@ function apis() "target.set_config_h_prefix" -- deprecated -- target.add_xxx , "target.add_links" + , "target.add_syslinks" , "target.add_cflags" , "target.add_cxflags" , "target.add_cxxflags" @@ -186,6 +187,7 @@ function apis() , "option.add_ctypes" , "option.add_cxxtypes" , "option.add_links" + , "option.add_syslinks" , "option.add_cflags" , "option.add_cxflags" , "option.add_cxxflags" diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua index 7326cd562..8ec9958c4 100644 --- a/xmake/languages/c++/xmake.lua +++ b/xmake/languages/c++/xmake.lua @@ -105,13 +105,17 @@ language("c++") , "platform.rpathdirs" , "platform.frameworkdirs" , "config.links" - , "config.frameworks" , "target.links" - , "target.frameworks" , "option.links" - , "option.frameworks" , "platform.links" + , "config.frameworks" + , "target.frameworks" + , "option.frameworks" , "platform.frameworks" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , shared = { @@ -131,13 +135,17 @@ language("c++") , "platform.rpathdirs" , "platform.frameworkdirs" , "config.links" - , "config.frameworks" , "target.links" - , "target.frameworks" , "option.links" - , "option.frameworks" , "platform.links" + , "config.frameworks" + , "target.frameworks" + , "option.frameworks" , "platform.frameworks" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , static = { @@ -171,6 +179,7 @@ language("c++") , {category = "Cross Complation Configuration/Builtin Flags Configuration" } , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "syslinks", "kv", nil, "The System Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } , {nil, "includedirs", "kv", nil, "The Include Search Directories" } , {nil, "frameworks", "kv", nil, "The Frameworks" } diff --git a/xmake/languages/cuda/api.lua b/xmake/languages/cuda/api.lua index 45cd432c3..792a284f1 100644 --- a/xmake/languages/cuda/api.lua +++ b/xmake/languages/cuda/api.lua @@ -30,12 +30,14 @@ function apis() { -- target.add_xxx "target.add_links" + , "target.add_syslinks" , "target.add_cuflags" , "target.add_ldflags" , "target.add_arflags" , "target.add_shflags" -- option.add_xxx , "option.add_links" + , "option.add_syslinks" , "option.add_cuflags" , "option.add_ldflags" , "option.add_arflags" diff --git a/xmake/languages/cuda/xmake.lua b/xmake/languages/cuda/xmake.lua index 2cf982ba2..7eff663e1 100644 --- a/xmake/languages/cuda/xmake.lua +++ b/xmake/languages/cuda/xmake.lua @@ -77,6 +77,10 @@ language("cuda") , "target.links" , "option.links" , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , shared = { @@ -90,6 +94,10 @@ language("cuda") , "target.links" , "option.links" , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , static = { @@ -112,6 +120,7 @@ language("cuda") , {category = "Cross Complation Configuration/Builtin Flags Configuration" } , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "syslinks", "kv", nil, "The System Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } , {nil, "includedirs","kv", nil, "The Include Search Directories" } } diff --git a/xmake/languages/dlang/api.lua b/xmake/languages/dlang/api.lua index 44414db89..ecf462856 100644 --- a/xmake/languages/dlang/api.lua +++ b/xmake/languages/dlang/api.lua @@ -30,12 +30,14 @@ function apis() { -- target.add_xxx "target.add_links" + , "target.add_syslinks" , "target.add_dcflags" , "target.add_ldflags" , "target.add_arflags" , "target.add_shflags" -- option.add_xxx , "option.add_links" + , "option.add_syslinks" , "option.add_dcflags" , "option.add_ldflags" , "option.add_arflags" diff --git a/xmake/languages/dlang/xmake.lua b/xmake/languages/dlang/xmake.lua index 3987bb992..4dd87567a 100644 --- a/xmake/languages/dlang/xmake.lua +++ b/xmake/languages/dlang/xmake.lua @@ -77,6 +77,10 @@ language("dlang") , "target.links" , "option.links" , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , shared = { @@ -90,6 +94,10 @@ language("dlang") , "target.links" , "option.links" , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , static = { @@ -112,6 +120,7 @@ language("dlang") , {category = "Cross Complation Configuration/Builtin Flags Configuration" } , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "syslinks", "kv", nil, "The System Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } , {nil, "includedirs","kv", nil, "The Include Search Directories" } } diff --git a/xmake/languages/golang/api.lua b/xmake/languages/golang/api.lua index fd741483c..221c532ac 100644 --- a/xmake/languages/golang/api.lua +++ b/xmake/languages/golang/api.lua @@ -30,11 +30,13 @@ function apis() { -- target.add_xxx "target.add_links" + , "target.add_syslinks" , "target.add_gcflags" , "target.add_ldflags" , "target.add_arflags" -- option.add_xxx , "option.add_links" + , "option.add_syslinks" , "option.add_gcflags" , "option.add_ldflags" , "option.add_arflags" diff --git a/xmake/languages/golang/xmake.lua b/xmake/languages/golang/xmake.lua index 38c9d4d97..117034930 100644 --- a/xmake/languages/golang/xmake.lua +++ b/xmake/languages/golang/xmake.lua @@ -78,6 +78,10 @@ language("golang") , "target.links" , "option.links" , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , shared = { @@ -91,6 +95,10 @@ language("golang") , "target.links" , "option.links" , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } } @@ -107,6 +115,7 @@ language("golang") , {category = "Cross Complation Configuration/Builtin Flags Configuration" } , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "syslinks", "kv", nil, "The System Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } , {nil, "includedirs","kv", nil, "The Include Search Directories" } } diff --git a/xmake/languages/objc++/api.lua b/xmake/languages/objc++/api.lua index bd8b00235..26e7155dc 100644 --- a/xmake/languages/objc++/api.lua +++ b/xmake/languages/objc++/api.lua @@ -32,6 +32,7 @@ function apis() "target.set_config_h_prefix" -- deprecated -- target.add_xxx , "target.add_links" + , "target.add_syslinks" , "target.add_mflags" , "target.add_mxflags" , "target.add_mxxflags" @@ -51,6 +52,7 @@ function apis() , "option.add_ctypes" , "option.add_cxxtypes" , "option.add_links" + , "option.add_syslinks" , "option.add_mflags" , "option.add_mxflags" , "option.add_mxxflags" diff --git a/xmake/languages/objc++/xmake.lua b/xmake/languages/objc++/xmake.lua index d2fff34a8..5880ad8b2 100644 --- a/xmake/languages/objc++/xmake.lua +++ b/xmake/languages/objc++/xmake.lua @@ -105,13 +105,17 @@ language("objc++") , "platform.rpathdirs" , "platform.frameworkdirs" , "config.links" - , "config.frameworks" , "target.links" - , "target.frameworks" , "option.links" - , "option.frameworks" , "platform.links" + , "config.frameworks" + , "target.frameworks" + , "option.frameworks" , "platform.frameworks" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , shared = { @@ -128,13 +132,17 @@ language("objc++") , "platform.linkdirs" , "platform.frameworkdirs" , "config.links" - , "config.frameworks" , "target.links" - , "target.frameworks" , "option.links" - , "option.frameworks" , "platform.links" + , "config.frameworks" + , "target.frameworks" + , "option.frameworks" , "platform.frameworks" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , static = { @@ -168,6 +176,7 @@ language("objc++") , {category = "Cross Complation Configuration/Builtin Flags Configuration" } , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "syslinks", "kv", nil, "The System Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } , {nil, "includedirs", "kv", nil, "The Include Search Directories" } , {nil, "frameworks", "kv", nil, "The Frameworks" } diff --git a/xmake/languages/rust/api.lua b/xmake/languages/rust/api.lua index 1d542ede9..2aefdc17b 100644 --- a/xmake/languages/rust/api.lua +++ b/xmake/languages/rust/api.lua @@ -30,12 +30,14 @@ function apis() { -- target.add_xxx "target.add_links" + , "target.add_syslinks" , "target.add_rcflags" , "target.add_ldflags" , "target.add_arflags" , "target.add_shflags" -- option.add_xxx , "option.add_links" + , "option.add_syslinks" , "option.add_rcflags" , "option.add_ldflags" , "option.add_arflags" diff --git a/xmake/languages/rust/xmake.lua b/xmake/languages/rust/xmake.lua index 3d7c9a4ad..579f995a6 100644 --- a/xmake/languages/rust/xmake.lua +++ b/xmake/languages/rust/xmake.lua @@ -70,6 +70,14 @@ language("rust") , "option.rpathdirs" , "platform.linkdirs" , "platform.rpathdirs" + , "config.links" + , "target.links" + , "option.links" + , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , shared = { @@ -79,6 +87,14 @@ language("rust") , "target.symbols" , "option.linkdirs" , "platform.linkdirs" + , "config.links" + , "target.links" + , "option.links" + , "platform.links" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , static = { @@ -100,6 +116,8 @@ language("rust") , {nil, "rc-sh", "kv", nil, "The Rust Shared Library Linker" } , {category = "Cross Complation Configuration/Builtin Flags Configuration" } + , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "syslinks", "kv", nil, "The System Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } } } diff --git a/xmake/languages/swift/api.lua b/xmake/languages/swift/api.lua index ee1b4566f..7aba58dc6 100644 --- a/xmake/languages/swift/api.lua +++ b/xmake/languages/swift/api.lua @@ -30,6 +30,7 @@ function apis() { -- target.add_xxx "target.add_links" + , "target.add_syslinks" , "target.add_scflags" , "target.add_ldflags" , "target.add_arflags" @@ -37,6 +38,7 @@ function apis() , "target.add_frameworks" -- option.add_xxx , "option.add_links" + , "option.add_syslinks" , "option.add_scflags" , "option.add_ldflags" , "option.add_arflags" diff --git a/xmake/languages/swift/xmake.lua b/xmake/languages/swift/xmake.lua index b1e47e7b5..6fa960623 100644 --- a/xmake/languages/swift/xmake.lua +++ b/xmake/languages/swift/xmake.lua @@ -100,13 +100,17 @@ language("swift") , "platform.rpathdirs" , "platform.frameworkdirs" , "config.links" - , "config.frameworks" , "target.links" - , "target.frameworks" , "option.links" - , "option.frameworks" , "platform.links" + , "config.frameworks" + , "target.frameworks" + , "option.frameworks" , "platform.frameworks" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , shared = { @@ -123,13 +127,17 @@ language("swift") , "platform.linkdirs" , "platform.frameworkdirs" , "config.links" - , "config.frameworks" , "target.links" - , "target.frameworks" , "option.links" - , "option.frameworks" , "platform.links" + , "config.frameworks" + , "target.frameworks" + , "option.frameworks" , "platform.frameworks" + , "config.syslinks" + , "target.syslinks" + , "option.syslinks" + , "platform.syslinks" } , static = { @@ -151,6 +159,7 @@ language("swift") , { category = "Cross Complation Configuration/Builtin Flags Configuration" } , { nil, "links", "kv", nil, "The Link Libraries" } + , { nil, "syslinks", "kv", nil, "The System Link Libraries" } , { nil, "linkdirs", "kv", nil, "The Link Search Directories" } , { nil, "includedirs", "kv", nil, "The Include Search Directories" } , { nil, "frameworks", "kv", nil, "The Frameworks" } diff --git a/xmake/modules/core/tools/cparser.lua b/xmake/modules/core/tools/cparser.lua index 84eb91fc4..c993b8317 100644 --- a/xmake/modules/core/tools/cparser.lua +++ b/xmake/modules/core/tools/cparser.lua @@ -139,6 +139,11 @@ function nf_link(self, lib) return "-l" .. lib end +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + -- make the linkdir flag function nf_linkdir(self, dir) return "-L" .. os.args(dir) diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua index cb3565207..d02044803 100644 --- a/xmake/modules/core/tools/dmd.lua +++ b/xmake/modules/core/tools/dmd.lua @@ -137,6 +137,11 @@ function nf_link(self, lib) return "-L-l" .. lib end +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + -- make the linkdir flag function nf_linkdir(self, dir) return "-L-L" .. os.args(dir) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 551a158e3..91e4396bf 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -251,6 +251,11 @@ function nf_link(self, lib) return "-l" .. lib end +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + -- make the linkdir flag function nf_linkdir(self, dir) return "-L" .. os.args(dir) diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua index ae2112559..baf300ff2 100644 --- a/xmake/modules/core/tools/link.lua +++ b/xmake/modules/core/tools/link.lua @@ -83,6 +83,11 @@ function nf_link(self, lib) return lib .. ".lib" end +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + -- make the linkdir flag function nf_linkdir(self, dir) return "-libpath:" .. os.args(dir) diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 316dae6ea..ab35d93c8 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -130,6 +130,11 @@ function nf_link(self, lib) return "-l" .. lib end +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + -- make the linkdir flag function nf_linkdir(self, dir) return "-L" .. os.args(dir) diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua index 8df967401..537175c93 100644 --- a/xmake/modules/core/tools/rustc.lua +++ b/xmake/modules/core/tools/rustc.lua @@ -93,6 +93,11 @@ function nf_linkdir(self, dir) return "-L" .. os.args(dir) end +-- make the link flag +function nf_link(self, lib) + return "-l" .. lib +end + -- make the build arguments list function buildargv(self, sourcefiles, targetkind, targetfile, flags) return self:program(), table.join(flags, "-o", targetfile, sourcefiles) diff --git a/xmake/modules/core/tools/swiftc.lua b/xmake/modules/core/tools/swiftc.lua index 7f72be37f..9701e08d6 100644 --- a/xmake/modules/core/tools/swiftc.lua +++ b/xmake/modules/core/tools/swiftc.lua @@ -182,6 +182,11 @@ function nf_link(self, lib) return "-l" .. lib end +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + -- make the linkdir flag function nf_linkdir(self, dir) return "-L" .. os.args(dir) diff --git a/xmake/modules/core/tools/tcc.lua b/xmake/modules/core/tools/tcc.lua index 98c157edf..dd2bb594a 100644 --- a/xmake/modules/core/tools/tcc.lua +++ b/xmake/modules/core/tools/tcc.lua @@ -139,6 +139,11 @@ function nf_link(self, lib) return "-l" .. lib end +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + -- make the linkdir flag function nf_linkdir(self, dir) return "-L" .. os.args(dir) |
