From 7bb2d23a6e90e7ec44724a8a8d9447b1641dc8bb Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 10 Apr 2022 19:25:02 +0800 Subject: connect local project --- .../private/service/client/remote_build_client.lua | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/xmake/modules/private/service/client/remote_build_client.lua b/xmake/modules/private/service/client/remote_build_client.lua index 9fcd38fcf..aa98fed66 100644 --- a/xmake/modules/private/service/client/remote_build_client.lua +++ b/xmake/modules/private/service/client/remote_build_client.lua @@ -20,6 +20,7 @@ -- imports import("core.base.socket") +import("core.project.config", {alias = "project_config"}) import("private.service.config") import("private.service.message") import("private.service.client.client") @@ -32,6 +33,17 @@ local super = remote_build_client:class() -- init client function remote_build_client:init() super.init(self) + + -- load project config + local projectdir = os.projectdir() + local projectfile = os.projectfile() + if projectfile and os.isfile(projectfile) and projectdir then + project_config.load() + self._PROJECTDIR = projectdir + self._WORKDIR = path.join(project_config.directory(), "remote_build") + else + raise("we need enter a project directory with xmake.lua first!") + end end -- get class @@ -56,7 +68,7 @@ function remote_build_client:connect(addr, port) end end if connected then - print("%s: connected!", client) + print("%s: connected!", self) io.save(statusfile, {addr = addr, port = port}) else print("%s: connect %s:%d failed", self, addr, port) @@ -96,6 +108,16 @@ function remote_build_client:statusfile() return path.join(self:workdir(), "status.txt") end +-- get the project directory +function remote_build_client:projectdir() + return self._PROJECTDIR +end + +-- get working directory +function remote_build_client:workdir() + return self._WORKDIR +end + function remote_build_client:__tostring() return "" end -- cgit v1.3.1