#cargo-build #cargo #cargo-test #cargo-subcommand #build

bin+lib cargo-export

Utility to export compiler artifacts from cargo build process

7 releases

new 0.3.0 Mar 18, 2025
0.2.5 Dec 21, 2023
0.1.0 May 7, 2023

#172 in Cargo plugins

Download history 33/week @ 2024-11-27 25/week @ 2024-12-04 52/week @ 2024-12-11 163/week @ 2024-12-18 295/week @ 2024-12-25 471/week @ 2025-01-01 580/week @ 2025-01-08 417/week @ 2025-01-15 438/week @ 2025-01-22 574/week @ 2025-01-29 938/week @ 2025-02-05 632/week @ 2025-02-12 527/week @ 2025-02-19 476/week @ 2025-02-26 477/week @ 2025-03-05 523/week @ 2025-03-12

2,138 downloads per month

MIT license

15KB
203 lines

CI Crates.io GitHub release (with filter) GitHub License

Exporting cargo compiler artifacts (tests, benches)

Motivation

It's quite challenging to export secondary artifacts like tests and benchmark executables. Those kind of artifacts can be very valuable for different reasons:

  1. packing test executables in the contaier to run them later on a different platform
  2. comparing and analyzing assembly of performance benchmarks

For final artifacts we have target/(release|debug)/{crate-name}, but test and benchmark executables are containing hash like target/release/deps/app-25de5d28a523d3c2. Moreover it changes every time compiler options are changed. For this reason methods like find and cp doesn't work well for extracting such artifacts.

Thankfully, compiler provide service messages (cargo build --message-format=json) which allows to list all the artifacts generated by the compiler.

Installing

$ cargo install cargo-export

Using

Local

  • export all test binaries to target/tests directory

    $ cargo export target/tests -- test
    

    Under the hood this command will run cargo test --no-run --message-format=json and copy all the generated binaries in the target/tests directory.

  • export all benchmark binaries to target/bench directory

    $ cargo export target/bench -- bench
    
  • export all benchmark binaries to target/bench directory and add postfix -main to each executable

    $ cargo export target/bench -t main -- bench
    
  • build and export benchmarks with a specific feature

    $ cargo export target/bench -- bench --feature=my-feature
    
  • build and export benchmarks using nightly

    $ cargo +nightly export target/bench -- bench
    

GitHub Actions

You can use taiki-e/install-action@v2 to install cargo-export in your GitHub Actions workflow.

name: Test

jobs:
  test:
    runs-on: ubuntu-22.04
    steps:
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-export
      - name: Export Tests
        run: cargo export target/bench -- test

Dependencies

~1.8–3MB
~53K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy