summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-05 16:06:45 +0800
committerruki <[email protected]>2015-06-05 16:06:45 +0800
commit411e3138ec53ab99c73f0124ef93ac98d746cdc9 (patch)
treed7e719ea57e12402f630deb1ed998a00304510ff /xmake/scripts/base
parentfe68854c321f2e586cab55dce6856b89241b4c20 (diff)
join flags for compiler and linker
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/compiler.lua44
-rw-r--r--xmake/scripts/base/linker.lua23
2 files changed, 16 insertions, 51 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index 101347c19..3db08581a 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -26,6 +26,7 @@ local compiler = compiler or {}
-- load modules
local path = require("base/path")
local utils = require("base/utils")
+local table = require("base/table")
local string = require("base/string")
local config = require("base/config")
local tools = require("tools/tools")
@@ -129,32 +130,21 @@ function compiler.make(module, target, srcfile, objfile)
end
-- get the common flags from the current compiler
- local flags_common = ""
+ local flags = {}
for _, flag_name in ipairs(flag_names) do
- flags_common = flags_common:append(module[flag_name], " ")
+ table.join2(flags, module[flag_name])
end
-- get the target flags from the current project
- local flags_target = ""
for _, flag_name in ipairs(flag_names) do
-
- -- get flags
- local flags = table.concat(compiler._mapflags(module, utils.wrap(target[flag_name])), " ")
-
- -- trim the spaces
- flags = flags:trim()
-
- -- append flags
- if flags and #flags ~= 0 then
- flags_target = flags_target:append(flags, " ")
- end
+ table.join2(flags, compiler._mapflags(module, utils.wrap(target[flag_name])))
end
-- get the includedirs flags from the current project
if module._make_includedir then
local includedirs = utils.wrap(target.includedirs)
for _, includedir in ipairs(includedirs) do
- flags_target = flags_target:append(module.flag_includedir(includedir), " ")
+ table.join2(flags, module.flag_includedir(includedir))
end
end
@@ -162,35 +152,17 @@ function compiler.make(module, target, srcfile, objfile)
if module._make_define then
local defines = utils.wrap(target.defines)
for _, define in ipairs(defines) do
- flags_target = flags_target:append(module.flag_define(define), " ")
+ table.join2(flags, module.flag_define(define))
end
end
-- get the config flags
- local flags_config = ""
for _, flag_name in ipairs(flag_names) do
-
- -- get flags
- local flags = table.concat(compiler._mapflags(module, utils.wrap(config.get(flag_name))), " ")
-
- -- trim the spaces
- flags = flags:trim()
-
- -- append flags
- if flags and #flags ~= 0 then
- flags_config = flags_config:append(flags, " ")
- end
+ table.join2(flags, compiler._mapflags(module, utils.wrap(config.get(flag_name))))
end
- -- make the flags string
- local flags = ""
- flags = flags:append(flags_common, " ")
- flags = flags:append(flags_target, " ")
- flags = flags:append(flags_config, " ")
- flags = flags:trim()
-
-- make the compile command
- return module.command_compile(srcfile, objfile, flags)
+ return module.command_compile(srcfile, objfile, table.concat(flags, " "):trim())
end
-- return module: compiler
diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua
index 2516bbd29..6f3e7c972 100644
--- a/xmake/scripts/base/linker.lua
+++ b/xmake/scripts/base/linker.lua
@@ -25,6 +25,7 @@ local linker = linker or {}
-- load modules
local utils = require("base/utils")
+local table = require("base/table")
local string = require("base/string")
local config = require("base/config")
local tools = require("tools/tools")
@@ -75,17 +76,17 @@ function linker.make(module, target, objfiles, targetfile)
end
-- get the common flags from the current linker
- local flags_common = module[flag_name] or ""
+ local flags = {}
+ table.join2(flags, module[flag_name])
-- get the target flags from the current project
- local flags_target = table.concat(linker._mapflags(module, utils.wrap(target[flag_name])), " ")
- assert(flags_target)
+ table.join2(flags, linker._mapflags(module, utils.wrap(target[flag_name])))
-- get the linkdirs flags from the current project
if module._make_linkdir then
local linkdirs = utils.wrap(target.linkdirs)
for _, linkdir in ipairs(linkdirs) do
- flags_target = flags_target:append(module.flag_linkdir(linkdir), " ")
+ table.join2(flags, module.flag_linkdir(linkdir))
end
end
@@ -93,23 +94,15 @@ function linker.make(module, target, objfiles, targetfile)
if module._make_link then
local links = utils.wrap(target.links)
for _, link in ipairs(links) do
- flags_target = flags_target:append(module.flag_link(link), " ")
+ table.join2(flags, module.flag_link(link))
end
end
-- get the config flags
- local flags_config = table.concat(linker._mapflags(module, utils.wrap(config.get(flag_name))), " ")
- assert(flags_config)
-
- -- make the flags string
- local flags = ""
- flags = flags:append(flags_common, " ")
- flags = flags:append(flags_target, " ")
- flags = flags:append(flags_config, " ")
- flags = flags:trim()
+ table.join2(flags, linker._mapflags(module, utils.wrap(config.get(flag_name))))
-- make the link command
- return module.command_link(table.concat(objfiles, " "), targetfile, flags)
+ return module.command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim())
end
-- get the linker from the given kind