diff options
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/_xmake_main.lua | 1 | ||||
| -rw-r--r-- | xmake/scripts/action/_config.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/base/config.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/base/io.lua | 3 | ||||
| -rw-r--r-- | xmake/scripts/base/main.lua | 47 | ||||
| -rw-r--r-- | xmake/scripts/base/project.lua | 71 | ||||
| -rw-r--r-- | xmake/scripts/base/utils.lua | 3 | ||||
| -rw-r--r-- | xmake/scripts/platform/android/prober.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphoneos/prober.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/platform/iphonesimulator/prober.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/prober.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/platform/macosx/prober.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/tools/clang.lua | 3 |
13 files changed, 109 insertions, 87 deletions
diff --git a/xmake/scripts/_xmake_main.lua b/xmake/scripts/_xmake_main.lua index b897468f6..89a8c7fc2 100644 --- a/xmake/scripts/_xmake_main.lua +++ b/xmake/scripts/_xmake_main.lua @@ -30,6 +30,7 @@ xmake._VERSION = "XMake v1.0.1" xmake._PROGRAM_DIR = _PROGRAM_DIR xmake._PROJECT_DIR = _PROJECT_DIR xmake._SCRIPTS_DIR = _PROGRAM_DIR .. "/scripts" +xmake._PROJECT_FILE = "xmake.lua" xmake._OPTIONS = {} xmake._CONFIGS = {} diff --git a/xmake/scripts/action/_config.lua b/xmake/scripts/action/_config.lua index 9ef333abe..027c22288 100644 --- a/xmake/scripts/action/_config.lua +++ b/xmake/scripts/action/_config.lua @@ -117,15 +117,13 @@ function _config.menu() , " - debug" , " - release" , " - profile" } - , {'-', "host", "kv", xmake._HOST, "The current host environment." } + , {nil, "host", "kv", xmake._HOST, "The current host environment." } - , {} - , {'o', "buildir", "kv", "build", "Set the build directory." } - , {'k', "packages", "kv", "pkg", "Set the packages directory." } + -- the options for project + , function () return project.menu() end , {} - , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." - , " --ccache=[y|n]" } + , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." } , {} , {nil, "cross", "kv", nil, "The cross toolchains prefix" @@ -167,6 +165,7 @@ function _config.menu() , " 1. The Given Command Argument" , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR" , " 3. The Current Directory" } + , {'o', "buildir", "kv", "build", "Set the build directory." } , {} diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua index f8fb8afca..62db41dee 100644 --- a/xmake/scripts/base/config.lua +++ b/xmake/scripts/base/config.lua @@ -114,7 +114,7 @@ end function config.get(name) -- check - assert(config._CURRENT) + if not config._CURRENT then return end -- the value local value = config._CURRENT[name] diff --git a/xmake/scripts/base/io.lua b/xmake/scripts/base/io.lua index 4a5a3b65a..db2164c04 100644 --- a/xmake/scripts/base/io.lua +++ b/xmake/scripts/base/io.lua @@ -29,9 +29,6 @@ local utils = require("base/utils") -- save object with the level function io._save_with_level(file, object, level) - -- check - assert(object) - -- save string if type(object) == "string" then file:write(string.format("%q", object)) diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index 8f61b6940..77db5b2de 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -129,21 +129,6 @@ function main._prepare_project() local options = xmake._OPTIONS assert(options) - -- init the project directory - options.project = options.project or options._DEFAULTS.project or xmake._PROJECT_DIR - options.project = path.absolute(options.project) - assert(options.project) - - -- save the project directory - xmake._PROJECT_DIR = options.project - - -- init the xmake.lua file path - options.file = options.file or options._DEFAULTS.file or "xmake.lua" - if not path.is_absolute(options.file) then - options.file = path.absolute(options.file, options.project) - end - assert(options.file) - -- init the build directory if options.buildir and path.is_absolute(options.buildir) then options.buildir = path.relative(options.buildir, xmake._PROJECT_DIR) @@ -182,7 +167,7 @@ function main._prepare_project() end -- load xmake.lua file - return project.load(options.file) + return project.load(xmake._PROJECT_FILE) end -- done help @@ -283,14 +268,34 @@ function main._done_option() return action.done(options._ACTION or "build") end +-- the init function for main +function main._init() + + -- init the project directory + local projectdir = option.find(xmake._ARGV, "project", "P") or xmake._PROJECT_DIR + if projectdir and not path.is_absolute(projectdir) then + projectdir = path.absolute(projectdir) + elseif projectdir then + projectdir = path.translate(projectdir) + end + xmake._PROJECT_DIR = projectdir + assert(projectdir) + + -- init the xmake.lua file path + local projectfile = option.find(xmake._ARGV, "file", "f") or xmake._PROJECT_FILE + if projectfile and not path.is_absolute(projectfile) then + projectfile = path.absolute(projectfile, projectdir) + end + xmake._PROJECT_FILE = projectfile + assert(projectfile) + +end + -- the main function function main.done() - -- init project directory first - local projectdir = option.find(xmake._ARGV, "project", "P") - if projectdir then - xmake._PROJECT_DIR = path.absolute(projectdir) - end + -- init + main._init() -- init option if not option.init(xmake._ARGV, menu) then diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index db4600307..27041ac81 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -34,7 +34,7 @@ function project._api_modes(env, ...) -- get the current mode local mode = config.get("mode") - assert(mode) + if not mode then return false end -- exists this mode? for _, m in ipairs(table.join(...)) do @@ -49,7 +49,7 @@ function project._api_plats(env, ...) -- get the current platform local plat = config.get("plat") - assert(plat) + if not plat then return false end -- exists this platform? for _, p in ipairs(table.join(...)) do @@ -64,7 +64,7 @@ function project._api_archs(env, ...) -- get the current architecture local arch = config.get("arch") - assert(arch) + if not arch then return false end -- exists this architecture? for _, a in ipairs(table.join(...)) do @@ -373,18 +373,8 @@ function project._make(configs) end end --- get the current configure for targets -function project.targets() - - -- check - assert(project._TARGETS) - - -- return it - return project._TARGETS -end - -- load the project file -function project.load(file) +function project._load(file) -- check assert(file) @@ -491,8 +481,25 @@ function project.load(file) return errors end - -- make the current project configure - project._make(newenv._CONFIGS) + -- get the project configure + return newenv._CONFIGS +end + +-- get the current configure for targets +function project.targets() + + -- check + assert(project._TARGETS) + + -- return it + return project._TARGETS +end + +-- load the project file +function project.load(file) + + -- load and make the project configure + project._make(project._load(file)) end -- dump the current configure @@ -540,5 +547,37 @@ function project.makeconf(target_name) return true end +-- get the project menu +function project.menu() + + -- attempt to load project configure + local configs = nil + local projectfile = xmake._PROJECT_FILE + if projectfile and os.isfile(projectfile) then + configs = project._load(projectfile) + end + + -- the options + local options = nil + if configs then options = configs._OPTIONS end + if not options then return {} end + + -- make menu + local menu = {{}} + for name, opt in pairs(options) do + + -- the default + local default = utils.unwrap(opt.default) + if default then default = "true" + else default = "auto" end + + -- append it + table.insert(menu, {nil, name, "kv", default, utils.unwrap(opt.description)}) + end + + -- ok? + return menu +end + -- return module: project return project diff --git a/xmake/scripts/base/utils.lua b/xmake/scripts/base/utils.lua index 469fb4a4a..a2efbb482 100644 --- a/xmake/scripts/base/utils.lua +++ b/xmake/scripts/base/utils.lua @@ -53,9 +53,6 @@ end -- dump object with the level function utils._dump_with_level(object, exclude, level) - -- check - assert(object) - -- dump string if type(object) == "string" then io.write(string.format("%q", object)) diff --git a/xmake/scripts/platform/android/prober.lua b/xmake/scripts/platform/android/prober.lua index 9e564b0cd..43863555e 100644 --- a/xmake/scripts/platform/android/prober.lua +++ b/xmake/scripts/platform/android/prober.lua @@ -49,14 +49,11 @@ end -- probe the ccache function prober._probe_ccache(configs) - -- get the ccache mode - local mode = configs.ccache - -- ok? - if mode and mode == "y" and configs.__ccache then return true end + if configs.ccache and configs.__ccache then return true end -- disable? - if mode and mode == "n" then + if not configs.ccache then configs.__ccache = nil return true end @@ -66,10 +63,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = "y" + configs.ccache = true configs.__ccache = ccache_path else - configs.ccache = "n" + configs.ccache = false end -- ok diff --git a/xmake/scripts/platform/iphoneos/prober.lua b/xmake/scripts/platform/iphoneos/prober.lua index 33ebe03ad..f1868e3a3 100644 --- a/xmake/scripts/platform/iphoneos/prober.lua +++ b/xmake/scripts/platform/iphoneos/prober.lua @@ -129,14 +129,11 @@ end -- probe the ccache function prober._probe_ccache(configs) - -- get the ccache mode - local mode = configs.ccache - -- ok? - if mode and mode == "y" and configs.__ccache then return true end + if configs.ccache and configs.__ccache then return true end -- disable? - if mode and mode == "n" then + if not configs.ccache then configs.__ccache = nil return true end @@ -146,10 +143,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = "y" + configs.ccache = true configs.__ccache = ccache_path else - configs.ccache = "n" + configs.ccache = false end -- ok diff --git a/xmake/scripts/platform/iphonesimulator/prober.lua b/xmake/scripts/platform/iphonesimulator/prober.lua index 6740720bf..55717002e 100644 --- a/xmake/scripts/platform/iphonesimulator/prober.lua +++ b/xmake/scripts/platform/iphonesimulator/prober.lua @@ -129,14 +129,11 @@ end -- probe the ccache function prober._probe_ccache(configs) - -- get the ccache mode - local mode = configs.ccache - -- ok? - if mode and mode == "y" and configs.__ccache then return true end + if configs.ccache and configs.__ccache then return true end -- disable? - if mode and mode == "n" then + if not configs.ccache then configs.__ccache = nil return true end @@ -146,10 +143,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = "y" + configs.ccache = true configs.__ccache = ccache_path else - configs.ccache = "n" + configs.ccache = false end -- ok diff --git a/xmake/scripts/platform/linux/prober.lua b/xmake/scripts/platform/linux/prober.lua index 963cc440d..92f670394 100644 --- a/xmake/scripts/platform/linux/prober.lua +++ b/xmake/scripts/platform/linux/prober.lua @@ -49,14 +49,11 @@ end -- probe the ccache function prober._probe_ccache(configs) - -- get the ccache mode - local mode = configs.ccache - -- ok? - if mode and mode == "y" and configs.__ccache then return true end + if configs.ccache and configs.__ccache then return true end -- disable? - if mode and mode == "n" then + if not configs.ccache then configs.__ccache = nil return true end @@ -66,10 +63,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = "y" + configs.ccache = true configs.__ccache = ccache_path else - configs.ccache = "n" + configs.ccache = false end -- ok diff --git a/xmake/scripts/platform/macosx/prober.lua b/xmake/scripts/platform/macosx/prober.lua index f3077d913..fe28126c8 100644 --- a/xmake/scripts/platform/macosx/prober.lua +++ b/xmake/scripts/platform/macosx/prober.lua @@ -129,14 +129,11 @@ end -- probe the ccache function prober._probe_ccache(configs) - -- get the ccache mode - local mode = configs.ccache - -- ok? - if mode and mode == "y" and configs.__ccache then return true end + if configs.ccache and configs.__ccache then return true end -- disable? - if mode and mode == "n" then + if not configs.ccache then configs.__ccache = nil return true end @@ -146,10 +143,10 @@ function prober._probe_ccache(configs) -- probe ok? update it if ccache_path then - configs.ccache = "y" + configs.ccache = true configs.__ccache = ccache_path else - configs.ccache = "n" + configs.ccache = false end -- ok diff --git a/xmake/scripts/tools/clang.lua b/xmake/scripts/tools/clang.lua index 73acc5deb..102e93f20 100644 --- a/xmake/scripts/tools/clang.lua +++ b/xmake/scripts/tools/clang.lua @@ -89,8 +89,7 @@ function clang.init(name) clang.shflags = { flags_arch, "-dynamiclib" } -- suppress warning for the ccache bug - local ccache = config.get("ccache") - if ccache and ccache == "y" then + if config.get("ccache") then table.join2(clang.cxflags, "-Qunused-arguments") table.join2(clang.mxflags, "-Qunused-arguments") end |
