summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-06-27 00:38:18 +0800
committerruki <[email protected]>2019-06-26 21:51:08 +0800
commit78aff8d5199448d604c8e9456063f9550d00c6b6 (patch)
tree3d0c6a08ae93caf1c0cb6bf6fd9e4001f6800de6
parent6b6fdf451392f5519ff8b8c99bb5df0692c18b36 (diff)
fix xmake update
-rw-r--r--xmake/actions/update/main.lua4
-rw-r--r--xmake/modules/devel/git/checkout.lua3
-rw-r--r--xmake/modules/devel/git/clean.lua3
-rw-r--r--xmake/modules/devel/git/clone.lua5
-rw-r--r--xmake/modules/devel/git/ls_remote.lua10
-rw-r--r--xmake/modules/devel/git/pull.lua3
-rw-r--r--xmake/modules/devel/git/submodule/update.lua77
7 files changed, 103 insertions, 2 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua
index 8ef60b5cb..0de44628d 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,9 @@ function main()
if version:find('.', 1, true) then
git.clone(url, {outputdir = sourcedir})
git.checkout(version, {repodir = sourcedir})
+ submodule.update({repodir = sourcedir, init = true, recursive = true})
else
- git.clone(url, {depth = 1, branch = version, outputdir = sourcedir})
+ git.clone(url, {depth = 1, recursive = true, 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