diff options
| author | ruki <[email protected]> | 2015-06-06 22:52:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-06 22:52:00 +0800 |
| commit | 70aafd951297294b4f6e8e3ec8ee5058461fa59a (patch) | |
| tree | bade5bf24566df41de9a1cb2a171d9301d8a3205 /xmake/scripts/base/compiler.lua | |
| parent | 7c091cff74f038381c5e16576afeb7d4713bc917 (diff) | |
append warning flags
Diffstat (limited to 'xmake/scripts/base/compiler.lua')
| -rw-r--r-- | xmake/scripts/base/compiler.lua | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua index 2f0ef38b5..a1c24f82b 100644 --- a/xmake/scripts/base/compiler.lua +++ b/xmake/scripts/base/compiler.lua @@ -83,37 +83,23 @@ function compiler._mapflags(module, flags) return flags_mapped end --- get the compiler warning flags from name -function compiler._flag_warning(module, name) +-- get the compiler flags from names +function compiler._getflags(module, names, flags) - -- init the flags table - local flags = - { - none = "-w" - , all = "-Wall" - , error = {"-Wall", "-Werror"} - } - - -- get it - return compiler._mapflags(module, flags[name]) -end + -- check + assert(flags) --- get the compiler optimize flags from name -function compiler._flag_optimize(module, name) + -- the mapped flags + local flags_mapped = {} - -- init the flags table - local flags = - { - none = "-O0" - , fast = "-O1" - , faster = "-O2" - , fastest = "-O3" - , smallest = "-Os" - , aggressive = "-Ofast" - } + -- wrap it first + names = utils.wrap(names) + for _, name in ipairs(names) do + table.join2(flags_mapped, compiler._mapflags(module, flags[name])) + end -- get it - return compiler._mapflags(module, flags[name]) + return flags_mapped end -- get the compiler name from the source file type @@ -201,10 +187,19 @@ function compiler.make(module, target, srcfile, objfile) end -- append the warning flags from the current project - table.join2(flags, compiler._flag_warning(module, target.warning)) + table.join2(flags, compiler._getflags(module, target.warnings, { none = "-w" + , all = "-Wall" + , error = "-Werror" + })) -- append the optimize flags from the current project - table.join2(flags, compiler._flag_optimize(module, target.optimize)) + table.join2(flags, compiler._getflags(module, target.optimize, { none = "-O0" + , fast = "-O1" + , faster = "-O2" + , fastest = "-O3" + , smallest = "-Os" + , aggressive = "-Ofast" + })) -- append the includedirs flags from the current project if module._make_includedir then |
