aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-10-29 19:00:12 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-10-31 19:18:10 +0300
commita6b270a6e0116f2975f05dc9db731885f956bdc6 (patch)
tree1152946fc058356d0974072cc3a8dd957e670a03
parent7a12f8bdcb4d497489a4df1e1024e724b316085a (diff)
Use environment task manifest value to locate environment setup executable
-rw-r--r--bbot/worker/worker.cxx31
-rw-r--r--doc/manual.cli39
-rw-r--r--tests/integration/testscript11
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: <repository-url>
machine: <machine-name>
target: <target-triplet>
+[environment]: <environment-name>
[config]: <config-args>
[warning-regex]: <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]: <environment-name>
+\
+
+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:
\
-<machine-pattern> <config> <target> <classes> [<config-arg>]* [<warning-regex>]*
+<machine-pattern> <config> <target>[/<environment>] <classes> [<config-arg>]* [<warning-regex>]*
<config-arg> = [<prefix>:](<variable>|<option>)
<prefix> = <tool>[.<operation>[.<command>]]
@@ -919,11 +930,12 @@ are ignored. All other lines in this file have the following format:
Where \c{<machine-pattern>} is filesystem wildcard pattern that is matched
against available machine names, \c{<config>} is the configuration name,
-\c{<target>} is the build target, \c{<classes>} is a space-separated list of
-configuration classes that is matched against the package \c{builds} values,
-optional \c{<config-arg>} list is additional configuration options and
-variables, and optional \c{<warning-regex>} list is additional regular
-expressions that should be used to detect warnings in the logs.
+\c{<target>} is the build target, optional \c{<environment>} is the build
+environment name, \c{<classes>} is a space-separated list of configuration
+classes that is matched against the package \c{builds} values, optional
+\c{<config-arg>} list is additional configuration options and variables, and
+optional \c{<warning-regex>} list is additional regular expressions that
+should be used to detect warnings in the logs.
The build configurations can belong to multiple classes with their names
reflecting some common configuration aspects, such as the operating system,
@@ -938,8 +950,9 @@ Regular expressions must start with \c{~}, to be distinguished from
configuration options and variables. Note that the \c{<config-arg>} and
\c{<warning-regex>} lists have the same quoting semantics as in the \c{config}
and the \c{warning-regex} value in the build task manifest. The matched
-machine name, the target, configuration options/variables, and regular
-expressions are included into the build task manifest.
+machine name, the target, the environment name, configuration
+options/variables, and regular expressions are included into the build task
+manifest.
Values in the \c{<config-arg>} list can be opionally prefixed with the \i{step
id} or a leading portion thereof to restrict it to a specific step, operation,
diff --git a/tests/integration/testscript b/tests/integration/testscript
index 7692436..2e7deb2 100644
--- a/tests/integration/testscript
+++ b/tests/integration/testscript
@@ -27,6 +27,7 @@ sudo /usr/sbin/in.tftpd \
machine = linux-gcc
target = x86_64-linux-gnu
+environment =
c = gcc
cxx = g++
@@ -96,6 +97,10 @@ bpkg.test-installed.create:\"config.bin.rpath='$~/install/lib'\""
config: $config
EOI
++if ("$environment" != "")
+ echo "environment: $environment" >+task
+end
+
#
#
tftp = 127.0.0.1:55123
@@ -119,7 +124,9 @@ a = $0
: worker
:
{
- cat <<"EOI" >=$target;
+ env = ("$environment" != "" ? "$environment" : "default")
+
+ cat <<"EOI" >=$env;
#!/bin/sh
t="\$1"
@@ -127,7 +134,7 @@ a = $0
exec "\$@" cc config.c=$c config.cxx=$cxx
EOI
- chmod ugo+x $target;
+ chmod ugo+x $env;
sleep $wait;
$w --verbose 3 --startup --tftp-host $tftp --environments $~ \
&build/*** &?build-installed/*** &?build-tests-installed/*** \