diff options
| author | ruki <[email protected]> | 2015-06-18 13:41:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-18 13:41:23 +0800 |
| commit | a2037440e4b4211fc67e602d62ab2d598bfe9fca (patch) | |
| tree | 2154cd518a51023f90652108a0275b016aca1a03 /xmake/scripts/base | |
| parent | b29768c25b1eb62b397de5d287e39ed6991c2fd7 (diff) | |
add cfuncs for target and fix parse argv bug
Diffstat (limited to 'xmake/scripts/base')
| -rw-r--r-- | xmake/scripts/base/config.lua | 10 | ||||
| -rw-r--r-- | xmake/scripts/base/makefile.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/base/project.lua | 60 |
3 files changed, 67 insertions, 7 deletions
diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua index 6b2849564..d03a98c93 100644 --- a/xmake/scripts/base/config.lua +++ b/xmake/scripts/base/config.lua @@ -179,6 +179,12 @@ function config.load() assert(option._MENU) assert(option._MENU.config) + -- the target name + local name = options.target or options._DEFAULTS.target + if not name then + return "no given target name!" + end + -- does not clean the cached configure? if not options.clean then @@ -235,10 +241,6 @@ function config.load() end end - -- the target name - local name = options.target or options._DEFAULTS.target - assert(name and type(name) == "string") - -- init configs if not exists if not config._CONFIGS then -- clear configs and mark as "rebuild" diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua index 7b1ca2e7d..26b45d856 100644 --- a/xmake/scripts/base/makefile.lua +++ b/xmake/scripts/base/makefile.lua @@ -74,7 +74,7 @@ function makefile._make_object(file, target, srcfile, objfile) -- make body file:write(string.format("\t@echo %scompiling%s %s\n", utils.ifelse(ccache, "ccache ", ""), mode, srcfile)) - file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end))) + file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[=\"]", function (w) return string.format("%%%x", w:byte()) end))) file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile))) file:write(string.format("\t@%s\n", cmd)) @@ -180,7 +180,7 @@ function makefile._make_target(file, name, target) local cmd = linker.make(l, target, objfiles, targetfile, makefile._LOGFILE) -- the verbose - local verbose = cmd:gsub("[%s=\"<]", function (w) return string.format("%%%x", w:byte()) end) + local verbose = cmd:gsub("[=\"<]", function (w) return string.format("%%%x", w:byte()) end) -- too long? if verbose and #verbose > 256 then verbose = verbose:sub(1, 256) .. " ..." diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index 2442a9d1a..7dc98b5b0 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -129,6 +129,56 @@ function project._api_get_pathes(...) return results end +-- add c functions +function project._api_add_cfuncs(env, module, links, includes, ...) + + -- check + assert(env and module) + + -- done + for _, cfunc in ipairs({...}) do + + -- make the option name + local name = string.format("__%s_%s", module, cfunc) + + -- make option + env.add_option(name) + env.set_option_category("cfuncs") + env.add_option_cfuncs(cfunc) + if links then env.add_option_links(links) end + if includes then env.add_option_cincludes(includes) end + env.add_option_defines_h_if_ok(string.format("$(prefix)_%s_HAVE_%s", module:upper(), cfunc:upper())) + + -- add this option + env.add_options(name) + end +end + +-- add c++ functions +function project._api_add_cxxfuncs(env, module, links, includes, ...) + + -- check + assert(env and module) + + -- done + for _, cxxfunc in ipairs({...}) do + + -- make the option name + local name = string.format("__%s_%s", module, cxxfunc) + + -- make option + env.add_option(name) + env.set_option_category("cxxfuncs") + env.add_option_cxxfuncs(cxxfunc) + if links then env.add_option_links(links) end + if includes then env.add_option_cincludes(includes) end + env.add_option_defines_h_if_ok(string.format("$(prefix)_%s_HAVE_%s", module:upper(), cxxfunc:upper())) + + -- add this option + env.add_options(name) + end +end + -- add target function project._api_add_target(env, name) @@ -901,6 +951,10 @@ function project._load_options(file) newenv.add_subdirs = function (...) return project._api_add_subdirs(newenv, ...) end newenv.add_subfiles = function (...) return project._api_add_subfiles(newenv, ...) end + -- register interfaces for the functions + newenv.add_cfuncs = function (...) return project._api_add_cfuncs(newenv, ...) end + newenv.add_cxxfuncs = function (...) return project._api_add_cxxfuncs(newenv, ...) end + -- register interfaces for setting option values local interfaces = { "enable" , "showmenu" @@ -993,7 +1047,11 @@ function project._load_targets(file) -- register interfaces for the subproject files newenv.add_subdirs = function (...) return project._api_add_subdirs(newenv, ...) end newenv.add_subfiles = function (...) return project._api_add_subfiles(newenv, ...) end - + + -- register interfaces for the functions + newenv.add_cfuncs = function (...) return project._api_add_cfuncs(newenv, ...) end + newenv.add_cxxfuncs = function (...) return project._api_add_cxxfuncs(newenv, ...) end + -- register interfaces for setting values local interfaces = { "kind" , "config_h_prefix" |
