Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
356ca41f7d | ||
|
|
91d78d9182 | ||
|
|
30e7adeceb | ||
|
|
ec63efbd36 | ||
|
|
54e4a464ed | ||
|
|
d1d76ade32 | ||
|
|
2bfd2f169a | ||
|
|
42a1f46405 | ||
|
|
58c5e42ace | ||
|
|
2f68f636e2 | ||
|
|
5bd32448aa | ||
|
|
4dfe96e52b | ||
|
|
9a602122c2 | ||
|
|
b34ced72c6 | ||
|
|
aa7ccd3cba |
207
.github/workflows/test.yml
vendored
Normal file
207
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
name: Self-test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- platform_name: FreeBSD-x86_64
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: x86_64-unknown-freebsd
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "x86-64.+FreeBSD"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: false
|
||||||
|
|
||||||
|
- platform_name: Linux-x86_64
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: x86_64-unknown-linux-musl
|
||||||
|
expect_cross: false
|
||||||
|
expect_file: "ELF.+x86-64"
|
||||||
|
expect_stripped: true
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-aarch64
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: aarch64-unknown-linux-musl
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "aarch64"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-arm
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: arm-unknown-linux-musleabi
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "32.+ARM"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-i586
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: i586-unknown-linux-musl
|
||||||
|
expect_cross: false
|
||||||
|
expect_file: "ELF.+80386"
|
||||||
|
expect_stripped: true
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-mips
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: mips-unknown-linux-musl
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "MIPS32.+mips-"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-mipsel
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: mipsel-unknown-linux-musl
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "MIPS32.+mipsel-"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-mips64
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: mips64-unknown-linux-muslabi64
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "MIPS64"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-mips64el
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: mips64el-unknown-linux-muslabi64
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "MIPS64"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-powerpc
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: powerpc-unknown-linux-gnu
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "32.+PowerPC"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-powerpc64
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: powerpc64-unknown-linux-gnu
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "64.+PowerPC"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-powerpc64le
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: powerpc64le-unknown-linux-gnu
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "64.+PowerPC"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-riscv64
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: riscv64gc-unknown-linux-gnu
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "64.+RISC-V"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Linux-s390x
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: s390x-unknown-linux-gnu
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "64.+S/390"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: NetBSD-x86_64
|
||||||
|
os: ubuntu-20.04
|
||||||
|
target: x86_64-unknown-netbsd
|
||||||
|
expect_cross: true
|
||||||
|
expect_file: "x86-64.+NetBSD"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: false
|
||||||
|
|
||||||
|
- platform_name: Windows-aarch64
|
||||||
|
os: windows-latest
|
||||||
|
target: aarch64-pc-windows-msvc
|
||||||
|
expect_cross: false
|
||||||
|
expect_file: "Aarch64.+Windows"
|
||||||
|
expect_stripped: false
|
||||||
|
can_test: false
|
||||||
|
|
||||||
|
- platform_name: Windows-i686
|
||||||
|
os: windows-latest
|
||||||
|
target: i686-pc-windows-msvc
|
||||||
|
expect_cross: false
|
||||||
|
expect_file: "80386.+Windows"
|
||||||
|
expect_stripped: true
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: Windows-x86_64
|
||||||
|
os: windows-latest
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
expect_cross: false
|
||||||
|
expect_file: "x86-64.+Windows"
|
||||||
|
expect_stripped: true
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: macOS-x86_64
|
||||||
|
os: macOS-latest
|
||||||
|
target: x86_64-apple-darwin
|
||||||
|
expect_cross: false
|
||||||
|
expect_file: "Mach-O.+x86_64"
|
||||||
|
expect_stripped: true
|
||||||
|
can_test: true
|
||||||
|
|
||||||
|
- platform_name: macOS-aarch64
|
||||||
|
os: macOS-latest
|
||||||
|
target: aarch64-apple-darwin
|
||||||
|
expect_cross: false
|
||||||
|
expect_file: "Mach-O.+arm64"
|
||||||
|
expect_stripped: true
|
||||||
|
can_test: false
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Copy test project to root
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cp -a test-project/* .
|
||||||
|
rm -fr test-project
|
||||||
|
- name: Run both commands
|
||||||
|
uses: "houseabsolute/actions-rust-cross@v0"
|
||||||
|
with:
|
||||||
|
command: both
|
||||||
|
target: ${{ matrix.platform.target }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
if: ${{ matrix.platform.can_test }}
|
||||||
|
- name: Run test command
|
||||||
|
uses: "houseabsolute/actions-rust-cross@v0"
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
target: ${{ matrix.platform.target }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
if: ${{ matrix.platform.can_test }}
|
||||||
|
- name: Run build command
|
||||||
|
uses: "houseabsolute/actions-rust-cross@v0"
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
target: ${{ matrix.platform.target }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
strip: true
|
||||||
|
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tests/check-binary.sh "${{ matrix.platform.target }}" "${{ matrix.platform.expect_cross }}" "${{ matrix.platform.expect_file }}" "${{ matrix.platform.expect_stripped }}"
|
||||||
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/node_modules
|
||||||
|
/package-lock.json
|
||||||
|
/package.json
|
||||||
|
.\#*
|
||||||
|
\#*\#
|
||||||
|
test-project/target/**
|
||||||
33
Changes.md
33
Changes.md
@@ -1,3 +1,34 @@
|
|||||||
|
## 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
|
||||||
|
than stable. This supports picking on of "stable", "beta", or "nightly".
|
||||||
|
- Fixed binary stripping to work in more situations. Previously it depended on
|
||||||
|
a very specific setup plus expected to be run in the context of the matrix I
|
||||||
|
use for my own projects.
|
||||||
|
- Fixed a reference to a matrix variable that should have referenced an input
|
||||||
|
variable.
|
||||||
|
|
||||||
|
## 0.0.3 - 2023-03-17
|
||||||
|
|
||||||
|
- This action now supports running the `build` and `test` commands, or both,
|
||||||
|
with a new input parameter, `command`. The default is `build`.
|
||||||
|
|
||||||
|
## 0.0.2 - 2023-03-05
|
||||||
|
|
||||||
|
- Fixed some typos in the `README.md` documentation.
|
||||||
|
|
||||||
## 0.0.1 - 2023-03-05
|
## 0.0.1 - 2023-03-05
|
||||||
|
|
||||||
* First release upon an unsuspecting world.
|
- First release upon an unsuspecting world.
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -3,7 +3,7 @@
|
|||||||
This action lets you easily cross-compile Rust projects using
|
This action lets you easily cross-compile Rust projects using
|
||||||
[cross](https://github.com/cross-rs/cross).
|
[cross](https://github.com/cross-rs/cross).
|
||||||
|
|
||||||
Here's an example from the release workflor for
|
Here's an example from the release workflow for
|
||||||
[my tool `precious`](https://github.com/houseabsolute/precious):
|
[my tool `precious`](https://github.com/houseabsolute/precious):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -18,18 +18,21 @@ jobs:
|
|||||||
target: x86_64-unknown-freebsd
|
target: x86_64-unknown-freebsd
|
||||||
bin: precious
|
bin: precious
|
||||||
name: precious-FreeBSD-x86_64.tar.gz
|
name: precious-FreeBSD-x86_64.tar.gz
|
||||||
|
command: build
|
||||||
|
|
||||||
- release_for: Windows-x86_64
|
- release_for: Windows-x86_64
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
bin: precious.exe
|
bin: precious.exe
|
||||||
name: precious-Windows-x86_64.zip
|
name: precious-Windows-x86_64.zip
|
||||||
|
command: both
|
||||||
|
|
||||||
- release_for: macOS-x86_64
|
- release_for: macOS-x86_64
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
bin: precious
|
bin: precious
|
||||||
name: precious-Darwin-x86_64.tar.gz
|
name: precious-Darwin-x86_64.tar.gz
|
||||||
|
command: both
|
||||||
|
|
||||||
# more release targets here ...
|
# more release targets here ...
|
||||||
|
|
||||||
@@ -40,6 +43,7 @@ jobs:
|
|||||||
- name: Build binary
|
- name: Build binary
|
||||||
uses: houseabsolute/actions-rust-cross@v0
|
uses: houseabsolute/actions-rust-cross@v0
|
||||||
with:
|
with:
|
||||||
|
command: ${{ matrix.platform.command }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
args: "--locked --release"
|
args: "--locked --release"
|
||||||
strip: true
|
strip: true
|
||||||
@@ -51,12 +55,14 @@ jobs:
|
|||||||
|
|
||||||
This action takes the following parameters:
|
This action takes the following parameters:
|
||||||
|
|
||||||
| Key | Type | Required? | Description |
|
| Key | Type | Required? | Description |
|
||||||
| -------------- | --------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
| -------------- | ---------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
|
| `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. |
|
||||||
| `GITHUB_TOKEN` | string | no | Defaults to the value of `${{ github.token }}`. |
|
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
|
||||||
| `args` | string | no | A string-separated list of arguments to be passed to the `cross build`, like `--release --locked`. |
|
| `toolchain` | string (one of `stable`, `beta`, or `nightly`) | no | The Rust toolchain version to install. The default is `stable` |
|
||||||
| `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. |
|
| `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
|
## How it Works
|
||||||
|
|
||||||
|
|||||||
36
action.yml
36
action.yml
@@ -6,9 +6,17 @@ branding:
|
|||||||
description: |
|
description: |
|
||||||
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
|
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
|
||||||
inputs:
|
inputs:
|
||||||
|
command:
|
||||||
|
description: |
|
||||||
|
The commands to run (one of "build", "test", or "both").
|
||||||
|
default: build
|
||||||
target:
|
target:
|
||||||
description: The target platform
|
description: The target platform
|
||||||
required: true
|
required: true
|
||||||
|
toolchain:
|
||||||
|
description: |
|
||||||
|
The target toolchain to use (one of "stable", "beta", or "nightly").
|
||||||
|
default: stable
|
||||||
GITHUB_TOKEN:
|
GITHUB_TOKEN:
|
||||||
description: |
|
description: |
|
||||||
A GitHub token, available in the secrets.GITHUB_TOKEN context variable.
|
A GitHub token, available in the secrets.GITHUB_TOKEN context variable.
|
||||||
@@ -32,9 +40,10 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: set-cross-compile.sh ${{ inputs.target }}
|
run: set-cross-compile.sh ${{ inputs.target }}
|
||||||
- name: Install toolchain if not cross-compiling
|
- name: Install toolchain if not cross-compiling
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.platform.target }}
|
targets: ${{ inputs.target }}
|
||||||
|
toolchain: ${{ inputs.toolchain }}
|
||||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'false' }}
|
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'false' }}
|
||||||
- name: Install cross if cross-compiling (*nix)
|
- name: Install cross if cross-compiling (*nix)
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -52,23 +61,32 @@ runs:
|
|||||||
id: set-build-command
|
id: set-build-command
|
||||||
shell: bash
|
shell: bash
|
||||||
run: set-build-command.sh
|
run: set-build-command.sh
|
||||||
- name: Build binary (*nix)
|
- name: Run tests (*nix)
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
if: ${{ runner.os != 'Windows' }}
|
if: ${{ inputs.command != 'build' && runner.os != 'Windows' }}
|
||||||
# We want to run in Powershell on Windows to make sure we compile in a
|
# 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
|
# native Windows environment. Some things won't compile properly under
|
||||||
# msys, notably OpenSSL, which is compiled locally when using the
|
# msys, notably OpenSSL, which is compiled locally when using the
|
||||||
# `openssl` crate with the `vendored` feature.
|
# `openssl` crate with the `vendored` feature.
|
||||||
|
- name: Run tests (Windows)
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
& ${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
|
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
||||||
|
- name: Build binary (*nix)
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
|
if: ${{ inputs.command != 'test' && runner.os != 'Windows' }}
|
||||||
- name: Build binary (Windows)
|
- name: Build binary (Windows)
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
& ${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
& ${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
if: ${{ runner.os == 'Windows' }}
|
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
||||||
- name: Strip binary
|
- name: Strip binary
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: strip-binary.sh ${{ inputs.target }}
|
||||||
strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
|
|
||||||
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
||||||
if: ${{ 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' }}
|
||||||
|
|||||||
43
dev/bin/install-dev-tools.sh
Executable file
43
dev/bin/install-dev-tools.sh
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
function run () {
|
||||||
|
echo $1
|
||||||
|
eval $1
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_tools () {
|
||||||
|
curl --silent --location \
|
||||||
|
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
|
||||||
|
sh
|
||||||
|
run "rustup component add clippy"
|
||||||
|
run "ubi --project houseabsolute/precious --in ~/bin"
|
||||||
|
run "npm install prettier"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" == "-v" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p $HOME/bin
|
||||||
|
|
||||||
|
set +e
|
||||||
|
echo ":$PATH:" | grep --extended-regexp ":$HOME/bin:" >& /dev/null
|
||||||
|
if [ "$?" -eq "0" ]; then
|
||||||
|
path_has_home_bin=1
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$path_has_home_bin" ]; then
|
||||||
|
PATH=$HOME/bin:$PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
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."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
15
git/hooks/pre-commit.sh
Executable file
15
git/hooks/pre-commit.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
status=0
|
||||||
|
|
||||||
|
PRECIOUS=$(which precious)
|
||||||
|
if [[ -z $PRECIOUS ]]; then
|
||||||
|
PRECIOUS=./bin/precious
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$PRECIOUS" lint -s
|
||||||
|
if (( $? != 0 )); then
|
||||||
|
status+=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $status
|
||||||
26
git/setup.pl
Executable file
26
git/setup.pl
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Cwd qw( abs_path );
|
||||||
|
|
||||||
|
symlink_hook('pre-commit');
|
||||||
|
|
||||||
|
sub symlink_hook {
|
||||||
|
my $hook = shift;
|
||||||
|
|
||||||
|
my $dot = ".git/hooks/$hook";
|
||||||
|
my $file = "git/hooks/$hook.sh";
|
||||||
|
my $link = "../../$file";
|
||||||
|
|
||||||
|
if ( -e $dot ) {
|
||||||
|
if ( -l $dot ) {
|
||||||
|
return if readlink $dot eq $link;
|
||||||
|
}
|
||||||
|
warn "You already have a hook at $dot!\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
symlink $link, $dot;
|
||||||
|
}
|
||||||
26
precious.toml
Normal file
26
precious.toml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
exclude = [
|
||||||
|
"target",
|
||||||
|
]
|
||||||
|
|
||||||
|
[commands.prettier]
|
||||||
|
type = "both"
|
||||||
|
include = [ "**/*.md", "**/*.yml" ]
|
||||||
|
cmd = [ "./node_modules/.bin/prettier", "--no-config" ]
|
||||||
|
lint_flags = "--check"
|
||||||
|
tidy_flags = "--write"
|
||||||
|
ok_exit_codes = 0
|
||||||
|
lint_failure_exit_codes = 1
|
||||||
|
ignore_stderr = [ "Code style issues" ]
|
||||||
|
|
||||||
|
[commands.omegasort-gitignore]
|
||||||
|
type = "both"
|
||||||
|
include = "**/.gitignore"
|
||||||
|
cmd = [ "omegasort", "--sort", "path", "--unique" ]
|
||||||
|
lint_flags = "--check"
|
||||||
|
tidy_flags = "--in-place"
|
||||||
|
ok_exit_codes = 0
|
||||||
|
lint_failure_exit_codes = 1
|
||||||
|
ignore_stderr = [
|
||||||
|
"The .+ file is not sorted",
|
||||||
|
"The .+ file is not unique",
|
||||||
|
]
|
||||||
33
strip-binary.sh
Executable file
33
strip-binary.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
for type in debug release; do
|
||||||
|
if [ -d "target/$TARGET/$type" ]; then
|
||||||
|
strip_binary "target/$TARGET/$type"
|
||||||
|
elif [ -d "target/$type" ]; then
|
||||||
|
strip_binary "target/$type"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$stripped" ]; then
|
||||||
|
echo "No binaries were stripped"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
7
test-project/Cargo.lock
generated
Normal file
7
test-project/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-project"
|
||||||
|
version = "0.1.0"
|
||||||
6
test-project/Cargo.toml
Normal file
6
test-project/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "test-project"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
11
test-project/src/main.rs
Normal file
11
test-project/src/main.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
#[test]
|
||||||
|
fn test_something() {
|
||||||
|
assert_eq!(1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
49
tests/check-binary.sh
Executable file
49
tests/check-binary.sh
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
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