From a6b270a6e0116f2975f05dc9db731885f956bdc6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 29 Oct 2019 19:00:12 +0300 Subject: Use environment task manifest value to locate environment setup executable --- bbot/worker/worker.cxx | 31 ++++++++++++++++++++++++------- doc/manual.cli | 39 ++++++++++++++++++++++++++------------- tests/integration/testscript | 11 +++++++++-- 3 files changed, 59 insertions(+), 22 deletions(-) diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index e991910..cb47651 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -1356,15 +1356,31 @@ startup () // not apply) we still use process::path_search() to automatically handle // appending platform-specific executable extensions (.exe/.bat, etc). // - string tg (tm.target.string ()); - process_path pp (process::try_path_search (env_dir / tg, false)); + process_path pp; + + if (tm.environment) + { + try + { + pp = process::try_path_search (env_dir / *tm.environment, + false /* init */); + } + catch (const invalid_path& e) + { + fail << "invalid environment name '" << e.path << "': " << e; + } - if (pp.empty ()) - pp = process::try_path_search (env_dir / "default", false); + if (pp.empty ()) + fail << "no environment setup executable in " << env_dir << " " + << "for environment name '" << *tm.environment << "'"; + } + else + { + pp = process::try_path_search (env_dir / "default", false /* init */); - if (pp.empty ()) - fail << "no environment setup executable in " << env_dir << " " - << "for target '" << tg << "'"; + if (pp.empty ()) + fail << "no default environment setup executable in " << env_dir; + } // Run it. // @@ -1391,6 +1407,7 @@ startup () // Exit code 2 signals abnormal termination but where the worker uploaded // the result itself. // + string tg (tm.target.string ()); switch (run_exit (trace, pp, tg, argv0.effect_string (), os)) { case 2: return 1; diff --git a/doc/manual.cli b/doc/manual.cli index 4182be5..b4fc15b 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -325,6 +325,7 @@ repository-url: machine: target: +[environment]: [config]: [warning-regex]: \ @@ -409,6 +410,16 @@ triplet} format as autotools for \c{target}, it is not flexible enough for \c{machine}. +\h2#arch-task-environment|\c{environment}| + +\ +[environment]: +\ + +The name of the build environment to use. See \l{#arch-worker Worker Logic} +for details. + + \h2#arch-task-config|\c{config}| \ @@ -728,11 +739,11 @@ components: the execution environment (environment variables, etc), build system modules, as well as configuration options and variables. Setting up of the environment is performed by an executable (script, batch -file, etc). Specifically, upon receiving a build task, the worker obtains its -target and looks for the environment setup executable with this name in a -specific directory. If not found, then the worker looks for the executable -called \c{default}. Not being able to locate the environment executable is an -error. +file, etc). Specifically, upon receiving a build task, if it specifies the +environment name then the worker looks for the environment setup executable +with this name in a specific directory and for the executable called +\c{default} otherwise. Not being able to locate the environment executable is +an error. Once the environment setup executable is determined, the worker re-executes itself as that executable passing to it as command line arguments the target @@ -911,7 +922,7 @@ machines (as reported by agents) to \i{build configurations} according to the are ignored. All other lines in this file have the following format: \ - []* []* + [/] []* []* = [:](|