Skip to content

Possibility of setting cargo key:value on commandline  #2294

Closed
@emoon

Description

@emoon

Hi,

I'm adding support for Cargo it the Tundra build system here https://github.com/emoon/tundra/tree/rust-support

The reason is that I have a bunch of native code in Tundra already but I want to build some Rust code as well and also link with static libs produced by Tundra. Another reason is that I will have several Cargo executables/shared libs and Tundra can schedule them in parallel which would speed up my builds a bit.

Now the problem is that (from what I understand) there is no way to set Cargo key:value (the same way build.rs would output to stdio) on command-line. Which causes some issues:

My current approach will be to generate/patch an existing build.rs file for the Cargo project and adding all the libs that needs to linked to the executable/shared lib. I feel that this is somewhat hacky and has one issue that Tundra supports building debug/release configuration at the same time so there will be a race condition here if more than one thread is trying to update the build.rs file. With command line parameters this wouldn't be an issue.

Also setting the cargo target dir is possible using the CARGO_TARGET_DIR env which I currently do so from so that the build command being executed from tundra looks like this

"set CARGO_TARGET_DIR=some_dir ; cargo build ..."

Now this works fine but having a command-line option like --target-dir=.../ to Cargo directly would be a bit nicer.

Another issue which I have seen (when using a build.rs) is that if dependencies update (like staticlibs) Cargo doesn't seem to know about it and will not link again. So a --force-link flag would be nice as well.

So to summarize. Something like this would be awesome :)

--set=key:value
--set-target-dir=..
--force-link

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions