summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
Diffstat (limited to 'xmake')
-rw-r--r--xmake/actions/build/xmake.lua2
-rw-r--r--xmake/actions/clean/xmake.lua2
-rw-r--r--xmake/actions/config/xmake.lua6
-rw-r--r--xmake/actions/install/xmake.lua2
-rw-r--r--xmake/actions/package/xmake.lua2
-rw-r--r--xmake/actions/run/xmake.lua17
-rw-r--r--xmake/actions/uninstall/xmake.lua2
-rw-r--r--xmake/core/project/target.lua34
-rw-r--r--xmake/modules/private/utils/complete_helper.lua46
-rw-r--r--xmake/plugins/show/main.lua2
-rw-r--r--xmake/plugins/show/xmake.lua3
11 files changed, 76 insertions, 42 deletions
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua
index 8d3b28291..700bb8996 100644
--- a/xmake/actions/build/xmake.lua
+++ b/xmake/actions/build/xmake.lua
@@ -59,7 +59,7 @@ task("build")
, {}
, {nil, "target", "v", nil , "The target name. It will build all default targets if this parameter is not specified."
- , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
+ , 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 0d9b265c1..2c0213d37 100644
--- a/xmake/actions/clean/xmake.lua
+++ b/xmake/actions/clean/xmake.lua
@@ -45,7 +45,7 @@ task("clean")
, {}
, {nil, "target", "v", nil , "The target name. It will clean all default targets if this parameter is not specified."
- , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
+ , 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 c53844e5c..2c8bb97c1 100644
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -206,11 +206,7 @@ task("config")
, {}
, {nil, "target", "v" , nil , "Configure for the given target."
- , values = function ()
- return try { function ()
- return table.keys(import("core.project.project").targets())
- end }
- end }
+ , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
}
}
diff --git a/xmake/actions/install/xmake.lua b/xmake/actions/install/xmake.lua
index 09ecc883f..3b859238a 100644
--- a/xmake/actions/install/xmake.lua
+++ b/xmake/actions/install/xmake.lua
@@ -50,7 +50,7 @@ task("install")
, { }
, {nil, "target", "v", nil , "The target name. It will install all default targets if this parameter is not specified."
- , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
+ , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
}
}
diff --git a/xmake/actions/package/xmake.lua b/xmake/actions/package/xmake.lua
index 13c3f4b28..d15c3eec1 100644
--- a/xmake/actions/package/xmake.lua
+++ b/xmake/actions/package/xmake.lua
@@ -45,7 +45,7 @@ task("package")
, {'a', "all", "k", nil , "Package all targets." }
, {}
, {nil, "target", "v", nil , "The target name. It will package all default targets if this parameter is not specified."
- , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
+ , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
}
}
diff --git a/xmake/actions/run/xmake.lua b/xmake/actions/run/xmake.lua
index bfdce3af1..a44eb1158 100644
--- a/xmake/actions/run/xmake.lua
+++ b/xmake/actions/run/xmake.lua
@@ -49,21 +49,8 @@ task("run")
" --workdir=`pwd`" }
, {}
, {nil, "target", "v", nil , "The target name. It will run all default targets if this parameter is not specified."
- , values = function ()
- return try{
- function ()
- import("core.project.project")
- local targets = project.targets()
- local runable = {}
- for k, v in pairs(targets) do
- if v:script("run") or v:get("kind") == "binary" then
- table.insert(runable, k)
- end
- end
- return runable
- end
- }
- end }
+ , 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/uninstall/xmake.lua b/xmake/actions/uninstall/xmake.lua
index 4f70922c2..882499668 100644
--- a/xmake/actions/uninstall/xmake.lua
+++ b/xmake/actions/uninstall/xmake.lua
@@ -52,7 +52,7 @@ task("uninstall")
"or $ PREFIX=local xmake uninstall" }
, { }
, {nil, "target", "v", nil , "The target name. It will uninstall all default targets if this parameter is not specified."
- , values = function () return try{ function () return table.keys(import("core.project.project").targets()) end } end }
+ , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end }
}
}
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 652ae4758..d7f44c4af 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -881,24 +881,28 @@ function _instance:targetdir()
-- get build directory
targetdir = config.buildir()
+ end
- -- append plat sub-directory
- local plat = self:plat()
- if plat then
- targetdir = path.join(targetdir, plat)
- end
+ if not targetdir then
+ return nil
+ end
- -- append arch sub-directory
- local arch = self:arch()
- if arch then
- targetdir = path.join(targetdir, arch)
- end
+ -- append plat sub-directory
+ local plat = self:plat()
+ if plat then
+ targetdir = path.join(targetdir, plat)
+ end
- -- append mode sub-directory
- local mode = config.get("mode")
- if mode then
- targetdir = path.join(targetdir, mode)
- end
+ -- append arch sub-directory
+ local arch = self:arch()
+ if arch then
+ targetdir = path.join(targetdir, arch)
+ end
+
+ -- append mode sub-directory
+ local mode = config.get("mode")
+ if mode then
+ targetdir = path.join(targetdir, mode)
end
-- ok?
diff --git a/xmake/modules/private/utils/complete_helper.lua b/xmake/modules/private/utils/complete_helper.lua
new file mode 100644
index 000000000..a8a547dd7
--- /dev/null
+++ b/xmake/modules/private/utils/complete_helper.lua
@@ -0,0 +1,46 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
+--
+-- @author OpportunityLiu
+-- @file complete_helper.lua
+--
+
+function targets()
+ return try
+ {
+ function ()
+ import("core.project.project")
+ return table.keys(project.targets())
+ end
+ }
+end
+
+function runable_targets()
+ return try
+ {
+ function ()
+ import("core.project.project")
+ local targets = project.targets()
+ local runable = {}
+ for k, v in pairs(targets) do
+ if v:script("run") or v:get("kind") == "binary" then
+ table.insert(runable, k)
+ end
+ end
+ return runable
+ end
+ }
+end \ No newline at end of file
diff --git a/xmake/plugins/show/main.lua b/xmake/plugins/show/main.lua
index b1c7b3183..9503b1a75 100644
--- a/xmake/plugins/show/main.lua
+++ b/xmake/plugins/show/main.lua
@@ -23,7 +23,7 @@ import("core.base.option")
-- show list
function _show_list(name)
- assert(import("lists." .. name, {try = true, anonymous = true}), "unknown list name(%s)", name)()
+ assert(#name > 0 and import("lists." .. name, {try = true, anonymous = true}), "unknown list name(%s)", name)()
end
-- main entry
diff --git a/xmake/plugins/show/xmake.lua b/xmake/plugins/show/xmake.lua
index 729d2eece..159eec1a6 100644
--- a/xmake/plugins/show/xmake.lua
+++ b/xmake/plugins/show/xmake.lua
@@ -42,7 +42,8 @@ task("show")
, values = function (complete, opt)
return import("list").lists()
end},
- {'t', "target" , "kv" , nil , "Show the information of the given target."}
+ {'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 }
}
}