summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-06-18 21:33:10 +0800
committerGitHub <[email protected]>2026-06-18 21:33:10 +0800
commite782a2fbb9815e217671216e218fb3017f3cf60b (patch)
tree527e8d557370d6a9cb2303ffdd317444f7659de6
parent9b8df1e3c6bf7aa841c3c62f8f80d5016690367b (diff)
parent6aeb1e3fef16f55f6ff20e60bb48ddded9c90faf (diff)
Merge pull request #7608 from xmake-io/format
format menus
-rw-r--r--xmake/actions/build/xmake.lua74
-rw-r--r--xmake/actions/clean/xmake.lua41
-rw-r--r--xmake/actions/config/xmake.lua173
-rw-r--r--xmake/actions/create/xmake.lua68
-rw-r--r--xmake/actions/global/xmake.lua136
-rw-r--r--xmake/actions/install/xmake.lua51
-rw-r--r--xmake/actions/require/xmake.lua179
-rw-r--r--xmake/actions/run/xmake.lua69
-rw-r--r--xmake/actions/service/xmake.lua116
-rw-r--r--xmake/actions/test/xmake.lua36
-rw-r--r--xmake/actions/uninstall/xmake.lua42
-rw-r--r--xmake/actions/update/xmake.lua113
-rw-r--r--xmake/plugins/check/xmake.lua9
-rw-r--r--xmake/plugins/doxygen/xmake.lua32
-rw-r--r--xmake/plugins/format/xmake.lua63
-rw-r--r--xmake/plugins/lua/xmake.lua104
-rw-r--r--xmake/plugins/macro/xmake.lua107
-rw-r--r--xmake/plugins/pack/xmake.lua5
-rw-r--r--xmake/plugins/plugin/xmake.lua14
-rw-r--r--xmake/plugins/project/xmake.lua86
-rw-r--r--xmake/plugins/repo/xmake.lua43
-rw-r--r--xmake/plugins/show/xmake.lua20
-rw-r--r--xmake/plugins/watch/xmake.lua60
23 files changed, 742 insertions, 899 deletions
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua
index 655b28207..c1b90d6f8 100644
--- a/xmake/actions/build/xmake.lua
+++ b/xmake/actions/build/xmake.lua
@@ -22,43 +22,37 @@ task("build")
set_category("main")
on_run("main")
set_menu {
- usage = "xmake [task] [options] [targets]"
- , description = "Build targets if no given tasks."
- , shortname = 'b'
- , options =
- {
- {nil, "version", "k", nil , "Print the version number and exit." }
- , {'b', "build", "k", nil , "Build target. This is default building mode and optional." }
- , {'r', "rebuild", "k", nil , "Rebuild the target." }
- , {'a', "all", "k", nil , "Build all targets." }
- , {nil, "shallow", "k", nil , "Only re-build the given targets without dependencies." }
- , {'g', "group", "kv", nil , "Build all targets of the given group. It support path pattern matching.",
- "e.g.",
- " xmake -g test",
- " xmake -g test_*",
- " xmake --group=benchmark/*" }
- , {nil, "dry-run", "k", nil , "Dry run to build target." }
-
- , {}
- , {'j', "jobs", "kv", tostring(os.default_njob()),
- "Set the number of parallel compilation jobs." }
- , {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs." }
- , {'w', "warning", "k", false , "Enable the warnings output. (deprecated)" }
- , {nil, "linkonly", "k", false , "Only link targets if object files have been compiled." }
- , {nil, "files", "kv", nil , "Build the given source files.",
- "e.g. ",
- " - xmake --files=src/main.c",
- " - xmake --files='src/*.c' [target]",
- " - xmake --files='src/**.c|excluded_file.c'",
- " - xmake --files='src/main.c" .. path.envsep() .. "src/test.c'" }
-
- , {}
- , {nil, "targets", "vs", nil , "The target names. It will build all default targets if this parameter is not specified.",
- "e.g.",
- " xmake build target1 target2 ..."
- , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
- }
- }
-
-
-
+ usage = "xmake [task] [options] [targets]",
+ description = "Build targets if no given tasks.",
+ shortname = 'b',
+ options = {
+ {nil, "version", "k", nil, "Print the version number and exit."},
+ {'b', "build", "k", nil, "Build target. This is default building mode and optional."},
+ {'r', "rebuild", "k", nil, "Rebuild the target."},
+ {'a', "all", "k", nil, "Build all targets."},
+ {nil, "shallow", "k", nil, "Only re-build the given targets without dependencies."},
+ {'g', "group", "kv", nil, "Build all targets of the given group. It supports path pattern matching.",
+ "e.g.",
+ " xmake -g test",
+ " xmake -g test_*",
+ " xmake --group=benchmark/*"},
+ {nil, "dry-run", "k", nil, "Dry run to build target."},
+ {},
+ {'j', "jobs", "kv", tostring(os.default_njob()),
+ "Set the number of parallel compilation jobs."},
+ {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs."},
+ {'w', "warning", "k", false, "Enable the warnings output. (deprecated)"},
+ {nil, "linkonly", "k", false, "Only link targets if object files have been compiled."},
+ {nil, "files", "kv", nil, "Build the given source files.",
+ "e.g. ",
+ " - xmake --files=src/main.c",
+ " - xmake --files='src/*.c' [target]",
+ " - xmake --files='src/**.c|excluded_file.c'",
+ " - xmake --files='src/main.c" .. path.envsep() .. "src/test.c'"},
+ {},
+ {nil, "targets", "vs", nil, "The target names. It will build all default targets if this parameter is not specified.",
+ "e.g.",
+ " xmake build target1 target2 ...",
+ values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end},
+ }
+ }
diff --git a/xmake/actions/clean/xmake.lua b/xmake/actions/clean/xmake.lua
index 980ee2b28..d20bec3dd 100644
--- a/xmake/actions/clean/xmake.lua
+++ b/xmake/actions/clean/xmake.lua
@@ -21,28 +21,21 @@
task("clean")
set_category("action")
on_run("main")
-
set_menu {
- usage = "xmake clean|c [options] [targets]"
- , description = "Remove all binary and temporary files."
- , shortname = 'c'
-
- , options =
- {
- {'a', "all", "k", nil , "Clean all auto-generated files by xmake." }
- , {'g', "group", "kv", nil , "Clean all targets of the given group. It support path pattern matching.",
- "e.g.",
- " xmake clean -g test",
- " xmake clean -g test_*",
- " xmake clean --group=benchmark/*" }
-
- , {}
- , {nil, "targets", "vs", nil , "The target names. It will clean all default targets if this parameter is not specified.",
- "e.g.",
- " xmake clean target1 target2 ..."
- , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
- }
- }
-
-
-
+ usage = "xmake clean|c [options] [targets]",
+ description = "Remove all binary and temporary files.",
+ shortname = 'c',
+ options = {
+ {'a', "all", "k", nil, "Clean all auto-generated files by xmake."},
+ {'g', "group", "kv", nil, "Clean all targets of the given group. It supports path pattern matching.",
+ "e.g.",
+ " xmake clean -g test",
+ " xmake clean -g test_*",
+ " xmake clean --group=benchmark/*"},
+ {},
+ {nil, "targets", "vs", nil, "The target names. It will clean all default targets if this parameter is not specified.",
+ "e.g.",
+ " xmake clean target1 target2 ...",
+ values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end},
+ }
+ }
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index 4c9f5ea4b..3bc2cd882 100644
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -165,90 +165,89 @@ task("config")
set_category("action")
on_run("main")
set_menu {
- usage = "xmake config|f [options]",
- description = "Configure the project.",
- shortname = 'f',
- options = {
- {'c', "clean", "k", nil , "Clean the cached user configs and detection cache."},
- {nil, "check", "k", nil , "Just ignore detection cache and force to check all, it will reserve the cached user configs."},
- {nil, "export", "kv", nil , "Export the current configuration to the given file."
- , " e.g."
- , " - xmake f -m debug -xxx=y --export=build/config.txt"},
- {nil, "import", "kv", nil , "Import configs from the given file."
- , " e.g."
- , " - xmake f -import=build/config.txt"},
- {nil, "menu", "k", nil , "Configure project with a menu-driven user interface."},
- {category = "."},
- {'p', "plat", "kv", "auto" , "Compile for the given platform.", values = _plat_values},
- {'a', "arch", "kv", "auto" , "Compile for the given architecture.", _arch_description, values = _arch_values},
- {'m', "mode", "kv", "auto" , "Compile for the given mode.", values = _mode_values},
- {'k', "kind", "kv", "static" , "Compile for the given target kind.", values = {"static", "shared", "binary"}},
- {nil, "host", "kv", "$(host)" , "Set the current host environment."},
- {nil, "policies", "kv", nil , "Set the project policies.",
- " e.g.",
- " - xmake f --policies=package.fetch_only",
- " - xmake f --policies=package.precompiled:n,package.install_only"},
- {category = "Package Configuration"},
- {nil, "require", "kv", nil , "Require all dependent packages?", values = {"yes", "no"}},
- {nil, "pkg_searchdirs", "kv", nil , "The search directories of the remote package."
- , " e.g."
- , " - xmake f --pkg_searchdirs=/dir1" .. path.envsep() .. "/dir2"},
- {category = "Cross Complation Configuration"},
- {nil, "cross", "kv", nil, "Set cross toolchains prefix"
- , "e.g."
- , " - i386-mingw32-"
- , " - arm-linux-androideabi-"},
- {nil, "target_os", "kv", nil, "Set target os only for cross-compilation"},
- {nil, "bin", "kv", nil, "Set cross toolchains bin directory"
- , "e.g."
- , " - sdk/bin (/arm-linux-gcc ..)"},
- {nil, "sdk", "kv", nil, "Set cross SDK directory"
- , "e.g."
- , " - sdk/bin"
- , " - sdk/lib"
- , " - sdk/include"},
- {nil, "toolchain", "kv", nil, "Set toolchain name"
- , "e.g. "
- , " - xmake f --toolchain=clang"
- , " - xmake f --toolchain=[cross|llvm|sdcc ..] --sdk=/xxx"
- , " - run `xmake show -l toolchains` to get all toolchains"
- , values = _toolchain_values},
- {nil, "toolchain_host", "kv", nil, "Set host toolchain name, it's only for building packages on host machine."
- , "e.g. "
- , " - xmake f --toolchain_host=clang"
- , " - xmake f --toolchain_host=[cross|llvm|sdcc ..] --sdk=/xxx"
- , " - run `xmake show -l toolchains` to get all toolchains"
- , values = _toolchain_values},
- {nil, "runtimes", "kv", nil, "Set the compiler runtime library."
- , "e.g. "
- , " - xmake f --runtimes=MTd"
- , " - xmake f --runtimes=MT,c++_static"
- , values = {"MT", "MTd", "MD", "MDd", -- only for msvc
- "c++_static", "c++_shared", -- gcc/clang/android ndk
- "stdc++_static", "stdc++_shared", -- gcc/clang
- "gnustl_static", "gnustl_shared", -- only for old android ndk
- "stlport_static", "stlport_shared"}}, -- only for old android ndk
- _language_menu_options,
- _platform_menu_options,
- {category = "Other Configuration"},
- {nil, "debugger", "kv", "auto" , "Set debugger"},
- {nil, "ccache", "kv", true , "Enable or disable the c/c++ compiler cache."},
- {nil, "ccachedir", "kv", nil , "Set the ccache directory."},
- {nil, "trybuild", "kv", nil , "Enable try-build mode and set the third-party buildsystem tool.",
- "e.g.",
- " - xmake f --trybuild=auto; xmake",
- " - xmake f --trybuild=autoconf -p android --ndk=xxx; xmake",
- "",
- "the third-party buildsystems:"
- , values = {"auto", "make", "autoconf", "cmake", "scons", "meson", "bazel", "ninja", "msbuild", "xcodebuild", "ndkbuild", "xrepo"}},
- {nil, "tryconfigs", "kv", nil , "Set the extra configurations of the third-party buildsystem for the try-build mode.",
- "e.g.",
- " - xmake f --trybuild=autoconf --tryconfigs='--enable-shared=no'"},
- {'o', "builddir", "kv", "build" , "Set build directory."},
- {nil, "buildir", "kv", nil , "Set build directory. (deprecated)"},
- {},
- {category = "Project Configuration"},
- _project_menu_options}}
-
-
-
+ usage = "xmake config|f [options]",
+ description = "Configure the project.",
+ shortname = 'f',
+ options = {
+ {'c', "clean", "k", nil, "Clean the cached user configs and detection cache."},
+ {nil, "check", "k", nil, "Just ignore detection cache and force to check all, it will reserve the cached user configs."},
+ {nil, "export", "kv", nil, "Export the current configuration to the given file.",
+ " e.g.",
+ " - xmake f -m debug -xxx=y --export=build/config.txt"},
+ {nil, "import", "kv", nil, "Import configs from the given file.",
+ " e.g.",
+ " - xmake f --import=build/config.txt"},
+ {nil, "menu", "k", nil, "Configure project with a menu-driven user interface."},
+ {category = "."},
+ {'p', "plat", "kv", "auto", "Compile for the given platform.", values = _plat_values},
+ {'a', "arch", "kv", "auto", "Compile for the given architecture.", _arch_description, values = _arch_values},
+ {'m', "mode", "kv", "auto", "Compile for the given mode.", values = _mode_values},
+ {'k', "kind", "kv", "static", "Compile for the given target kind.", values = {"static", "shared", "binary"}},
+ {nil, "host", "kv", "$(host)", "Set the current host environment."},
+ {nil, "policies", "kv", nil, "Set the project policies.",
+ " e.g.",
+ " - xmake f --policies=package.fetch_only",
+ " - xmake f --policies=package.precompiled:n,package.install_only"},
+ {category = "Package Configuration"},
+ {nil, "require", "kv", nil, "Require all dependent packages?", values = {"yes", "no"}},
+ {nil, "pkg_searchdirs", "kv", nil, "The search directories of the remote package.",
+ " e.g.",
+ " - xmake f --pkg_searchdirs=/dir1" .. path.envsep() .. "/dir2"},
+ {category = "Cross Compilation Configuration"},
+ {nil, "cross", "kv", nil, "Set cross toolchains prefix",
+ "e.g.",
+ " - i386-mingw32-",
+ " - arm-linux-androideabi-"},
+ {nil, "target_os", "kv", nil, "Set target os only for cross-compilation"},
+ {nil, "bin", "kv", nil, "Set cross toolchains bin directory",
+ "e.g.",
+ " - sdk/bin (/arm-linux-gcc ..)"},
+ {nil, "sdk", "kv", nil, "Set cross SDK directory",
+ "e.g.",
+ " - sdk/bin",
+ " - sdk/lib",
+ " - sdk/include"},
+ {nil, "toolchain", "kv", nil, "Set toolchain name",
+ "e.g. ",
+ " - xmake f --toolchain=clang",
+ " - xmake f --toolchain=[cross|llvm|sdcc ..] --sdk=/xxx",
+ " - run `xmake show -l toolchains` to get all toolchains",
+ values = _toolchain_values},
+ {nil, "toolchain_host", "kv", nil, "Set host toolchain name, it's only for building packages on host machine.",
+ "e.g. ",
+ " - xmake f --toolchain_host=clang",
+ " - xmake f --toolchain_host=[cross|llvm|sdcc ..] --sdk=/xxx",
+ " - run `xmake show -l toolchains` to get all toolchains",
+ values = _toolchain_values},
+ {nil, "runtimes", "kv", nil, "Set the compiler runtime library.",
+ "e.g. ",
+ " - xmake f --runtimes=MTd",
+ " - xmake f --runtimes=MT,c++_static",
+ values = {"MT", "MTd", "MD", "MDd", -- only for msvc
+ "c++_static", "c++_shared", -- gcc/clang/android ndk
+ "stdc++_static", "stdc++_shared", -- gcc/clang
+ "gnustl_static", "gnustl_shared", -- only for old android ndk
+ "stlport_static", "stlport_shared"}}, -- only for old android ndk
+ _language_menu_options,
+ _platform_menu_options,
+ {category = "Other Configuration"},
+ {nil, "debugger", "kv", "auto", "Set debugger"},
+ {nil, "ccache", "kv", true, "Enable or disable the c/c++ compiler cache."},
+ {nil, "ccachedir", "kv", nil, "Set the ccache directory."},
+ {nil, "trybuild", "kv", nil, "Enable try-build mode and set the third-party buildsystem tool.",
+ "e.g.",
+ " - xmake f --trybuild=auto; xmake",
+ " - xmake f --trybuild=autoconf -p android --ndk=xxx; xmake",
+ "",
+ "the third-party buildsystems:",
+ values = {"auto", "make", "autoconf", "cmake", "scons", "meson", "bazel", "ninja", "msbuild", "xcodebuild", "ndkbuild", "xrepo"}},
+ {nil, "tryconfigs", "kv", nil, "Set the extra configurations of the third-party buildsystem for the try-build mode.",
+ "e.g.",
+ " - xmake f --trybuild=autoconf --tryconfigs='--enable-shared=no'"},
+ {'o', "builddir", "kv", "build", "Set build directory."},
+ {nil, "buildir", "kv", nil, "Set build directory. (deprecated)"},
+ {},
+ {category = "Project Configuration"},
+ _project_menu_options,
+ }
+ }
diff --git a/xmake/actions/create/xmake.lua b/xmake/actions/create/xmake.lua
index 98e3b68bb..6e7091d21 100644
--- a/xmake/actions/create/xmake.lua
+++ b/xmake/actions/create/xmake.lua
@@ -25,41 +25,41 @@ task("create")
usage = "xmake create [options] [target]",
description = "Create a new project.",
options = {
- {'f', "force", "k", nil, "Force to create project in a non-empty directory."},
- {nil, "list", "k", nil, "List all templates for each language."
- , " e.g."
- , " - xmake create --list"
- , " - xmake create --list -l c++"},
- {'l', "language", "kv", "c++", "The project language",
- values = function (complete, opt)
- import("actions.create.template", {rootdir = os.programdir()})
+ {'f', "force", "k", nil, "Force to create project in a non-empty directory."},
+ {nil, "list", "k", nil, "List all templates for each language.",
+ " e.g.",
+ " - xmake create --list",
+ " - xmake create --list -l c++"},
+ {'l', "language", "kv", "c++", "The project language",
+ values = function (complete, opt)
+ import("actions.create.template", {rootdir = os.programdir()})
- local languages = template.languages()
- if not complete or not opt.template then
- return languages
- end
- return template.languages_for_template(opt.template)
- end },
- {'t', "template", "kv", "console", "Select the project template id or name of the given language.",
- " Use `xmake create --list` to view all templates.",
- values = function (complete, opt)
- if complete then
- import("actions.create.template", {rootdir = os.programdir()})
- import("core.base.hashset")
- local templates_set = hashset.new()
- local languages = opt.language and {opt.language} or template.languages()
- for _, l in ipairs(languages) do
- for _, t in ipairs(template.templates(l)) do
- templates_set:insert(t)
- end
- end
- local templates = templates_set:to_array()
- table.sort(templates)
- return templates
- end
- end},
+ local languages = template.languages()
+ if not complete or not opt.template then
+ return languages
+ end
+ return template.languages_for_template(opt.template)
+ end},
+ {'t', "template", "kv", "console", "Select the project template id or name of the given language.",
+ " Use `xmake create --list` to view all templates.",
+ values = function (complete, opt)
+ if complete then
+ import("actions.create.template", {rootdir = os.programdir()})
+ import("core.base.hashset")
+ local templates_set = hashset.new()
+ local languages = opt.language and {opt.language} or template.languages()
+ for _, l in ipairs(languages) do
+ for _, t in ipairs(template.templates(l)) do
+ templates_set:insert(t)
+ end
+ end
+ local templates = templates_set:to_array()
+ table.sort(templates)
+ return templates
+ end
+ end},
{},
- {nil, "target", "v", nil, "Create the given target."
- , "Uses the project name as target if not exists."}
+ {nil, "target", "v", nil, "Create the given target.",
+ "Uses the project name as target if not exists."},
}
}
diff --git a/xmake/actions/global/xmake.lua b/xmake/actions/global/xmake.lua
index fda843294..1c7261688 100644
--- a/xmake/actions/global/xmake.lua
+++ b/xmake/actions/global/xmake.lua
@@ -22,75 +22,67 @@ task("global")
set_category("action")
on_run("main")
set_menu {
- usage = "xmake global|g [options] [target]",
- description = "Configure the global options for xmake.",
- shortname = 'g',
- options = {
- {'c', "clean", "k", nil , "Clean the cached user configs and detection cache."},
- {nil, "check", "k", nil , "Just ignore detection cache and force to check all, it will reserve the cached user configs."},
- {nil, "menu", "k" , nil , "Configure with a menu-driven user interface." },
- {category = "."},
- {nil, "theme", "kv", "default" , "The theme name."
- , values = function ()
- return import("core.theme.theme.names")()
- end},
- {nil, "debugger", "kv", "auto" , "The debugger program path." },
- {nil, "ccache", "kv", nil , "Enable or disable the c/c++ compiler cache." },
- {category = "Build Configuration"},
- {nil, "cachedir", "kv", nil , "The global cache directory." },
- {nil, "policies", "kv", nil , "Set the global project policies.",
- " e.g.",
- " - xmake g --policies=run.autobuild",
- " - xmake g --policies=build.warning:n" },
- -- network configuration
- {category = "Network Configuration"},
- {nil, "network", "kv", "public" , "Set the network mode."
- , values = {"public", "private"} },
- {nil, "insecure-ssl", "kv", nil , "Disable to check ssl certificates for downloading." },
- {'x', "proxy", "kv", nil , "Use proxy on given port. [protocol://]host[:port]"
- , " e.g."
- , " - xmake g --proxy='http://host:port'"
- , " - xmake g --proxy='https://host:port'"
- , " - xmake g --proxy='socks5://host:port'" },
- {nil, "proxy_hosts", "kv", nil , "Only enable proxy for the given hosts list, it will enable all if be unset,"
- , "and we can pass match pattern to list:"
- , " e.g."
- , " - xmake g --proxy_hosts='github.com,gitlab.*,*.xmake.io'"},
- {nil, "proxy_pac", "kv", "pac.lua" , "Set the auto proxy configuration file."
- , " e.g."
- , " - xmake g --proxy_pac=pac.lua (in $(globaldir) or absolute path)"
- , " - function main(url, host)"
- , " if host == 'github.com' then"
- , " return true"
- , " end"
- , " end"
- , ""
- , "Builtin pac files:"
- , function ()
- local description = {}
- local pacfiles = os.files(path.join(os.programdir(), "scripts", "pac", "*.lua"))
- for _, pacfile in ipairs(pacfiles) do
- table.insert(description, " - " .. path.filename(pacfile))
- end
- return description
- end},
-
- -- package configuration
- {category = "Package Configuration"},
- {nil, "pkg_searchdirs", "kv", nil , "The search directories of the remote package."
- , " e.g."
- , " - xmake g --pkg_searchdirs=/dir1" .. path.envsep() .. "/dir2"},
- {nil, "pkg_cachedir", "kv", nil , "The cache root directory of the remote package."},
- {nil, "pkg_installdir", "kv", nil , "The install root directory of the remote package."},
-
- -- show platform menu options
- {category = "Platform Configuration"},
- function ()
- import("core.platform.menu")
- return menu.options("global")
- end
- }
- }
-
-
-
+ usage = "xmake global|g [options] [target]",
+ description = "Configure the global options for xmake.",
+ shortname = 'g',
+ options = {
+ {'c', "clean", "k", nil, "Clean the cached user configs and detection cache."},
+ {nil, "check", "k", nil, "Just ignore detection cache and force to check all, it will reserve the cached user configs."},
+ {nil, "menu", "k", nil, "Configure with a menu-driven user interface."},
+ {category = "."},
+ {nil, "theme", "kv", "default", "The theme name.",
+ values = function ()
+ return import("core.theme.theme.names")()
+ end},
+ {nil, "debugger", "kv", "auto", "The debugger program path."},
+ {nil, "ccache", "kv", nil, "Enable or disable the c/c++ compiler cache."},
+ {category = "Build Configuration"},
+ {nil, "cachedir", "kv", nil, "The global cache directory."},
+ {nil, "policies", "kv", nil, "Set the global project policies.",
+ " e.g.",
+ " - xmake g --policies=run.autobuild",
+ " - xmake g --policies=build.warning:n"},
+ {category = "Network Configuration"},
+ {nil, "network", "kv", "public", "Set the network mode.",
+ values = {"public", "private"}},
+ {nil, "insecure-ssl", "kv", nil, "Disable to check ssl certificates for downloading."},
+ {'x', "proxy", "kv", nil, "Use proxy on given port. [protocol://]host[:port]",
+ " e.g.",
+ " - xmake g --proxy='http://host:port'",
+ " - xmake g --proxy='https://host:port'",
+ " - xmake g --proxy='socks5://host:port'"},
+ {nil, "proxy_hosts", "kv", nil, "Only enable proxy for the given hosts list, it will enable all if be unset,",
+ "and we can pass match pattern to list:",
+ " e.g.",
+ " - xmake g --proxy_hosts='github.com,gitlab.*,*.xmake.io'"},
+ {nil, "proxy_pac", "kv", "pac.lua", "Set the auto proxy configuration file.",
+ " e.g.",
+ " - xmake g --proxy_pac=pac.lua (in $(globaldir) or absolute path)",
+ " - function main(url, host)",
+ " if host == 'github.com' then",
+ " return true",
+ " end",
+ " end",
+ "",
+ "Builtin pac files:",
+ function ()
+ local description = {}
+ local pacfiles = os.files(path.join(os.programdir(), "scripts", "pac", "*.lua"))
+ for _, pacfile in ipairs(pacfiles) do
+ table.insert(description, " - " .. path.filename(pacfile))
+ end
+ return description
+ end},
+ {category = "Package Configuration"},
+ {nil, "pkg_searchdirs", "kv", nil, "The search directories of the remote package.",
+ " e.g.",
+ " - xmake g --pkg_searchdirs=/dir1" .. path.envsep() .. "/dir2"},
+ {nil, "pkg_cachedir", "kv", nil, "The cache root directory of the remote package."},
+ {nil, "pkg_installdir", "kv", nil, "The install root directory of the remote package."},
+ {category = "Platform Configuration"},
+ function ()
+ import("core.platform.menu")
+ return menu.options("global")
+ end
+ }
+ }
diff --git a/xmake/actions/install/xmake.lua b/xmake/actions/install/xmake.lua
index 679ddbc81..e894e2787 100644
--- a/xmake/actions/install/xmake.lua
+++ b/xmake/actions/install/xmake.lua
@@ -26,33 +26,32 @@ task("install")
description = "Package and install the target binary files.",
shortname = 'i',
options = {
- {'o', "installdir", "kv", nil , "Set the install directory.",
- "e.g.",
- " $ xmake install -o /usr/local",
- "or $ DESTDIR=/usr/local xmake install",
- "or $ INSTALLDIR=/usr/local xmake install" },
- {nil, "bindir", "kv", nil , "Set install binaries directory in INSTALLDIR/DIR. (default: ${installdir}/bin)"},
- {nil, "libdir", "kv", nil , "Set install libraries directory in INSTALLDIR/DIR. (default: ${installdir}/lib)"},
- {nil, "includedir", "kv", nil , "Set install includes directory in INSTALLDIR/DIR. (default: ${installdir}/include)"},
- {'g', "group", "kv", nil , "Install all targets of the given group. It support path pattern matching.",
- "e.g.",
- " xmake install -g test",
- " xmake install -g test_*",
- " xmake install --group=benchmark/*" },
- {'a', "all", "k", nil , "Install all targets." },
- {nil, "binaries", "kv", true , "Enable or disable install binary files." },
- {nil, "headers", "kv", true , "Enable or disable install header files." },
- {nil, "libraries", "kv", true , "Enable or disable install library files." },
- {nil, "packages", "kv", true , "Enable or disable install package files." },
+ {'o', "installdir", "kv", nil, "Set the install directory.",
+ "e.g.",
+ " $ xmake install -o /usr/local",
+ "or $ DESTDIR=/usr/local xmake install",
+ "or $ INSTALLDIR=/usr/local xmake install"},
+ {nil, "bindir", "kv", nil, "Set install binaries directory in INSTALLDIR/DIR. (default: ${installdir}/bin)"},
+ {nil, "libdir", "kv", nil, "Set install libraries directory in INSTALLDIR/DIR. (default: ${installdir}/lib)"},
+ {nil, "includedir", "kv", nil, "Set install includes directory in INSTALLDIR/DIR. (default: ${installdir}/include)"},
+ {'g', "group", "kv", nil, "Install all targets of the given group. It supports path pattern matching.",
+ "e.g.",
+ " xmake install -g test",
+ " xmake install -g test_*",
+ " xmake install --group=benchmark/*"},
+ {'a', "all", "k", nil, "Install all targets."},
+ {nil, "binaries", "kv", true, "Enable or disable install binary files."},
+ {nil, "headers", "kv", true, "Enable or disable install header files."},
+ {nil, "libraries", "kv", true, "Enable or disable install library files."},
+ {nil, "packages", "kv", true, "Enable or disable install package files."},
{},
- {nil, "admin", "k", nil , "Try to request administrator permission to install"},
+ {nil, "admin", "k", nil, "Try to request administrator permission to install"},
{},
- {nil, "targets", "vs", nil , "The target names. It will install all default targets if this parameter is not specified.",
- "e.g.",
- " xmake install target1 target2 ...",
- values = function (complete, opt)
- return import("private.utils.complete_helper.targets")(complete, opt)
- end}
+ {nil, "targets", "vs", nil, "The target names. It will install all default targets if this parameter is not specified.",
+ "e.g.",
+ " xmake install target1 target2 ...",
+ values = function (complete, opt)
+ return import("private.utils.complete_helper.targets")(complete, opt)
+ end}
}
}
-
diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua
index e1596da52..bf81e3810 100644
--- a/xmake/actions/require/xmake.lua
+++ b/xmake/actions/require/xmake.lua
@@ -18,104 +18,89 @@
-- @file require.lua
--
--- define task
task("require")
-
- -- set category
set_category("action")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake require [options] [packages]"
-
- -- description
- , description = "Install and update required packages."
-
- -- xmake q
- , shortname = 'q'
-
- -- options
- , options =
- {
- {'c', "clean", "k", nil, "Clear all package caches and uninstall all not-referenced packages.",
- "e.g.",
- " $ xmake require --clean",
- " $ xmake require --clean zlib tbox pcr*" }
- , {nil, "clean_modes","kv", nil, "Set the modes of cleaning packages.",
- "e.g.",
- " $ xmake require --clean --clean_modes=cache,package" }
- , {'f', "force", "k", nil, "Force to reinstall all package dependencies." }
- , {'j', "jobs", "kv", tostring(os.default_njob()),
- "Set the number of parallel compilation jobs." }
- , {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs." }
- , {nil, "shallow", "k", nil, "Does not install or download dependent packages." }
- , {nil, "build", "k", nil, "Always build and install packages from source." }
- , {'l', "list", "k", nil, "List all package dependencies in project.",
- "e.g.",
- " $ xmake require --list" }
- , {nil, "scan", "k", nil, "Scan the given or all installed packages.",
- "e.g.",
- " $ xmake require --scan",
- " $ xmake require --scan zlib tbox pcr*" }
- , { }
- , {nil, "info", "k", nil, "Show the given package info.",
- "e.g.",
- " $ xmake require --info tbox" }
- , {nil, "depgraph", "k", nil, "Show the dependency graph of the given packages.",
- "e.g.",
- " $ xmake require --depgraph libpng",
- " $ xmake require --depgraph --format=json libpng",
- " $ xmake require --depgraph --format=dot libpng" }
- , {nil, "format", "kv", nil, "Set the output format.",
- "e.g.",
- " $ xmake require --info --format=json zlib",
- " $ xmake require --depgraph --format=dot libpng",
- "values: json (for --info/--depgraph), dot (for --depgraph only)",
- values = {"plain", "json", "dot"} }
- , {nil, "check", "k", nil, "Check whether the given package is supported",
- "e.g.",
- " $ xmake require --check tbox" }
- , {nil, "fetch", "k", nil, "Fetch the library info of given package.",
- "e.g.",
- " $ xmake require --fetch tbox" }
- , {nil, "fetch_modes","kv", nil, "Set the modes of fetching packages.",
- "e.g.",
- " $ xmake require --fetch --fetch_modes=cflags,external tbox",
- " $ xmake require --fetch --fetch_modes=deps,cflags,ldflags tbox" }
- , {'s', "search", "k", nil, "Search for the given packages from repositories.",
- "e.g.",
- " $ xmake require --search tbox" }
- , {nil, "upgrade", "k", nil, "Upgrade the installed packages." }
- , {nil, "download", "k", nil, "Only download the given package source archive files." }
- , {nil, "uninstall", "k", nil, "Uninstall the installed packages.",
- "e.g.",
- " $ xmake require --uninstall",
- " $ xmake require --uninstall tbox",
- " $ xmake require --uninstall --extra=\"{debug=true}\" tbox" }
- , {nil, "export", "k", nil, "Export the installed packages and their dependencies.",
- "e.g.",
- " $ xmake require --export",
- " $ xmake require --export tbox zlib",
- " $ xmake require --export --packagedir=packagesdir zlib",
- " $ xmake require --export --extra=\"{debug=true}\" tbox" }
- , {nil, "import", "k", nil, "Import the installed packages and their dependencies.",
- "e.g.",
- " $ xmake require --import",
- " $ xmake require --import tbox zlib",
- " $ xmake require --import --packagedir=packagesdir zlib",
- " $ xmake require --import --extra=\"{debug=true}\" tbox" }
- , {nil, "packagedir", "kv", "packages","Set the packages directory for exporting, importing and downloading."}
- , {nil, "debugdir", "kv", nil, "Set the source directory of the current package for debugging." }
- , {nil, "extra", "kv", nil, "Set the extra info of packages." }
- , { }
- , {nil, "requires", "vs", nil, "The package requires.",
- "e.g.",
- " $ xmake require zlib tbox",
- " $ xmake require \"zlib >=1.2.11\" \"tbox master\"",
- " $ xmake require --extra=\"{debug=true,configs={xxx=true}}\" tbox"}
- }
- }
+ usage = "xmake require [options] [packages]",
+ description = "Install and update required packages.",
+ shortname = 'q',
+ options = {
+ {'c', "clean", "k", nil, "Clear all package caches and uninstall all not-referenced packages.",
+ "e.g.",
+ " $ xmake require --clean",
+ " $ xmake require --clean zlib tbox pcr*"},
+ {nil, "clean_modes", "kv", nil, "Set the modes of cleaning packages.",
+ "e.g.",
+ " $ xmake require --clean --clean_modes=cache,package"},
+ {'f', "force", "k", nil, "Force to reinstall all package dependencies."},
+ {'j', "jobs", "kv", tostring(os.default_njob()),
+ "Set the number of parallel compilation jobs."},
+ {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs."},
+ {nil, "shallow", "k", nil, "Does not install or download dependent packages."},
+ {nil, "build", "k", nil, "Always build and install packages from source."},
+ {'l', "list", "k", nil, "List all package dependencies in project.",
+ "e.g.",
+ " $ xmake require --list"},
+ {nil, "scan", "k", nil, "Scan the given or all installed packages.",
+ "e.g.",
+ " $ xmake require --scan",
+ " $ xmake require --scan zlib tbox pcr*"},
+ {},
+ {nil, "info", "k", nil, "Show the given package info.",
+ "e.g.",
+ " $ xmake require --info tbox"},
+ {nil, "depgraph", "k", nil, "Show the dependency graph of the given packages.",
+ "e.g.",
+ " $ xmake require --depgraph libpng",
+ " $ xmake require --depgraph --format=json libpng",
+ " $ xmake require --depgraph --format=dot libpng"},
+ {nil, "format", "kv", nil, "Set the output format.",
+ "e.g.",
+ " $ xmake require --info --format=json zlib",
+ " $ xmake require --depgraph --format=dot libpng",
+ "values: json (for --info/--depgraph), dot (for --depgraph only)",
+ values = {"plain", "json", "dot"}},
+ {nil, "check", "k", nil, "Check whether the given package is supported",
+ "e.g.",
+ " $ xmake require --check tbox"},
+ {nil, "fetch", "k", nil, "Fetch the library info of given package.",
+ "e.g.",
+ " $ xmake require --fetch tbox"},
+ {nil, "fetch_modes", "kv", nil, "Set the modes of fetching packages.",
+ "e.g.",
+ " $ xmake require --fetch --fetch_modes=cflags,external tbox",
+ " $ xmake require --fetch --fetch_modes=deps,cflags,ldflags tbox"},
+ {'s', "search", "k", nil, "Search for the given packages from repositories.",
+ "e.g.",
+ " $ xmake require --search tbox"},
+ {nil, "upgrade", "k", nil, "Upgrade the installed packages."},
+ {nil, "download", "k", nil, "Only download the given package source archive files."},
+ {nil, "uninstall", "k", nil, "Uninstall the installed packages.",
+ "e.g.",
+ " $ xmake require --uninstall",
+ " $ xmake require --uninstall tbox",
+ " $ xmake require --uninstall --extra=\"{debug=true}\" tbox"},
+ {nil, "export", "k", nil, "Export the installed packages and their dependencies.",
+ "e.g.",
+ " $ xmake require --export",
+ " $ xmake require --export tbox zlib",
+ " $ xmake require --export --packagedir=packagesdir zlib",
+ " $ xmake require --export --extra=\"{debug=true}\" tbox"},
+ {nil, "import", "k", nil, "Import the installed packages and their dependencies.",
+ "e.g.",
+ " $ xmake require --import",
+ " $ xmake require --import tbox zlib",
+ " $ xmake require --import --packagedir=packagesdir zlib",
+ " $ xmake require --import --extra=\"{debug=true}\" tbox"},
+ {nil, "packagedir", "kv", "packages", "Set the packages directory for exporting, importing and downloading."},
+ {nil, "debugdir", "kv", nil, "Set the source directory of the current package for debugging."},
+ {nil, "extra", "kv", nil, "Set the extra info of packages."},
+ {},
+ {nil, "requires", "vs", nil, "The package requires.",
+ "e.g.",
+ " $ xmake require zlib tbox",
+ " $ xmake require \"zlib >=1.2.11\" \"tbox master\"",
+ " $ xmake require --extra=\"{debug=true,configs={xxx=true}}\" tbox"}
+ }
+ }
diff --git a/xmake/actions/run/xmake.lua b/xmake/actions/run/xmake.lua
index fd44ba413..5e4cbc8ad 100644
--- a/xmake/actions/run/xmake.lua
+++ b/xmake/actions/run/xmake.lua
@@ -18,51 +18,32 @@
-- @file xmake.lua
--
--- define task
task("run")
-
- -- set category
set_category("action")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake run|r [options] [target] [arguments]"
-
- -- description
- , description = "Run the project target."
-
- -- xmake r
- , shortname = 'r'
-
- -- options
- , options =
- {
- {'d', "debug", "k", nil , "Run and debug the given target." }
- , {'a', "all", "k", nil , "Run all targets." }
- , {'g', "group", "kv", nil , "Run all targets of the given group. It support path pattern matching.",
- "e.g.",
- " xmake run -g test",
- " xmake run -g test_*",
- " xmake run --group=benchmark/*" }
- , {'w', "workdir", "kv", nil , "Work directory of running targets, default is folder of targetfile",
- "e.g.",
- " xmake run -w .",
- " xmake run --workdir=`pwd`" }
- , {'j', "jobs", "kv", "1", "Set the number of parallel compilation jobs." }
- , {nil, "detach", "k", nil, "Run targets in detached processes." }
- , {}
- , {nil, "target", "v", nil , "The target name. It will run all default targets if this parameter is not specified."
- , values = function (complete, opt)
- return import("private.utils.complete_helper.runable_targets")(complete, opt)
- end }
-
- , {nil, "arguments", "vs", nil , "The target arguments" }
- }
- }
-
-
-
+ usage = "xmake run|r [options] [target] [arguments]",
+ description = "Run the project target.",
+ shortname = 'r',
+ options = {
+ {'d', "debug", "k", nil, "Run and debug the given target."},
+ {'a', "all", "k", nil, "Run all targets."},
+ {'g', "group", "kv", nil, "Run all targets of the given group. It supports path pattern matching.",
+ "e.g.",
+ " xmake run -g test",
+ " xmake run -g test_*",
+ " xmake run --group=benchmark/*"},
+ {'w', "workdir", "kv", nil, "Work directory of running targets, default is folder of targetfile",
+ "e.g.",
+ " xmake run -w .",
+ " xmake run --workdir=`pwd`"},
+ {'j', "jobs", "kv", "1", "Set the number of parallel compilation jobs."},
+ {nil, "detach", "k", nil, "Run targets in detached processes."},
+ {},
+ {nil, "target", "v", nil, "The target name. It will run all default targets if this parameter is not specified.",
+ values = function (complete, opt)
+ return import("private.utils.complete_helper.runable_targets")(complete, opt)
+ end},
+ {nil, "arguments", "vs", nil, "The target arguments"}
+ }
+ }
diff --git a/xmake/actions/service/xmake.lua b/xmake/actions/service/xmake.lua
index b292a73a2..10155f0b7 100644
--- a/xmake/actions/service/xmake.lua
+++ b/xmake/actions/service/xmake.lua
@@ -22,60 +22,62 @@ task("service")
set_category("action")
on_run("main")
- set_menu {usage = "xmake service [options]",
- description = "Start service for remote or distributed compilation and etc.",
- options = {
- {nil, "start", "k", nil, "Start daemon service.",
- "e.g.",
- " - xmake service --start",
- " - xmake service --start --remote",
- " - xmake service --start --distcc",
- " - xmake service --start --remote --distcc" },
- {nil, "restart", "k", nil, "Restart daemon service." },
- {nil, "stop" , "k", nil, "Stop daemon service." },
- {nil, "connect" , "k", nil, "Connect current project to the remote daemon service.",
- "e.g.",
- " - xmake service --connect",
- " - xmake service --connect --remote",
- " - xmake service --connect --distcc",
- " - xmake service --connect --remote --distcc",
- " - xmake service --connect --host=windows",
- " - xmake service --connect --host=10.5.139.8:9691" },
- {nil, "session" , "kv", nil,"Connect with the given session name, it will generate a session id via name.",
- "e.g.",
- " -- xmake service --connect --ccache --session=foo" },
- {nil, "reconnect", "k", nil, "Reconnect current project to the remote daemon service." },
- {nil, "disconnect", "k", nil, "Disconnect current project in the remote daemon service." },
- {nil, "remote", "k", nil, "Start or connect the remote build service." },
- {nil, "distcc", "k", nil, "Start or connect the distributed build service." },
- {nil, "ccache", "k", nil, "Start or connect the remote c/c++ cache service." },
- {nil, "sync", "k", nil, "Sync current project files in the remote daemon service." },
- {nil, "xmakesrc", "kv", nil, "Sync xmake program files in the remote daemon service.",
- "e.g.",
- " - xmake service --sync --xmakesrc=/xmakeproj/xmake" },
- {nil, "pull", "k", nil, "Pull the given file or directory in the remote daemon service.",
- "e.g.",
- " - xmake service --pull build outputdir",
- " - xmake service --pull 'build/**' outputdir" },
- {nil, "clean", "k", nil, "Clean current project files in the remote daemon service." },
- {nil, "all", "k", nil, "Clean all project files in the remote daemon service.",
- "e.g.",
- " - xmake service --clean --all" },
- {nil, "add-user", "kv", nil, "Add user in the server.",
- "e.g.",
- " - xmake service --add-user=root" },
- {nil, "rm-user", "kv", nil, "Remove user in the server.",
- "e.g.",
- " - xmake service --rm-user=root" },
- {nil, "gen-token", "k", nil, "Generate a new token in the server.",
- "e.g.",
- " - xmake service --gen-token" },
- {nil, "host", "kv", nil, "Connect to the specific host by name or address.",
- "e.g.",
- " - xmake service --connect --host=windows",
- " - xmake service --connect --host=10.5.139.8:9691",
- " - xmake service --connect --host=10.5.139.8" },
- {nil, "logs", "k", nil, "Show service logs if the daemon service has been started." },
- {nil, "status", "k", nil, "Show service status if the daemon service has been started." },
- {nil, "values", "vs", nil, "The values list for pull/.. options." }
- }}
+ set_menu {
+ usage = "xmake service [options]",
+ description = "Start service for remote or distributed compilation and etc.",
+ options = {
+ {nil, "start", "k", nil, "Start daemon service.",
+ "e.g.",
+ " - xmake service --start",
+ " - xmake service --start --remote",
+ " - xmake service --start --distcc",
+ " - xmake service --start --remote --distcc"},
+ {nil, "restart", "k", nil, "Restart daemon service."},
+ {nil, "stop" , "k", nil, "Stop daemon service."},
+ {nil, "connect" , "k", nil, "Connect current project to the remote daemon service.",
+ "e.g.",
+ " - xmake service --connect",
+ " - xmake service --connect --remote",
+ " - xmake service --connect --distcc",
+ " - xmake service --connect --remote --distcc",
+ " - xmake service --connect --host=windows",
+ " - xmake service --connect --host=10.5.139.8:9691"},
+ {nil, "session" , "kv", nil, "Connect with the given session name, it will generate a session id via name.",
+ "e.g.",
+ " -- xmake service --connect --ccache --session=foo"},
+ {nil, "reconnect", "k", nil, "Reconnect current project to the remote daemon service."},
+ {nil, "disconnect", "k", nil, "Disconnect current project in the remote daemon service."},
+ {nil, "remote", "k", nil, "Start or connect the remote build service."},
+ {nil, "distcc", "k", nil, "Start or connect the distributed build service."},
+ {nil, "ccache", "k", nil, "Start or connect the remote c/c++ cache service."},
+ {nil, "sync", "k", nil, "Sync current project files in the remote daemon service."},
+ {nil, "xmakesrc", "kv", nil, "Sync xmake program files in the remote daemon service.",
+ "e.g.",
+ " - xmake service --sync --xmakesrc=/xmakeproj/xmake"},
+ {nil, "pull", "k", nil, "Pull the given file or directory in the remote daemon service.",
+ "e.g.",
+ " - xmake service --pull build outputdir",
+ " - xmake service --pull 'build/**' outputdir"},
+ {nil, "clean", "k", nil, "Clean current project files in the remote daemon service."},
+ {nil, "all", "k", nil, "Clean all project files in the remote daemon service.",
+ "e.g.",
+ " - xmake service --clean --all"},
+ {nil, "add-user", "kv", nil, "Add user in the server.",
+ "e.g.",
+ " - xmake service --add-user=root"},
+ {nil, "rm-user", "kv", nil, "Remove user in the server.",
+ "e.g.",
+ " - xmake service --rm-user=root"},
+ {nil, "gen-token", "k", nil, "Generate a new token in the server.",
+ "e.g.",
+ " - xmake service --gen-token"},
+ {nil, "host", "kv", nil, "Connect to the specific host by name or address.",
+ "e.g.",
+ " - xmake service --connect --host=windows",
+ " - xmake service --connect --host=10.5.139.8:9691",
+ " - xmake service --connect --host=10.5.139.8"},
+ {nil, "logs", "k", nil, "Show service logs if the daemon service has been started."},
+ {nil, "status", "k", nil, "Show service status if the daemon service has been started."},
+ {nil, "values", "vs", nil, "The values list for pull/.. options."},
+ }
+ }
diff --git a/xmake/actions/test/xmake.lua b/xmake/actions/test/xmake.lua
index 1e04ab5f2..9b13cfe58 100644
--- a/xmake/actions/test/xmake.lua
+++ b/xmake/actions/test/xmake.lua
@@ -25,25 +25,23 @@ task("test")
usage = "xmake test [options] [tests]",
description = "Run the project tests.",
options = {
- {'g', "group", "kv", nil , "Run all tests of the given group. It support path pattern matching.",
- "e.g.",
- " xmake test -g test",
- " xmake test -g test_*",
- " xmake test --group=benchmark/*" },
- {'w', "workdir", "kv", nil , "Work directory of running targets, default is folder of targetfile",
- "e.g.",
- " xmake test -w .",
- " xmake test --workdir=`pwd`" },
- {'j', "jobs", "kv", tostring(os.default_njob()), "Set the number of parallel compilation jobs." },
- {'r', "rebuild", "k", nil , "Rebuild the target." },
+ {'g', "group", "kv", nil, "Run all tests of the given group. It supports path pattern matching.",
+ "e.g.",
+ " xmake test -g test",
+ " xmake test -g test_*",
+ " xmake test --group=benchmark/*"},
+ {'w', "workdir", "kv", nil, "Work directory of running targets, default is folder of targetfile",
+ "e.g.",
+ " xmake test -w .",
+ " xmake test --workdir=`pwd`"},
+ {'j', "jobs", "kv", tostring(os.default_njob()),
+ "Set the number of parallel compilation jobs."},
+ {'r', "rebuild", "k", nil, "Rebuild the target."},
{},
- {nil, "tests", "vs", nil , "The test names. It support pattern matching.",
- "e.g.",
- " xmake test foo",
- " xmake test */foo",
- " xmake test targetname/*" }
+ {nil, "tests", "vs", nil, "The test names. It supports pattern matching.",
+ "e.g.",
+ " xmake test foo",
+ " xmake test */foo",
+ " xmake test targetname/*"},
}
}
-
-
-
diff --git a/xmake/actions/uninstall/xmake.lua b/xmake/actions/uninstall/xmake.lua
index a31b7736b..2e43c55ed 100644
--- a/xmake/actions/uninstall/xmake.lua
+++ b/xmake/actions/uninstall/xmake.lua
@@ -26,27 +26,27 @@ task("uninstall")
description = "Uninstall the project binary files.",
shortname = 'u',
options = {
- {nil, "installdir", "kv", nil , "Set the install directory.",
- "e.g.",
- " $ xmake uninstall --installdir=/usr/local",
- "or $ DESTDIR=/usr/local xmake uninstall",
- "or $ INSTALLDIR=/usr/local xmake uninstall" },
- {nil, "bindir", "kv", nil , "Set install binaries directory in INSTALLDIR/DIR. (default: ${installdir}/bin)"},
- {nil, "libdir", "kv", nil , "Set install libraries directory in INSTALLDIR/DIR. (default: ${installdir}/lib)"},
- {nil, "includedir", "kv", nil , "Set install includes directory in INSTALLDIR/DIR. (default: ${installdir}/include)"},
- {'g', "group", "kv", nil , "Uninstall all targets of the given group. It support path pattern matching.",
- "e.g.",
- " xmake uninstall -g test",
- " xmake uninstall -g test_*",
- " xmake uninstall --group=benchmark/*" },
- {nil, "admin", "k", nil , "Try to request administrator permission to uninstall"},
- { },
- {nil, "targets", "vs", nil , "The target names. It will uninstall all default targets if this parameter is not specified.",
- "e.g.",
- " xmake uninstall target1 target2 ...",
- values = function (complete, opt)
- return import("private.utils.complete_helper.targets")(complete, opt)
- end}
+ {nil, "installdir", "kv", nil, "Set the install directory.",
+ "e.g.",
+ " $ xmake uninstall --installdir=/usr/local",
+ "or $ DESTDIR=/usr/local xmake uninstall",
+ "or $ INSTALLDIR=/usr/local xmake uninstall"},
+ {nil, "bindir", "kv", nil, "Set install binaries directory in INSTALLDIR/DIR. (default: ${installdir}/bin)"},
+ {nil, "libdir", "kv", nil, "Set install libraries directory in INSTALLDIR/DIR. (default: ${installdir}/lib)"},
+ {nil, "includedir", "kv", nil, "Set install includes directory in INSTALLDIR/DIR. (default: ${installdir}/include)"},
+ {'g', "group", "kv", nil, "Uninstall all targets of the given group. It supports path pattern matching.",
+ "e.g.",
+ " xmake uninstall -g test",
+ " xmake uninstall -g test_*",
+ " xmake uninstall --group=benchmark/*"},
+ {nil, "admin", "k", nil, "Try to request administrator permission to uninstall"},
+ {},
+ {nil, "targets", "vs", nil, "The target names. It will uninstall all default targets if this parameter is not specified.",
+ "e.g.",
+ " xmake uninstall target1 target2 ...",
+ values = function (complete, opt)
+ return import("private.utils.complete_helper.targets")(complete, opt)
+ end},
}
}
diff --git a/xmake/actions/update/xmake.lua b/xmake/actions/update/xmake.lua
index 1c4045461..8ca11d971 100644
--- a/xmake/actions/update/xmake.lua
+++ b/xmake/actions/update/xmake.lua
@@ -18,75 +18,62 @@
-- @file xmake.lua
--
--- define task
task("update")
-
- -- set category
set_category("action")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake update [options] [xmakever]"
-
- -- description
- , description = "Update and uninstall the xmake program."
-
- -- options
- , options =
- {
- {nil, "uninstall", "k", nil, "Uninstall the current xmake program." }
- , { }
- , {'s', "scriptonly", "k", nil, "Update scripts only." }
- , {nil, "integrate", "k", nil, "Integrate xmake with default shell." }
- , {'f', "force", "k", nil, "Force to update and reinstall the given version." }
- , {nil, "xmakever", "v", nil, "The given xmake version, or a git source (and branch). ",
- "e.g.",
- " from official source: ",
- " latest, ~2.2.3, dev, master",
- " from custom source:",
- " https://github.com/xmake-io/xmake",
- " github:xmake-io/xmake#~2.2.3",
- " git://github.com/xmake-io/xmake.git#master",
- values = function (complete)
- if not complete then
- return
- end
- return try{ function ()
- import("private.action.update.fetch_version")
+ usage = "xmake update [options] [xmakever]",
+ description = "Update and uninstall the xmake program.",
+ options = {
+ {nil, "uninstall", "k", nil, "Uninstall the current xmake program."},
+ {},
+ {'s', "scriptonly", "k", nil, "Update scripts only."},
+ {nil, "integrate", "k", nil, "Integrate xmake with default shell."},
+ {'f', "force", "k", nil, "Force to update and reinstall the given version."},
+ {nil, "xmakever", "v", nil, "The given xmake version, or a git source (and branch). ",
+ "e.g.",
+ " from official source: ",
+ " latest, ~2.2.3, dev, master",
+ " from custom source:",
+ " https://github.com/xmake-io/xmake",
+ " github:xmake-io/xmake#~2.2.3",
+ " git://github.com/xmake-io/xmake.git#master",
+ values = function (complete)
+ if not complete then
+ return
+ end
+ return try{ function ()
+ import("private.action.update.fetch_version")
- local seg = complete:split('#', { plain = true, limit = 2, strict = true })
- if #seg == 1 then
- if seg[1]:find(':', 1, true) then
- -- incomplete custom source
- return
- else
- seg[1] = ""
- end
- end
+ local seg = complete:split('#', { plain = true, limit = 2, strict = true })
+ if #seg == 1 then
+ if seg[1]:find(':', 1, true) then
+ -- incomplete custom source
+ return
+ else
+ seg[1] = ""
+ end
+ end
- local versions = fetch_version(seg[1])
- for i,v in ipairs(versions.tags) do
- if v:startswith("v") and #v > 5 then
- versions.tags[i] = v:sub(2)
- end
- end
- local candidates = table.join("latest", versions.branches, table.reverse(versions.tags))
- if versions.is_official then
- return candidates
- else
- for i, v in ipairs(candidates) do
- candidates[i] = seg[1] .. "#" .. v
- end
- return candidates
- end
- end }
- end}
- }
- }
+ local versions = fetch_version(seg[1])
+ for i,v in ipairs(versions.tags) do
+ if v:startswith("v") and #v > 5 then
+ versions.tags[i] = v:sub(2)
+ end
+ end
+ local candidates = table.join("latest", versions.branches, table.reverse(versions.tags))
+ if versions.is_official then
+ return candidates
+ else
+ for i, v in ipairs(candidates) do
+ candidates[i] = seg[1] .. "#" .. v
+ end
+ return candidates
+ end
+ end }
+ end},
+ }
+ }
diff --git a/xmake/plugins/check/xmake.lua b/xmake/plugins/check/xmake.lua
index 07b045a71..4664c3888 100644
--- a/xmake/plugins/check/xmake.lua
+++ b/xmake/plugins/check/xmake.lua
@@ -34,12 +34,11 @@ task("check")
" - xmake check api.target.languages",
"",
"The supported checkers list:",
- values = function (complete, opt)
- return import("private.check.checker").complete(complete, opt)
- end},
+ values = function (complete, opt)
+ return import("private.check.checker").complete(complete, opt)
+ end},
{nil, "arguments", "vs", nil, "Set the checker arguments.",
"e.g.",
- " - xmake check clang.tidy [arguments]"}
+ " - xmake check clang.tidy [arguments]"},
}
}
-
diff --git a/xmake/plugins/doxygen/xmake.lua b/xmake/plugins/doxygen/xmake.lua
index a849af053..f9adc0126 100644
--- a/xmake/plugins/doxygen/xmake.lua
+++ b/xmake/plugins/doxygen/xmake.lua
@@ -18,31 +18,15 @@
-- @file doxygen.lua
--
--- define task
task("doxygen")
-
- -- set category
set_category("plugin")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake doxygen [options] [arguments]"
-
- -- description
- , description = "Generate the doxygen document."
-
- -- options
- , options =
- {
- {'o', "outputdir", "kv", nil, "Set the output directory." }
- , {}
- , {nil, "srcdir", "v", "src", "Set the source code directory." }
- }
- }
-
-
-
+ usage = "xmake doxygen [options] [arguments]",
+ description = "Generate the doxygen document.",
+ options = {
+ {'o', "outputdir", "kv", nil, "Set the output directory."},
+ {},
+ {nil, "srcdir", "v", "src", "Set the source code directory."},
+ }
+ }
diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua
index 5de1b8120..964fa1d34 100644
--- a/xmake/plugins/format/xmake.lua
+++ b/xmake/plugins/format/xmake.lua
@@ -22,35 +22,34 @@ task("format")
set_category("plugin")
on_run("main")
set_menu {
- usage = "xmake format [options] [arguments]",
- description = "Format the current project.",
- options = {
- {'s', "style", "kv", nil, "Set the path of .clang-format file, a coding style",
- values = {"LLVM", "Google", "Chromium", "Mozilla", "WebKit"}},
- {nil, "create", "k", nil, "Create a .clang-format file from a coding style"},
- {'n', "dry-run", "k", nil, "Do not make any changes, just show the files that would be formatted."},
- {'e', "error", "k", nil, "If set, changes formatting warnings to errors."},
- {'j', "jobs", "kv", tostring(os.default_njob()),
- "Set the number of parallel format jobs."},
- {'a', "all", "k", nil, "Format all targets."},
- {'g', "group", "kv", nil, "Format all targets of the given group. It support path pattern matching.",
- "e.g.",
- " xmake format -g test",
- " xmake format -g test_*",
- " xmake format --group=benchmark/*"},
- {'f', "files", "kv", nil, "Build the given source files.",
- "e.g.",
- " - xmake format --files=src/main.c",
- " - xmake format --files='src/*.c' [target]",
- " - xmake format --files='src/**.c|excluded_file.c'",
- " - xmake format --files='src/main.c" .. path.envsep() .. "src/test.c'" },
- {},
- {nil, "targets", "vs", nil, "The target names. It will format all default targets if this parameter is not specified.",
- "e.g.",
- " xmake format target1 target2 ..."
- , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
- }
- }
-
-
-
+ usage = "xmake format [options] [arguments]",
+ description = "Format the current project.",
+ options = {
+ {'s', "style", "kv", nil, "Set the path of .clang-format file, a coding style",
+ values = {"LLVM", "Google", "Chromium", "Mozilla", "WebKit"}},
+ {nil, "create", "k", nil, "Create a .clang-format file from a coding style"},
+ {'n', "dry-run", "k", nil, "Do not make any changes, just show the files that would be formatted."},
+ {'e', "error", "k", nil, "If set, changes formatting warnings to errors."},
+ {'j', "jobs", "kv", tostring(os.default_njob()),
+ "Set the number of parallel format jobs."},
+ {'a', "all", "k", nil, "Format all targets."},
+ {'g', "group", "kv", nil, "Format all targets of the given group. It supports path pattern matching.",
+ "e.g.",
+ " xmake format -g test",
+ " xmake format -g test_*",
+ " xmake format --group=benchmark/*"},
+ {'f', "files", "kv", nil, "Build the given source files.",
+ "e.g.",
+ " - xmake format --files=src/main.c",
+ " - xmake format --files='src/*.c' [target]",
+ " - xmake format --files='src/**.c|excluded_file.c'",
+ " - xmake format --files='src/main.c" .. path.envsep() .. "src/test.c'"},
+ {},
+ {nil, "targets", "vs", nil, "The target names. It will format all default targets if this parameter is not specified.",
+ "e.g.",
+ " xmake format target1 target2 ...",
+ values = function (complete, opt)
+ return import("private.utils.complete_helper.targets")(complete, opt)
+ end},
+ }
+ }
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua
index dee1707b6..2c56c637e 100644
--- a/xmake/plugins/lua/xmake.lua
+++ b/xmake/plugins/lua/xmake.lua
@@ -18,69 +18,49 @@
-- @file xmake.lua
--
--- define task
task("lua")
-
- -- set category
set_category("plugin")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake lua|l [options] [script] [arguments]"
-
- -- description
- , description = "Run the lua script."
-
- -- xmake l
- , shortname = 'l'
-
- -- options
- , options =
- {
-
- {'l', "list" , "k" , nil , "List all scripts." }
- , {'c', "command" , "k" , nil , "Run script as command" }
- , {'d', "deserialize" , "kv" , nil , "Deserialize arguments starts with given prefix" }
- , {nil, "stdin" , "k" , nil , "Run script from stdin",
- "e.g.",
- " - echo 'print(\"hello\")' | xmake lua --stdin",
- " - cat script.lua | xmake lua --stdin"
- }
- , {nil, "script" , "v" , nil , "Run the given lua script name, file or module and enter interactive mode if no given script.",
- "e.g.",
- " - xmake lua (enter interactive mode)",
- " - xmake lua /tmp/script.lua",
- " - xmake lua echo 'hello xmake'",
- " - xmake lua core.xxx.xxx",
- " - xmake lua -c 'print(...)' hello xmake!"
- , values = function (complete, opt)
- if not complete or opt.command or opt.list then
- return
- end
- local list = import("main.scripts")()
- if list and complete then
- local result = {}
- for _, item in ipairs(list) do
- if item:startswith(complete) then
- table.insert(result, item)
- end
- end
- if #result > 0 then
- return result
- end
- end
- -- we just return nil and fallback to system autocomplete
- -- it will complete file path, e.g. `xmake l scripts/test.lua`
- end }
- , {nil, "arguments" , "vs" , nil , "The script arguments, use '--deserialize' option to enable deserializing.",
- "e.g.",
- " - xmake lua -d@ lib.detect.find_tool tar @{version=true}" }
- }
- }
-
-
-
+ usage = "xmake lua|l [options] [script] [arguments]",
+ description = "Run the lua script.",
+ shortname = 'l',
+ options = {
+ {'l', "list", "k", nil, "List all scripts."},
+ {'c', "command", "k", nil, "Run script as command"},
+ {'d', "deserialize", "kv", nil, "Deserialize arguments starts with given prefix"},
+ {nil, "stdin", "k", nil, "Run script from stdin",
+ "e.g.",
+ " - echo 'print(\"hello\")' | xmake lua --stdin",
+ " - cat script.lua | xmake lua --stdin"},
+ {nil, "script", "v", nil, "Run the given lua script name, file or module and enter interactive mode if no given script.",
+ "e.g.",
+ " - xmake lua (enter interactive mode)",
+ " - xmake lua /tmp/script.lua",
+ " - xmake lua echo 'hello xmake'",
+ " - xmake lua core.xxx.xxx",
+ " - xmake lua -c 'print(...)' hello xmake!",
+ values = function (complete, opt)
+ if not complete or opt.command or opt.list then
+ return
+ end
+ local list = import("main.scripts")()
+ if list and complete then
+ local result = {}
+ for _, item in ipairs(list) do
+ if item:startswith(complete) then
+ table.insert(result, item)
+ end
+ end
+ if #result > 0 then
+ return result
+ end
+ end
+ -- we just return nil and fallback to system autocomplete
+ -- it will complete file path, e.g. `xmake l scripts/test.lua`
+ end},
+ {nil, "arguments", "vs", nil, "The script arguments, use '--deserialize' option to enable deserializing.",
+ "e.g.",
+ " - xmake lua -d@ lib.detect.find_tool tar @{version=true}"},
+ }
+ }
diff --git a/xmake/plugins/macro/xmake.lua b/xmake/plugins/macro/xmake.lua
index 2a8710924..2cd022d6a 100644
--- a/xmake/plugins/macro/xmake.lua
+++ b/xmake/plugins/macro/xmake.lua
@@ -18,69 +18,54 @@
-- @file macro.lua
--
--- define task
task("macro")
-
- -- set category
set_category("plugin")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake macro|m [options] [name] [arguments]"
-
- -- description
- , description = "Run the given macro."
-
- -- xmake m
- , shortname = 'm'
-
- -- options
- , options =
- {
- {'b', "begin", "k", nil, "Start to record macro."
- , "e.g."
- , "Record macro with name: test"
- , " xmake macro --begin"
- , " xmake config --plat=macosx"
- , " xmake clean"
- , " xmake -r"
- , " xmake package"
- , " xmake macro --end test" }
- , {'e', "end", "k", nil, "Stop to record macro." }
- , {}
- , {nil, "show", "k", nil, "Show the content of the given macro." }
- , {'l', "list", "k", nil, "List all macros." }
- , {'d', "delete", "k", nil, "Delete the given macro." }
- , {'c', "clear", "k", nil, "Clear the all macros." }
- , {}
- , {nil, "import", "kv", nil, "Import the given macro file or directory."
- , "e.g."
- , " xmake macro --import=/xxx/macro.lua test"
- , " xmake macro --import=/xxx/macrodir" }
- , {nil, "export", "kv", nil, "Export the given macro to file or directory."
- , "e.g."
- , " xmake macro --export=/xxx/macro.lua test"
- , " xmake macro --export=/xxx/macrodir" }
- , {}
- , {nil, "name", "v", ".", "Set the macro name."
- , "e.g."
- , " Run the given macro: xmake macro test"
- , " Run the anonymous macro: xmake macro ."
- , " Run the last command: xmake macro .."
- , values = function (complete, opt)
- -- hide in help menu
- if not complete then return end
- -- don't need name
- if opt.begin or opt.list or opt.clear then return end
- -- name should be given by user
- if opt["end"] or opt.import then return end
+ usage = "xmake macro|m [options] [name] [arguments]",
+ description = "Run the given macro.",
+ shortname = 'm',
+ options = {
+ {'b', "begin", "k", nil, "Start to record macro.",
+ "e.g.",
+ "Record macro with name: test",
+ " xmake macro --begin",
+ " xmake config --plat=macosx",
+ " xmake clean",
+ " xmake -r",
+ " xmake package",
+ " xmake macro --end test"},
+ {'e', "end", "k", nil, "Stop to record macro."},
+ {},
+ {nil, "show", "k", nil, "Show the content of the given macro."},
+ {'l', "list", "k", nil, "List all macros."},
+ {'d', "delete", "k", nil, "Delete the given macro."},
+ {'c', "clear", "k", nil, "Clear the all macros."},
+ {},
+ {nil, "import", "kv", nil, "Import the given macro file or directory.",
+ "e.g.",
+ " xmake macro --import=/xxx/macro.lua test",
+ " xmake macro --import=/xxx/macrodir"},
+ {nil, "export", "kv", nil, "Export the given macro to file or directory.",
+ "e.g.",
+ " xmake macro --export=/xxx/macro.lua test",
+ " xmake macro --export=/xxx/macrodir"},
+ {},
+ {nil, "name", "v", ".", "Set the macro name.",
+ "e.g.",
+ " Run the given macro: xmake macro test",
+ " Run the anonymous macro: xmake macro .",
+ " Run the last command: xmake macro ..",
+ values = function (complete, opt)
+ -- hide in help menu
+ if not complete then return end
+ -- don't need name
+ if opt.begin or opt.list or opt.clear then return end
+ -- name should be given by user
+ if opt["end"] or opt.import then return end
- return import("main.macros")(".")
- end }
- , {nil, "arguments", "vs", nil, "Set the macro arguments." }
- }
- }
+ return import("main.macros")(".")
+ end},
+ {nil, "arguments", "vs", nil, "Set the macro arguments."}
+ }
+ }
diff --git a/xmake/plugins/pack/xmake.lua b/xmake/plugins/pack/xmake.lua
index f95abcf98..6e0a358aa 100644
--- a/xmake/plugins/pack/xmake.lua
+++ b/xmake/plugins/pack/xmake.lua
@@ -28,13 +28,14 @@ task("pack")
{'o', "outputdir", "kv", nil, "Set the output directory. (default: build/xpack)"},
{nil, "basename", "kv", nil, "Set the basename of the output file."},
{nil, "autobuild", "kv", true, "Build targets automatically."},
- {'j', "jobs", "kv", tostring(os.default_njob()), "Set the number of parallel compilation jobs." },
+ {'j', "jobs", "kv", tostring(os.default_njob()),
+ "Set the number of parallel compilation jobs."},
{'f', "formats", "kv", "all", "Pack the given package formats.",
"e.g.",
" - xmake pack -f nsis,deb,rpm",
"values:",
values = {"nsis", "wix", "deb", "srpm", "rpm", "runself", "targz", "tarxz", "zip", "srctargz", "srctarxz", "srczip"}},
{},
- {nil, "packages", "vs", nil, "The package names."}
+ {nil, "packages", "vs", nil, "The package names."},
}
}
diff --git a/xmake/plugins/plugin/xmake.lua b/xmake/plugins/plugin/xmake.lua
index f05021828..05d9e3631 100644
--- a/xmake/plugins/plugin/xmake.lua
+++ b/xmake/plugins/plugin/xmake.lua
@@ -25,12 +25,12 @@ task("plugin")
usage = "xmake plugin [options]",
description = "Manage plugins of xmake.",
options = {
- {'i', "install", "k", nil, "Install plugins." },
- {'u', "update", "k", nil, "Update plugins." },
- {'c', "clear", "k", nil, "Clear all installed plugins." },
- {nil, "plugins", "v", nil, "The plugins path or url.",
- "e.g.",
- " $ xmake plugin --install https://github.com/xmake-io/xmake-plugins",
- " $ xmake plugin --update"}
+ {'i', "install", "k", nil, "Install plugins."},
+ {'u', "update", "k", nil, "Update plugins."},
+ {'c', "clear", "k", nil, "Clear all installed plugins."},
+ {nil, "plugins", "v", nil, "The plugins path or url.",
+ "e.g.",
+ " $ xmake plugin --install https://github.com/xmake-io/xmake-plugins",
+ " $ xmake plugin --update"}
}
}
diff --git a/xmake/plugins/project/xmake.lua b/xmake/plugins/project/xmake.lua
index 15333d58b..ed5b35d9f 100644
--- a/xmake/plugins/project/xmake.lua
+++ b/xmake/plugins/project/xmake.lua
@@ -18,59 +18,43 @@
-- @file xmake.lua
--
--- define task
task("project")
-
- -- set category
set_category("plugin")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake project [options] [outputdir]"
-
- -- description
- , description = "Generate the project file."
-
- -- options
- , options =
- {
- {'k', "kind", "kv" , "makefile", "Set the project kind."
- , " - make"
- , " - xmakefile (makefile with xmake)"
- , " - cmake"
- , " - ninja"
- , " - xcode"
- , " - compile_flags"
- , " - compile_commands (clang compilation database with json format)"
- , " - vs (auto detect), vs2002 - vs2026"
- , " - vsxmake (auto detect), vsxmake2010 ~ vsxmake2026"
- , values = function (complete, opt)
- if not complete then return end
-
- local values = table.keys(import("main.makers")())
- table.sort(values, function (a, b) return a > b end)
- return values
- end }
- , {'m', "modes", "kv" , nil , "Set the project modes."
- , " e.g. "
- , " - xmake project -k vsxmake -m \"release,debug\"" }
- , {'a', "archs", "kv" , nil , "Set the project archs."
- , " e.g. "
- , " - xmake project -k vsxmake -a \"x86,x64\"" }
- , {'t', "target", "kv" , nil , "Set the project target."
- , " e.g. "
- , " - xmake project -k compile_commands -t \"custom\"" }
- , {nil, "lsp", "kv" , nil , "Set the LSP backend for compile_commands."
- , " e.g. "
- , " - xmake project -k compile_commands --lsp=clangd"
- , values = {"clangd", "cpptools", "ccls"}}
- , {nil, "outputdir", "v" , "." , "Set the output directory." }
- }
- }
-
-
+ usage = "xmake project [options] [outputdir]",
+ description = "Generate the project file.",
+ options = {
+ {'k', "kind", "kv", "makefile", "Set the project kind.",
+ " - make",
+ " - xmakefile (makefile with xmake)",
+ " - cmake",
+ " - ninja",
+ " - xcode",
+ " - compile_flags",
+ " - compile_commands (clang compilation database with json format)",
+ " - vs (auto detect), vs2002 - vs2026",
+ " - vsxmake (auto detect), vsxmake2010 ~ vsxmake2026",
+ values = function (complete, opt)
+ if not complete then return end
+ local values = table.keys(import("main.makers")())
+ table.sort(values, function (a, b) return a > b end)
+ return values
+ end},
+ {'m', "modes", "kv", nil, "Set the project modes.",
+ " e.g. ",
+ " - xmake project -k vsxmake -m \"release,debug\""},
+ {'a', "archs", "kv", nil, "Set the project archs.",
+ " e.g. ",
+ " - xmake project -k vsxmake -a \"x86,x64\""},
+ {'t', "target", "kv", nil, "Set the project target.",
+ " e.g. ",
+ " - xmake project -k compile_commands -t \"custom\""},
+ {nil, "lsp", "kv", nil, "Set the LSP backend for compile_commands.",
+ " e.g. ",
+ " - xmake project -k compile_commands --lsp=clangd",
+ values = {"clangd", "cpptools", "ccls"}},
+ {nil, "outputdir", "v", ".", "Set the output directory."}
+ }
+ }
diff --git a/xmake/plugins/repo/xmake.lua b/xmake/plugins/repo/xmake.lua
index 590bb665d..f7260e9b9 100644
--- a/xmake/plugins/repo/xmake.lua
+++ b/xmake/plugins/repo/xmake.lua
@@ -18,36 +18,23 @@
-- @file repo.lua
--
--- define task
task("repo")
-
- -- set category
set_category("plugin")
-
- -- on run
on_run("main")
-
- -- set menu
set_menu {
- -- usage
- usage = "xmake repo [options] [name] [url] [branch]"
-
- -- description
- , description = "Manage package repositories."
-
- -- options
- , options =
- {
- {'a', "add", "k", nil, "Add the given remote repository url." }
- , {'r', "remove", "k", nil, "Remove the given remote repository url." }
- , {'u', "update", "k", nil, "Update all local repositories from the remote." }
- , {'c', "clear", "k", nil, "Clear all added repositories." }
- , { }
- , {'l', "list", "k", nil, "List all added repositories." }
- , {'g', "global", "k", nil, "Save repository to global. (default: local)" }
- , { }
- , {nil, "name", "v", nil, "The repository name." }
- , {nil, "url", "v", nil, "The repository url" }
- , {nil, "branch", "v", nil, "The repository branch" }
- }
+ usage = "xmake repo [options] [name] [url] [branch]",
+ description = "Manage package repositories.",
+ options = {
+ {'a', "add", "k", nil, "Add the given remote repository url."},
+ {'r', "remove", "k", nil, "Remove the given remote repository url."},
+ {'u', "update", "k", nil, "Update all local repositories from the remote."},
+ {'c', "clear", "k", nil, "Clear all added repositories."},
+ {},
+ {'l', "list", "k", nil, "List all added repositories."},
+ {'g', "global", "k", nil, "Save repository to global. (default: local)"},
+ {},
+ {nil, "name", "v", nil, "The repository name."},
+ {nil, "url", "v", nil, "The repository url"},
+ {nil, "branch", "v", nil, "The repository branch"}
+ }
}
diff --git a/xmake/plugins/show/xmake.lua b/xmake/plugins/show/xmake.lua
index ef3ea0fe2..5cbe973e9 100644
--- a/xmake/plugins/show/xmake.lua
+++ b/xmake/plugins/show/xmake.lua
@@ -26,9 +26,9 @@ task("show")
description = "Show the given project information.",
options = {
{'l', "list", "kv", nil, "Show the values list of the given name.",
- values = function (complete, opt)
- return import("list").lists()
- end},
+ values = function (complete, opt)
+ return import("list").lists()
+ end},
{'g', "group", "kv", nil, "Filter targets by the given group name."},
{nil, "json", "k", false, "Show information with json format (deprecated, use --format=json)."},
{nil, "pretty", "k", false, "Enable pretty formatted output."},
@@ -44,14 +44,12 @@ task("show")
" - xmake show --info=depgraph --target=app",
" - xmake show --info=depgraph --format=json",
" - xmake show --info=depgraph --format=dot",
- values = function (complete, opt)
- return import("list").infos()
- end},
+ values = function (complete, opt)
+ return import("list").infos()
+ end},
{'t', "target", "kv", nil, "Show the information of the given target.",
- values = function (complete, opt)
- return import("private.utils.complete_helper.targets")(complete, opt)
- end}
+ values = function (complete, opt)
+ return import("private.utils.complete_helper.targets")(complete, opt)
+ end}
}
}
-
-
diff --git a/xmake/plugins/watch/xmake.lua b/xmake/plugins/watch/xmake.lua
index 1b04b092c..1583cab09 100644
--- a/xmake/plugins/watch/xmake.lua
+++ b/xmake/plugins/watch/xmake.lua
@@ -22,35 +22,31 @@ task("watch")
set_category("plugin")
on_run("main")
set_menu {
- usage = "xmake watch [options] [arguments]"
- , description = "Watch the project directories and run command."
- , options =
- {
- {'c', "commands" , "kv" , nil , "Run the multiple commands instead of the default build command.",
- "e.g.",
- " $ xmake watch -c 'xmake -rv'",
- " $ xmake watch -c 'xmake -vD; xmake run hello'"},
- {'s', "script" , "kv" , nil , "Run the given lua script file.",
- "e.g.",
- " $ xmake watch -s /tmp/watch.lua"},
- {'d', "watchdirs" , "kv" , nil , "Set the given recursive watch directories, the project directories will be watched by default.",
- "e.g.",
- " $ xmake watch -d src",
- " $ xmake watch -d 'src/*" .. path.envsep() .. "tests/**/subdir'"},
- {'p', "plaindirs" , "kv" , nil , "Set the given non-recursive watch directories, the project directories will be watched by default.",
- "e.g.",
- " $ xmake watch -p src",
- " $ xmake watch -p 'src/*" .. path.envsep() .. "tests/**/subdir'"},
- {'r', "run" , "k" , nil , "Build and run target."},
- {'t', "target" , "kv" , nil , "Build the given target.",
- values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end },
- {'-', "arbitrary" , "vs" , nil , "Run an arbitrary command.",
- "e.g.",
- " $ xmake watch -- echo hello xmake!",
- " $ xmake watch -- xmake run",
- " $ xmake watch -- xmake -rv"}
- }
- }
-
-
-
+ usage = "xmake watch [options] [arguments]",
+ description = "Watch the project directories and run command.",
+ options = {
+ {'c', "commands", "kv", nil, "Run the multiple commands instead of the default build command.",
+ "e.g.",
+ " $ xmake watch -c 'xmake -rv'",
+ " $ xmake watch -c 'xmake -vD; xmake run hello'"},
+ {'s', "script", "kv", nil, "Run the given lua script file.",
+ "e.g.",
+ " $ xmake watch -s /tmp/watch.lua"},
+ {'d', "watchdirs", "kv", nil, "Set the given recursive watch directories, the project directories will be watched by default.",
+ "e.g.",
+ " $ xmake watch -d src",
+ " $ xmake watch -d 'src/*" .. path.envsep() .. "tests/**/subdir'"},
+ {'p', "plaindirs", "kv", nil, "Set the given non-recursive watch directories, the project directories will be watched by default.",
+ "e.g.",
+ " $ xmake watch -p src",
+ " $ xmake watch -p 'src/*" .. path.envsep() .. "tests/**/subdir'"},
+ {'r', "run", "k", nil, "Build and run target."},
+ {'t', "target", "kv", nil, "Build the given target.",
+ values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end},
+ {'-', "arbitrary", "vs", nil, "Run an arbitrary command.",
+ "e.g.",
+ " $ xmake watch -- echo hello xmake!",
+ " $ xmake watch -- xmake run",
+ " $ xmake watch -- xmake -rv"}
+ }
+ }