Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .aspect/axl.axl
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def test_large_bes(ctx: TaskContext, tc: int, temp_dir: str) -> int:
"//...",
flags = ["--noremote_accept_cached"],
build_events = [iter],
current_dir = "./examples/large_bes",
directory = "./examples/large_bes",
)

# Iterate through all build events - this would hang before the fix
Expand Down
29 changes: 21 additions & 8 deletions crates/axl-runtime/src/engine/bazel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
/// * `stdio` - Shorthand: set both `stdout` and `stderr` from a single
/// `Stdio` bundle (typically `ctx.std.io`). Cannot be combined with
/// `stdout`/`stderr`.
/// * `current_dir` - Working directory for the Bazel invocation.
/// * `directory` - Working directory for the Bazel invocation; selects
/// the workspace / server (used for git-worktree execution).
/// * `announce_version` - Print an `INFO: Bazel <version>` line before
/// spawning. Resolved from the `--announce-bazel-version` task flag.
/// * `announce_command` - Print an `INFO: Spawning: <command>` line (the
Expand Down Expand Up @@ -432,7 +433,7 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
#[starlark(require = named)] stdout: Option<NoneOr<Writable>>,
#[starlark(require = named)] stderr: Option<NoneOr<Writable>>,
#[starlark(require = named, default = NoneOr::None)] stdio: NoneOr<StdStdio>,
#[starlark(require = named, default = NoneOr::None)] current_dir: NoneOr<String>,
#[starlark(require = named, default = NoneOr::None)] directory: NoneOr<String>,
#[starlark(require = named, default = false)] announce_version: bool,
#[starlark(require = named, default = false)] announce_command: bool,
eval: &mut Evaluator<'v, '_, '_>,
Expand All @@ -456,7 +457,7 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
resolved_startup_flags,
stdout,
stderr,
current_dir.into_option(),
directory.into_option(),
build::AnnounceSpawn {
version: announce_version,
command: announce_command,
Expand Down Expand Up @@ -492,7 +493,8 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
/// * `stdio` - Shorthand: set both `stdout` and `stderr` from a single
/// `Stdio` bundle (typically `ctx.std.io`). Cannot be combined with
/// `stdout`/`stderr`.
/// * `current_dir` - Working directory for the Bazel invocation.
/// * `directory` - Working directory for the Bazel invocation; selects
/// the workspace / server (used for git-worktree execution).
/// * `announce_version` - Print an `INFO: Bazel <version>` line before
/// spawning. Resolved from the `--announce-bazel-version` task flag.
/// * `announce_command` - Print an `INFO: Spawning: <command>` line (the
Expand Down Expand Up @@ -544,7 +546,7 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
#[starlark(require = named)] stdout: Option<NoneOr<Writable>>,
#[starlark(require = named)] stderr: Option<NoneOr<Writable>>,
#[starlark(require = named, default = NoneOr::None)] stdio: NoneOr<StdStdio>,
#[starlark(require = named, default = NoneOr::None)] current_dir: NoneOr<String>,
#[starlark(require = named, default = NoneOr::None)] directory: NoneOr<String>,
#[starlark(require = named, default = false)] announce_version: bool,
#[starlark(require = named, default = false)] announce_command: bool,
eval: &mut Evaluator<'v, '_, '_>,
Expand All @@ -568,7 +570,7 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
resolved_startup_flags,
stdout,
stderr,
current_dir.into_option(),
directory.into_option(),
build::AnnounceSpawn {
version: announce_version,
command: announce_command,
Expand All @@ -593,6 +595,8 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
/// its own `.bazelrc`.
/// * `flags` - Per-call command extras appended after the rc expansion.
/// Same `str | (str, version-constraint)` shape as `build` / `test`.
/// * `directory` - Working directory for the query; selects the
/// workspace / server. Used for git-worktree-scoped discovery.
/// * `announce_version` / `announce_command` - Mirror the build/test
/// spawn disclosure.
///
Expand All @@ -609,6 +613,7 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
#[starlark(require = named, default = UnpackList::default())] flags: UnpackList<
Either<values::StringValue<'v>, (values::StringValue<'v>, values::StringValue<'v>)>,
>,
#[starlark(require = named, default = NoneOr::None)] directory: NoneOr<String>,
#[starlark(require = named, default = false)] announce_version: bool,
#[starlark(require = named, default = false)] announce_command: bool,
) -> anyhow::Result<query::Query> {
Expand All @@ -625,6 +630,7 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
&expr,
&startup,
&command_flags,
directory.into_option(),
build::AnnounceSpawn {
version: announce_version,
command: announce_command,
Expand All @@ -638,7 +644,8 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
/// with a non-zero code.
///
/// # Arguments
/// * `workdir`: workspace root to run `bazel info` in (default: inferred from ctx)
/// * `directory`: working directory to run `bazel info` in; selects the
/// workspace / server (default: the parent process cwd).
///
/// **Examples**
///
Expand All @@ -648,12 +655,18 @@ pub(crate) fn bazel_methods(registry: &mut MethodsBuilder) {
/// print(info["output_base"])
/// print(info["execution_root"])
/// ```
fn info<'v>(this: values::Value<'v>) -> anyhow::Result<SmallMap<String, String>> {
fn info<'v>(
this: values::Value<'v>,
#[starlark(require = named, default = NoneOr::None)] directory: NoneOr<String>,
) -> anyhow::Result<SmallMap<String, String>> {
let startup_flags = read_startup_flags(this)?;

let mut cmd = bazel_command();
cmd.args(&startup_flags);
cmd.arg("info");
if let Some(dir) = directory.into_option() {
cmd.current_dir(dir);
}
cmd.stdout(Stdio::piped());
cmd.stderr(Stdio::null());
cmd.stdin(Stdio::null());
Expand Down
4 changes: 4 additions & 0 deletions crates/axl-runtime/src/engine/bazel/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ pub fn run(
expr: &str,
startup_flags: &[String],
flags: &[String],
current_dir: Option<String>,
announce: super::build::AnnounceSpawn,
) -> anyhow::Result<Query> {
let mut cmd = super::bazel_command();
Expand All @@ -169,6 +170,9 @@ pub fn run(
cmd.arg(expr);
cmd.args(flags);
cmd.arg("--output=streamed_proto");
if let Some(dir) = current_dir {
cmd.current_dir(dir);
}
let out = temp_dir().join("query.bin");
let _ = fs::remove_file(&out);
let errfile_path = temp_dir().join("query.err");
Expand Down
Loading