summaryrefslogtreecommitdiff
path: root/xmake/scripts/base/compiler.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-07-06 18:30:24 +0800
committerruki <[email protected]>2015-07-06 18:30:24 +0800
commit2533ac84c32b30bebddf8226776d00a3f4863119 (patch)
tree632b4e610932adcc70369a46ac91a31811e436eb /xmake/scripts/base/compiler.lua
parenta83bfd36699514d6f44cd1a614f20bf84f59538f (diff)
add some api for options
Diffstat (limited to 'xmake/scripts/base/compiler.lua')
-rw-r--r--xmake/scripts/base/compiler.lua60
1 files changed, 10 insertions, 50 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index 3bb42cb81..64b385a5c 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -168,6 +168,7 @@ function compiler._addflags_from_platform(module, flags, flagnames)
end
end
+
-- add flags from the target
function compiler._addflags_from_target(module, flags, flagnames, target)
@@ -265,36 +266,19 @@ function compiler._addflags_from_target(module, flags, flagnames, target)
if nil ~= opt then
-- add the flags from the option
- for _, flagname in ipairs(flagnames) do
- table.join2(flags, compiler._mapflags(module, opt[flagname]))
- end
-
- -- add the includedirs flags from the option
- if module.flag_includedir then
- for _, includedir in ipairs(utils.wrap(opt.includedirs)) do
- table.join2(flags, module:flag_includedir(includedir))
- end
- end
-
- -- add the defines flags from the option
- if module.flag_define then
-
- local defines = {}
- if opt.defines then table.join2(defines, opt.defines) end
- if opt.defines_if_ok then table.join2(defines, opt.defines_if_ok) end
+ compiler._addflags_from_target(module, flags, flagnames, opt)
+ -- append the defines flags
+ if opt.defines_if_ok and module.flag_define then
+ local defines = utils.wrap(opt.defines_if_ok)
for _, define in ipairs(defines) do
table.join2(flags, module:flag_define(define))
end
end
- -- add the undefines flags from the option
- if module.flag_undefine then
-
- local undefines = {}
- if opt.undefines then table.join2(undefines, opt.undefines) end
- if opt.undefines_if_ok then table.join2(undefines, opt.undefines_if_ok) end
-
+ -- append the undefines flags
+ if opt.undefines_if_ok and module.flag_undefine then
+ local undefines = utils.wrap(opt.undefines_if_ok)
for _, undefine in ipairs(undefines) do
table.join2(flags, module:flag_undefine(undefine))
end
@@ -310,33 +294,9 @@ function compiler._addflags_from_option(module, flags, flagnames, opt)
-- check
assert(module and flags and flagnames and opt)
- -- append the option flags
- for _, flagname in ipairs(flagnames) do
- table.join2(flags, compiler._mapflags(module, opt[flagname]))
- end
-
- -- append the defines flags
- if opt.defines_if_ok and module.flag_define then
- local defines = utils.wrap(opt.defines_if_ok)
- for _, define in ipairs(defines) do
- table.join2(flags, module:flag_define(define))
- end
- end
+ -- add the flags from the option
+ compiler._addflags_from_target(module, flags, flagnames, opt)
- -- append the undefines flags
- if opt.undefines_if_ok and module.flag_undefine then
- local undefines = utils.wrap(opt.undefines_if_ok)
- for _, undefine in ipairs(undefines) do
- table.join2(flags, module:flag_undefine(undefine))
- end
- end
-
- -- append the includedirs flags
- if opt.includedirs and module.flag_includedir then
- for _, includedir in ipairs(utils.wrap(opt.includedirs)) do
- table.join2(flags, module:flag_includedir(includedir))
- end
- end
end
-- get the flag names from the given compiler name