ensc
ensc

Reputation: 6994

What is the recommended way to install the binaries built by Cargo for packaging purposes?

How can I access the generated foo binary when I have this in my Cargo.toml?

[[bin]]
name = "foo"
path = "src/foo.rs"

Ideally I would like to have something which works like

make install DESTDIR=$(pwd)/i

I tried:

I could dig into the target directory, but there are a lot of unwanted files so globs will not work and I will have to know exactly the artifact name, including automatic suffices like .a, .so, .so.1.2.3, etc.

Upvotes: 2

Views: 3344

Answers (1)

KamilCuk
KamilCuk

Reputation: 141698

How to access binaries built by cargo?

The cargo install --path . --root $(pwd)/i is the correct way to specify the destination installation directory.

but it seems to be impossible to set flags like --release or its opposite variant (yes: I want the debug binary!)

It's possible with the --debug flag.

cargo install --debug --path . --root $(pwd)/i

See cargo install manual.

Upvotes: 5

Related Questions