summaryrefslogtreecommitdiff
path: root/xmake/scripts/action
diff options
context:
space:
mode:
authorruki <[email protected]>2016-01-14 09:19:14 +0800
committerruki <[email protected]>2016-01-14 09:19:14 +0800
commitcdcf953259aee5e7e1a06855ddbedbaabf585bc9 (patch)
tree47b8e5de10522cca3b67354fa527b3525193e880 /xmake/scripts/action
parent8c50566e7ab2139b9f6c2976b9ce875b7ad11b7a (diff)
rename script directory to core
Diffstat (limited to 'xmake/scripts/action')
-rw-r--r--xmake/scripts/action/_build.lua120
-rw-r--r--xmake/scripts/action/_clean.lua106
-rw-r--r--xmake/scripts/action/_config.lua215
-rw-r--r--xmake/scripts/action/_create.lua173
-rw-r--r--xmake/scripts/action/_debug.lua89
-rw-r--r--xmake/scripts/action/_global.lua104
-rw-r--r--xmake/scripts/action/_install.lua224
-rw-r--r--xmake/scripts/action/_lua.lua168
-rw-r--r--xmake/scripts/action/_man.lua89
-rw-r--r--xmake/scripts/action/_package.lua365
-rw-r--r--xmake/scripts/action/_run.lua179
-rw-r--r--xmake/scripts/action/_uninstall.lua160
-rw-r--r--xmake/scripts/action/action.lua190
13 files changed, 0 insertions, 2182 deletions
diff --git a/xmake/scripts/action/_build.lua b/xmake/scripts/action/_build.lua
deleted file mode 100644
index bf660eab5..000000000
--- a/xmake/scripts/action/_build.lua
+++ /dev/null
@@ -1,120 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _build.lua
---
-
--- define module: _build
-local _build = _build or {}
-
--- load modules
-local rule = require("base/rule")
-local utils = require("base/utils")
-local clean = require("base/clean")
-local config = require("base/config")
-local project = require("base/project")
-local makefile = require("base/makefile")
-
--- need access to the given file?
-function _build.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _build.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- the target name
- local target_name = options.target
-
- -- check target
- if not project.checktarget(target_name) then
- return false
- end
-
- -- rebuild it?
- if options.rebuild or config.get("__rebuild") then
- clean.remove(target_name, "build")
- -- update it?
- elseif options.update then
- clean.remove(target_name, "targets")
- end
-
- -- clear rebuild mark and save configure to file
- if config.get("__rebuild") then
-
- -- clear it
- config.set("__rebuild", nil)
-
- -- save the configure
- if not config.save() then
- -- error
- utils.error("update configure failed!")
- end
- end
-
- -- check makefile
- if not os.isfile(rule.makefile()) then
-
- -- make the configure file for the given target
- if not project.makeconf(options.target) then
- -- error
- utils.error("make configure failed!")
- return false
- end
-
- -- make makefile
- if not makefile.make() then
- -- error
- utils.error("make makefile failed!")
- return false
- end
- end
-
- -- build target for makefile
- if not makefile.build(target_name) then
- -- error
- print("")
- if options.verbose then
- io.cat(rule.logfile())
- else
- io.tail(rule.logfile(), 32)
- end
- utils.error("build target: %s failed!\n", target_name)
- return false
- end
-
- -- ok
- print("build ok!")
- return true
-end
-
--- return module: _build
-return _build
diff --git a/xmake/scripts/action/_clean.lua b/xmake/scripts/action/_clean.lua
deleted file mode 100644
index 677ff2470..000000000
--- a/xmake/scripts/action/_clean.lua
+++ /dev/null
@@ -1,106 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _clean.lua
---
-
--- define module: _clean
-local _clean = _clean or {}
-
--- load modules
-local clean = require("base/clean")
-local config = require("base/config")
-local project = require("base/project")
-local utils = require("base/utils")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _clean.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { global = true, config = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _clean.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- check target
- if not project.checktarget(options.target) then
- return false
- end
-
- -- clean the current target
- if not clean.remove(options.target, utils.ifelse(options.all, "all", "build")) then
- return false
- end
-
- -- trace
- print("clean ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function _clean.menu()
-
- return {
- -- xmake c
- shortname = 'c'
-
- -- usage
- , usage = "xmake clean|c [options] [target]"
-
- -- description
- , description = "Remove all binary and temporary files."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {}
- , {'a', "all", "k", nil, "Clean all auto-generated files by xmake." }
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Clean for the given target." }
- }
- }
-end
-
--- return module: _clean
-return _clean
diff --git a/xmake/scripts/action/_config.lua b/xmake/scripts/action/_config.lua
deleted file mode 100644
index a883b0499..000000000
--- a/xmake/scripts/action/_config.lua
+++ /dev/null
@@ -1,215 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _config.lua
---
-
--- define module: _config
-local _config = _config or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local project = require("base/project")
-local makefile = require("base/makefile")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _config.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _config.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- check target
- if not project.checktarget(options.target) then
- return false
- end
-
- -- trace
- print("configure ...")
-
- -- save the configure
- if not config.save() then
- -- error
- utils.error("save configure failed!")
- return false
- end
-
- -- make the configure file for the given target
- if not project.makeconf(options.target) then
- -- error
- utils.error("make configure failed!")
- return false
- end
-
- -- make makefile
- if not makefile.make() then
- -- error
- utils.error("make makefile failed!")
- return false
- end
-
- -- dump configure
- config.dump()
-
- -- trace
- print("configure ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function _config.menu()
-
- return {
- -- xmake f
- shortname = 'f'
-
- -- usage
- , usage = "xmake config|f [options] [target]"
-
- -- description
- , description = "Configure the project."
-
- -- options
- , options =
- {
- {'c', "clean", "k", nil, "Clean the cached configure and configure all again." }
-
- , {}
- , {'p', "plat", "kv", xmake._HOST, "Compile for the given platform."
- , function ()
- local descriptions = {}
- local plats = platform.plats()
- if plats then
- for i, plat in ipairs(plats) do
- descriptions[i] = " - " .. plat
- end
- end
- return descriptions
- end }
- , {'a', "arch", "kv", "auto", "Compile for the given architecture."
- , function ()
- local descriptions = {}
- local plats = platform.plats()
- if plats then
- for i, plat in ipairs(plats) do
- descriptions[i] = " - " .. plat .. ":"
- local archs = platform.archs(plat)
- if archs then
- for _, arch in ipairs(archs) do
- descriptions[i] = descriptions[i] .. " " .. arch
- end
- end
- end
- end
- return descriptions
- end }
- , {'m', "mode", "kv", "release", "Compile for the given mode."
- , " - debug"
- , " - release"
- , " - profile" }
- , {'k', "kind", "kv", "static", "Compile for the given target kind."
- , " - static"
- , " - shared"
- , " - binary" }
- , {nil, "host", "kv", xmake._HOST, "The current host environment." }
-
- -- the options for project
- , function () return project.menu() end
-
- , {}
- , {nil, "make", "kv", "auto", "Set the make path." }
- , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." }
-
- , {}
- , {nil, "cross", "kv", nil, "The cross toolchains prefix"
- , ".e.g"
- , " - i386-mingw32-"
- , " - arm-linux-androideabi-" }
- , {nil, "toolchains", "kv", nil, "The cross toolchains directory" }
-
- , {}
- , {nil, "cc", "kv", nil, "The C Compiler" }
- , {nil, "cxx", "kv", nil, "The C++ Compiler" }
- , {nil, "cflags", "kv", nil, "The C Compiler Flags" }
- , {nil, "cxflags", "kv", nil, "The C/C++ compiler Flags" }
- , {nil, "cxxflags", "kv", nil, "The C++ Compiler Flags" }
-
- , {}
- , {nil, "as", "kv", nil, "The Assembler" }
- , {nil, "asflags", "kv", nil, "The Assembler Flags" }
-
- , {}
- , {nil, "sc", "kv", nil, "The Swift Compiler" }
- , {nil, "scflags", "kv", nil, "The Swift Compiler Flags" }
-
- , {}
- , {nil, "ld", "kv", nil, "The Linker" }
- , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" }
-
- , {}
- , {nil, "ar", "kv", nil, "The Static Library Linker" }
- , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" }
-
- , {}
- , {nil, "sh", "kv", nil, "The Shared Library Linker" }
- , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" }
-
- -- the options for all platforms
- , function () return platform.menu("config") end
-
- , {}
- , {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'o', "buildir", "kv", "build", "Set the build directory." }
-
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Configure for the given target." }
- }
- }
-end
-
--- return module: _config
-return _config
diff --git a/xmake/scripts/action/_create.lua b/xmake/scripts/action/_create.lua
deleted file mode 100644
index 840631f65..000000000
--- a/xmake/scripts/action/_create.lua
+++ /dev/null
@@ -1,173 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _create.lua
---
-
--- define module: _create
-local _create = _create or {}
-
--- load modules
-local utils = require("base/utils")
-local template = require("base/template")
-
--- need access to the given file?
-function _create.need(name)
-
- -- no accessors
- return false
-end
-
--- done
-function _create.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- the target name
- local targetname = options.target or options.name or path.basename(xmake._PROJECT_DIR) or "demo"
-
- -- trace
- utils.printf("create %s ...", targetname)
-
- -- the language
- local language = options.language
- if not language then
- utils.error("no language!")
- return false
- end
-
- -- the template id
- local templateid = tonumber(options.template)
- if type(templateid) ~= "number" then
- utils.error("invalid template id: %s!", options.template)
- return false
- end
-
- -- load all templates for the given language
- local templates = template.loadall(language)
-
- -- load the template module
- local module = nil
- if templates then module = templates[templateid] end
- if not module then
- utils.error("invalid template id: %s!", options.template)
- return false
- end
-
- -- enter the template directory
- if not module._DIRECTORY or not os.cd(module._DIRECTORY) then
- -- error
- utils.error("not found template id: %s!", options.template)
- return false
- end
-
- -- check the template project
- if not os.isdir("project") then
- -- errors
- utils.error("the template project not exists!")
- return false
- end
-
- -- ensure the project directory
- if not os.isdir(xmake._PROJECT_DIR) then
- os.mkdir(xmake._PROJECT_DIR)
- end
-
- -- copy the project files
- local ok, errors = os.cp("project/*", xmake._PROJECT_DIR)
- if not ok then
- -- errors
- utils.error(errors)
- return false
- end
-
- -- done the template files
- if not module.done(targetname, xmake._PROJECT_DIR, xmake._PACKAGES_DIR) then
- utils.error("update the template failed!")
- return false
- end
-
- -- trace
- utils.printf("create %s ok!", targetname)
-
- -- ok
- return true
-end
-
--- the menu
-function _create.menu()
-
- return {
- -- usage
- usage = "xmake create [options] [target]"
-
- -- description
- , description = "Create a new project."
-
- -- options
- , options =
- {
- {'n', "name", "kv", nil, "The project name." }
- , {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'l', "language", "kv", "c", "The project language"
- , function ()
- local descriptions = {}
- local languages = template.languages()
- for _, language in ipairs(languages) do
- table.insert(descriptions, " - " .. language)
- end
- return descriptions
- end }
- , {'t', "template", "kv", "1", "Select the project template id of the given language."
- , function ()
- local descriptions = {}
- local languages = template.languages()
- for _, language in ipairs(languages) do
- table.insert(descriptions, string.format(" - language: %s", language))
- local templates = template.loadall(language)
- if templates then
- for i, template in ipairs(templates) do
- table.insert(descriptions, string.format(" %d. %s", i, utils.ifelse(template.description, template.description, "The Unknown Project")))
- end
- end
- end
- return descriptions
- end }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", nil, "Create the given target."
- , "Uses the project name as target if not exists." }
- }
- }
-end
-
--- return module: _create
-return _create
diff --git a/xmake/scripts/action/_debug.lua b/xmake/scripts/action/_debug.lua
deleted file mode 100644
index c84d78073..000000000
--- a/xmake/scripts/action/_debug.lua
+++ /dev/null
@@ -1,89 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _debug.lua
---
-
--- define module: _debug
-local _debug = _debug or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _debug.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _debug.done()
-
- -- TODO
- print("not implement!")
-
- -- ok
- return true
-end
-
--- the menu
-function _debug.menu()
-
- return {
- -- xmake d
- shortname = 'd'
-
- -- usage
- , usage = "xmake debug|d [options] [target]"
-
- -- description
- , description = "Debug target."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", nil, "Debug a given target" }
- }
- }
-end
-
--- return module: _debug
-return _debug
diff --git a/xmake/scripts/action/_global.lua b/xmake/scripts/action/_global.lua
deleted file mode 100644
index a8fffa0bc..000000000
--- a/xmake/scripts/action/_global.lua
+++ /dev/null
@@ -1,104 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _global.lua
---
-
--- define module: _global
-local _global = _global or {}
-
--- load modules
-local utils = require("base/utils")
-local global = require("base/global")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _global.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { global = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _global.done()
-
- -- probe the global platform configure
- if not platform.probe(true) then
- return false
- end
-
- -- clear up the global configure
- global.clearup()
-
- -- save the global configure
- if not global.save() then
- -- error
- utils.error("save configure failed!")
- return false
- end
-
- -- dump global
- global.dump()
-
- -- ok
- print("configure ok!")
- return true
-end
-
--- the menu
-function _global.menu()
-
- return {
- -- xmake g
- shortname = 'g'
-
- -- usage
- , usage = "xmake global|g [options] [target]"
-
- -- description
- , description = "Configure the global options for xmake."
-
- -- options
- , options =
- {
- {'c', "clean", "k", nil, "Clean the cached configure and configure all again." }
- , {nil, "make", "kv", "auto", "Set the make path." }
- , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache."
- , " --ccache=[y|n]" }
-
- , {}
- -- the options for all platforms
- , function () return platform.menu("global") end
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
- }
- }
-end
-
--- return module: _global
-return _global
diff --git a/xmake/scripts/action/_install.lua b/xmake/scripts/action/_install.lua
deleted file mode 100644
index 28ef3650d..000000000
--- a/xmake/scripts/action/_install.lua
+++ /dev/null
@@ -1,224 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _install.lua
---
-
--- define module: _install
-local _install = _install or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local global = require("base/global")
-local install = require("base/install")
-local package = require("base/package")
-local project = require("base/project")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _install.need(name)
-
- -- no accessors
- return false
-end
-
--- make configure for the given target
-function _install._makeconf(configs, target_name, target)
-
- -- check
- assert(configs and target_name and target)
-
- -- init configs for targets
- configs[target_name] = configs[target_name] or {}
- local configs_target = configs[target_name]
-
- -- save the install script
- local installscript = target.installscript
- if type(installscript) == "string" and os.isfile(installscript) then
- local script, errors = loadfile(installscript)
- if script then
- installscript = script()
- if type(installscript) == "table" and installscript.main then
- installscript = installscript.main
- end
- else
- utils.error(errors)
- return false
- end
- end
- if target.installscript and type(installscript) ~= "function" then
- utils.error("invalid install script!")
- return false
- end
- configs_target.installscript = installscript
-
- -- ok
- return true
-end
-
--- package target
-function _install._package(target_name)
-
- -- get the target name
- if not target_name or target_name == "all" then
- target_name = ""
- end
-
- -- package it
- if os.execute(string.format("xmake p -P %s -f %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, target_name)) ~= 0 then
- return false
- end
-
- -- ok
- return true
-end
-
--- done
-function _install.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- trace
- print("install: ...")
-
- -- load the global configure first
- global.load()
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- errors
- utils.error("not found project: %s!", xmake._PROJECT_DIR)
- return false
- end
-
- -- package the given target first
- if not _install._package(options.target) then
- -- errors
- utils.error("package: failed!")
- return false
- end
-
- -- load the package configure
- local configs, errors = package.load()
- if not configs then
- -- errors
- utils.error(errors)
- return false
- end
-
- -- reload configure
- local errors = config.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- make the platform configure
- if not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- reload project
- local errors = project.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- update the outputdir
- for _, target in pairs(configs) do
- target.outputdir = options.installdir
- end
-
- -- the targets
- local targets = project.targets()
- assert(targets)
-
- -- make configure for the given target
- if target_name and target_name ~= "all" then
- if not _install._makeconf(configs, target_name, targets[target_name]) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- else
- for target_name, target in pairs(targets) do
- if not _install._makeconf(configs, target_name, target) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- end
- end
-
- -- done install
- if not install.done(configs) then
- -- errors
- utils.error("install: failed!")
- return false
- end
-
- -- trace
- print("install: ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function _install.menu()
-
- return {
- -- xmake i
- shortname = 'i'
-
- -- usage
- , usage = "xmake install|i [options] [target]"
-
- -- description
- , description = "Package and install the project binary files."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'o', "installdir", "kv", nil, "Set the install directory." }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Install the given target." }
- }
- }
-end
-
--- return module: _install
-return _install
diff --git a/xmake/scripts/action/_lua.lua b/xmake/scripts/action/_lua.lua
deleted file mode 100644
index c1a89dc39..000000000
--- a/xmake/scripts/action/_lua.lua
+++ /dev/null
@@ -1,168 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _lua.lua
---
-
--- define module: _lua
-local _lua = _lua or {}
-
--- load modules
-local os = require("base/os")
-local path = require("base/path")
-local utils = require("base/utils")
-local config = require("base/config")
-local string = require("base/string")
-local tools = require("tools/tools")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _lua.need(name)
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- do not load config if be not given -f or -P options
- if options.file == nil and options.project == nil then
- return false
- end
-
- -- patch target for loading config ok
- options.target = "all"
-
- -- the accessors
- local accessors = { config = true, global = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _lua.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- no script?
- if not options.script then
- return false
- end
-
- -- the arguments
- local arguments = options.arguments or {}
- if type(arguments) ~= "table" then
- arguments = {}
- end
-
- -- is string script?
- if options.string then
-
- -- trace
- utils.verbose("script: %s", options.script)
-
- -- load and run string
- local script = loadstring(options.script)
- if script then
- return script(arguments)
- end
- else
- -- attempt to load script from the given file if exists
- local file = options.script
- if not path.is_absolute(file) then
- file = path.absolute(file)
- end
-
- -- attempt to load script from the tools directory
- if not os.isfile(file) then
- file = tools.find(options.script, xmake._SCRIPTS_DIR .. "/tools")
- end
-
- -- load and run the script file
- if os.isfile(file) then
-
- -- load script
- local script = loadfile(file)
- if script then
-
- -- load module
- local module = script()
- if module then
-
- -- init module
- if module.init then
- module:init(options.script)
- end
-
- -- done module
- return module:main(arguments)
- end
- end
- end
- end
-
- -- failed
- utils.error("cannot run this script: %s", options.script)
- return false
-end
-
--- the menu
-function _lua.menu()
-
- return {
- -- xmake l
- shortname = 'l'
-
- -- usage
- , usage = "xmake lua|l [options] [script] [arguments]"
-
- -- description
- , description = "Run the lua script."
-
- -- options
- , options =
- {
- {'f', "file", "kv", nil, "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'s', "string", "k", nil, "Run the lua string script." }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "script", "v", nil, "Run the given lua script."
- , " - The script name from the xmake tool directory"
- , " - The script file"
- , " - The script string" }
- , {nil, "arguments", "vs", nil, "The script arguments" }
- }
- }
-end
-
--- return module: _lua
-return _lua
diff --git a/xmake/scripts/action/_man.lua b/xmake/scripts/action/_man.lua
deleted file mode 100644
index feb70dd92..000000000
--- a/xmake/scripts/action/_man.lua
+++ /dev/null
@@ -1,89 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _man.lua
---
-
--- define module: _man
-local _man = _man or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _man.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _man.done()
-
- -- TODO
- print("not implement!")
-
- -- ok
- return true
-end
-
--- the menu
-function _man.menu()
-
- return {
- -- xmake m
- shortname = 'm'
-
- -- usage
- , usage = "xmake man|m [options] [target]"
-
- -- description
- , description = "Create a project man."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Create man for the given target" }
- }
- }
-end
-
--- return module: _man
-return _man
diff --git a/xmake/scripts/action/_package.lua b/xmake/scripts/action/_package.lua
deleted file mode 100644
index e39604a33..000000000
--- a/xmake/scripts/action/_package.lua
+++ /dev/null
@@ -1,365 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _package.lua
---
-
--- define module: _package
-local _package = _package or {}
-
--- load modules
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local config = require("base/config")
-local global = require("base/global")
-local string = require("base/string")
-local project = require("base/project")
-local package = require("base/package")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _package.need(name)
-
- -- no accessors
- return false
-end
-
--- configure target for the given architecture
-function _package._config(arch, target_name)
-
- -- need not configure it
- if not arch then return true end
-
- -- done the command
- return os.execute(string.format("xmake f -P %s -f %s -a %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, arch, target_name)) == 0;
-end
-
--- build target for the given architecture
-function _package._build(arch, target_name)
-
- -- get the target name
- if not target_name or target_name == "all" then
- target_name = ""
- end
-
- -- configure it first
- if not _package._config(arch, target_name) then return false end
-
- -- build it
- if os.execute(string.format("xmake -P %s %s", xmake._PROJECT_DIR, target_name)) ~= 0 then
- -- errors
- utils.error("build failed!")
- return false
- end
-
- -- ok
- return true
-end
-
--- backup the target files
-function _package._backup(rootdir, filepath)
-
- -- the relative file path
- if filepath and path.is_absolute(filepath) then
- filepath = path.relative(filepath, xmake._PROJECT_DIR)
- end
-
- -- not exists? return it directly
- if not filepath or not os.isfile(filepath) then return end
-
- -- the backup file
- local backupfile = string.format("%s/%s", rootdir, filepath)
-
- -- backup it
- local ok, errors = os.cp(filepath, backupfile)
- if not ok then
- -- errors
- utils.error(errors)
- return
- end
-
- -- ok
- return filepath
-end
-
--- make configure for the given target
-function _package._makeconf(target_name, target)
-
- -- check
- assert(target_name and target)
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- the configs
- local configs = _package._CONFIGS
- assert(configs)
-
- -- the architecture
- local arch = config.get("arch")
- if not arch then return false end
-
- -- init configs for targets
- configs[target_name] = configs[target_name] or {}
- local configs_target = configs[target_name]
-
- -- init configs for architectures
- configs_target.archs = configs_target.archs or {}
-
- -- init configs for architecture
- configs_target.archs[arch] = configs_target.archs[arch] or {}
- local configs_arch = configs_target.archs[arch]
-
- -- save name
- configs_target.name = target_name
-
- -- save kind
- configs_target.kind = target.kind
-
- -- save the output directory
- configs_target.outputdir = options.outputdir or config.get("buildir")
-
- -- save the header files
- configs_target.headers = target.headers
-
- -- save the target directory
- configs_arch.targetdir = rule.backupdir(target_name, arch)
-
- -- save the config file
- configs_arch.config_h = _package._backup(configs_arch.targetdir, rule.config_h(target))
-
- -- save the target file
- configs_arch.targetfile = _package._backup(configs_arch.targetdir, rule.targetfile(target_name, target))
-
- -- save the package script
- local packagescript = target.packagescript
- if type(packagescript) == "string" and os.isfile(packagescript) then
- local script, errors = loadfile(packagescript)
- if script then
- packagescript = script()
- if type(packagescript) == "table" and packagescript.main then
- packagescript = packagescript.main
- end
- else
- utils.error(errors)
- return false
- end
- end
- if target.packagescript and type(packagescript) ~= "function" then
- utils.error("invalid package script!")
- return false
- end
- configs_target.packagescript = packagescript
-
- -- ok
- return true
-end
-
--- load configure for the given target
-function _package._loadconf(target_name)
-
- -- reload configure
- local errors = config.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- make the platform configure
- if not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- reload project
- local errors = project.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- the targets
- local targets = project.targets()
- assert(targets)
-
- -- make configure for the given target
- if target_name and target_name ~= "all" then
- if not _package._makeconf(target_name, targets[target_name]) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- else
- for target_name, target in pairs(targets) do
- if not _package._makeconf(target_name, target) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- end
- end
-
- -- ok
- return true
-end
-
--- build target for all architectures
-function _package._build_all(archs, target_name)
-
- -- exists the given architectures?
- if archs then
-
- -- split all architectures
- archs = archs:split(",")
- if not archs then return false end
-
- -- build for all architectures
- for _, arch in ipairs(archs) do
-
- -- trim it
- arch = arch:trim()
-
- -- build it
- if not _package._build(arch, target_name) then return false end
-
- -- load configure
- if not _package._loadconf(target_name) then return false end
-
- end
-
- -- build for single architecture
- else
-
- -- build it
- if not _package._build(nil, target_name) then return false end
-
- -- load configure
- if not _package._loadconf(target_name) then return false end
-
- end
-
- -- ok
- return true
-end
-
--- done
-function _package.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- trace
- print("package: ...")
-
- -- init configs
- _package._CONFIGS = _package._CONFIGS or {}
- local configs = _package._CONFIGS
-
- -- load the global configure first
- global.load()
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- errors
- utils.error("not found project: %s!", xmake._PROJECT_DIR)
- return false
- end
-
- -- build the given target first for all architectures
- if not _package._build_all(options.archs, options.target) then
- -- errors
- utils.error("build package failed!")
- return false
- end
-
- -- done package
- if not package.done(configs) then
- -- errors
- utils.error("package: failed!")
- return false
- end
-
- -- trace
- print("package: ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function _package.menu()
-
- return {
- -- xmake p
- shortname = 'p'
-
- -- usage
- , usage = "xmake package|p [options] [target]"
-
- -- description
- , description = "Package target."
-
- -- options
- , options =
- {
- {'a', "archs", "kv", nil, "Package multiple given architectures."
- , " .e.g --archs=\"armv7, arm64\" or -a i386"
- , ""
- , function ()
- local descriptions = {}
- local plats = platform.plats()
- if plats then
- for i, plat in ipairs(plats) do
- descriptions[i] = " - " .. plat .. ":"
- local archs = platform.archs(plat)
- if archs then
- for _, arch in ipairs(archs) do
- descriptions[i] = descriptions[i] .. " " .. arch
- end
- end
- end
- end
- return descriptions
- end }
-
- , {}
- , {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'o', "outputdir", "kv", nil, "Set the output directory." }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Package a given target" }
- }
- }
-end
-
--- return module: _package
-return _package
diff --git a/xmake/scripts/action/_run.lua b/xmake/scripts/action/_run.lua
deleted file mode 100644
index 64649fcb8..000000000
--- a/xmake/scripts/action/_run.lua
+++ /dev/null
@@ -1,179 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _run.lua
---
-
--- define module: _run
-local _run = _run or {}
-
--- load modules
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local config = require("base/config")
-local project = require("base/project")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _run.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function _run.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options and xmake._PROJECT_DIR)
-
- -- the target name
- local name = options.target
- if not name then
- -- error
- utils.error("no runable target!")
- return false
- end
-
- -- the arguments
- local arguments = options.arguments or {}
- if type(arguments) ~= "table" then
- arguments = {}
- end
-
- -- the targets
- local targets = project.targets()
- if not targets or not targets[name] then
- -- error
- utils.error("not found target: %s!", name)
- return false
- end
-
- -- the target
- local target = targets[name]
-
- -- the target file
- local targetfile = rule.targetfile(name, target)
- if targetfile and not path.is_absolute(targetfile) then
- targetfile = path.absolute(targetfile, xmake._PROJECT_DIR)
- end
-
- -- load the run script
- local runscript = target.runscript
- if type(runscript) == "string" and os.isfile(runscript) then
- local script, errors = loadfile(runscript)
- if script then
- runscript = script()
- if type(runscript) == "table" and runscript.main then
- runscript = runscript.main
- end
- else
- utils.error(errors)
- return false
- end
- end
-
- -- run script
- if runscript ~= nil then
- if type(runscript) == "function" then
-
- -- make passed target
- local target_passed = {}
- target_passed.name = name
- target_passed.arguments = arguments
- target_passed.targetfile = targetfile
-
- -- run it
- local ok = runscript(target_passed)
- if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end
- else
- utils.error("invalid run script!")
- return false
- end
- end
-
- -- not executale?
- if not target.kind or type(target.kind) ~= "string" or target.kind ~= "binary" then
- -- error
- utils.error("the target %s is not executale!", name)
- return false
- end
-
- -- check the target file
- if not targetfile and not os.isfile(targetfile) then
- -- error
- utils.error("not found target file: %s!", targetfile)
- return false
- end
-
- -- done
- local ok = os.execute(string.format("%s %s", targetfile, table.concat(arguments, " ")))
-
- -- ok?
- return utils.ifelse(ok == 0, true, false)
-end
-
--- the menu
-function _run.menu()
-
- return {
- -- xmake r
- shortname = 'r'
-
- -- usage
- , usage = "xmake run|r [options] [target] [arguments]"
-
- -- description
- , description = "Run the project target."
-
- -- options
- , options =
- {
- {'d', "debug", "k", nil, "Run and debug the given target." }
- , {nil, "debugger", "kv", "auto", "Set the debugger path." }
-
- , {}
- , {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", nil, "Run the given target." }
- , {nil, "arguments", "vs", nil, "The target arguments" }
- }
- }
-end
-
--- return module: _run
-return _run
diff --git a/xmake/scripts/action/_uninstall.lua b/xmake/scripts/action/_uninstall.lua
deleted file mode 100644
index 8f82907d6..000000000
--- a/xmake/scripts/action/_uninstall.lua
+++ /dev/null
@@ -1,160 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file _uninstall.lua
---
-
--- define module: _uninstall
-local _uninstall = _uninstall or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local global = require("base/global")
-local install = require("base/install")
-local uninstall = require("base/uninstall")
-local package = require("base/package")
-local project = require("base/project")
-local platform = require("platform/platform")
-
--- need access to the given file?
-function _uninstall.need(name)
-
- -- no accessors
- return false
-end
-
--- package target
-function _uninstall._package(target_name)
-
- -- get the target name
- if not target_name or target_name == "all" then
- target_name = ""
- end
-
- -- package it
- if os.execute(string.format("xmake p -P %s -f %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, target_name)) ~= 0 then
- return false
- end
-
- -- ok
- return true
-end
-
-
--- done
-function _uninstall.done()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- trace
- print("uninstall: ...")
-
- -- load the global configure first
- global.load()
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- errors
- utils.error("not found project: %s!", xmake._PROJECT_DIR)
- return false
- end
-
- -- load the install configure
- local configs, errors = install.load()
- if not configs then
- -- errors
- utils.error(errors)
- return false
- end
-
- -- reload configure
- local errors = config.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- make the platform configure
- if not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- reload project
- local errors = project.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- done uninstall
- if not uninstall.done(configs) then
- -- errors
- utils.error("uninstall: failed!")
- return false
- end
-
- -- trace
- print("uninstall: ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function _uninstall.menu()
-
- return {
- -- xmake u
- shortname = 'u'
-
- -- usage
- , usage = "xmake uninstall|u [options] [target]"
-
- -- description
- , description = "Uninstall the project binary files."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Install the given target." }
- }
- }
-end
-
--- return module: _uninstall
-return _uninstall
diff --git a/xmake/scripts/action/action.lua b/xmake/scripts/action/action.lua
deleted file mode 100644
index 1174b140a..000000000
--- a/xmake/scripts/action/action.lua
+++ /dev/null
@@ -1,190 +0,0 @@
---!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) 2009 - 2015, ruki All rights reserved.
---
--- @author ruki
--- @file action.lua
---
-
--- define module: action
-local action = action or {}
-
--- load modules
-local os = require("base/os")
-local path = require("base/path")
-local utils = require("base/utils")
-local global = require("base/global")
-local config = require("base/config")
-local project = require("base/project")
-local platform = require("platform/platform")
-
--- load the given action
-function action._load(name)
-
- -- load the given action
- return require("action/_" .. name)
-end
-
--- load the project file
-function action._load_project()
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- error
- return string.format("not found project: %s!", xmake._PROJECT_DIR)
- end
-
- -- check the project file
- if not os.isfile(xmake._PROJECT_FILE) then
- return string.format("not found the project file: %s", xmake._PROJECT_FILE)
- end
-
- -- init the build directory
- if options.buildir and path.is_absolute(options.buildir) then
- options.buildir = path.relative(options.buildir, xmake._PROJECT_DIR)
- end
-
- -- xmake config or marked as "reconfig"?
- if options._ACTION == "config" or config._RECONFIG then
-
- -- probe the current project
- project.probe()
-
- -- clear up the configure
- config.clearup()
-
- end
-
- -- load the project
- return project.load()
-end
-
--- done the given action
-function action.done(name)
-
- -- the options
- local options = xmake._OPTIONS
- assert(options)
-
- -- load the given action
- local _action = action._load(name)
- if not _action then return false end
-
- -- load the global configure first
- if _action.need("global") then global.load() end
-
- -- load the project configure
- if _action.need("config") then
- local errors = config.load()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
- end
-
- -- probe the platform
- if _action.need("platform") and (options._ACTION == "config" or config._RECONFIG) then
- if not platform.probe(false) then
- return false
- end
- end
-
- -- merge the default options
- for k, v in pairs(options._DEFAULTS) do
- if nil == options[k] then options[k] = v end
- end
-
- -- make the platform configure
- if _action.need("platform") and not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- load the project file
- if _action.need("project") then
- local errors = action._load_project()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
- end
-
- -- reconfig it first if marked as "reconfig"
- if _action.need("config") and config._RECONFIG then
-
- -- config it
- local _action_config = action._load("config")
- if not _action_config or not _action_config.done() then
- -- error
- utils.error("reconfig failed for the changed host!")
- return false
- end
- end
-
- -- done the given action
- return _action.done()
-end
-
--- list the all actions
-function action.list()
-
- -- find all action scripts
- local list = {}
- local files = os.match(xmake._SCRIPTS_DIR .. "/action/_*.lua")
- if files then
- for _, file in ipairs(files) do
- local name = path.basename(file)
- if name and name ~= "_build" then
- table.insert(list, name:sub(2))
- end
- end
- end
-
- -- ok?
- return list
-end
-
--- get the all action menus
-function action.menu()
-
- -- get all actions
- local menus = {}
- local actions = action.list()
- for _, name in ipairs(actions) do
-
- -- load action
- local a = action._load(name)
- if a and a.menu then
- local m = a.menu()
- if m then
- menus[name] = m
- end
- end
- end
-
- -- ok?
- return menus
-end
-
--- return module: action
-return action