3 Commits

Author SHA1 Message Date
Dave Rolsky
356ca41f7d Make strip script strip all binaries under target
Some checks failed
Self-test / Test (map[can_test:false expect_cross:false expect_file:Aarch64.+Windows expect_stripped:false os:windows-latest platform_name:Windows-aarch64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:false expect_file:Mach-O.+arm64 expect_stripped:true os:macOS-latest platform_name:macOS-aarch64 target:aarch64-apple-darwin]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:true expect_file:x86-64.+FreeBSD expect_stripped:false os:ubuntu-20.04 platform_name:FreeBSD-x86_64 target:x86_64-unknown-freebsd]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:true expect_file:x86-64.+NetBSD expect_stripped:false os:ubuntu-20.04 platform_name:NetBSD-x86_64 target:x86_64-unknown-netbsd]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:80386.+Windows expect_stripped:true os:windows-latest platform_name:Windows-i686 target:i686-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:ELF.+80386 expect_stripped:true os:ubuntu-20.04 platform_name:Linux-i586 target:i586-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:ELF.+x86-64 expect_stripped:true os:ubuntu-20.04 platform_name:Linux-x86_64 target:x86_64-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:Mach-O.+x86_64 expect_stripped:true os:macOS-latest platform_name:macOS-x86_64 target:x86_64-apple-darwin]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:x86-64.+Windows expect_stripped:true os:windows-latest platform_name:Windows-x86_64 target:x86_64-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:32.+ARM expect_stripped:false os:ubuntu-20.04 platform_name:Linux-arm target:arm-unknown-linux-musleabi]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:32.+PowerPC expect_stripped:false os:ubuntu-20.04 platform_name:Linux-powerpc target:powerpc-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+PowerPC expect_stripped:false os:ubuntu-20.04 platform_name:Linux-powerpc64 target:powerpc64-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+PowerPC expect_stripped:false os:ubuntu-20.04 platform_name:Linux-powerpc64le target:powerpc64le-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+RISC-V expect_stripped:false os:ubuntu-20.04 platform_name:Linux-riscv64 target:riscv64gc-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+S/390 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-s390x target:s390x-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS32.+mips- expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mips target:mips-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS32.+mipsel- expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mipsel target:mipsel-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS64 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mips64 target:mips64-unknown-linux-muslabi64]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS64 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mips64el target:mips64el-unknown-linux-muslabi64]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:aarch64 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-aarch64 target:aarch64-unknown-linux-musl]) (push) Has been cancelled
If there were both debug & release dirs it would only strip one binary, and if
the debug dir had no binary at all it would error, even if the release dir had
one.
2023-04-21 22:39:30 -05:00
Dave Rolsky
91d78d9182 Use dtolnay/rust-toolchain@master instead of @stable
Some checks failed
Self-test / Test (map[can_test:false expect_cross:false expect_file:Aarch64.+Windows expect_stripped:false os:windows-latest platform_name:Windows-aarch64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:false expect_file:Mach-O.+arm64 expect_stripped:true os:macOS-latest platform_name:macOS-aarch64 target:aarch64-apple-darwin]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:true expect_file:x86-64.+FreeBSD expect_stripped:false os:ubuntu-20.04 platform_name:FreeBSD-x86_64 target:x86_64-unknown-freebsd]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:true expect_file:x86-64.+NetBSD expect_stripped:false os:ubuntu-20.04 platform_name:NetBSD-x86_64 target:x86_64-unknown-netbsd]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:80386.+Windows expect_stripped:true os:windows-latest platform_name:Windows-i686 target:i686-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:ELF.+80386 expect_stripped:true os:ubuntu-20.04 platform_name:Linux-i586 target:i586-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:ELF.+x86-64 expect_stripped:true os:ubuntu-20.04 platform_name:Linux-x86_64 target:x86_64-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:Mach-O.+x86_64 expect_stripped:true os:macOS-latest platform_name:macOS-x86_64 target:x86_64-apple-darwin]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:x86-64.+Windows expect_stripped:true os:windows-latest platform_name:Windows-x86_64 target:x86_64-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:32.+ARM expect_stripped:false os:ubuntu-20.04 platform_name:Linux-arm target:arm-unknown-linux-musleabi]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:32.+PowerPC expect_stripped:false os:ubuntu-20.04 platform_name:Linux-powerpc target:powerpc-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+PowerPC expect_stripped:false os:ubuntu-20.04 platform_name:Linux-powerpc64 target:powerpc64-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+PowerPC expect_stripped:false os:ubuntu-20.04 platform_name:Linux-powerpc64le target:powerpc64le-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+RISC-V expect_stripped:false os:ubuntu-20.04 platform_name:Linux-riscv64 target:riscv64gc-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+S/390 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-s390x target:s390x-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS32.+mips- expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mips target:mips-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS32.+mipsel- expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mipsel target:mipsel-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS64 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mips64 target:mips64-unknown-linux-muslabi64]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS64 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-mips64el target:mips64el-unknown-linux-muslabi64]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:aarch64 expect_stripped:false os:ubuntu-20.04 platform_name:Linux-aarch64 target:aarch64-unknown-linux-musl]) (push) Has been cancelled
This allows passing the `toolchain` input.
2023-03-20 12:18:06 -04:00
Dave Rolsky
30e7adeceb Add toolchain input to README.md docs 2023-03-19 17:43:22 -04:00
4 changed files with 41 additions and 28 deletions

