mmstick / cargo-deb

A cargo subcommand that generates Debian packages from information in Cargo.toml
615 stars 50 forks source link

Appended application with --no_release argument. #195

Closed svenrademakers closed 3 years ago

svenrademakers commented 3 years ago

--no-build assumes that a package is build in release mode. added a flag that will load binaries/libs from the debug path.

You could explicit set the debug path in the "assets" option to work-around cargo-deb looking in the wrong folder. However this doesnt scale nice, if you have a lot of different compile targets. You would have to create a variant for each output target. Instead, pass a flag, --no-release, to look in the /target/debug output-dir.

Chose this solution over an fallback solution. e.g. when files dont exist in the target/release folder, try target/debug

kornelski commented 3 years ago

What's the use-case for this?

There's [profile.release] in Cargo.toml that you can use to add debug info or use faster optimization settings.

svenrademakers commented 3 years ago

To give some more context, i need to package debug binaries. Since the actual compilation of the binaries is already done in another step in my CI, im run --no-build for deb packaging. i dont want to recompile my project again. The issue is that cargo-deb is globbing build-paths in /target//release. Which is in correct in my case, as my binaries are located in /target//debug.

I could work around it to explicitly, in the Cargo.toml file, declare the files for each target triple. But i have quite some and depending if you pass --target to cargo build, the asset path also changes.

The easiest would be to add a test to see if files exists in /target/release, if not try /target/debug. But i saw a comment not to do this, so i went for another program flag instead.

I could indeed configure my rust projects in such a way that my release profile matches my debug profile. But i have reasons not having to alter my projects to accommodate for this

kornelski commented 3 years ago

Cargo is a bit messy with its naming. target/debug is for development only (maps to [profiles.dev]). It's distinguished not by presence of debug information, but by unsuitability for releasing binaries.

"Debug binary" in Debian sense maps to Cargo's --release build with [profile.release] debug = true setting.

I haven't tested, but Cargo documents that you can also use CARGO_PROFILE_release_DEBUG = 1 env var instead of modifying Cargo.toml.

So I'm going to close this pull request. This limitation in cargo-deb exists on purpose, specifically to stop users from misusing target/debug for adding debug information to executables.