diff options
| author | ruki <[email protected]> | 2016-03-24 13:59:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-03-24 13:59:41 +0800 |
| commit | df4bd403becbdd74b13cf92bd906d0d1caa9908c (patch) | |
| tree | efde2f9dd25024013c9dee86f3eb948a399d478f | |
| parent | 9612b87afb5e86ca62457c4deacccaa3d0696373 (diff) | |
check xmake.lua
| -rwxr-xr-x | xmake/actions/clean/main.lua | 67 | ||||
| -rwxr-xr-x | xmake/actions/clean/xmake.lua | 32 | ||||
| -rwxr-xr-x | xmake/actions/config/config_h.lua | 2 | ||||
| -rwxr-xr-x | xmake/actions/config/main.lua | 10 | ||||
| -rwxr-xr-x | xmake/actions/config/makefile.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 7 | ||||
| -rw-r--r-- | xmake/core/sandbox/sandbox.lua | 13 |
7 files changed, 131 insertions, 2 deletions
diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua new file mode 100755 index 000000000..a46742b05 --- /dev/null +++ b/xmake/actions/clean/main.lua @@ -0,0 +1,67 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("core.project.global") +import("core.project.project") +import("core.platform.platform") + +-- main +function main() + + -- check xmake.lua + if not os.isfile(project.file()) then + raise("xmake.lua not found!") + end + + -- get the target name + local targetname = option.get("target") + + -- load global configure + global.load() + + -- load project configure + config.load(targetname) + + -- load platform + platform.load(config.plat()) + + -- load project + project.load() + + -- check target + if targetname and targetname ~= "all" and nil == project.target(targetname) then + raise("unknown target: %s", targetname) + end + + -- enter project directory + os.cd(project.directory()) + + -- leave project directory + os.cd("-") + + -- trace + print("clean ok!") + +end diff --git a/xmake/actions/clean/xmake.lua b/xmake/actions/clean/xmake.lua new file mode 100755 index 000000000..41ef2fbc0 --- /dev/null +++ b/xmake/actions/clean/xmake.lua @@ -0,0 +1,32 @@ +-- define task +task("clean") + + -- set category + set_task_category("action") + + -- on run + on_task_run("main") + + -- set menu + set_task_menu({ + -- usage + usage = "xmake clean|c [options] [target]" + + -- description + , description = "Remove all binary and temporary files." + + -- xmake c + , shortname = 'c' + + -- options + , options = + { + {'a', "all", "k", nil, "Clean all auto-generated files by xmake." } + + , {} + , {nil, "target", "v", "all", "Clean for the given target." } + } + }) + + + diff --git a/xmake/actions/config/config_h.lua b/xmake/actions/config/config_h.lua index acd94eeb2..cdd18c5dc 100755 --- a/xmake/actions/config/config_h.lua +++ b/xmake/actions/config/config_h.lua @@ -125,7 +125,7 @@ function make() local targetname = option.get("target") -- enter project directory - os.cd("$(projectdir)") + os.cd(project.directory()) -- init files local files = {} diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 5936f94f1..9027573b2 100755 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -37,6 +37,11 @@ end -- main function main() + -- check xmake.lua + if not os.isfile(project.file()) then + raise("xmake.lua not found!") + end + -- the target name local targetname = option.get("target") @@ -92,6 +97,11 @@ function main() -- load project project.load() + -- check xmake.lua + if not os.isfile(project.file()) then + raise("xmake.lua not found!") + end + -- check target if targetname and targetname ~= "all" and nil == project.target(targetname) then raise("unknown target: %s", targetname) diff --git a/xmake/actions/config/makefile.lua b/xmake/actions/config/makefile.lua index 57c94d503..e0b66bd8b 100755 --- a/xmake/actions/config/makefile.lua +++ b/xmake/actions/config/makefile.lua @@ -221,7 +221,7 @@ end function make() -- enter project directory - os.cd("$(projectdir)") + os.cd(project.directory()) -- remove the log makefile first os.rm(_logfile()) diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 0e527df38..6805d661a 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -66,6 +66,13 @@ function sandbox_core_project_project.targets() return targets end +-- get the project file +function sandbox_core_project_project.file() + + -- get it + return xmake._PROJECT_FILE +end + -- get the project directory function sandbox_core_project_project.directory() diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua index 244f1032d..dd2dcc23c 100644 --- a/xmake/core/sandbox/sandbox.lua +++ b/xmake/core/sandbox/sandbox.lua @@ -29,10 +29,23 @@ local path = require("base/path") local table = require("base/table") local utils = require("base/utils") local string = require("base/string") +local option = require("base/option") -- traceback function sandbox._traceback(errors) + -- not verbose? + if not option.get("verbose") then + if errors then + -- remove the prefix info + local _, pos = errors:find(":%d+: ") + if pos then + return errors:sub(pos + 1) + end + end + return errors + end + -- init results local results = "" if errors then |
