From b5bb39846e3743741339037a72e569fac1676011 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 21 Nov 2023 17:26:29 +0100 Subject: just serve: Add configuration fields for remote builds --- src/buildtool/main/serve.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/buildtool/main/serve.cpp') diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp index 74d78bdc..1c079032 100644 --- a/src/buildtool/main/serve.cpp +++ b/src/buildtool/main/serve.cpp @@ -14,6 +14,8 @@ #include "src/buildtool/main/serve.hpp" +#include + #ifndef BOOTSTRAP_BUILD_TOOL #include @@ -346,6 +348,58 @@ void ReadJustServeConfig(gsl::not_null const& clargs) { clargs->endpoint.remote_execution_address = address->String(); } } + // read jobs value + auto jobs = serve_config["jobs"]; + if (jobs.IsNotNull()) { + if (not jobs->IsNumber()) { + Logger::Log(LogLevel::Error, + "just serve: configuration-file provided jobs has to " + "be a number, but found {}", + jobs->ToString()); + std::exit(kExitFailure); + } + clargs->common.jobs = jobs->Number(); + } + // read build options + auto build_args = serve_config["build"]; + if (build_args.IsNotNull()) { + if (not build_args->IsMap()) { + Logger::Log(LogLevel::Error, + "just-serve: configuration-file provided build " + "arguments has to be a map, but found {}", + build_args->ToString()); + std::exit(kExitFailure); + } + // read the build jobs + auto build_jobs = build_args->Get("build jobs", Expression::none_t{}); + if (build_jobs.IsNotNull()) { + if (not build_jobs->IsNumber()) { + Logger::Log( + LogLevel::Error, + "just serve: configuration-file provided build jobs " + "has to be a number, but found {}", + build_jobs->ToString()); + std::exit(kExitFailure); + } + clargs->build.build_jobs = build_jobs->Number(); + } + else { + clargs->build.build_jobs = clargs->common.jobs; + } + // read action timeout + auto timeout = build_args->Get("action timeout", Expression::none_t{}); + if (timeout.IsNotNull()) { + if (not timeout->IsNumber()) { + Logger::Log(LogLevel::Error, + "just serve: configuration-file provided action " + "timeout has to be a number, but found {}", + timeout->ToString()); + std::exit(kExitFailure); + } + clargs->build.timeout = + std::size_t(timeout->Number()) * std::chrono::seconds{1}; + } + } } #endif // BOOTSTRAP_BUILD_TOOL -- cgit v1.2.3