Hi all,
I have a question that struggles me for at least a day. I want to use third party binary in my Rust project called patched version of spin
project as both as binary artifact and library:
So far, I managed to build the binary as follows:
Cargo.toml
spin-cli = { git = "https://github.com/yordanmadzhunkov/spin", tag="v2.4.2", lib = true, artifact = "bin"}
this produces an executable called target/debug/deps/artifact/spin-cli-c8eeda24a0cce06b/bin/spin-c8eeda24a0cce06b
which is awesome, but I want to be able to invoke it from my scripts like following:
cargo run spin -- args
Unfortunetly I am not able to find a way to get the path to to it automatically. I want to be able to always refer to the latest build of this executable. Can you give me any pointers or suggestions.
Also, I tried the following approach as described in the cargo documentation with any success. CARGO_BIN_FILE_SPIN_CLI
is not set as enviroument variable by cargo as the docs claim it should be
https://doc.rust-lang.org/cargo/reference/unstable.html#artifact-dependencies
artifact-dependencies: Environment variables
After building an artifact dependency, Cargo provides the following environment variables that you can use to access the artifact:
CARGO_<ARTIFACT-TYPE>_DIR_<DEP> — This is the directory containing all the artifacts from the dependency.
<ARTIFACT-TYPE> is the artifact specified for the dependency (uppercased as in CDYLIB, STATICLIB, or BIN) and <DEP> is the name of the dependency. As with other Cargo environment variables, dependency names are converted to uppercase, with dashes replaced by underscores.
Thank you in advance!
PS. If this is not the proper place for such question, please redirect me.