Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e35168ee8f | ||
|
|
9e709706e7 | ||
|
|
294bb6a7fe | ||
|
|
99d882779c | ||
|
|
9a3029eecb | ||
|
|
ede19eddfb | ||
|
|
e021eb0bd0 | ||
|
|
2092d69e17 | ||
|
|
d5709df172 | ||
|
|
ad283b2fc6 | ||
|
|
52a0827e28 | ||
|
|
e4e3cc18ae | ||
|
|
46b4378cc7 | ||
|
|
e67629a125 | ||
|
|
83cb238ff9 | ||
|
|
b80da53df0 | ||
|
|
6f63b60be6 | ||
|
|
ace37a7d90 | ||
|
|
2297f8e434 | ||
|
|
9b467e6799 | ||
|
|
c464bd9469 | ||
|
|
a0b2ccd631 | ||
|
|
8c9b9d6490 | ||
|
|
778bb6075f | ||
|
|
1bbdab0f68 | ||
|
|
c40662f61a | ||
|
|
7d5643fe34 | ||
|
|
3be49880a3 | ||
|
|
070eee0271 | ||
|
|
d4b2d5201c | ||
|
|
e1ea800ed7 | ||
|
|
fc51bd6dfd | ||
|
|
d02a87e838 | ||
|
|
3de92613ad | ||
|
|
c507aeb1b5 | ||
|
|
9fb7236944 | ||
|
|
883c7a0854 | ||
|
|
ef5051e603 |
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
name: Check that code is lint clean using precious
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.email "jdoe@example.com"
|
||||
|
||||
121
.github/workflows/test.yml
vendored
121
.github/workflows/test.yml
vendored
@@ -14,6 +14,7 @@ jobs:
|
||||
- platform_name: FreeBSD-x86_64
|
||||
os: ubuntu-20.04
|
||||
target: x86_64-unknown-freebsd
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+FreeBSD"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -22,6 +23,7 @@ jobs:
|
||||
- platform_name: Linux-x86_64
|
||||
os: ubuntu-20.04
|
||||
target: x86_64-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+x86-64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
@@ -30,14 +32,69 @@ jobs:
|
||||
- platform_name: Linux-aarch64
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-aarch64 (no cache)
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cache-cross-binary: false
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cross-version: "v0.2.3"
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "0.2.3"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3 (no cache)
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cross-version: "v0.2.3"
|
||||
cache-cross-binary: false
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "0.2.3"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cross-version: "19be834"
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "19be834"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834
|
||||
os: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cross-version: "19be834"
|
||||
cache-cross-binary: false
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "19be834"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-arm
|
||||
os: ubuntu-20.04
|
||||
target: arm-unknown-linux-musleabi
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "32.+ARM"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -46,39 +103,17 @@ jobs:
|
||||
- platform_name: Linux-i586
|
||||
os: ubuntu-20.04
|
||||
target: i586-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+80386"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-mips
|
||||
os: ubuntu-20.04
|
||||
target: mips-unknown-linux-musl
|
||||
expect_file_re: "MIPS32.+mips-"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-mipsel
|
||||
- platform_name: Linux-i686
|
||||
os: ubuntu-20.04
|
||||
target: mipsel-unknown-linux-musl
|
||||
expect_file_re: "MIPS32.+mipsel-"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-mips64
|
||||
os: ubuntu-20.04
|
||||
target: mips64-unknown-linux-muslabi64
|
||||
expect_file_re: "MIPS64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
|
||||
- platform_name: Linux-mips64el
|
||||
os: ubuntu-20.04
|
||||
target: mips64el-unknown-linux-muslabi64
|
||||
expect_file_re: "MIPS64"
|
||||
target: i686-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+80386"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
can_test: true
|
||||
@@ -86,6 +121,7 @@ jobs:
|
||||
- platform_name: Linux-powerpc
|
||||
os: ubuntu-20.04
|
||||
target: powerpc-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "32.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -94,6 +130,7 @@ jobs:
|
||||
- platform_name: Linux-powerpc64
|
||||
os: ubuntu-20.04
|
||||
target: powerpc64-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -102,6 +139,7 @@ jobs:
|
||||
- platform_name: Linux-powerpc64le
|
||||
os: ubuntu-20.04
|
||||
target: powerpc64le-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -110,6 +148,7 @@ jobs:
|
||||
- platform_name: Linux-riscv64
|
||||
os: ubuntu-20.04
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+RISC-V"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -118,6 +157,7 @@ jobs:
|
||||
- platform_name: Linux-s390x
|
||||
os: ubuntu-20.04
|
||||
target: s390x-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+S/390"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -126,6 +166,7 @@ jobs:
|
||||
- platform_name: NetBSD-x86_64
|
||||
os: ubuntu-20.04
|
||||
target: x86_64-unknown-netbsd
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+NetBSD"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -134,6 +175,7 @@ jobs:
|
||||
- platform_name: Windows-aarch64
|
||||
os: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Aarch64.+Windows"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
@@ -142,6 +184,7 @@ jobs:
|
||||
- platform_name: Windows-i686
|
||||
os: windows-latest
|
||||
target: i686-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "80386.+Windows"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
@@ -150,6 +193,7 @@ jobs:
|
||||
- platform_name: Windows-x86_64
|
||||
os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+Windows"
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_test: true
|
||||
@@ -157,6 +201,7 @@ jobs:
|
||||
- platform_name: macOS-x86_64
|
||||
os: macOS-latest
|
||||
target: x86_64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Mach-O.+x86_64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
@@ -165,6 +210,7 @@ jobs:
|
||||
- platform_name: macOS-aarch64
|
||||
os: macOS-latest
|
||||
target: aarch64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Mach-O.+arm64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--expect-stripped"
|
||||
@@ -173,7 +219,7 @@ jobs:
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Copy test project to root
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -183,6 +229,8 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
command: both
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
@@ -190,13 +238,27 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
command: test
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
- name: Run test command with args
|
||||
uses: ./
|
||||
with:
|
||||
command: test
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: "-- --ignored"
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
- name: Run build command
|
||||
uses: ./
|
||||
with:
|
||||
command: build
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
strip: true
|
||||
@@ -204,6 +266,8 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
command: build
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
working-directory: subcrate
|
||||
target: ${{ matrix.platform.target }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -214,5 +278,6 @@ jobs:
|
||||
tests/check-binary.pl \
|
||||
--target "${{ matrix.platform.target }}" \
|
||||
--expect-file-re "${{ matrix.platform.expect_file_re }}" \
|
||||
--expect-cross-version "${{ matrix.platform.expect_cross_version }}" \
|
||||
${{ matrix.platform.expect_cross }} \
|
||||
${{ matrix.platform.expect_stripped }}
|
||||
|
||||
39
Changes.md
39
Changes.md
@@ -1,3 +1,42 @@
|
||||
## 0.0.16 - 2024-11-17
|
||||
|
||||
- Arguments passed in the `args` parameter are now always last when executing `cargo`. This lets you
|
||||
pass arguments to test binaries like `-- --something`. First reported by @mateocabanal (Mateo
|
||||
Cabanal) as GH #12 and fully fixed by @donatello (Aditya Manthramurthy) in GH #30.
|
||||
|
||||
## 0.0.15 - 2024-09-21
|
||||
|
||||
- The `musl` packages are only installed when not cross-compiling.
|
||||
|
||||
## 0.0.14 - 2024-08-25
|
||||
|
||||
- When the given `target` includes the string `musl`, this action will install the `musl-tools`
|
||||
package. This allows crates with C or C++ code to compile properly. Fixes #20. Reported by Matteo
|
||||
Pietro Dazzi (@ilteoood).
|
||||
|
||||
## 0.0.13 - 2024-05-18
|
||||
|
||||
- It's now possible to set `cross-version` to a git ref like a commit hash or `HEAD`. This will
|
||||
install `cross` from its git repo.
|
||||
|
||||
## 0.0.12 - 2024-02-25
|
||||
|
||||
- Bumped the version of `actions/cache` used in this action to v4. The v3 version uses Node 16,
|
||||
which causes warnings when run. Implemented by @hms5232. GH #13.
|
||||
|
||||
## 0.0.11 - 2023-12-17
|
||||
|
||||
- Use `cross` when compiling for 32-bit Linux targets. While in theory this should work without
|
||||
`cross`, compiling `openssl` with the `vendored` feature fails when we run
|
||||
`cargo build --target i686-unknown-linux-musl`.
|
||||
|
||||
## 0.0.10 - 2023-12-10
|
||||
|
||||
- Fixed handling of crates with multiple binaries. Attempting to strip binaries for such a crate
|
||||
caused the build to fail. Reported by Tomaž Hribernik. GH #8
|
||||
- Added a new `cross-version` parameter. This can be specified to make this action use a specific
|
||||
version of `cross`. If this is not specified, the latest version will be used.
|
||||
|
||||
## 0.0.9 - 2023-09-10
|
||||
|
||||
- Added a `working-directory` parameter. By default this is the current directory (`.`) but you can
|
||||
|
||||
81
README.md
81
README.md
@@ -3,40 +3,44 @@
|
||||
This action lets you easily cross-compile Rust projects using
|
||||
[cross](https://github.com/cross-rs/cross).
|
||||
|
||||
Here's an example from the release workflow for
|
||||
[my tool `precious`](https://github.com/houseabsolute/precious):
|
||||
Here's a simplified example from the test and release workflow for
|
||||
[my tool `ubi`](https://github.com/houseabsolute/ubi):
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
release:
|
||||
name: Release - ${{ matrix.platform.release_for }}
|
||||
name: Release - ${{ matrix.platform.os-name }}
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- release_for: FreeBSD-x86_64
|
||||
os: ubuntu-20.04
|
||||
- os-name: FreeBSD-x86_64
|
||||
runs-on: ubuntu-20.04
|
||||
target: x86_64-unknown-freebsd
|
||||
bin: precious
|
||||
name: precious-FreeBSD-x86_64.tar.gz
|
||||
command: build
|
||||
skip_tests: true
|
||||
|
||||
- release_for: Windows-x86_64
|
||||
os: windows-latest
|
||||
- os-name: Linux-x86_64
|
||||
runs-on: ubuntu-20.04
|
||||
target: x86_64-unknown-linux-musl
|
||||
|
||||
- os-name: Linux-aarch64
|
||||
runs-on: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
|
||||
- os-name: Linux-riscv64
|
||||
runs-on: ubuntu-20.04
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
|
||||
- os-name: Windows-x86_64
|
||||
runs-on: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
bin: precious.exe
|
||||
name: precious-Windows-x86_64.zip
|
||||
command: both
|
||||
|
||||
- release_for: macOS-x86_64
|
||||
os: macOS-latest
|
||||
- os-name: macOS-x86_64
|
||||
runs-on: macOS-latest
|
||||
target: x86_64-apple-darwin
|
||||
bin: precious
|
||||
name: precious-Darwin-x86_64.tar.gz
|
||||
command: both
|
||||
|
||||
# more release targets here ...
|
||||
# more targets here ...
|
||||
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
runs-on: ${{ matrix.platform.runs-on }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -47,27 +51,36 @@ jobs:
|
||||
target: ${{ matrix.platform.target }}
|
||||
args: "--locked --release"
|
||||
strip: true
|
||||
|
||||
# more packaging stuff goes here ...
|
||||
- name: Publish artifacts and release
|
||||
uses: houseabsolute/actions-rust-release@v0
|
||||
with:
|
||||
executable-name: ubi
|
||||
target: ${{ matrix.platform.target }}
|
||||
```
|
||||
|
||||
Note that for Linux or BSD targets, you should always set the `runs-on` key to an x86-64
|
||||
architecture runner. If you want to do native ARM compilation, for example using
|
||||
`ubuntu-latest-arm`, then there's no point in using this action. This action is only tested on
|
||||
Ubuntu x86-64, Windows, and macOS runners.
|
||||
|
||||
## Input Parameters
|
||||
|
||||
This action takes the following parameters:
|
||||
|
||||
| Key | Type | Required? | Description |
|
||||
| ------------------- | ---------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `command` | string (one of `build`, `test`, or `both`) | no | The command(s) to run. The default is `build`. Running the `test` command will fails with \*BSD targets, non-x86 Windows, and macOS ARM. |
|
||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
|
||||
| `working-directory` | string | no | The working directory in which to run the `cargo` or `cross` commands. Defaults to the current directory (`.`). |
|
||||
| `toolchain` | string (one of `stable`, `beta`, or `nightly`) | no | The Rust toolchain version to install. The default is `stable`. |
|
||||
| `GITHUB_TOKEN` | string | no | Defaults to the value of `${{ github.token }}`. |
|
||||
| `args` | string | no | A string-separated list of arguments to be passed to `cross build`, like `--release --locked`. |
|
||||
| `strip` | boolean (`true` or `false`) | no | If this is true, then the resulting binary will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
||||
| Key | Type | Required? | Description |
|
||||
| ------------------- | ---------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `command` | string (one of `build`, `test`, or `both`) | no | The command(s) to run. The default is `build`. Running the `test` command will fail with \*BSD targets and non-x86 Windows. |
|
||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets found by running `rustup target list`. |
|
||||
| `working-directory` | string | no | The working directory in which to run the `cargo` or `cross` commands. Defaults to the current directory (`.`). |
|
||||
| `toolchain` | string (one of `stable`, `beta`, or `nightly`) | no | The Rust toolchain version to install. The default is `stable`. |
|
||||
| `GITHUB_TOKEN` | string | no | Defaults to the value of `${{ github.token }}`. |
|
||||
| `args` | string | no | A string-separated list of arguments to be passed to `cross build`, like `--release --locked`. |
|
||||
| `strip` | boolean (`true` or `false`) | no | If this is true, then the resulting binaries will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
||||
| `cross-version` | string | no | This can be used to set the version of `cross` to use. If specified, it should be a specific `cross` release tag (like `v0.2.3`) or a git ref (commit hash, `HEAD`, etc.). If this is not set then the latest released version will always be used. If this is set to a git ref then the version corresponding to that ref will be installed. |
|
||||
|
||||
## How it Works
|
||||
|
||||
Under the hood, this action will compile your binary with either `cargo` or `cross`, depending on
|
||||
Under the hood, this action will compile your binaries with either `cargo` or `cross`, depending on
|
||||
the host machine and target. For Linux builds, it will always use `cross` except for builds
|
||||
targeting an x86 architecture like `x86_64` or `i686`.
|
||||
|
||||
@@ -81,12 +94,12 @@ build `cross`.
|
||||
When compiling on Windows, it will do so in a Powershell environment, which can matter in some
|
||||
corner cases, like compiling the `openssl` crate with the `vendored` feature.
|
||||
|
||||
Finally, it will run `strip` to strip the binary if the `strip` parameter is true. This is only
|
||||
Finally, it will run `strip` to strip the binaries if the `strip` parameter is true. This is only
|
||||
possible for builds that are not done via `cross`. In addition, Windows builds for `aarch64` cannot
|
||||
be stripped either.
|
||||
|
||||
## Caching Rust Compilation Output
|
||||
|
||||
You can use the [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) action with this one
|
||||
seemlessly, whether or not a specific build target needs `cross`. There is no special configuration
|
||||
seamlessly, whether or not a specific build target needs `cross`. There is no special configuration
|
||||
that you need for this. It just works.
|
||||
|
||||
49
action.yml
49
action.yml
@@ -32,6 +32,15 @@ inputs:
|
||||
strip:
|
||||
description: Strip the compiled binary
|
||||
default: false
|
||||
cross-version:
|
||||
description: |
|
||||
The version of cross to use. If not specified, then the latest version
|
||||
will be used.
|
||||
cache-cross-binary:
|
||||
description: |
|
||||
Cache the cross binary if one is installed. This is primarily for use in
|
||||
tests of this action.
|
||||
default: true
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
@@ -47,33 +56,37 @@ runs:
|
||||
with:
|
||||
targets: ${{ inputs.target }}
|
||||
toolchain: ${{ inputs.toolchain }}
|
||||
- name: Determine latest cross version
|
||||
id: determine-latest-cross-version
|
||||
- name: Determine cross version
|
||||
id: determine-cross-version
|
||||
shell: bash
|
||||
run: determine-latest-cross-version.sh
|
||||
run: determine-cross-version.sh "${{ inputs.cross-version }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
# We need to accesss this in both this YAML config and shell scripts. It
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||
# We need to access this in both this YAML config and shell scripts. It
|
||||
# doesn't seem like using ${{ env.RUNNER_TEMP }} works in the YAML config.
|
||||
- name: Set directory for installing cross
|
||||
id: set-cross-dir
|
||||
shell: bash
|
||||
run: set-cross-dir.sh
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||
- name: Cache cross
|
||||
id: cache-cross
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
||||
key: ${{ runner.os }}-${{ steps.determine-latest-cross-version.outputs.cross-version }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
key: ${{ runner.os }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && inputs.cache-cross-binary == 'true'
|
||||
- name: Install cross if cross-compiling (*nix)
|
||||
shell: bash
|
||||
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true' }}
|
||||
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }} ${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
- name: Install musl-tools on Linux if target includes "musl"
|
||||
shell: bash
|
||||
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
|
||||
if: steps.determine-cross-compile.outputs.needs-cross != 'true' && contains(inputs.target, 'musl')
|
||||
- name: Set build command
|
||||
id: set-build-command
|
||||
shell: bash
|
||||
@@ -82,8 +95,8 @@ runs:
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'build' && runner.os != 'Windows' }}
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: inputs.command != 'build' && runner.os != 'Windows'
|
||||
# We want to run in Powershell on Windows to make sure we compile in a
|
||||
# native Windows environment. Some things won't compile properly under
|
||||
# msys, notably OpenSSL, which is compiled locally when using the
|
||||
@@ -92,23 +105,23 @@ runs:
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: powershell
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: inputs.command != 'build' && runner.os == 'Windows'
|
||||
- name: Build binary (*nix)
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'test' && runner.os != 'Windows' }}
|
||||
if: inputs.command != 'test' && runner.os != 'Windows'
|
||||
- name: Build binary (Windows)
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: powershell
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
||||
if: inputs.command != 'test' && runner.os == 'Windows'
|
||||
- name: Strip binary
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
run: strip-binary.sh ${{ inputs.target }}
|
||||
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
||||
if: ${{ inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}
|
||||
if: inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc'
|
||||
|
||||
17
determine-cross-version.sh
Executable file
17
determine-cross-version.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
VERSION=$1
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
JSON=$(curl \
|
||||
--request GET \
|
||||
--header "Authorization: Bearer $GITHUB_TOKEN" \
|
||||
https://api.github.com/repos/cross-rs/cross/releases/latest)
|
||||
VERSION=$(echo "$JSON" | jq -r ".tag_name")
|
||||
fi
|
||||
|
||||
echo "cross-version=$VERSION" >>"$GITHUB_OUTPUT"
|
||||
@@ -1,11 +0,0 @@
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
JSON=$( curl \
|
||||
--request GET \
|
||||
--header "Authorization: Bearer $GITHUB_TOKEN" \
|
||||
https://api.github.com/repos/cross-rs/cross/releases/latest )
|
||||
VERSION=$( echo "$JSON" | jq -r ".tag_name")
|
||||
|
||||
echo "cross-version=$VERSION" >> $GITHUB_OUTPUT
|
||||
@@ -1,32 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
set -x
|
||||
|
||||
function run () {
|
||||
echo $1
|
||||
eval $1
|
||||
function run() {
|
||||
echo "$1"
|
||||
eval "$1"
|
||||
}
|
||||
|
||||
function install_tools () {
|
||||
function install_tools() {
|
||||
curl --silent --location \
|
||||
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
|
||||
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
|
||||
sh
|
||||
run "ubi --project houseabsolute/precious --in ~/bin"
|
||||
run "ubi --project houseabsolute/omegasort --in ~/bin"
|
||||
run "ubi --project houseabsolute/precious --in $HOME/bin"
|
||||
run "ubi --project houseabsolute/omegasort --in $HOME/bin"
|
||||
run "ubi --project koalaman/shellcheck --in $HOME/bin"
|
||||
run "ubi --project mvdan/sh --in $HOME/bin --exe shfmt"
|
||||
run "ubi --project crate-ci/typos --in $HOME/bin"
|
||||
run "npm install prettier"
|
||||
run "curl -L https://cpanmin.us/ -o ~/bin/cpanm"
|
||||
run "chmod 0755 ~/bin/cpanm"
|
||||
run "~/bin/cpanm --sudo --notest Perl::Tidy"
|
||||
run "curl -L https://cpanmin.us/ -o $HOME/bin/cpanm"
|
||||
run "chmod 0755 $HOME/bin/cpanm"
|
||||
run "$HOME/bin/cpanm --sudo --notest Perl::Tidy"
|
||||
}
|
||||
|
||||
if [ "$1" == "-v" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
mkdir -p $HOME/bin
|
||||
mkdir -p "$HOME"/bin
|
||||
|
||||
set +e
|
||||
echo ":$PATH:" | grep --extended-regexp ":$HOME/bin:" >& /dev/null
|
||||
echo ":$PATH:" | grep --extended-regexp ":$HOME/bin:" >&/dev/null
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" -eq "0" ]; then
|
||||
path_has_home_bin=1
|
||||
fi
|
||||
@@ -40,7 +45,7 @@ install_tools
|
||||
|
||||
echo "Tools were installed into $HOME/bin."
|
||||
if [ -z "$path_has_home_bin" ]; then
|
||||
echo "You should add $HOME/bin to your PATH."
|
||||
echo "You should add $HOME/bin to your PATH."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -i status
|
||||
status=0
|
||||
|
||||
PRECIOUS=$(which precious)
|
||||
@@ -7,8 +8,7 @@ if [[ -z $PRECIOUS ]]; then
|
||||
PRECIOUS=./bin/precious
|
||||
fi
|
||||
|
||||
"$PRECIOUS" lint -s
|
||||
if (( $? != 0 )); then
|
||||
if ! "$PRECIOUS" lint -s; then
|
||||
status+=1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,11 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
CROSS_DIR="$1"
|
||||
VERSION="$2"
|
||||
|
||||
cd "$CROSS_DIR"
|
||||
|
||||
if [[ -n $VERSION ]] && ! [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
cargo install cross --git https://github.com/cross-rs/cross --rev "$VERSION" --force
|
||||
mv "$HOME/.cargo/bin/cross" .
|
||||
CROSS_NO_WARNINGS=0 ./cross --version
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VERSION_ARGS=""
|
||||
if [ -n "$VERSION" ]; then
|
||||
VERSION_ARGS="--tag $VERSION"
|
||||
fi
|
||||
|
||||
export TARGET=.
|
||||
curl --silent --location \
|
||||
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
|
||||
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
|
||||
sh
|
||||
./ubi --project cross-rs/cross --matching musl --in .
|
||||
# shellcheck disable=SC2086
|
||||
./ubi --project cross-rs/cross --matching musl --in . $VERSION_ARGS
|
||||
CROSS_NO_WARNINGS=0 ./cross --version
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
exclude = [
|
||||
"target",
|
||||
"tests/lib/**/*",
|
||||
]
|
||||
|
||||
[commands.typos]
|
||||
type = "both"
|
||||
include = "**/*"
|
||||
exclude = "**/*.tar.gz"
|
||||
invoke = "once"
|
||||
cmd = "typos"
|
||||
tidy_flags = "--write-changes"
|
||||
ok-exit-codes = 0
|
||||
lint-failure-exit-codes = 2
|
||||
|
||||
[commands.perltidy]
|
||||
type = "both"
|
||||
include = [ "**/*.{pl,pm,t,psgi}" ]
|
||||
@@ -45,3 +56,19 @@ ignore_stderr = [
|
||||
"The .+ file is not sorted",
|
||||
"The .+ file is not unique",
|
||||
]
|
||||
|
||||
[commands.shellcheck]
|
||||
type = "lint"
|
||||
include = "**/*.sh"
|
||||
cmd = "shellcheck"
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 1
|
||||
|
||||
[commands.shfmt]
|
||||
type = "both"
|
||||
include = "**/*.sh"
|
||||
cmd = ["shfmt", "--simplify", "--indent", "4"]
|
||||
lint_flags = "--diff"
|
||||
tidy_flags = "--write"
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 1
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
CROSS_DIR="$1"
|
||||
if [ -f "$CROSS_DIR/cross" ]; then
|
||||
echo "build-command=$CROSS_DIR/cross" >> $GITHUB_OUTPUT
|
||||
echo "build-command=$CROSS_DIR/cross" >>"$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "build-command=cargo" >> $GITHUB_OUTPUT
|
||||
echo "build-command=cargo" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
TARGET="$1"
|
||||
|
||||
# On macOS and Windows, we can cross-compile to all possible targets without
|
||||
# using cross.
|
||||
if uname -a | grep --quiet --extended-regexp -i "darwin|msys|windows"; then
|
||||
echo "needs-cross=false" >> $GITHUB_OUTPUT
|
||||
echo "needs-cross=false" >>"$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if echo "$TARGET" | grep --quiet --extended-regexp -i '(x86_64|586|686).+linux-(gnu|musl)'; then
|
||||
echo "needs-cross=false" >> $GITHUB_OUTPUT
|
||||
# On Linux, we should be able to cross-compile to i586 and i686, but in
|
||||
# practice this fails with some crates, notably openssl with the "vendored"
|
||||
# feature. This feature makes it compile openssl itself, which fails without
|
||||
# cross.
|
||||
if echo "$TARGET" | grep --quiet --extended-regexp -i 'x86_64.+linux-(gnu|musl)'; then
|
||||
echo "needs-cross=false" >>"$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "needs-cross=true" >> $GITHUB_OUTPUT
|
||||
echo "needs-cross=true" >>"$GITHUB_OUTPUT"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
echo "cross-dir=$RUNNER_TEMP" >> $GITHUB_OUTPUT
|
||||
echo "cross-dir=$RUNNER_TEMP" >>"$GITHUB_OUTPUT"
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
TARGET=$1
|
||||
stripped=""
|
||||
did_strip=""
|
||||
|
||||
strip_binary () {
|
||||
if [[ $( uname -s ) =~ "Darwin" ]]; then
|
||||
EXE=$( find "$1" -maxdepth 1 -type f -perm +111 )
|
||||
strip_binary() {
|
||||
if [[ $(uname -s) =~ "Darwin" ]]; then
|
||||
stripped=$(
|
||||
find "$1" -maxdepth 1 -type f -perm +111 | while read -r exe; do
|
||||
strip "$exe"
|
||||
echo "stripped $exe"
|
||||
done
|
||||
)
|
||||
else
|
||||
EXE=$( find "$1" -maxdepth 1 -type f -executable )
|
||||
stripped=$(
|
||||
find "$1" -maxdepth 1 -type f -executable | while read -r exe; do
|
||||
strip "$exe"
|
||||
echo "stripped $exe"
|
||||
done
|
||||
)
|
||||
fi
|
||||
|
||||
if [ -z "$EXE" ]; then
|
||||
echo "Could not find a binary to strip in $1"
|
||||
if [ -z "$stripped" ]; then
|
||||
echo "Could not find any binaries to strip in $1"
|
||||
else
|
||||
strip "$EXE"
|
||||
stripped="$EXE"
|
||||
did_strip="true"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -27,7 +39,7 @@ for type in debug release; do
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$stripped" ]; then
|
||||
if [ -z "$did_strip" ]; then
|
||||
echo "No binaries were stripped"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -3,4 +3,25 @@ name = "test-project"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# For testing it would be nice to create a binary with spaces in the name, but
|
||||
# right now the `name` value must be a valid crate name, and there's no
|
||||
# separate setting for the compiled executable's name. See
|
||||
# https://github.com/rust-lang/cargo/issues/9778.
|
||||
[[bin]]
|
||||
name = "bin1"
|
||||
path = "src/bin1.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "bin2"
|
||||
path = "src/bin2.rs"
|
||||
|
||||
# workaround for https://github.com/cross-rs/cross/issues/1345
|
||||
[package.metadata.cross.target.x86_64-unknown-netbsd]
|
||||
pre-build = [
|
||||
"mkdir -p /tmp/netbsd",
|
||||
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
|
||||
"tar -C /tmp/netbsd -xJf base.tar.xz",
|
||||
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
|
||||
"rm base.tar.xz",
|
||||
"rm -rf /tmp/netbsd",
|
||||
]
|
||||
|
||||
17
test-project/src/bin2.rs
Normal file
17
test-project/src/bin2.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
#[test]
|
||||
fn test_something() {
|
||||
assert_eq!(1, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_something_ignored() {
|
||||
assert_eq!(2, 2);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,13 @@ name = "subcrate"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
# workaround for https://github.com/cross-rs/cross/issues/1345
|
||||
[package.metadata.cross.target.x86_64-unknown-netbsd]
|
||||
pre-build = [
|
||||
"mkdir -p /tmp/netbsd",
|
||||
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
|
||||
"tar -C /tmp/netbsd -xJf base.tar.xz",
|
||||
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
|
||||
"rm base.tar.xz",
|
||||
"rm -rf /tmp/netbsd",
|
||||
]
|
||||
|
||||
@@ -19,20 +19,27 @@ use Test::More;
|
||||
sub main {
|
||||
my $target;
|
||||
my $expect_cross;
|
||||
my $expect_cross_version;
|
||||
my $expect_file_re;
|
||||
my $expect_stripped;
|
||||
|
||||
GetOptions(
|
||||
'target=s' => \$target,
|
||||
'expect-file-re=s' => \$expect_file_re,
|
||||
'expect-cross!' => \$expect_cross,
|
||||
'expect-stripped!' => \$expect_stripped,
|
||||
'target=s' => \$target,
|
||||
'expect-file-re=s' => \$expect_file_re,
|
||||
'expect-cross!' => \$expect_cross,
|
||||
'expect-cross-version=s' => \$expect_cross_version,
|
||||
'expect-stripped!' => \$expect_stripped,
|
||||
);
|
||||
|
||||
check_cross( path( $ENV{RUNNER_TEMP} ), $expect_cross );
|
||||
check_cross(
|
||||
path( $ENV{RUNNER_TEMP} ),
|
||||
$expect_cross,
|
||||
$expect_cross_version
|
||||
);
|
||||
|
||||
for my $bin (
|
||||
path( qw( . target ), $target, qw( debug test-project ) ),
|
||||
path( qw( . target ), $target, qw( debug bin1 ) ),
|
||||
path( qw( . target ), $target, qw( debug bin2 ) ),
|
||||
path( qw( . subcrate target ), $target, qw( debug subcrate ) )
|
||||
) {
|
||||
check_binary( $bin, $expect_file_re, $expect_stripped );
|
||||
@@ -41,10 +48,17 @@ sub main {
|
||||
done_testing();
|
||||
}
|
||||
|
||||
sub check_cross ( $bin_dir, $expect_cross ) {
|
||||
sub check_cross ( $bin_dir, $expect_cross, $expect_cross_version ) {
|
||||
my $cross = $bin_dir->child('cross');
|
||||
if ($expect_cross) {
|
||||
ok( $cross->is_file && -x $cross, 'found `cross` in $PATH' );
|
||||
if ($expect_cross_version) {
|
||||
my $version = capturex( $cross, '--version' );
|
||||
like(
|
||||
$version, qr/\Q$expect_cross_version/,
|
||||
'cross version matches expected version'
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ok( !$cross->exists, 'did not find `cross` in $PATH' );
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
TARGET=$1
|
||||
EXPECT_CROSS=$2
|
||||
EXPECT_FILE_RE=$3
|
||||
EXPECT_STRIPPED=$4
|
||||
|
||||
if [ "$EXPECT_CROSS" == "true" ]; then
|
||||
if [ ! -f "$RUNNER_TEMP/cross" ]; then
|
||||
echo "Could not find cross in path: $PATH"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ -f "$RUNNER_TEMP/cross" ]; then
|
||||
echo "Found cross in path: $PATH"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
FILE=$(file --brief ./target/$TARGET/debug/test-project)
|
||||
if [[ "$FILE" =~ $EXPECT_FILE_RE ]]; then
|
||||
echo "file output matches $EXPECT_FILE_RE"
|
||||
else
|
||||
echo "file output does not match $EXPECT_FILE_RE"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ $( uname -s ) =~ "Darwin" ]]; then
|
||||
# File on macOS doesn't report whether the binary is stripped or not.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$FILE" =~ "not stripped" ]]; then
|
||||
echo "binary was not stripped"
|
||||
GOT_STRIPPED="false"
|
||||
elif [[ "$FILE" =~ "stripped" ]]; then
|
||||
echo "binary was stripped"
|
||||
GOT_STRIPPED="true"
|
||||
else
|
||||
# On Windows the aarch64 binary's file info doesn't include the word
|
||||
# "stripped" at all.
|
||||
echo "binary was not stripped"
|
||||
GOT_STRIPPED="false"
|
||||
fi
|
||||
|
||||
if [ "$EXPECT_STRIPPED" != "$GOT_STRIPPED" ]; then
|
||||
exit 3
|
||||
fi
|
||||
Reference in New Issue
Block a user