cargo-dist
cargo-dist copied to clipboard
How to include non packaged system dependencies
In my situation, I have proper system dependencies for Linux and MacOS with apt/brew (working fine!). For Windows, I have a few lines to run before building my executables (nothing available on choco).
I found the "reusable workflow" item in the documentation, but it is not clear to me whether what I would install with such a workflow would persist in the runners of the build artifact matrix later?
More generally, I like listing dependencies and let the scripts write the install commands on my behalf, but I assume there's often some patching to do in addition, so what is the official recommendation here?
In that case, build.rs is the right approach: https://doc.rust-lang.org/cargo/reference/build-scripts.html I haven't used it myself yet, but the cc crate is used to help with this. https://crates.io/crates/cc
I see, thank you!
Here is what I need to run for Windows. Ideally, I would just add this to the generated release.yml.
Isn't it overkill to go with build.rs which looks more designed to compile code?
runs-on: windows-latest
steps:
- uses: actions/checkout@xx
- ...
- name: Windows dependencies
shell: bash
run: |
curl -L https://downloads.myriadrf.org/builds/PothosSDR/PothosSDR-2021.07.25-vc16-x64.exe -o pothossdr.exe
7z x -opothos -y pothossdr.exe
echo "${{github.workspace}}/pothos/bin" >> $GITHUB_PATH
Chiming in to say that I've seen this in other spots as well. I understand that build.rs would work but I don't disagree that using it might be more than I would personally want to do for my own projects. I wonder if there's a way for us to let folks specify these as config instead of asking them to write rust code (as a "build.rs" solution wouldn't work for a non-rust project anyways)
Thanks for jumping in @ashleygwilliams
Yes indeed, I think it would be reasonable to have something basic in the Cargo.toml starting from
[workspace.metadata.dist.dependencies.script]
target1 = "script_target1.sh"
target2 = "script_target2.sh"
hey @xoolive i think that looks very reasonable and is similar to the config we have for generic builds (https://opensource.axo.dev/cargo-dist/book/generic-builds.html). inparticular- wrapping things in a shell file that is set to a config value is a pattern we've used before. - would you be at all interested in contributing/collaborating on this feature?
Hi @ashleygwilliams I will try to come up with something, although I cannot commit to any ETA. I am quite new to Rust, but will do my best and ask for a review. Do we agree that I can focus on a solution that generates the proper output in cargo dist plan --output-format=json?