diff options
| author | ruki <[email protected]> | 2015-06-15 10:30:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-15 10:30:14 +0800 |
| commit | ddf03c22b1b6fcab81e0d3ce5c4a081b704f3a65 (patch) | |
| tree | 98cdbfc56ad0e911c826cfddfde92d4a9a12de38 /xmake/scripts | |
| parent | 31bba0ba7852b0699e41642815455afb62ddc8b7 (diff) | |
enable and disable show menu for option
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/base/project.lua | 102 | ||||
| -rw-r--r-- | xmake/scripts/base/table.lua | 10 | ||||
| -rw-r--r-- | xmake/scripts/tools/gcc.lua | 10 |
3 files changed, 57 insertions, 65 deletions
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index c17060d9f..88cfa4ff9 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -252,7 +252,7 @@ function project._makeconf_for_target(target_name, target) assert(target_name and target) -- get the target configure file - local configfile = target.configfile + local configfile = target.config_h if not configfile then return true end @@ -265,7 +265,7 @@ function project._makeconf_for_target(target_name, target) end -- the prefix - local prefix = (target.configprefix or target_name:upper()) .. "_CONFIG" + local prefix = (target.config_h_prefix or target_name:upper()) .. "_CONFIG" -- open the file local file = project._CONFILES[configfile] or io.openmk(configfile) @@ -292,27 +292,13 @@ function project._makeconf_for_target(target_name, target) file:write("\n") end - -- make the undefines - if target.undefines then - file:write("// undefines\n") - for _, undefine in ipairs(utils.wrap(target.undefines)) do - file:write(string.format("#ifdef %s\n", undefine)) - file:write(string.format("# undef %s\n", undefine)) - file:write("#endif\n") - end - file:write("\n") - end - -- make the defines - if target.defines then - file:write("// defines\n") - for _, define in ipairs(utils.wrap(target.defines)) do - file:write(string.format("#ifndef %s\n", define:gsub("=.*", ""))) - file:write(string.format("# define %s\n", define:gsub("=", " "))) - file:write("#endif\n") - end - file:write("\n") - end + local defines = {} + if target.defines_to_config_h then table.join2(defines, target.defines_to_config_h) end + + -- make the undefines + local undefines = {} + if target.undefines_to_config_h then table.join2(undefines, target.undefines_to_config_h) end -- the options if target.options then @@ -324,40 +310,33 @@ function project._makeconf_for_target(target_name, target) if nil ~= opt then -- get the option defines - 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 + if opt.defines_to_config_h then table.join2(defines, opt.defines_to_config_h) end -- get the option undefines - 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 - - -- make the defines for options - if #defines ~= 0 then - file:write(string.format("// defines for %s\n", name)) - for _, define in ipairs(defines) do - file:write(string.format("#ifndef %s\n", define:gsub("=.*", ""))) - file:write(string.format("# define %s\n", define:gsub("=", " "))) - file:write("#endif\n") - end - file:write("\n") - end + if opt.undefines_to_config_h then table.join2(undefines, opt.undefines_to_config_h) end - -- make the undefines for options - if #undefines ~= 0 then - file:write(string.format("// undefines for %s\n", name)) - for _, undefine in ipairs(undefines) do - file:write(string.format("#ifdef %s\n", undefine)) - file:write(string.format("# undef %s\n", undefine)) - file:write("#endif\n") - end - file:write("\n") - end end end end + -- make the defines + if #defines ~= 0 then + file:write("// defines\n") + for _, define in ipairs(defines) do + file:write(string.format("#define %s\n", define:gsub("=", " "))) + end + file:write("\n") + end + + -- make the undefines + if #undefines ~= 0 then + file:write("// undefines\n") + for _, undefine in ipairs(undefines) do + file:write(string.format("#undef %s\n", undefine)) + end + file:write("\n") + end + -- make the tail file:write("#endif\n") @@ -648,6 +627,7 @@ function project._load_options(file) -- register interfaces for setting option values local interfaces = { "default" + , "showmenu" , "description"} for _, interface in ipairs(interfaces) do @@ -668,8 +648,8 @@ function project._load_options(file) , "ldflags" , "defines" , "undefines" - , "defines_if_ok" - , "undefines_if_ok"} + , "defines_to_config_h" + , "undefines_to_config_h"} for _, interface in ipairs(interfaces) do newenv["add_option_" .. interface] = function (...) return project._api_add_values(newenv._OPTION, interface, ...) end @@ -728,8 +708,8 @@ function project._load_targets(file) , "headerdir" , "targetdir" , "objectdir" - , "configfile" - , "configprefix" + , "config_h" + , "config_h_prefix" , "version" , "strip" , "options" @@ -760,6 +740,8 @@ function project._load_targets(file) , "options" , "defines" , "undefines" + , "defines_to_config_h" + , "undefines_to_config_h" , "languages" , "vectorexts"} for _, interface in ipairs(interfaces) do @@ -884,12 +866,16 @@ function project.menu() local menu = {{}} for name, opt in pairs(options) do - -- the default - local default = utils.unwrap(opt.default) - if not default then default = "auto" end + -- show menu? + if opt.showmenu then + + -- the default + local default = utils.unwrap(opt.default) + if not default then default = "auto" end - -- append it - table.insert(menu, {nil, name, "kv", default, utils.unwrap(opt.description)}) + -- append it + table.insert(menu, {nil, name, "kv", default, utils.unwrap(opt.description)}) + end end -- ok? diff --git a/xmake/scripts/base/table.lua b/xmake/scripts/base/table.lua index d6f6990d7..52b726412 100644 --- a/xmake/scripts/base/table.lua +++ b/xmake/scripts/base/table.lua @@ -31,8 +31,9 @@ function table.join(...) local result = {} for _, t in ipairs(args) do if type(t) == "table" then - for _, v in ipairs(t) do - table.insert(result, v) + for k, v in pairs(t) do + if type(k) == "number" then table.insert(result, v) + else result[k] = v end end else table.insert(result, t) @@ -53,8 +54,9 @@ function table.join2(self, ...) local args = {...} for _, t in ipairs(args) do if type(t) == "table" then - for _, v in ipairs(t) do - table.insert(self, v) + for k, v in pairs(t) do + if type(k) == "number" then table.insert(self, v) + else self[k] = v end end else table.insert(self, t) diff --git a/xmake/scripts/tools/gcc.lua b/xmake/scripts/tools/gcc.lua index be7abad9f..9c735b7ca 100644 --- a/xmake/scripts/tools/gcc.lua +++ b/xmake/scripts/tools/gcc.lua @@ -40,15 +40,19 @@ function gcc._check(self, flag) end -- check it + local result = flag if 0 ~= os.execute(string.format("%s %s -S -o %s -xc %s > %s 2>&1", self._NAME, flag, xmake._NULDEV, xmake._NULDEV, xmake._NULDEV)) then - flag = "" + result = "" end + -- trace + utils.verbose("checking for the compiler flags %s ... %s", flag, utils.ifelse(#result ~= 0, "ok", "no")) + -- save it - self._CHECK[flag] = flag + self._CHECK[flag] = result -- ok? - return flag + return result end -- the init function |
