cargo-export 0.3.0

Utility to export compiler artifacts from cargo build process
Documentation
[![CI](https://github.com/bazhenov/cargo-export/actions/workflows/ci.yaml/badge.svg)](https://github.com/bazhenov/cargo-export/actions/workflows/ci.yaml)
[![Crates.io](https://img.shields.io/crates/v/cargo-export)
](https://crates.io/crates/cargo-export)
[![GitHub release (with filter)](https://img.shields.io/github/v/release/bazhenov/cargo-export)](https://github.com/bazhenov/cargo-export/releases)
[![GitHub License](https://img.shields.io/github/license/bazhenov/cargo-export)](https://github.com/bazhenov/cargo-export?tab=MIT-1-ov-file#readme)

# 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

```console
$ cargo install cargo-export
```

## Using

### Local

- export all test binaries to `target/tests` directory
  ```console
  $ 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
  ```console
  $ cargo export target/bench -- bench
  ```

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

- build and export benchmarks with a specific feature
  ```console
  $ cargo export target/bench -- bench --feature=my-feature
  ```

- build and export benchmarks using nightly
  ```console
  $ 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.

```yaml
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
```