summaryrefslogtreecommitdiff
path: root/xmake/modules/private/service/remote_build/client.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-14 22:43:23 +0800
committerruki <[email protected]>2023-09-14 22:43:23 +0800
commitb6276282eb660a335e955073748d72ff24dbf23c (patch)
treeb43248fabb4d5bf909263d1eb58e326a77fcdc25 /xmake/modules/private/service/remote_build/client.lua
parentb57ec2d39075b4b433a339c19e873559f1401466 (diff)
sync xmakesrc
Diffstat (limited to 'xmake/modules/private/service/remote_build/client.lua')
-rw-r--r--xmake/modules/private/service/remote_build/client.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/xmake/modules/private/service/remote_build/client.lua b/xmake/modules/private/service/remote_build/client.lua
index 65e41eaf1..3c42af2ea 100644
--- a/xmake/modules/private/service/remote_build/client.lua
+++ b/xmake/modules/private/service/remote_build/client.lua
@@ -191,12 +191,13 @@ function remote_build_client:sync()
local errors
local ok = false
local diff_files
+ local xmakesrc = option.get("xmakesrc")
cprint("${dim}%s: sync files in %s:%d ..", self, addr, port)
while sock do
-- diff files
local stream = socket_stream(sock, {send_timeout = self:send_timeout(), recv_timeout = self:recv_timeout()})
- diff_files, errors = self:_diff_files(stream)
+ diff_files, errors = self:_diff_files(stream, {xmakesrc = xmakesrc})
if not diff_files then
break
end
@@ -208,7 +209,8 @@ function remote_build_client:sync()
-- do sync
cprint("Uploading files ..")
local send_ok = false
- if stream:send_msg(message.new_sync(session_id, diff_files, {token = self:token()}), {compress = true}) and stream:flush() then
+ if stream:send_msg(message.new_sync(session_id, diff_files,
+ {token = self:token(), xmakesrc = xmakesrc and true or false}), {compress = true}) and stream:flush() then
if self:_send_diff_files(stream, diff_files) then
send_ok = true
end
@@ -458,16 +460,24 @@ function remote_build_client:_filesync()
end
-- diff server files
-function remote_build_client:_diff_files(stream)
+function remote_build_client:_diff_files(stream, opt)
+ opt = opt or {}
assert(self:is_connected(), "%s: has been not connected!", self)
print("Scanning files ..")
local filesync = self:_filesync()
+ if opt.xmakesrc then
+ assert(os.isdir(opt.xmakesrc), "%s: %s not found!", opt.xmakesrc)
+ filesync = new_filesync(opt.xmakesrc, path.join(self:workdir(), "xmakesrc_manifest.txt"))
+ filesync:ignorefiles_add(".git/**")
+ end
local manifest, filecount = filesync:snapshot()
local session_id = self:session_id()
local count = 0
local result, errors
cprint("Comparing ${bright}%d${clear} files ..", filecount)
- if stream:send_msg(message.new_diff(session_id, manifest, {token = self:token()}), {compress = true}) and stream:flush() then
+ if stream:send_msg(message.new_diff(session_id, manifest,
+ {token = self:token(), xmakesrc = opt.xmakesrc and true or false}),
+ {compress = true}) and stream:flush() then
local msg = stream:recv_msg({timeout = -1})
if msg and msg:success() then
result = msg:body().manifest