View File

@@ -1,3 +1,15 @@
## 0.0.6 - 2023-04-21
- When the `strip` parameter was true, stripping binaries could fail if there
were both `target/*/debug` and `target/*/release` directories present and
the `debug` directory didn't have a binary. Now it will strip all binaries
it finds under `target`.
## 0.0.5 - 2023-03-19
- Fix use of `dtolnay/rust-toolchain` action to allow passing a `toolchain`
input.
## 0.0.4 - 2023-03-19
- Added a new `toolchain` parameter to allow selecting a Rust toolchain other

View File

@@ -55,13 +55,14 @@ jobs:
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`. |
| `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 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`. |
| `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. |
## How it Works

View File

@@ -40,7 +40,7 @@ runs:
shell: bash
run: set-cross-compile.sh ${{ inputs.target }}
- name: Install toolchain if not cross-compiling
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@master
with:
targets: ${{ inputs.target }}
toolchain: ${{ inputs.toolchain }}

View File

@@ -2,32 +2,32 @@ set -e
set -x
TARGET=$1
stripped=""
strip_binary () {
if [[ $( uname -s ) =~ "Darwin" ]]; then
EXE=$( find "$1" -maxdepth 1 -type f -perm +111 )
else
EXE=$( find "$1" -maxdepth 1 -type f -executable )
fi
if [ -z "$EXE" ]; then
echo "Could not find a binary to strip in $1"
else
strip "$EXE"
stripped="$EXE"
fi
}
DIR=""
for type in debug release; do
if [ -d "target/$TARGET/$type" ]; then
DIR="target/$TARGET/$type"
break
strip_binary "target/$TARGET/$type"
elif [ -d "target/$type" ]; then
DIR="target/$type"
break
strip_binary "target/$type"
fi
done
if [ -z "$DIR" ]; then
echo "Could not find directory with binary in it under target/"
if [ -z "$stripped" ]; then
echo "No binaries were stripped"
exit 1
fi
if [[ $( uname -s ) =~ "Darwin" ]]; then
EXE=$( find "$DIR" -maxdepth 1 -type f -perm +111 )
else
EXE=$( find "$DIR" -maxdepth 1 -type f -executable )
fi
if [ -z "$EXE" ]; then
echo "Could not find a binary to strip in $DIR"
exit 2
fi
strip "$EXE"