aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/script')
-rw-r--r--libbuild2/script/parser.cxx14
-rw-r--r--libbuild2/script/parser.hxx9
-rw-r--r--libbuild2/script/run.cxx2
-rw-r--r--libbuild2/script/script.cxx5
-rw-r--r--libbuild2/script/script.hxx10
5 files changed, 29 insertions, 11 deletions
diff --git a/libbuild2/script/parser.cxx b/libbuild2/script/parser.cxx
index ae6da76..84d2afc 100644
--- a/libbuild2/script/parser.cxx
+++ b/libbuild2/script/parser.cxx
@@ -1134,9 +1134,10 @@ namespace build2
if (t.value == "env")
{
parsed_env r (parse_env_builtin (t, tt));
- c.cwd = move (r.cwd);
- c.variables = move (r.variables);
- c.timeout = r.timeout;
+ c.cwd = move (r.cwd);
+ c.variables = move (r.variables);
+ c.timeout = r.timeout;
+ c.timeout_success = r.timeout_success;
env = true;
}
else if (t.value == "for")
@@ -1601,6 +1602,10 @@ namespace build2
{
r.timeout = chrono::seconds (*v);
}
+ else if (o == "-s" || o == "--timeout-success")
+ {
+ r.timeout_success = true;
+ }
else if (optional<dir_path> v = dir ("--cwd", "-c"))
{
r.cwd = move (*v);
@@ -1615,6 +1620,9 @@ namespace build2
break;
}
+ if (r.timeout_success && !r.timeout)
+ fail (l) << "env: -s|--timeout-success specified without -t|--timeout";
+
// Parse arguments (variable sets).
//
for (; i != e; ++i)
diff --git a/libbuild2/script/parser.hxx b/libbuild2/script/parser.hxx
index cadf909..795ce4e 100644
--- a/libbuild2/script/parser.hxx
+++ b/libbuild2/script/parser.hxx
@@ -163,14 +163,15 @@ namespace build2
pre_parse_line_start (token&, token_type&, lexer_mode);
// Parse the env pseudo-builtin arguments up to the program name. Return
- // the program execution timeout, CWD, the list of the variables that
- // should be unset ("name") and/or set ("name=value") in the command
- // environment, and the token/type that starts the program name. Note
- // that the variable unsets come first, if present.
+ // the program execution timeout and its success flag, CWD, the list of
+ // the variables that should be unset ("name") and/or set ("name=value")
+ // in the command environment, and the token/type that starts the
+ // program name. Note that the variable unsets come first, if present.
//
struct parsed_env
{
optional<duration> timeout;
+ bool timeout_success = false;
optional<dir_path> cwd;
environment_vars variables;
};
diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx
index 6d73a7e..f8f98c1 100644
--- a/libbuild2/script/run.cxx
+++ b/libbuild2/script/run.cxx
@@ -2069,7 +2069,7 @@ namespace build2
if (c.timeout)
{
- deadline d (system_clock::now () + *c.timeout, false /* success */);
+ deadline d (system_clock::now () + *c.timeout, c.timeout_success);
if (!dl || d < *dl)
dl = d;
}
diff --git a/libbuild2/script/script.cxx b/libbuild2/script/script.cxx
index 4a6ca33..b53fc23 100644
--- a/libbuild2/script/script.cxx
+++ b/libbuild2/script/script.cxx
@@ -425,9 +425,14 @@ namespace build2
// Timeout.
//
if (c.timeout)
+ {
o << " -t "
<< chrono::duration_cast<chrono::seconds> (*c.timeout).count ();
+ if (c.timeout_success)
+ o << " -s";
+ }
+
// CWD.
//
if (c.cwd)
diff --git a/libbuild2/script/script.hxx b/libbuild2/script/script.hxx
index cccad98..c406165 100644
--- a/libbuild2/script/script.hxx
+++ b/libbuild2/script/script.hxx
@@ -331,9 +331,13 @@ namespace build2
process_path program;
strings arguments;
- optional<dir_path> cwd; // From env builtin.
- environment_vars variables; // From env builtin.
- optional<duration> timeout; // From env builtin.
+
+ // These come from the env builtin.
+ //
+ optional<dir_path> cwd;
+ environment_vars variables;
+ optional<duration> timeout;
+ bool timeout_success;
optional<redirect> in;
optional<redirect> out;