Skip to content

Commit

Permalink
cargo-maelstrom uses cargo metadata to determine target directory
Browse files Browse the repository at this point in the history
Also it now creates it if it doesn't exist

see issue #230
  • Loading branch information
bobbobbio committed Apr 23, 2024
1 parent c901a55 commit a6a086d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/cargo-maelstrom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use maelstrom_base::{ArtifactType, JobSpec, NonEmpty, Sha256Digest, Timeout};
use maelstrom_client::{spec::ImageConfig, Client, ClientBgProcess};
use maelstrom_util::{
config::common::{BrokerAddr, CacheSize, InlineLimit, LogLevel, Slots},
fs::Fs,
process::ExitCode,
};
use metadata::{AllMetadata, TestMetadata};
Expand Down Expand Up @@ -548,6 +549,7 @@ impl MainAppDeps {
stderr_color: bool,
workspace_root: &impl AsRef<Path>,
workspace_packages: &[&CargoPackage],
target_directory: &impl AsRef<Path>,
broker_addr: Option<BrokerAddr>,
cache_size: CacheSize,
inline_limit: InlineLimit,
Expand All @@ -557,6 +559,7 @@ impl MainAppDeps {
manifest_options: ManifestOptions,
logger: Logger,
) -> Result<Self> {
let fs = Fs::new();
let logging_output = LoggingOutput::default();
let log = logger.build(logging_output.clone());
slog::debug!(
Expand All @@ -567,7 +570,8 @@ impl MainAppDeps {
"broker_addr" => ?broker_addr
);

let cache_dir = workspace_root.as_ref().join("target");
let cache_dir = target_directory.as_ref().to_owned();
fs.create_dir_all(&cache_dir)?;
let client = Client::new(
bg_proc,
broker_addr,
Expand Down
1 change: 1 addition & 0 deletions crates/cargo-maelstrom/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub fn main() -> Result<ExitCode> {
std::io::stderr().is_terminal(),
&cargo_metadata.workspace_root,
&cargo_metadata.workspace_packages(),
&cargo_metadata.target_directory,
config.broker,
config.cache_size,
config.inline_limit,
Expand Down

0 comments on commit a6a086d

Please sign in to comment.