summaryrefslogtreecommitdiff
path: root/xmake/scripts/action
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/scripts/action')
-rw-r--r--xmake/scripts/action/_clean.lua34
-rw-r--r--xmake/scripts/action/_config.lua115
-rw-r--r--xmake/scripts/action/_create.lua50
-rw-r--r--xmake/scripts/action/_global.lua33
-rw-r--r--xmake/scripts/action/_install.lua35
-rw-r--r--xmake/scripts/action/_lua.lua34
-rw-r--r--xmake/scripts/action/_run.lua39
-rw-r--r--xmake/scripts/action/action.lua54
8 files changed, 393 insertions, 1 deletions
diff --git a/xmake/scripts/action/_clean.lua b/xmake/scripts/action/_clean.lua
index 5af3604b7..2a479157f 100644
--- a/xmake/scripts/action/_clean.lua
+++ b/xmake/scripts/action/_clean.lua
@@ -26,6 +26,7 @@ local _clean = _clean or {}
-- load modules
local clean = require("base/clean")
local config = require("base/config")
+local platform = require("platform/platform")
-- done the given config
function _clean.done()
@@ -46,5 +47,38 @@ function _clean.done()
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" }
+ , {}
+ , {'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
index 2c1046ecf..9ef333abe 100644
--- a/xmake/scripts/action/_config.lua
+++ b/xmake/scripts/action/_config.lua
@@ -28,6 +28,7 @@ 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")
-- done the given config
function _config.done()
@@ -65,5 +66,119 @@ function _config.done()
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" }
+ , {'-', "host", "kv", xmake._HOST, "The current host environment." }
+
+ , {}
+ , {'o', "buildir", "kv", "build", "Set the build directory." }
+ , {'k', "packages", "kv", "pkg", "Set the packages directory." }
+
+ , {}
+ , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache."
+ , " --ccache=[y|n]" }
+
+ , {}
+ , {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, "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" }
+
+
+ , {}
+ , {'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
index f60666d71..59aac8a55 100644
--- a/xmake/scripts/action/_create.lua
+++ b/xmake/scripts/action/_create.lua
@@ -26,6 +26,7 @@ local _create = _create or {}
-- load modules
local utils = require("base/utils")
local config = require("base/config")
+local platform = require("platform/platform")
-- done the given config
function _create.done()
@@ -35,5 +36,54 @@ function _create.done()
return true
end
+-- the menu
+function _create.menu()
+
+ return {
+ -- xmake p
+ shortname = 'p'
+
+ -- usage
+ , usage = "xmake create|p [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"
+ , " - c"
+ , " - c++"
+ , " - objc"
+ , " - objc++"
+ , " - lua" }
+ , {'t', "type", "kv", "console", "The project type"
+ , " - console"
+ , " - library_static"
+ , " - library_shared"
+ , " - application_empty"
+ , " - application_singleview"
+ , " - game" }
+
+ , {}
+ , {'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/_global.lua b/xmake/scripts/action/_global.lua
index 5cfaf1bbd..329502c7d 100644
--- a/xmake/scripts/action/_global.lua
+++ b/xmake/scripts/action/_global.lua
@@ -26,6 +26,7 @@ local _global = _global or {}
-- load modules
local utils = require("base/utils")
local global = require("base/global")
+local platform = require("platform/platform")
-- done the given config
function _global.done()
@@ -45,5 +46,37 @@ function _global.done()
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, "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
index 5f5bfac9b..af7edc104 100644
--- a/xmake/scripts/action/_install.lua
+++ b/xmake/scripts/action/_install.lua
@@ -26,6 +26,7 @@ local _install = _install or {}
-- load modules
local utils = require("base/utils")
local config = require("base/config")
+local platform = require("platform/platform")
-- done the given config
function _install.done()
@@ -35,5 +36,39 @@ function _install.done()
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" }
+
+ , {}
+ , {'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
index 380c3438b..8801307d2 100644
--- a/xmake/scripts/action/_lua.lua
+++ b/xmake/scripts/action/_lua.lua
@@ -30,6 +30,7 @@ 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")
-- done the given config
function _lua.done()
@@ -100,5 +101,38 @@ function _lua.done()
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 =
+ {
+ {'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/_run.lua b/xmake/scripts/action/_run.lua
index 8de5ab5f1..c2b46ad9b 100644
--- a/xmake/scripts/action/_run.lua
+++ b/xmake/scripts/action/_run.lua
@@ -29,6 +29,7 @@ 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")
-- done the given config
function _run.done()
@@ -87,5 +88,43 @@ function _run.done()
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/action.lua b/xmake/scripts/action/action.lua
index eab768364..a0574ec58 100644
--- a/xmake/scripts/action/action.lua
+++ b/xmake/scripts/action/action.lua
@@ -23,16 +23,68 @@
-- define module: action
local action = action or {}
+-- load modules
+local os = require("base/os")
+local path = require("base/path")
+
+-- load the given action
+function action._load(name)
+
+ -- load the given action
+ return require("action/_" .. name)
+end
+
-- done the given action
function action.done(name)
-- load the given action
- local a = require("action/_" .. name)
+ local a = action._load(name)
if not a then return false end
-- done the given action
return a.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