summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
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
parenta83bfd36699514d6f44cd1a614f20bf84f59538f (diff)
add some api for options
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/compiler.lua60
-rw-r--r--xmake/scripts/base/package.lua3
-rw-r--r--xmake/scripts/base/project.lua4
3 files changed, 17 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
diff --git a/xmake/scripts/base/package.lua b/xmake/scripts/base/package.lua
index 37b6e7c1f..412f3b8c4 100644
--- a/xmake/scripts/base/package.lua
+++ b/xmake/scripts/base/package.lua
@@ -106,6 +106,9 @@ add_option("[targetname]")
-- set description
set_option_description("The [targetname] package")
+ -- set language: c99, c++11
+ set_option_languages("c99", "cxx11")
+
-- add defines to config.h if checking ok
add_option_defines_h_if_ok("$(prefix)_PACKAGE_HAVE_[TARGETNAME]")
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index 4063f9de0..4d1976570 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -977,6 +977,9 @@ function project._load_options(file)
local interfaces = { "enable"
, "showmenu"
, "category"
+ , "warnings"
+ , "optimize"
+ , "languages"
, "description"}
for _, interface in ipairs(interfaces) do
@@ -995,6 +998,7 @@ function project._load_options(file)
, "cxflags"
, "cxxflags"
, "ldflags"
+ , "vectorexts"
, "defines"
, "defines_if_ok"
, "defines_h_if_ok"