summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2017-07-13 10:52:42 +0800
committerruki <[email protected]>2017-07-13 10:52:42 +0800
commitb7ae88c507b9afe89cd677ee81894e44a961a4b4 (patch)
treea8aca817b422ca83f76d8310678351eaa3f3cf75 /xmake/modules
parentb9e5a411e38224db1f71a39cad57cc54dc13fee6 (diff)
improve flags for linker and compiler
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/core/tools/cl.lua10
-rw-r--r--xmake/modules/core/tools/dmd.lua16
-rw-r--r--xmake/modules/core/tools/gcc.lua2
-rw-r--r--xmake/modules/core/tools/go.lua4
-rw-r--r--xmake/modules/core/tools/link.lua2
-rw-r--r--xmake/modules/core/tools/rustc.lua16
-rw-r--r--xmake/modules/core/tools/swiftc.lua14
-rw-r--r--xmake/modules/lib/detect/has_flags.lua14
8 files changed, 46 insertions, 32 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 0fa1ab65d..542469c5b 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -39,7 +39,7 @@ function init(self)
, ["-O1"] = ""
, ["-Os"] = "-O1"
, ["-O3"] = "-Ox"
- , ["-Ofast"] = {"-Ox", "-fp:fast"}
+ , ["-Ofast"] = "-Ox -fp:fast"
, ["-fomit-frame-pointer"] = "-Oy"
-- symbols
@@ -97,9 +97,9 @@ function nf_symbol(self, level, target)
local flags = nil
if level == "debug" then
if target and target.symbolfile then
- flags = {"-ZI", "-Fd" .. target:symbolfile()}
+ flags = "-ZI -Fd" .. target:symbolfile()
if self:has_flags({"-ZI", "-FS", "-Fd" .. os.tmpfile() .. ".pdb"}) then
- table.insert(flags, 1, "-FS")
+ flags = "-FS " .. flags
end
else
flags = "-ZI"
@@ -135,9 +135,9 @@ function nf_optimize(self, level)
{
none = "-Od"
, faster = "-Ox"
- , fastest = {"-Ox", "-fp:fast"}
+ , fastest = "-Ox -fp:fast"
, smallest = "-O1"
- , aggressive = {"-Ox", "-fp:fast"}
+ , aggressive = "-Ox -fp:fast"
}
-- make it
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua
index 03855e4f3..ed30223cc 100644
--- a/xmake/modules/core/tools/dmd.lua
+++ b/xmake/modules/core/tools/dmd.lua
@@ -58,11 +58,11 @@ function nf_optimize(self, level)
-- the maps
local maps =
{
- fast = {"-O"}
- , faster = {"-O", "-release"}
- , fastest = {"-O", "-release", "-inline", "-boundscheck=off"}
- , smallest = {"-O", "-release", "-boundscheck=off"}
- , aggressive = {"-O", "-release", "-inline", "-boundscheck=off"}
+ fast = "-O"
+ , faster = "-O -release"
+ , fastest = "-O -release -inline -boundscheck=off"
+ , smallest = "-O -release -boundscheck=off"
+ , aggressive = "-O -release -inline -boundscheck=off"
}
-- make it
@@ -89,7 +89,7 @@ function nf_symbol(self, level)
-- the maps
local maps =
{
- debug = {"-g", "-debug"}
+ debug = "-g -debug"
}
-- make it
@@ -104,8 +104,8 @@ function nf_warning(self, level)
{
none = "-d"
, less = "-w"
- , more = {"-w", "-wi"}
- , all = {"-w", "-wi"}
+ , more = "-w -wi"
+ , all = "-w -wi"
, error = "-de"
}
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index e952f8eb8..ef91c81e6 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -240,7 +240,7 @@ end
-- make the framework flag
function nf_framework(self, framework)
- return {"-framework", framework}
+ return "-framework " .. framework
end
-- make the link arguments list
diff --git a/xmake/modules/core/tools/go.lua b/xmake/modules/core/tools/go.lua
index cb597652f..47630f291 100644
--- a/xmake/modules/core/tools/go.lua
+++ b/xmake/modules/core/tools/go.lua
@@ -96,12 +96,12 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return {"-I", dir}
+ return "-I " .. dir
end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return {"-L", dir}
+ return "-L " .. dir
end
-- make the link arguments list
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index a193d2609..b5161bc2c 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -74,7 +74,7 @@ function nf_symbol(self, level, target)
local targetkind = target:get("kind")
if level == "debug" and (targetkind == "binary" or targetkind == "shared") then
if target and target.symbolfile then
- flags = {"-debug", "-pdb:" .. target:symbolfile()}
+ flags = "-debug -pdb:" .. target:symbolfile()
else
flags = "-debug"
end
diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua
index f82dcf006..6e102f69d 100644
--- a/xmake/modules/core/tools/rustc.lua
+++ b/xmake/modules/core/tools/rustc.lua
@@ -64,12 +64,12 @@ function nf_optimize(self, level)
-- the maps
local maps =
{
- none = {"-C", "opt-level=0"}
- , fast = {"-C", "opt-level=1"}
- , faster = {"-C", "opt-level=2"}
- , fastest = {"-C", "opt-level=3"}
- , smallest = {"-C", "opt-level=s"}
- , aggressive = {"-C", "opt-level=z"}
+ none = "-C opt-level=0"
+ , fast = "-C opt-level=1"
+ , faster = "-C opt-level=2"
+ , fastest = "-C opt-level=3"
+ , smallest = "-C opt-level=s"
+ , aggressive = "-C opt-level=z"
}
-- make it
@@ -82,7 +82,7 @@ function nf_symbol(self, level)
-- the maps
local maps =
{
- debug = {"-C", "debuginfo=2"}
+ debug = "-C debuginfo=2"
}
-- make it
@@ -91,7 +91,7 @@ end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return {"-L", dir}
+ return "-L" .. dir
end
-- make the build arguments list
diff --git a/xmake/modules/core/tools/swiftc.lua b/xmake/modules/core/tools/swiftc.lua
index cfe97a0c3..4ce63567c 100644
--- a/xmake/modules/core/tools/swiftc.lua
+++ b/xmake/modules/core/tools/swiftc.lua
@@ -74,8 +74,8 @@ function nf_strip(self, level)
-- the maps
local maps =
{
- debug = {"-Xlinker", "-S"}
- , all = {"-Xlinker", "-s"}
+ debug = "-Xlinker -S"
+ , all = "-Xlinker -s"
}
-- make it
@@ -147,27 +147,27 @@ function nf_vectorext(self, extension)
}
-- make it
- return maps[extension] or ""
+ return maps[extension]
end
-- make the includedir flag
function nf_includedir(self, dir)
- return {"-Xcc", "-I" .. dir}
+ return "-Xcc -I" .. dir
end
-- make the define flag
function nf_define(self, macro)
- return {"-Xcc", "-D" .. macro}
+ return "-Xcc -D" .. macro
end
-- make the undefine flag
function nf_undefine(self, macro)
- return {"-Xcc", "-U" .. macro}
+ return "-Xcc -U" .. macro
end
-- make the framework flag
function nf_framework(self, framework)
- return {"-framework", framework}
+ return "-framework " .. framework
end
-- make the link flag
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index 47347e5ed..1957a6b72 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -55,6 +55,20 @@ function main(name, flags, opt)
-- wrap flags
flags = table.wrap(flags)
+ -- split flag group, .e.g "-I /xxx" => {"-I", "/xxx"}
+ local results = {}
+ for _, flag in ipairs(flags) do
+ flag = flag:trim()
+ if #flag > 0 then
+ if flag:find(" ", 1, true) then
+ table.join2(results, os.argv(flag))
+ else
+ table.insert(results, flag)
+ end
+ end
+ end
+ flags = results
+
-- init tool
opt.toolname = tool.name
opt.program = tool.program