diff options
| author | ruki <[email protected]> | 2015-05-14 14:38:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-14 14:38:30 +0800 |
| commit | b303b16817e3773c729f2cd1096d685b491db75b (patch) | |
| tree | e1782f1bfe8e873554ce2818a3008726e2e030e6 /xmake/scripts/base/project.lua | |
| parent | 914fd0881e2242f01b497650dd09432316aa48d3 (diff) | |
register configure and impl project.lua
Diffstat (limited to 'xmake/scripts/base/project.lua')
| -rw-r--r-- | xmake/scripts/base/project.lua | 160 |
1 files changed, 94 insertions, 66 deletions
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index fe7986ba7..e208ea726 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -29,99 +29,69 @@ local _MAINENV = getfenv() setmetatable(_PROJECT, {__index = _G}) setfenv(1, _PROJECT) --- init the parent and current scope -local parent = nil -local current = nil +-- init the current scope +local current = nil -- configure scope end function scopend() -end - --- configure kind -function kind() -end - --- configure deps -function deps() -end --- configure files -function files() -end - --- configure links -function links() -end - --- configure headers -function headers() -end + -- check + assert(current) --- configure headerdir -function headerdir() + -- leave the current scope + current = current._PARENT end --- configure targetdir -function targetdir() -end +-- configure platforms +function plarforms(...) --- configure objectdir -function objectdir() -end + -- check + assert(current) --- configure linkdirs -function linkdirs() -end + -- init platforms + current._PLATFORMS = current._PLATFORMS or {} --- configure includedirs -function includedirs() -end + -- init scope + local scope = {} --- configure cflags -function cflags() -end + -- configure all platforms + local arg = arg or {...} + for _, name in ipairs(arg) do --- configure cxxflags -function cxxflags() -end + -- check + if current._PLATFORMS[name] then + -- error + utils.error("the platform: %s has been defined repeatly!", name) + assert(false) + end --- configure ldflags -function ldflags() -end + -- init the platform scope + current._PLATFORMS[name] = scope --- configure mflags -function mflags() -end - --- configure mxflags -function mxflags() -end - --- configure defines -function defines() -end + end --- configure plarforms -function plarforms() + -- enter scope + local parent = current + current = scope + current._PARENT = parent end -- configure target function target(name) -- check - assert(name and _ROOT) + assert(name and current) -- init targets --- current._TARGETS = current._TARGETS or {} + current._TARGETS = current._TARGETS or {} -- init target scope --- current._TARGETS[name] = {} + current._TARGETS[name] = {} - -- TODO -- enter target scope --- parent = current --- current = _ROOT._TARGETS[name] - + local parent = current + current = current._TARGETS[name] + current._PARENT = parent end -- configure project @@ -144,8 +114,66 @@ function project(name) -- init the current scope current = _ROOT + current._PARENT = nil + end +-- register configures +function _register(names) + + -- check + assert(_PROJECT) + assert(names and type(names) == "table") + + -- register all configures + for _, name in ipairs(names) do + + -- register the configure + _PROJECT[name] = _PROJECT[name] or function(...) + + -- check + assert(current) + + -- init ldflags + current[name] = current[name] or {} + + -- get arguments + local arg = arg or {...} + if table.getn(arg) == 0 then + -- no argument + current[name] = nil + elseif table.getn(arg) == 1 then + -- save only one argument + current[name] = arg[1] + else + -- save all arguments + for i, v in ipairs(arg) do + current[name][i] = v + end + end + end + end +end + +-- register all configures +_register { "kind" + , "deps" + , "files" + , "links" + , "mflags" + , "headers" + , "headerdir" + , "targetdir" + , "objectdir" + , "linkdirs" + , "includedirs" + , "cflags" + , "cxxflags" + , "ldflags" + , "mxflags" + , "defines"} + + -- leave project setfenv(1, _MAINENV) return _PROJECT |
