summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-16 10:54:25 +0800
committerruki <[email protected]>2022-04-16 10:54:25 +0800
commitbc28988cf61b1867f34929439f5014a68b123760 (patch)
tree49b1ab59622771b11dd845ee7a852b7b36a18f35
parent64a9469116255e93808fde7b752ee0a55a94a5df (diff)
improve check env
-rw-r--r--xmake/modules/private/service/config.lua3
-rw-r--r--xmake/modules/private/service/remote_build/client.lua4
-rw-r--r--xmake/modules/private/service/remote_build/environment.lua45
-rw-r--r--xmake/modules/private/service/start_service.lua17
4 files changed, 19 insertions, 50 deletions
diff --git a/xmake/modules/private/service/config.lua b/xmake/modules/private/service/config.lua
index e504ef237..1bff6893a 100644
--- a/xmake/modules/private/service/config.lua
+++ b/xmake/modules/private/service/config.lua
@@ -34,8 +34,7 @@ function _generate_configfile()
workdir = path.join(servicedir, "remote_build")
},
client = {
- connect = "127.0.0.1:90091",
- user = "user" -- remote ssh user
+ connect = "127.0.0.1:90091"
}
}
}
diff --git a/xmake/modules/private/service/remote_build/client.lua b/xmake/modules/private/service/remote_build/client.lua
index b1db62678..cbe5e89cf 100644
--- a/xmake/modules/private/service/remote_build/client.lua
+++ b/xmake/modules/private/service/remote_build/client.lua
@@ -53,8 +53,8 @@ function remote_build_client:init()
raise("we need enter a project directory with xmake.lua first!")
end
- -- enter git environment
- environment.enter()
+ -- check environment
+ environment.check(false)
end
-- get class
diff --git a/xmake/modules/private/service/remote_build/environment.lua b/xmake/modules/private/service/remote_build/environment.lua
index d273679a7..37250a227 100644
--- a/xmake/modules/private/service/remote_build/environment.lua
+++ b/xmake/modules/private/service/remote_build/environment.lua
@@ -20,42 +20,23 @@
-- imports
import("lib.detect.find_tool")
-import("private.action.require.impl.packagenv")
-import("private.action.require.impl.install_packages")
--- enter environment
+-- check environment
--
--- ensure that we can find some basic tools: git, ...
+-- ensure that we can find some basic tools: zip, 7zip, ...
--
-- If these tools not exist, we will install it first.
--
-function enter()
-
- -- enter the environments of git
- _g._OLDENVS = packagenv.enter("git")
-
- -- git not found? install it first
- local packages = {}
- local git = find_tool("git")
- if not git then
- table.join2(packages, install_packages("git"))
- end
-
- -- enter the environments of installed packages
- for _, instance in ipairs(packages) do
- instance:envs_enter()
- end
-
- -- we need force to detect and flush detect cache after loading all environments
- if not git then
- find_tool("git", {force = true})
- end
-end
-
--- leave environment
-function leave()
- local oldenvs = _g._OLDENVS
- if oldenvs then
- os.setenvs(oldenvs)
+function check(server_side)
+ if server_side then
+ -- unzip or 7zip is necessary
+ if not find_tool("unzip") and not find_tool("7z") then
+ raise("unzip or 7zip not found! we need install it first")
+ end
+ else
+ -- zip or 7zip is necessary
+ if not find_tool("zip") and not find_tool("7z") then
+ raise("zip or 7zip not found! we need install it first")
+ end
end
end
diff --git a/xmake/modules/private/service/start_service.lua b/xmake/modules/private/service/start_service.lua
index 36ba70f1b..f9dd357df 100644
--- a/xmake/modules/private/service/start_service.lua
+++ b/xmake/modules/private/service/start_service.lua
@@ -26,23 +26,12 @@ import("private.service.service")
import("private.service.remote_build.environment")
function main(opt)
- opt = opt or {}
- -- enter a working directory
- local workdir = path.join(os.tmpdir(), "service")
- if not os.isdir(workdir) then
- os.mkdir(workdir)
- os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
- else
- os.cd(workdir)
- end
- project.chdir(workdir)
-
- -- enter environment
- environment.enter()
+ -- check environment
+ environment.check(true)
-- start service
+ opt = opt or {}
if opt.daemon then
local argv = {"lua"}
if option.get("verbose") then