diff options
| author | ruki <[email protected]> | 2019-06-27 09:34:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-06-27 09:34:29 +0800 |
| commit | c747e9d70e13f0ebb52ae633d55bd08b50d38284 (patch) | |
| tree | 6affcfdb890d41b921a6f7b3c5525d48ac002550 /xmake | |
| parent | 2906db4c7cfc5f3398c47f62d9f427e02acacd9f (diff) | |
| parent | 9f73278f8f7631bc53daba27ffdf84d96068c562 (diff) | |
Merge branch 'submodule' into dev
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/actions/update/main.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/devel/git/checkout.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/devel/git/clean.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/devel/git/clone.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/devel/git/ls_remote.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/devel/git/pull.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/devel/git/submodule/update.lua | 77 | ||||
| -rw-r--r-- | xmake/plugins/hello/xmake.lua | 45 |
8 files changed, 105 insertions, 47 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua index 8ef60b5cb..b30ba0799 100644 --- a/xmake/actions/update/main.lua +++ b/xmake/actions/update/main.lua @@ -24,6 +24,7 @@ import("core.base.option") import("core.base.task") import("net.http") import("devel.git") +import("devel.git.submodule") import("net.fasturl") import("core.base.privilege") import("privilege.sudo") @@ -319,8 +320,11 @@ function main() if version:find('.', 1, true) then git.clone(url, {outputdir = sourcedir}) git.checkout(version, {repodir = sourcedir}) + if not script_only then + submodule.update({repodir = sourcedir, init = true, recursive = true}) + end else - git.clone(url, {depth = 1, branch = version, outputdir = sourcedir}) + git.clone(url, {depth = 1, recursive = not script_only, branch = version, outputdir = sourcedir}) end end return true diff --git a/xmake/modules/devel/git/checkout.lua b/xmake/modules/devel/git/checkout.lua index 12541e5ac..4a4c92bae 100644 --- a/xmake/modules/devel/git/checkout.lua +++ b/xmake/modules/devel/git/checkout.lua @@ -38,6 +38,9 @@ import("lib.detect.find_tool") -- function main(commit, opt) + -- init options + opt = opt or {} + -- find git local git = find_tool("git") if not git then diff --git a/xmake/modules/devel/git/clean.lua b/xmake/modules/devel/git/clean.lua index 2d80c2bac..4ed39a20f 100644 --- a/xmake/modules/devel/git/clean.lua +++ b/xmake/modules/devel/git/clean.lua @@ -37,6 +37,9 @@ import("lib.detect.find_tool") -- function main(opt) + -- init options + opt = opt or {} + -- find git local git = find_tool("git") if not git then diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua index 75a652b1d..4a77abbf5 100644 --- a/xmake/modules/devel/git/clone.lua +++ b/xmake/modules/devel/git/clone.lua @@ -60,6 +60,11 @@ function main(url, opt) table.insert(argv, ifelse(type(opt.depth) == "number", tostring(opt.depth), opt.depth)) end + -- recursive? + if opt.recursive then + table.insert(argv, "--recursive") + end + -- set outputdir if opt.outputdir then table.insert(argv, path.translate(opt.outputdir)) diff --git a/xmake/modules/devel/git/ls_remote.lua b/xmake/modules/devel/git/ls_remote.lua index 391b85caf..e946a054a 100644 --- a/xmake/modules/devel/git/ls_remote.lua +++ b/xmake/modules/devel/git/ls_remote.lua @@ -50,8 +50,16 @@ function main(reftype, url) -- init reference type reftype = reftype or "refs" + -- init arguments + local argv = {"ls-remote", "--" .. reftype, url or "."} + + -- trace + if option.get("verbose") then + print("%s %s", git.program, os.args(argv)) + end + -- get refs - local data = os.iorunv(git.program, {"ls-remote", "--" .. reftype, url or "."}) + local data = os.iorunv(git.program, argv) -- get commmits and tags local refs = {} diff --git a/xmake/modules/devel/git/pull.lua b/xmake/modules/devel/git/pull.lua index 3e0b67b30..4c274a70b 100644 --- a/xmake/modules/devel/git/pull.lua +++ b/xmake/modules/devel/git/pull.lua @@ -37,6 +37,9 @@ import("lib.detect.find_tool") -- function main(opt) + -- init options + opt = opt or {} + -- find git local git = find_tool("git") if not git then diff --git a/xmake/modules/devel/git/submodule/update.lua b/xmake/modules/devel/git/submodule/update.lua new file mode 100644 index 000000000..403bf112d --- /dev/null +++ b/xmake/modules/devel/git/submodule/update.lua @@ -0,0 +1,77 @@ +--!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 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file update.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") + +-- update submodule +-- +-- @param opt the argument options, e.g. repodir, init, remote, force, checkout, merge, rebase, recursive, reference, pathes +-- +-- @code +-- +-- import("devel.git.submodule") +-- +-- submodule.update("master", {repodir = "/tmp/xmake", init = true, remote = true}) +-- submodule.update("v1.0.1", {repodir = "/tmp/xmake", recursive = true, reference = "xxx", pathes = "xxx"}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find git + local git = find_tool("git") + if not git then + return + end + + -- init argv + local argv = {"submodule", "update"} + for _, name in ipairs({"init", "remote", "force", "checkout", "merge", "rebase", "recursive"}) do + if opt[name] then + table.insert(argv, "--" .. name) + end + end + if opt.reference then + table.insert(argv, "--reference") + table.insert(argv, opt.reference) + end + if opt.pathes then + table.join2(argv, opt.pathes) + end + + -- enter repository directory + local oldir = nil + if opt.repodir then + oldir = os.cd(opt.repodir) + end + + -- submodule it + os.vrunv(git.program, argv) + + -- leave repository directory + if oldir then + os.cd(oldir) + end +end diff --git a/xmake/plugins/hello/xmake.lua b/xmake/plugins/hello/xmake.lua deleted file mode 100644 index fe39f7d50..000000000 --- a/xmake/plugins/hello/xmake.lua +++ /dev/null @@ -1,45 +0,0 @@ ---!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 - 2019, TBOOX Open Source Group. --- --- @author ruki --- @file hello.lua --- - --- define task -task("hello") - - -- set category - set_category("plugin") - - -- on run - on_run(function () - - -- trace - print("hello xmake!") - - end) - - -- set menu - set_menu { - -- usage - usage = "xmake hello [options]" - - -- description - , description = "Hello xmake!" - - -- options - , options = {} - } |
