cargo-dist icon indicating copy to clipboard operation
cargo-dist copied to clipboard

Can cargo dist build exactly the binary?

Open tisonkun opened this issue 1 year ago • 4 comments

I built a project that has several test-only, non-binary crates.

Now when cargo-dist runs cargo dist build, those crates will be built and some of them may fail - https://github.com/tisonkun/morax/actions/runs/11226860397/job/31208119385?pr=9

Since those crates have nothing to do with the binary I'd like to release, I wonder if it's possible to exclude their build.

tisonkun avatar Oct 08 '24 01:10 tisonkun

You can try adding a [metadata.dist] section to their Cargo.toml files with dist = false - that will tell cargo-dist not to try to build them. https://opensource.axo.dev/cargo-dist/book/reference/config.html#dist

mistydemeo avatar Oct 08 '24 02:10 mistydemeo

https://github.com/tisonkun/morax/pull/9/

@mistydemeo thanks for your suggestion. But it doesn't seem to work.

tisonkun avatar Oct 08 '24 03:10 tisonkun

At commit https://github.com/tisonkun/morax/pull/9/commits/f2e8ee7f8e94a99e781328d8943255e0cc25e69c

It failed with https://github.com/tisonkun/morax/actions/runs/11227771504/job/31210572728

It seems that the rdkafka crate still built although all its dependent is excluded by package.netadata.dist.dist = false.

building cargo target (x86_64-pc-windows-msvc/dist --workspace)
    Updating crates.io index
   Compiling morax-protos v0.1.0 (D:\a\morax\morax\api\protos)
   Compiling libz-sys v1.1.20
   Compiling morax-runtime v0.1.0 (D:\a\morax\morax\crates\runtime)
   Compiling kafka-api v0.4.1 (D:\a\morax\morax\api\kafka-api)
   Compiling morax-meta v0.1.0 (D:\a\morax\morax\crates\meta)
   Compiling morax-storage v0.1.0 (D:\a\morax\morax\crates\storage)
   Compiling zstd-sys v2.0.13+zstd.1.5.6
   Compiling morax-kafka-broker v0.1.0 (D:\a\morax\morax\crates\kafka-broker)
   Compiling morax-wal-broker v0.1.0 (D:\a\morax\morax\crates\wal-broker)
   Compiling morax-server v0.1.0 (D:\a\morax\morax\crates\server)
   Compiling lz4-sys v1.11.0
   Compiling zstd-safe v6.0.6
   Compiling libgit2-sys v0.[17](https://github.com/tisonkun/morax/actions/runs/11227771504/job/31210572728#step:8:18).0+1.8.1
   Compiling morax-telemetry v0.1.0 (D:\a\morax\morax\crates\telemetry)
   Compiling rdkafka-sys v4.7.0+2.3.0
   Compiling snap v1.1.1
error: failed to run custom build command for `rdkafka-sys v4.7.0+2.3.0`

Caused by:
  process didn't exit successfully: `D:\a\morax\morax\target\dist\build\rdkafka-sys-e938e9d14[18](https://github.com/tisonkun/morax/actions/runs/11227771504/job/31210572728#step:8:19)95f08\build-script-build` (exit code: 101)
  --- stdout
  Cloning librdkafka
  Configuring librdkafka

  --- stderr
  Building and linking librdkafka statically
  Running command: "cp -a librdkafka/. D:\a\morax\morax\target\x86_64-pc-windows-msvc\dist\build\rdkafka-sys-e3eacd032f9e3efa\out" in dir: .
  Running command: "\\?\D:\a\morax\morax\target\x86_64-pc-windows-msvc\dist\build\rdkafka-sys-e3eacd032f9e3efa\out\configure --disable-ssl --disable-gssapi --disable-curl --disable-zstd --disable-lz4-ext" in dir: D:\a\morax\morax\target\x86_64-pc-windows-msvc\dist\build\rdkafka-sys-e3eacd032f9e3efa\out
  thread 'main' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rdkafka-sys-4.7.0+2.3.0\build.rs:38:[19](https://github.com/tisonkun/morax/actions/runs/11227771504/job/31210572728#step:8:20):
  Command failed with error: %1 is not a valid Win32 application. (os error 193)
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
  × failed to find bin morax.exe for path+file:///D:/a/morax/morax/cmd/morax#[email protected]
  help: did the above build fail?

tisonkun avatar Oct 08 '24 13:10 tisonkun

~~Hi, I have the same problem. One package in the workspace fails as expected but should be excluded in build process. So in my case it builds all packages in the workspace and dist packages the binaries i want.~~

Im hitting this error where a cargo worskpace builds all binaries. I would like to be able to select which binaries should be built.

I believe i fixed my issue using precise-builds: https://axodotdev.github.io/cargo-dist/book/reference/config.html?highlight=package#precise-builds

pr0xr avatar Jan 05 '25 09:01 pr0xr