diff options
| author | ruki <[email protected]> | 2022-04-10 19:25:02 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-04-10 19:25:02 +0800 |
| commit | 7bb2d23a6e90e7ec44724a8a8d9447b1641dc8bb (patch) | |
| tree | 1e76f5a1bf2bfe89bf39df6b69c98602578ba859 | |
| parent | 1e0a67d3dcecd18f2756e02b57cb05e486d346ae (diff) | |
connect local project
| -rw-r--r-- | xmake/modules/private/service/client/remote_build_client.lua | 24 |
1 files changed, 23 insertions, 1 deletions
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 "<remote_build_client>" end |
