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

Respect build.target when getting target dir #554

Merged
merged 4 commits into from
May 4, 2021

Conversation

ark0f
Copy link
Contributor

@ark0f ark0f commented Apr 29, 2021

  • Use cargo_metadata crate
  • Respect build.target when getting target dir
  • Introduce RustTarget to cope better with future changes
  • Add CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY env var

Fixes #557

@ark0f ark0f changed the title Fix cargo-make don't respect build.target when getting target dir Respect build.target when getting target dir Apr 29, 2021
@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2021

Codecov Report

Merging #554 (537ec71) into 0.33.0 (30b6ba4) will increase coverage by 0.04%.
The diff coverage is 87.80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           0.33.0     #554      +/-   ##
==========================================
+ Coverage   93.01%   93.05%   +0.04%     
==========================================
  Files          98       98              
  Lines       19283    19278       -5     
==========================================
+ Hits        17936    17940       +4     
+ Misses       1347     1338       -9     
Impacted Files Coverage Δ
src/lib/types.rs 86.21% <ø> (+0.30%) ⬆️
src/lib/environment/crateinfo_test.rs 99.54% <85.71%> (-0.46%) ⬇️
src/lib/environment/crateinfo.rs 89.22% <86.95%> (+4.39%) ⬆️
src/lib/environment/mod.rs 92.98% <100.00%> (-0.18%) ⬇️
src/lib/cli.rs 91.81% <0.00%> (-0.44%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30b6ba4...537ec71. Read the comment docs.

@ark0f
Copy link
Contributor Author

ark0f commented Apr 29, 2021

cargo FS structure looks like this:

target
\---debug
\---x86_64-custom-target
    \---debug

so it can be wrong behavior. Is it better to introduce a new env var?

@sagiegurari sagiegurari self-assigned this Apr 30, 2021
deserializer: D,
) -> Result<Option<String>, D::Error> {
Option::<String>::deserialize(deserializer)?
.map(|target| target.trim_end_matches(".json").to_string())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need it in the deserialize? why not keep it simple and do it in the usage as today?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Cause it will lead us to code repetition. We need to trim string in crate_target_dir and crate_target_triple, but original string can be useful for env var like CARGO_MAKE_IS_CUSTOM_TARGET_TRIPLE

@sagiegurari
Copy link
Owner

Thanks a lot for the continued effort on this one :)

Is it better to introduce a new env var?

can you explain a bit? what new var did you have in mind? how would they be used if there were 2, meaning how do users know which one to use?

@ark0f
Copy link
Contributor Author

ark0f commented May 1, 2021

can you explain a bit?

Behavior with custom target triple:

  • cargo creates target folder with build scripts in it
  • cargo creates target/my_custom_triple folder with the rest

I don't know can cargo store there something else and will behavior be changed in the future.

What about workspaces? cargo ignores .cargo/config of member if you call cargo in workspace root (a bug?), but don't if you do it in member's folder, so you see that member will store its artifacts in target/my_custom_triple when others do it in target

what new var did you have in mind?

Something like CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY

how would they be used if there were 2, meaning how do users know which one to use?

User will decide which directory he needs - folder of custom target triple (target/my_custom_triple) or folder of host (target)

@sagiegurari sagiegurari changed the base branch from master to 0.33.0 May 3, 2021 06:10
@sagiegurari
Copy link
Owner

@ark0f thanks a lot for the answers and PR. i agree with your approach of adding another env var.
tell me when its ready :)

@sagiegurari
Copy link
Owner

looks awesome @ark0f thanks a lot

@pheki can you please verify that your use case is fixed with this PR?

After that i'll merge this into the 0.33 branch

@pheki
Copy link

pheki commented May 4, 2021

Oh, I missed this PR... It's great and I've verified, it fixes my use case.

Curiously, I'm also using a custom target, but its being set on [env] then passed in cargo build --target=${RUST_TARGET}, so I won't be able to use this new env var, but the current approach of joining the path works fine.

@sagiegurari
Copy link
Owner

@pheki thanks for confirming :)

@ark0f merging this. thanks a lot!!!

@sagiegurari sagiegurari merged commit dba8721 into sagiegurari:0.33.0 May 4, 2021
@ark0f ark0f deleted the respect-target branch May 5, 2021 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants