aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script/script.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/script/script.hxx')
-rw-r--r--libbuild2/script/script.hxx49
1 files changed, 44 insertions, 5 deletions
diff --git a/libbuild2/script/script.hxx b/libbuild2/script/script.hxx
index d162900..cccad98 100644
--- a/libbuild2/script/script.hxx
+++ b/libbuild2/script/script.hxx
@@ -27,6 +27,9 @@ namespace build2
cmd_elif,
cmd_elifn,
cmd_else,
+ cmd_while,
+ cmd_for_args, // `for x: ...`
+ cmd_for_stream, // `... | for x` and `for x <...`
cmd_end
};
@@ -40,7 +43,7 @@ namespace build2
union
{
- const variable* var; // Pre-entered for line_type::var.
+ const variable* var; // Pre-entered for line_type::{var,cmd_for_*}.
};
};
@@ -262,7 +265,7 @@ namespace build2
cleanup_type type;
build2::path path;
};
- using cleanups = vector<cleanup>;
+ using cleanups = small_vector<cleanup, 1>;
// command_exit
//
@@ -315,6 +318,10 @@ namespace build2
add (string);
};
+ // @@ For better diagnostics we may want to store an individual location
+ // of each command in the pipeline (maybe we can share the file part
+ // somehow since a pipline cannot span multiple files).
+ //
struct command
{
// We use NULL initial as an indication that the path stored in recall
@@ -354,6 +361,10 @@ namespace build2
// command_pipe
//
+ // Note that we cannot use small_vector here, since moving from objects of
+ // the command_pipe type would invalidate the command redirects of the
+ // reference type in this case.
+ //
using command_pipe = vector<command>;
void
@@ -372,7 +383,7 @@ namespace build2
command_pipe pipe;
};
- using command_expr = vector<expr_term>;
+ using command_expr = small_vector<expr_term, 1>;
void
to_stream (ostream&, const command_expr&, command_to_stream);
@@ -380,6 +391,15 @@ namespace build2
ostream&
operator<< (ostream&, const command_expr&);
+ // Stack-allocated linked list of iteration indexes of the nested loops.
+ //
+ struct iteration_index
+ {
+ size_t index; // 1-based.
+
+ const iteration_index* prev; // NULL for the top-most loop.
+ };
+
struct timeout
{
duration value;
@@ -495,7 +515,8 @@ namespace build2
// Register a cleanup. If the cleanup is explicit, then override the
// cleanup type if this path is already registered. Ignore implicit
- // registration of a path outside root directory (see below).
+ // registration of a path outside sandbox directory, if specified (see
+ // above).
//
void
clean (cleanup, bool implicit);
@@ -535,7 +556,7 @@ namespace build2
// Set variable value with optional (non-empty) attributes.
//
virtual void
- set_variable (string&& name,
+ set_variable (string name,
names&&,
const string& attrs,
const location&) = 0;
@@ -568,6 +589,20 @@ namespace build2
~environment () = default;
};
+ // Custom command function that can be executed at the end of the
+ // pipeline. Should throw io_error on the underlying OS error.
+ //
+ // Note: the pipeline can be NULL (think of `for x <<<='foo'`).
+ //
+ struct pipe_command;
+
+ using command_function = void (environment&,
+ const strings& args,
+ auto_fd in,
+ pipe_command* pipeline,
+ const optional<deadline>&,
+ const location&);
+
// Helpers.
//
// Issue diagnostics with the specified prefix and fail if the string
@@ -584,6 +619,10 @@ namespace build2
verify_environment_var_assignment (const string&,
const char* prefix,
const location&);
+
+ // "Unhide" operator<< from the build2 namespace.
+ //
+ using build2::operator<<;
}
}