Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move crate_target_dirs from RustInfo to CrateInfo #941

Merged
Merged
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
18 changes: 9 additions & 9 deletions src/lib/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn setup_env_for_duckscript() {
envmnt::set("CARGO_MAKE_DUCKSCRIPT_SDK_VERSION", version);
}

fn setup_env_for_crate() -> CrateInfo {
fn setup_env_for_crate(home: Option<PathBuf>) -> CrateInfo {
let crate_info = crateinfo::load();
let crate_info_clone = crate_info.clone();

Expand Down Expand Up @@ -400,6 +400,13 @@ fn setup_env_for_crate() -> CrateInfo {
let lock_file_exists = lock_file.exists();
envmnt::set_bool("CARGO_MAKE_CRATE_LOCK_FILE_EXISTS", lock_file_exists);

let crate_target_dirs = crateinfo::crate_target_dirs(home);
envmnt::set("CARGO_MAKE_CRATE_TARGET_DIRECTORY", crate_target_dirs.host);
envmnt::set_optional(
"CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY",
&crate_target_dirs.custom,
);

crate_info_clone
}

Expand Down Expand Up @@ -466,13 +473,6 @@ fn setup_env_for_rust(home: Option<PathBuf>) -> RustInfo {
&crateinfo::crate_target_triple(rustinfo.target_triple, home.clone()),
);

let crate_target_dirs = crateinfo::crate_target_dirs(home);
envmnt::set("CARGO_MAKE_CRATE_TARGET_DIRECTORY", crate_target_dirs.host);
envmnt::set_optional(
"CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY",
&crate_target_dirs.custom,
);

rust_info_clone
}

Expand Down Expand Up @@ -573,7 +573,7 @@ pub(crate) fn setup_env(
let crate_info = if config.config.skip_crate_env_info.unwrap_or(false) {
CrateInfo::new()
} else {
setup_env_for_crate()
setup_env_for_crate(home.clone())
};
time_summary::add(time_summary_vec, "[Setup Env - Crate Info]", now);

Expand Down
8 changes: 4 additions & 4 deletions src/lib/environment/mod_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@
envmnt::set("CARGO_MAKE_CRATE_HAS_DEPENDENCIES", "EMPTY");
envmnt::set("CARGO_MAKE_CRATE_WORKSPACE_MEMBERS", "EMPTY");

setup_env_for_crate();
setup_env_for_crate(None);

Check warning on line 1329 in src/lib/environment/mod_test.rs

View check run for this annotation

Codecov / codecov/patch

src/lib/environment/mod_test.rs#L1329

Added line #L1329 was not covered by tests

assert_eq!(envmnt::get_or_panic("CARGO_MAKE_CRATE_NAME"), "cargo-make");
assert_eq!(
Expand Down Expand Up @@ -1390,7 +1390,7 @@
assert!(envmnt::get_or_panic("CARGO_MAKE_WORKING_DIRECTORY") == "EMPTY");

setup_cwd(Some("examples"));
setup_env_for_crate();
setup_env_for_crate(None);

Check warning on line 1393 in src/lib/environment/mod_test.rs

View check run for this annotation

Codecov / codecov/patch

src/lib/environment/mod_test.rs#L1393

Added line #L1393 was not covered by tests
setup_cwd(Some(".."));

assert!(envmnt::get_or_panic("CARGO_MAKE_WORKING_DIRECTORY") != "EMPTY");
Expand Down Expand Up @@ -1422,7 +1422,7 @@
""
);

setup_env_for_crate();
setup_env_for_crate(None);

Check warning on line 1425 in src/lib/environment/mod_test.rs

View check run for this annotation

Codecov / codecov/patch

src/lib/environment/mod_test.rs#L1425

Added line #L1425 was not covered by tests

assert_eq!(envmnt::get_or_panic("CARGO_MAKE_CRATE_NAME"), "cargo-make");
assert_eq!(
Expand Down Expand Up @@ -1483,7 +1483,7 @@
envmnt::set("CARGO_MAKE_CRATE_WORKSPACE_MEMBERS", "EMPTY");

setup_cwd(Some("examples/workspace"));
setup_env_for_crate();
setup_env_for_crate(None);

Check warning on line 1486 in src/lib/environment/mod_test.rs

View check run for this annotation

Codecov / codecov/patch

src/lib/environment/mod_test.rs#L1486

Added line #L1486 was not covered by tests
setup_cwd(Some("../.."));

assert_eq!(envmnt::get_or_panic("CARGO_MAKE_CRATE_NAME"), "EMPTY");
Expand Down
Loading