Skip to content

Commit

Permalink
fix: make generic build commands take a working dir
Browse files Browse the repository at this point in the history
this is half-implemented as the other half is in #1116
  • Loading branch information
Gankra committed Jun 11, 2024
1 parent 7327c4e commit f29117b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cargo-dist/src/build/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{env, process::ExitStatus};

use axoprocess::Cmd;
use camino::Utf8PathBuf;
use camino::{Utf8Path, Utf8PathBuf};
use cargo_dist_schema::DistManifest;

use crate::{
Expand Down Expand Up @@ -102,10 +102,11 @@ fn platform_appropriate_cxx(target: &str) -> &str {

fn run_build(
dist_graph: &DistGraph,
command_string: &[String],
target: Option<&str>,
build_command: &[String],
working_dir: &Utf8Path,
target: Option<&TargetTriple>,
) -> DistResult<ExitStatus> {
let mut command_string = command_string.to_owned();
let mut command_string = build_command.to_owned();

let mut desired_extra_env = vec![];
let mut cflags = None;
Expand All @@ -125,6 +126,7 @@ fn run_build(
.first()
.expect("The build command must contain at least one entry");
let mut command = Cmd::new(command_name, format!("exec generic build: {command_name}"));
command.current_dir(working_dir);
command.stdout_to_stderr();
for arg in args {
command.arg(arg);
Expand Down Expand Up @@ -174,6 +176,7 @@ pub fn build_generic_target(
let result = run_build(
dist_graph,
&target.build_command,
&dist_graph.workspace_dir,
Some(&target.target_triple),
)?;

Expand Down Expand Up @@ -205,8 +208,7 @@ pub fn run_extra_artifacts_build(dist: &DistGraph, build: &ExtraBuildStep) -> Di
build.build_command.join(" ")
);

// TODO: run this in build.working_dir (conflicts with other inflight PR)
let result = run_build(dist, &build.build_command, None)?;
let result = run_build(dist, &build.build_command, &build.working_dir, None)?;

if !result.success() {
eprintln!("Build exited non-zero: {}", result);
Expand Down

0 comments on commit f29117b

Please sign in to comment.