summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-04-01 00:50:15 +0800
committerruki <[email protected]>2017-04-01 00:50:15 +0800
commit4124df8db74770f526942dbb18c4c834b39b917a (patch)
treecb58b86c2a53f85adef61be4cf416595178f7ba4
parent4e14211557bc663a2e4e43eadf7420fe99984050 (diff)
add --all arguments for build, install and package
-rw-r--r--docs/manual.md8
-rwxr-xr-xdocs/zh/manual.md9
-rw-r--r--xmake/actions/build/builder.lua5
-rw-r--r--xmake/actions/build/xmake.lua5
-rw-r--r--xmake/actions/install/install.lua4
-rw-r--r--xmake/actions/install/install_admin.lua2
-rw-r--r--xmake/actions/install/main.lua6
-rw-r--r--xmake/actions/install/xmake.lua1
-rw-r--r--xmake/actions/package/main.lua4
-rw-r--r--xmake/actions/package/xmake.lua4
-rw-r--r--xmake/actions/run/main.lua4
-rw-r--r--xmake/actions/run/xmake.lua1
12 files changed, 35 insertions, 18 deletions
diff --git a/docs/manual.md b/docs/manual.md
index 98eb42360..201d0ab41 100644
--- a/docs/manual.md
+++ b/docs/manual.md
@@ -649,10 +649,16 @@ target("test3")
如果不想使用默认的目标,那么可以手动指定需要构建安装的目标:
```bash
-$ xmake [-b|--build] targetname
+$ xmake build targetname
$ xmake install targetname
```
+如果要强制构建安装所有目标,可以传入`[-a|--all]`参数:
+
+```bash
+$ xmake build [-a|--all]
+$ xmake install [-a|--all]
+```
##### target:set_options
###### 设置关联选项
diff --git a/docs/zh/manual.md b/docs/zh/manual.md
index 68cc5a7c4..17d179f54 100755
--- a/docs/zh/manual.md
+++ b/docs/zh/manual.md
@@ -651,10 +651,17 @@ target("test3")
如果不想使用默认的目标,那么可以手动指定需要构建安装的目标:
```bash
-$ xmake [-b|--build] targetname
+$ xmake build targetname
$ xmake install targetname
```
+如果要强制构建安装所有目标,可以传入`[-a|--all]`参数:
+
+```bash
+$ xmake build [-a|--all]
+$ xmake install [-a|--all]
+```
+
##### target:set_options
###### 设置关联选项
diff --git a/xmake/actions/build/builder.lua b/xmake/actions/build/builder.lua
index 3053c1fda..beef67c41 100644
--- a/xmake/actions/build/builder.lua
+++ b/xmake/actions/build/builder.lua
@@ -23,6 +23,7 @@
--
-- imports
+import("core.base.option")
import("core.project.project")
import("core.platform.environment")
@@ -116,7 +117,7 @@ function _stat_target_count(targetname)
-- for default or all targets
for _, target in pairs(project.targets()) do
local default = target:get("default")
- if default == nil or default == true then
+ if default == nil or default == true or option.get("all") then
_stat_target_count_and_deps(target)
end
end
@@ -145,7 +146,7 @@ function build(targetname)
-- build default or all targets
for _, target in pairs(project.targets()) do
local default = target:get("default")
- if default == nil or default == true then
+ if default == nil or default == true or option.get("all") then
_build_target_and_deps(target)
end
end
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua
index 1451249f6..dc76f6457 100644
--- a/xmake/actions/build/xmake.lua
+++ b/xmake/actions/build/xmake.lua
@@ -42,8 +42,9 @@ task("build")
-- options
, options =
{
- {'b', "build", "k", nil, "Build project. This is default building mode and optional." }
- , {'r', "rebuild", "k", nil, "Rebuild the project." }
+ {'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." }
, {}
, {'j', "jobs", "kv", "4", "Specifies the number of jobs to build simultaneously." }
diff --git a/xmake/actions/install/install.lua b/xmake/actions/install/install.lua
index 720e300b6..c1e1d9c3d 100644
--- a/xmake/actions/install/install.lua
+++ b/xmake/actions/install/install.lua
@@ -80,13 +80,13 @@ function install(targetname)
_g.finished = {}
-- install the given target?
- if targetname then
+ if targetname and not targetname:startswith("__") then
_install_target_and_deps(project.target(targetname))
else
-- install default or all targets
for _, target in pairs(project.targets()) do
local default = target:get("default")
- if default == nil or default == true then
+ if default == nil or default == true or targetname == "__all" then
_install_target_and_deps(target)
end
end
diff --git a/xmake/actions/install/install_admin.lua b/xmake/actions/install/install_admin.lua
index 60a4ba9c0..386911027 100644
--- a/xmake/actions/install/install_admin.lua
+++ b/xmake/actions/install/install_admin.lua
@@ -53,7 +53,7 @@ function main(targetname, installdir)
end
-- install target
- install.install(ifelse(targetname ~= "__all", targetname, nil))
+ install.install(targetname)
-- restore the previous option context
option.restore()
diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua
index 150f90659..3ca155789 100644
--- a/xmake/actions/install/main.lua
+++ b/xmake/actions/install/main.lua
@@ -35,7 +35,7 @@ function main()
local targetname = option.get("target")
-- build it first
- task.run("build", {target = targetname})
+ task.run("build", {target = targetname, all = option.get("all")})
-- trace
print("installing to %s ...", option.get("installdir") or platform.get("installdir"))
@@ -46,7 +46,7 @@ function main()
function ()
-- install target
- install.install(targetname)
+ install.install(targetname or ifelse(option.get("all"), "__all", "__def"))
-- trace
cprint("${bright}install ok!${clear}${ok_hand}")
@@ -73,7 +73,7 @@ function main()
if answer == 'y' or answer == '' then
-- install target with administrator permission
- os.sudol(os.runv, path.join(os.scriptdir(), "install_admin.lua"), {targetname or "__all", option.get("installdir")})
+ os.sudol(os.runv, path.join(os.scriptdir(), "install_admin.lua"), {targetname or ifelse(option.get("all"), "__all", "__def"), option.get("installdir")})
-- trace
cprint("${bright}install ok!${clear}${ok_hand}")
diff --git a/xmake/actions/install/xmake.lua b/xmake/actions/install/xmake.lua
index f561fcba7..4a737d010 100644
--- a/xmake/actions/install/xmake.lua
+++ b/xmake/actions/install/xmake.lua
@@ -46,6 +46,7 @@ task("install")
, options =
{
{'o', "installdir", "kv", nil, "Set the install directory." }
+ , {'a', "all", "k", nil, "Install all targets." }
, {}
, {nil, "target", "v", nil, "Install the given target." }
diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua
index 7f931651b..0e0566c92 100644
--- a/xmake/actions/package/main.lua
+++ b/xmake/actions/package/main.lua
@@ -196,7 +196,7 @@ function main()
local targetname = option.get("target")
-- build it first
- task.run("build", {target = targetname})
+ task.run("build", {target = targetname, all = option.get("all")})
-- init finished states
_g.finished = {}
@@ -208,7 +208,7 @@ function main()
-- package default or all targets
for _, target in pairs(project.targets()) do
local default = target:get("default")
- if default == nil or default == true then
+ if default == nil or default == true or option.get("all") then
_package_target_and_deps(target)
end
end
diff --git a/xmake/actions/package/xmake.lua b/xmake/actions/package/xmake.lua
index 60f7b8eb9..fa4fc4402 100644
--- a/xmake/actions/package/xmake.lua
+++ b/xmake/actions/package/xmake.lua
@@ -46,9 +46,9 @@ task("package")
, options =
{
{'o', "outputdir", "kv", nil, "Set the output directory." }
- , {'a', "archs", "kv", nil, "Compile for the given architecture. (deprecated)" }
+ , {'a', "all", "k", nil, "Package all targets." }
, {}
- , {nil, "target", "v", nil, "Package a given target" }
+ , {nil, "target", "v", nil, "Package a given target." }
}
}
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua
index 57778985e..3082783fe 100644
--- a/xmake/actions/run/main.lua
+++ b/xmake/actions/run/main.lua
@@ -92,7 +92,7 @@ function main()
local targetname = option.get("target")
-- build it first
- task.run("build", {target = targetname})
+ task.run("build", {target = targetname, all = option.get("all")})
-- enter project directory
local olddir = os.cd(project.directory())
@@ -104,7 +104,7 @@ function main()
-- run default or all binary targets
for _, target in pairs(project.targets()) do
local default = target:get("default")
- if (default == nil or default == true) and target:get("kind") == "binary" then
+ if (default == nil or default == true or option.get("all")) and target:get("kind") == "binary" then
_run(target)
end
end
diff --git a/xmake/actions/run/xmake.lua b/xmake/actions/run/xmake.lua
index ee6c1aa0b..13d19a283 100644
--- a/xmake/actions/run/xmake.lua
+++ b/xmake/actions/run/xmake.lua
@@ -46,6 +46,7 @@ task("run")
, options =
{
{'d', "debug", "k", nil, "Run and debug the given target." }
+ , {'a', "all", "k", nil, "Run all targets." }
, {}
, {nil, "target", "v", nil, "Run the given target." }