diff options
| author | ruki <[email protected]> | 2019-03-15 22:42:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-15 10:16:08 +0800 |
| commit | cc02a8d5a54dd46a63f0da144cfb35b12dcf3263 (patch) | |
| tree | 826251e1187012ba02d8506771f138711d716088 | |
| parent | 9036abe2d5d282bd19c9f6bdd2acee9ac03051fc (diff) | |
add opt.name for has_xxx
| -rw-r--r-- | xmake/core/tool/builder.lua | 2 | ||||
| -rw-r--r-- | xmake/core/tool/compiler.lua | 14 | ||||
| -rw-r--r-- | xmake/core/tool/linker.lua | 16 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/check_cxsnippets.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_cfuncs.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_cincludes.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_ctypes.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_cxxfuncs.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_cxxincludes.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_cxxtypes.lua | 5 |
10 files changed, 32 insertions, 32 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index a08f7226f..0eee93313 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -366,6 +366,8 @@ function builder:_add_flags_from_argument(flags, target, args) if target then local key = target:type() self:_add_flags_from_language(flags, target, {[key] = function (name) return args[name] end}) + else + self:_add_flags_from_language(flags, nil, {target = function (name) return args[name] end}) end end diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index a3715379f..01b9bf659 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -47,12 +47,10 @@ end -- add flags from the platform function compiler:_add_flags_from_platform(flags, targetkind) - -- add flags - local toolname = self:name() - for _, flagkind in ipairs(self:_flagkinds()) do - - -- add flags for platform with the given target kind, e.g. binary.gcc.cxflags or binary.cxflags - if targetkind then + -- add flags for platform with the given target kind, e.g. binary.gcc.cxflags or binary.cxflags + if targetkind then + local toolname = self:name() + for _, flagkind in ipairs(self:_flagkinds()) do local toolflags = platform.get(targetkind .. '.' .. toolname .. '.' .. flagkind) table.join2(flags, toolflags or platform.get(targetkind .. '.' .. flagkind)) end @@ -306,9 +304,7 @@ function compiler:compflags(opt) end -- add flags from the platform - if target then - self:_add_flags_from_platform(flags, targetkind) - end + self:_add_flags_from_platform(flags, targetkind) -- add flags from the compiler self:_add_flags_from_compiler(flags, targetkind) diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 6f9d9e6eb..d582d62bb 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -43,13 +43,11 @@ local compiler = require("tool/compiler") -- add flags from the platform function linker:_add_flags_from_platform(flags, targetkind) - -- add flags - local toolkind = self:kind() - local toolname = self:name() - for _, flagkind in ipairs(self:_flagkinds()) do - - -- attempt to add special lanugage flags first for target kind, .e.g gc-ldflags, dc-arflags - if targetkind then + -- attempt to add special lanugage flags first for target kind, .e.g binary.gc-ldflags, static.dc-arflags + if targetkind then + local toolkind = self:kind() + local toolname = self:name() + for _, flagkind in ipairs(self:_flagkinds()) do local toolflags = platform.get(targetkind .. '.' .. toolname .. '.' .. toolkind .. 'flags') or platform.get(targetkind .. '.' .. toolname .. '.' .. flagkind) table.join2(flags, toolflags or platform.get(targetkind .. '.' .. toolkind .. 'flags') or platform.get(targetkind .. '.' .. flagkind)) end @@ -277,9 +275,7 @@ function linker:linkflags(opt) end -- add flags from the platform - if target then - self:_add_flags_from_platform(flags, targetkind) - end + self:_add_flags_from_platform(flags, targetkind) -- add flags from the compiler if target then diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua index 5ef642f09..3eff70a0c 100644 --- a/xmake/modules/lib/detect/check_cxsnippets.lua +++ b/xmake/modules/lib/detect/check_cxsnippets.lua @@ -199,7 +199,7 @@ function main(snippets, opt) -- trace if opt.verbose or option.get("verbose") or option.get("diagnosis") then - local kind = ifelse(sourcekind == "cc", "c", "c++") + local kind = opt.sourcekind == "cc" and "c" or "c++" if #includes > 0 then cprint("${dim}> checking for the %s includes(%s)", kind, table.concat(includes, ", ")) end diff --git a/xmake/modules/lib/detect/has_cfuncs.lua b/xmake/modules/lib/detect/has_cfuncs.lua index 6cf8f4cd3..73ab54eca 100644 --- a/xmake/modules/lib/detect/has_cfuncs.lua +++ b/xmake/modules/lib/detect/has_cfuncs.lua @@ -30,7 +30,7 @@ import("lib.detect.check_cxsnippets") -- @param funcs the funcs -- @param opt the argument options -- .e.g --- { verbose = false, target = [target|option], includes = "", config = {linkdirs = .., links = .., defines = .., ..}} +-- { verbose = false, target = [target|option], includes = "", configs = {linkdirs = .., links = .., defines = .., ..}} -- -- funcs: -- sigsetjmp @@ -55,5 +55,6 @@ function main(funcs, opt) opt.funcs = funcs -- has funcs? - return check_cxsnippets("", opt) + local name = opt.name or "has_cfuncs" + return check_cxsnippets({[name] = ""}, opt) end diff --git a/xmake/modules/lib/detect/has_cincludes.lua b/xmake/modules/lib/detect/has_cincludes.lua index a70c17f56..195a482e1 100644 --- a/xmake/modules/lib/detect/has_cincludes.lua +++ b/xmake/modules/lib/detect/has_cincludes.lua @@ -30,7 +30,7 @@ import("lib.detect.check_cxsnippets") -- @param includes the includes -- @param opt the argument options -- .e.g --- { verbose = false, target = [target|option], config = {defines = "..", .. }} +-- { verbose = false, target = [target|option], configs = {defines = "..", .. }} -- -- @return true or false -- @@ -49,5 +49,6 @@ function main(includes, opt) opt.includes = includes -- has includes? - return check_cxsnippets("", opt) + local name = opt.name or "has_cincludes" + return check_cxsnippets({[name] = ""}, opt) end diff --git a/xmake/modules/lib/detect/has_ctypes.lua b/xmake/modules/lib/detect/has_ctypes.lua index 2341b983d..2ac05a30e 100644 --- a/xmake/modules/lib/detect/has_ctypes.lua +++ b/xmake/modules/lib/detect/has_ctypes.lua @@ -30,7 +30,7 @@ import("lib.detect.check_cxsnippets") -- @param types the types -- @param opt the argument options -- .e.g --- { verbose = false, target = [target|option], includes = .., config = {defines = .., ..}} +-- { verbose = false, target = [target|option], includes = .., configs = {defines = .., ..}} -- -- @return true or false -- @@ -49,5 +49,6 @@ function main(types, opt) opt.types = types -- has types? - return check_cxsnippets("", opt) + local name = opt.name or "has_ctypes" + return check_cxsnippets({[name] = ""}, opt) end diff --git a/xmake/modules/lib/detect/has_cxxfuncs.lua b/xmake/modules/lib/detect/has_cxxfuncs.lua index 0ee26c897..e30a21416 100644 --- a/xmake/modules/lib/detect/has_cxxfuncs.lua +++ b/xmake/modules/lib/detect/has_cxxfuncs.lua @@ -30,7 +30,7 @@ import("lib.detect.check_cxsnippets") -- @param funcs the funcs -- @param opt the argument options -- .e.g --- { verbose = false, target = [target|option], includes = "", config = {linkdirs = .., links = .., defines = .., ..}} +-- { verbose = false, target = [target|option], includes = "", configs = {linkdirs = .., links = .., defines = .., ..}} -- -- funcs: -- sigsetjmp @@ -55,5 +55,6 @@ function main(funcs, opt) opt.funcs = funcs -- has funcs? - return check_cxsnippets("", opt) + local name = opt.name or "has_cxxfuncs" + return check_cxsnippets({[name] = ""}, opt) end diff --git a/xmake/modules/lib/detect/has_cxxincludes.lua b/xmake/modules/lib/detect/has_cxxincludes.lua index 57c08ddb6..6c4846134 100644 --- a/xmake/modules/lib/detect/has_cxxincludes.lua +++ b/xmake/modules/lib/detect/has_cxxincludes.lua @@ -30,7 +30,7 @@ import("lib.detect.check_cxsnippets") -- @param includes the includes -- @param opt the argument options -- .e.g --- { verbose = false, target = [target|option], config = {defines = "..", .. }} +-- { verbose = false, target = [target|option], configs = {defines = "..", .. }} -- -- @return true or false -- @@ -49,5 +49,6 @@ function main(includes, opt) opt.includes = includes -- has includes? - return check_cxsnippets("", opt) + local name = opt.name or "has_cxxincludes" + return check_cxsnippets({[name] = ""}, opt) end diff --git a/xmake/modules/lib/detect/has_cxxtypes.lua b/xmake/modules/lib/detect/has_cxxtypes.lua index 1011a4b5f..f52cee697 100644 --- a/xmake/modules/lib/detect/has_cxxtypes.lua +++ b/xmake/modules/lib/detect/has_cxxtypes.lua @@ -30,7 +30,7 @@ import("lib.detect.check_cxsnippets") -- @param types the types -- @param opt the argument options -- .e.g --- { verbose = false, target = [target|option], includes = .., config = {defines = .., ..}} +-- { verbose = false, target = [target|option], includes = .., configs = {defines = .., ..}} -- -- @return true or false -- @@ -49,5 +49,6 @@ function main(types, opt) opt.types = types -- has types? - return check_cxsnippets("", opt) + local name = opt.name or "has_cxxtypes" + return check_cxsnippets({[name] = ""}, opt) end |
