Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3de92613ad | ||
|
|
c507aeb1b5 | ||
|
|
9fb7236944 | ||
|
|
883c7a0854 | ||
|
|
ef5051e603 | ||
|
|
e89db86c83 | ||
|
|
d3cc976c26 | ||
|
|
42fe96a4c1 | ||
|
|
77a5caf54b | ||
|
|
7c7b8fbbff | ||
|
|
ab89553767 | ||
|
|
5d15c12d99 | ||
|
|
b1e766fe8f | ||
|
|
dd8fb2fac4 | ||
|
|
ab3f022734 | ||
|
|
e41de97f0a | ||
|
|
d788e00f15 | ||
|
|
356ca41f7d | ||
|
|
91d78d9182 | ||
|
|
30e7adeceb | ||
|
|
ec63efbd36 | ||
|
|
54e4a464ed | ||
|
|
d1d76ade32 | ||
|
|
2bfd2f169a | ||
|
|
42a1f46405 | ||
|
|
58c5e42ace |
25
.github/workflows/lint.yml
vendored
Normal file
25
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Check that code is lint clean using precious
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Configure Git
|
||||||
|
run: |
|
||||||
|
git config --global user.email "jdoe@example.com"
|
||||||
|
git config --global user.name "J. Doe"
|
||||||
|
- name: Run install-dev-tools.sh
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
mkdir $HOME/bin
|
||||||
|
./dev/bin/install-dev-tools.sh
|
||||||
|
- name: Run precious
|
||||||
|
run: |
|
||||||
|
PATH=$PATH:$HOME/bin precious lint -a
|
||||||
150
.github/workflows/test.yml
vendored
150
.github/workflows/test.yml
vendored
@@ -14,180 +14,220 @@ jobs:
|
|||||||
- platform_name: FreeBSD-x86_64
|
- platform_name: FreeBSD-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-freebsd
|
target: x86_64-unknown-freebsd
|
||||||
expect_file: "x86-64.+FreeBSD"
|
expect_file_re: "x86-64.+FreeBSD"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Linux-x86_64
|
- platform_name: Linux-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-linux-musl
|
target: x86_64-unknown-linux-musl
|
||||||
expect_file: "ELF.+x86-64"
|
expect_file_re: "ELF.+x86-64"
|
||||||
expect_cross: false
|
expect_cross: "--no-expect-cross"
|
||||||
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64
|
- platform_name: Linux-aarch64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-musl
|
||||||
expect_file: "aarch64"
|
expect_file_re: "aarch64"
|
||||||
expect_cross: true
|
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"
|
||||||
|
expect_file_re: "aarch64"
|
||||||
|
expect_cross: "--expect-cross"
|
||||||
|
expect_cross_version: "0.2.3"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-arm
|
- platform_name: Linux-arm
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: arm-unknown-linux-musleabi
|
target: arm-unknown-linux-musleabi
|
||||||
expect_file: "32.+ARM"
|
expect_file_re: "32.+ARM"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-i586
|
- platform_name: Linux-i586
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: i586-unknown-linux-musl
|
target: i586-unknown-linux-musl
|
||||||
expect_file: "ELF.+80386"
|
expect_file_re: "ELF.+80386"
|
||||||
expect_cross: false
|
expect_cross: "--no-expect-cross"
|
||||||
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips
|
- platform_name: Linux-mips
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips-unknown-linux-musl
|
target: mips-unknown-linux-musl
|
||||||
expect_file: "MIPS32.+mips-"
|
expect_file_re: "MIPS32.+mips-"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mipsel
|
- platform_name: Linux-mipsel
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mipsel-unknown-linux-musl
|
target: mipsel-unknown-linux-musl
|
||||||
expect_file: "MIPS32.+mipsel-"
|
expect_file_re: "MIPS32.+mipsel-"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips64
|
- platform_name: Linux-mips64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips64-unknown-linux-muslabi64
|
target: mips64-unknown-linux-muslabi64
|
||||||
expect_file: "MIPS64"
|
expect_file_re: "MIPS64"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips64el
|
- platform_name: Linux-mips64el
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips64el-unknown-linux-muslabi64
|
target: mips64el-unknown-linux-muslabi64
|
||||||
expect_file: "MIPS64"
|
expect_file_re: "MIPS64"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc
|
- platform_name: Linux-powerpc
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc-unknown-linux-gnu
|
target: powerpc-unknown-linux-gnu
|
||||||
expect_file: "32.+PowerPC"
|
expect_file_re: "32.+PowerPC"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64
|
- platform_name: Linux-powerpc64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc64-unknown-linux-gnu
|
target: powerpc64-unknown-linux-gnu
|
||||||
expect_file: "64.+PowerPC"
|
expect_file_re: "64.+PowerPC"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64le
|
- platform_name: Linux-powerpc64le
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc64le-unknown-linux-gnu
|
target: powerpc64le-unknown-linux-gnu
|
||||||
expect_file: "64.+PowerPC"
|
expect_file_re: "64.+PowerPC"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-riscv64
|
- platform_name: Linux-riscv64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: riscv64gc-unknown-linux-gnu
|
target: riscv64gc-unknown-linux-gnu
|
||||||
expect_file: "64.+RISC-V"
|
expect_file_re: "64.+RISC-V"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-s390x
|
- platform_name: Linux-s390x
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: s390x-unknown-linux-gnu
|
target: s390x-unknown-linux-gnu
|
||||||
expect_file: "64.+S/390"
|
expect_file_re: "64.+S/390"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: NetBSD-x86_64
|
- platform_name: NetBSD-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-netbsd
|
target: x86_64-unknown-netbsd
|
||||||
expect_file: "x86-64.+NetBSD"
|
expect_file_re: "x86-64.+NetBSD"
|
||||||
expect_cross: true
|
expect_cross: "--expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Windows-aarch64
|
- platform_name: Windows-aarch64
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: aarch64-pc-windows-msvc
|
target: aarch64-pc-windows-msvc
|
||||||
expect_file: "Aarch64.+Windows"
|
expect_file_re: "Aarch64.+Windows"
|
||||||
expect_cross: false
|
expect_cross: "--no-expect-cross"
|
||||||
|
expect_stripped: "--no-expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Windows-i686
|
- platform_name: Windows-i686
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: i686-pc-windows-msvc
|
target: i686-pc-windows-msvc
|
||||||
expect_file: "80386.+Windows"
|
expect_file_re: "80386.+Windows"
|
||||||
expect_cross: false
|
expect_cross: "--no-expect-cross"
|
||||||
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Windows-x86_64
|
- platform_name: Windows-x86_64
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
expect_file: "x86-64.+Windows"
|
expect_file_re: "x86-64.+Windows"
|
||||||
expect_cross: false
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: macOS-x86_64
|
- platform_name: macOS-x86_64
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
expect_file: "Mach-O.+x86_64"
|
expect_file_re: "Mach-O.+x86_64"
|
||||||
expect_cross: false
|
expect_cross: "--no-expect-cross"
|
||||||
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: macOS-aarch64
|
- platform_name: macOS-aarch64
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
expect_file: "Mach-O.+arm64"
|
expect_file_re: "Mach-O.+arm64"
|
||||||
expect_cross: false
|
expect_cross: "--no-expect-cross"
|
||||||
|
expect_stripped: "--expect-stripped"
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform.os }}
|
runs-on: ${{ matrix.platform.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
# This is installed here so we can check for it in $PATH later. This
|
|
||||||
# makes sure that the actions don't overwrite anything in $PATH.
|
|
||||||
- name: Install Protoc
|
|
||||||
uses: arduino/setup-protoc@v1
|
|
||||||
with:
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Copy test project to root
|
- name: Copy test project to root
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cp -a test-project/* .
|
cp -a test-project/* .
|
||||||
rm -fr test-project
|
rm -fr test-project
|
||||||
- name: Run both commands
|
- name: Run both commands
|
||||||
uses: "houseabsolute/actions-rust-cross@v0"
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: both
|
command: both
|
||||||
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
if: ${{ matrix.platform.can_test }}
|
if: ${{ matrix.platform.can_test }}
|
||||||
- name: Run test command
|
- name: Run test command
|
||||||
uses: "houseabsolute/actions-rust-cross@v0"
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
if: ${{ matrix.platform.can_test }}
|
if: ${{ matrix.platform.can_test }}
|
||||||
- name: Run build command
|
- name: Run build command
|
||||||
uses: "houseabsolute/actions-rust-cross@v0"
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
- name: Check for cross on ${{ matrix.platform.platform_name }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
strip: true
|
||||||
|
- name: Run build command for subdir
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
|
working-directory: subcrate
|
||||||
|
target: ${{ matrix.platform.target }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
strip: true
|
||||||
|
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
tests/check-binary.sh "${{ matrix.platform.target }}" "${{ matrix.platform.expect_cross }}" "${{ matrix.platform.expect_file }}"
|
tests/check-binary.pl \
|
||||||
- name: Check that $PATH is not overwritten
|
--target "${{ matrix.platform.target }}" \
|
||||||
shell: bash
|
--expect-file-re "${{ matrix.platform.expect_file_re }}" \
|
||||||
run: |
|
--expect-cross-version "${{ matrix.platform.expect_cross_version }}" \
|
||||||
tests/check-path.sh
|
${{ matrix.platform.expect_cross }} \
|
||||||
|
${{ matrix.platform.expect_stripped }}
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,4 +3,4 @@
|
|||||||
/package.json
|
/package.json
|
||||||
.\#*
|
.\#*
|
||||||
\#*\#
|
\#*\#
|
||||||
test-project/target/**
|
test-project/**/target/**
|
||||||
|
|||||||
@@ -2,17 +2,15 @@
|
|||||||
|
|
||||||
## Our Pledge
|
## Our Pledge
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers
|
||||||
contributors and maintainers pledge to making participation in our project and
|
pledge to making participation in our project and our community a harassment-free experience for
|
||||||
our community a harassment-free experience for everyone, regardless of age,
|
everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level
|
||||||
body size, disability, ethnicity, gender identity and expression, level of
|
of experience, education, socio-economic status, nationality, personal appearance, race, religion,
|
||||||
experience, education, socio-economic status, nationality, personal
|
or sexual identity and orientation.
|
||||||
appearance, race, religion, or sexual identity and orientation.
|
|
||||||
|
|
||||||
## Our Standards
|
## Our Standards
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
Examples of behavior that contributes to creating a positive environment include:
|
||||||
include:
|
|
||||||
|
|
||||||
- Using welcoming and inclusive language
|
- Using welcoming and inclusive language
|
||||||
- Being respectful of differing viewpoints and experiences
|
- Being respectful of differing viewpoints and experiences
|
||||||
@@ -22,53 +20,46 @@ include:
|
|||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
- The use of sexualized language or imagery and unwelcome sexual attention or
|
- The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||||
advances
|
|
||||||
- Trolling, insulting/derogatory comments, and personal or political attacks
|
- Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
- Public or private harassment
|
- Public or private harassment
|
||||||
- Publishing others' private information, such as a physical or electronic
|
- Publishing others' private information, such as a physical or electronic address, without explicit
|
||||||
address, without explicit permission
|
permission
|
||||||
- Other conduct which could reasonably be considered inappropriate in a
|
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Our Responsibilities
|
## Our Responsibilities
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
expected to take appropriate and fair corrective action in response to any instances of unacceptable
|
||||||
response to any instances of unacceptable behavior.
|
behavior.
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits,
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
|
||||||
threatening, offensive, or harmful.
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
## Scope
|
## Scope
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is
|
||||||
when an individual is representing the project or its community. Examples of
|
representing the project or its community. Examples of representing a project or community include
|
||||||
representing a project or community include using an official project e-mail
|
using an official project e-mail address, posting via an official social media account, or acting as
|
||||||
address, posting via an official social media account, or acting as an
|
an appointed representative at an online or offline event. Representation of a project may be
|
||||||
appointed representative at an online or offline event. Representation of a
|
further defined and clarified by project maintainers.
|
||||||
project may be further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting
|
||||||
reported by contacting the project team at autarch@urth.org. All complaints
|
the project team at autarch@urth.org. All complaints will be reviewed and investigated and will
|
||||||
will be reviewed and investigated and will result in a response that is deemed
|
result in a response that is deemed necessary and appropriate to the circumstances. The project team
|
||||||
necessary and appropriate to the circumstances. The project team is obligated
|
is obligated to maintain confidentiality with regard to the reporter of an incident. Further details
|
||||||
to maintain confidentiality with regard to the reporter of an incident.
|
of specific enforcement policies may be posted separately.
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
members of the project's leadership.
|
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at
|
||||||
version 1.4, available at
|
|
||||||
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|||||||
48
Changes.md
48
Changes.md
@@ -1,7 +1,51 @@
|
|||||||
|
## 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
|
||||||
|
set it to something else to compile a single crate or workspace in a subdirectory of the repo.
|
||||||
|
This allows you to use this action with monorepos with multiple crates. Based on GH #7 by
|
||||||
|
@aaronvg.
|
||||||
|
|
||||||
|
## 0.0.8 - 2023-07-22
|
||||||
|
|
||||||
|
- For builds that need the `cross` binary, this binary is now cached. A cache hit saves about 20
|
||||||
|
seconds in my tests. Suggested by @timon-schelling. GH #4.
|
||||||
|
|
||||||
|
## 0.0.7 - 2023-04-21
|
||||||
|
|
||||||
|
- The toolchain argument was (probably) not being respected with cross builds, though it's hard to
|
||||||
|
be sure since none of the output from past CI runs I've looked at it includes the toolchain
|
||||||
|
version in the output. But now the toolchain version is explicitly passed to all `cargo` and
|
||||||
|
`cross` commands.
|
||||||
|
|
||||||
|
## 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
|
## 0.0.3 - 2023-03-17
|
||||||
|
|
||||||
- This action now supports running the `build` and `test` commands, or both,
|
- This action now supports running the `build` and `test` commands, or both, with a new input
|
||||||
with a new input parameter, `command`. The default is `build`.
|
parameter, `command`. The default is `build`.
|
||||||
|
|
||||||
## 0.0.2 - 2023-03-05
|
## 0.0.2 - 2023-03-05
|
||||||
|
|
||||||
|
|||||||
23
README.md
23
README.md
@@ -55,13 +55,16 @@ jobs:
|
|||||||
|
|
||||||
This action takes the following parameters:
|
This action takes the following parameters:
|
||||||
|
|
||||||
| Key | Type | Required? | Description |
|
| 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. |
|
| `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, 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`. |
|
| `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 }}`. |
|
| `working-directory` | string | no | The working directory in which to run the `cargo` or `cross` commands. Defaults to the current directory (`.`). |
|
||||||
| `args` | string | no | A string-separated list of arguments to be passed to `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. |
|
||||||
|
| `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. If this is not set then the latest version will always be used. |
|
||||||
|
|
||||||
## How it Works
|
## How it Works
|
||||||
|
|
||||||
@@ -82,3 +85,9 @@ 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 binary 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
|
possible for builds that are not done via `cross`. In addition, Windows builds for `aarch64` cannot
|
||||||
be stripped either.
|
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
|
||||||
|
that you need for this. It just works.
|
||||||
|
|||||||
68
action.yml
68
action.yml
@@ -6,6 +6,9 @@ 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:
|
||||||
|
working-directory:
|
||||||
|
description: The working directory for each step
|
||||||
|
default: "."
|
||||||
command:
|
command:
|
||||||
description: |
|
description: |
|
||||||
The commands to run (one of "build", "test", or "both").
|
The commands to run (one of "build", "test", or "both").
|
||||||
@@ -13,9 +16,13 @@ inputs:
|
|||||||
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 working-directory variable.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
args:
|
args:
|
||||||
description: |
|
description: |
|
||||||
@@ -25,6 +32,10 @@ inputs:
|
|||||||
strip:
|
strip:
|
||||||
description: Strip the compiled binary
|
description: Strip the compiled binary
|
||||||
default: false
|
default: false
|
||||||
|
cross-version:
|
||||||
|
description: |
|
||||||
|
The version of cross to use. If not specified, then the latest version
|
||||||
|
will be used.
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
@@ -35,54 +46,73 @@ runs:
|
|||||||
id: determine-cross-compile
|
id: determine-cross-compile
|
||||||
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
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.platform.target }}
|
targets: ${{ inputs.target }}
|
||||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'false' }}
|
toolchain: ${{ inputs.toolchain }}
|
||||||
- name: Install cross if cross-compiling (*nix)
|
- name: Determine cross version
|
||||||
|
id: determine-cross-version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: install-cross-nix.sh
|
run: determine-cross-version.sh "${{ inputs.cross-version }}"
|
||||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && runner.os != 'Windows' }}
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||||
- name: Install cross if cross-compiling (Windows)
|
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||||
shell: powershell
|
# We need to accesss this in both this YAML config and shell scripts. It
|
||||||
run: install-cross-windows.ps1
|
# doesn't seem like using ${{ env.RUNNER_TEMP }} works in the YAML config.
|
||||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && runner.os == 'Windows' }}
|
- 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' }}
|
||||||
|
- name: Cache cross
|
||||||
|
id: cache-cross
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
||||||
|
key: ${{ runner.os }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||||
|
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||||
|
- name: Install cross if cross-compiling (*nix)
|
||||||
|
shell: bash
|
||||||
|
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:
|
env:
|
||||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||||
- name: Set build command
|
- name: Set build command
|
||||||
id: set-build-command
|
id: set-build-command
|
||||||
shell: bash
|
shell: bash
|
||||||
run: set-build-command.sh
|
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
||||||
- name: Run tests (*nix)
|
- name: Run tests (*nix)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
|
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
if: ${{ inputs.command != 'build' && 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)
|
- name: Run tests (Windows)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
& ${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
|
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||||
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
||||||
- name: Build binary (*nix)
|
- name: Build binary (*nix)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
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 }} +${{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)
|
- name: Build binary (Windows)
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
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 }} +${{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
|
- name: Strip binary
|
||||||
|
working-directory: ${{ inputs.working-directory }}
|
||||||
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.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' }}
|
||||||
|
|||||||
15
determine-cross-version.sh
Executable file
15
determine-cross-version.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
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
|
||||||
@@ -11,9 +11,12 @@ function install_tools () {
|
|||||||
curl --silent --location \
|
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
|
sh
|
||||||
run "rustup component add clippy"
|
|
||||||
run "ubi --project houseabsolute/precious --in ~/bin"
|
run "ubi --project houseabsolute/precious --in ~/bin"
|
||||||
|
run "ubi --project houseabsolute/omegasort --in ~/bin"
|
||||||
run "npm install prettier"
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" == "-v" ]; then
|
if [ "$1" == "-v" ]; then
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
cd "$RUNNER_TEMP"
|
CROSS_DIR="$1"
|
||||||
|
VERSION="$2"
|
||||||
|
|
||||||
|
VERSION_ARGS=""
|
||||||
|
if [ -n "$VERSION" ]; then
|
||||||
|
VERSION_ARGS="--tag $VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$CROSS_DIR"
|
||||||
export TARGET=.
|
export TARGET=.
|
||||||
curl --silent --location \
|
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
|
sh
|
||||||
./ubi --project cross-rs/cross --matching musl --in .
|
./ubi --project cross-rs/cross --matching musl --in . $VERSION_ARGS
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
cd $Env:RUNNER_TEMP
|
|
||||||
Invoke-WebRequest -URI 'https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.ps1' -UseBasicParsing | Invoke-Expression
|
|
||||||
.\ubi --project cross-rs/cross --in .
|
|
||||||
|
|
||||||
22
perltidyrc
Normal file
22
perltidyrc
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
-l=78
|
||||||
|
-i=4
|
||||||
|
-ci=4
|
||||||
|
-se
|
||||||
|
-b
|
||||||
|
-bar
|
||||||
|
-boc
|
||||||
|
-vt=0
|
||||||
|
-vtc=0
|
||||||
|
-cti=0
|
||||||
|
-pt=1
|
||||||
|
-bt=1
|
||||||
|
-sbt=1
|
||||||
|
-bbt=1
|
||||||
|
-nolq
|
||||||
|
-npro
|
||||||
|
-nsfs
|
||||||
|
--blank-lines-before-packages=0
|
||||||
|
--opening-hash-brace-right
|
||||||
|
--no-outdent-long-comments
|
||||||
|
--iterations=2
|
||||||
|
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
|
||||||
@@ -2,9 +2,30 @@ exclude = [
|
|||||||
"target",
|
"target",
|
||||||
]
|
]
|
||||||
|
|
||||||
[commands.prettier]
|
[commands.perltidy]
|
||||||
|
type = "both"
|
||||||
|
include = [ "**/*.{pl,pm,t,psgi}" ]
|
||||||
|
exclude = "tests/lib/**"
|
||||||
|
cmd = [ "perltidy", "--profile=$PRECIOUS_ROOT/perltidyrc" ]
|
||||||
|
lint_flags = [ "--assert-tidy", "--no-standard-output", "--outfile=/dev/null" ]
|
||||||
|
tidy_flags = [ "--backup-and-modify-in-place", "--backup-file-extension=/" ]
|
||||||
|
ok_exit_codes = 0
|
||||||
|
lint_failure_exit_codes = 2
|
||||||
|
ignore_stderr = "Begin Error Output Stream"
|
||||||
|
|
||||||
|
[commands.prettier-md]
|
||||||
type = "both"
|
type = "both"
|
||||||
include = [ "**/*.md", "**/*.yml" ]
|
include = [ "**/*.md" ]
|
||||||
|
cmd = [ "./node_modules/.bin/prettier", "--no-config", "--print-width", "100", "--prose-wrap", "always" ]
|
||||||
|
lint_flags = "--check"
|
||||||
|
tidy_flags = "--write"
|
||||||
|
ok_exit_codes = 0
|
||||||
|
lint_failure_exit_codes = 1
|
||||||
|
ignore_stderr = [ "Code style issues" ]
|
||||||
|
|
||||||
|
[commands.prettier-yml]
|
||||||
|
type = "both"
|
||||||
|
include = [ "**/*.yml" ]
|
||||||
cmd = [ "./node_modules/.bin/prettier", "--no-config" ]
|
cmd = [ "./node_modules/.bin/prettier", "--no-config" ]
|
||||||
lint_flags = "--check"
|
lint_flags = "--check"
|
||||||
tidy_flags = "--write"
|
tidy_flags = "--write"
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if [ -f "$RUNNER_TEMP/cross" ]; then
|
CROSS_DIR="$1"
|
||||||
echo "build-command=$RUNNER_TEMP/cross" >> $GITHUB_OUTPUT
|
if [ -f "$CROSS_DIR/cross" ]; then
|
||||||
|
echo "build-command=$CROSS_DIR/cross" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "build-command=cargo" >> $GITHUB_OUTPUT
|
echo "build-command=cargo" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|||||||
4
set-cross-dir.sh
Executable file
4
set-cross-dir.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
echo "cross-dir=$RUNNER_TEMP" >> $GITHUB_OUTPUT
|
||||||
42
strip-binary.sh
Executable file
42
strip-binary.sh
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
did_strip=""
|
||||||
|
|
||||||
|
strip_binary () {
|
||||||
|
if [[ $( uname -s ) =~ "Darwin" ]]; then
|
||||||
|
stripped=$(
|
||||||
|
find "$1" -maxdepth 1 -type f -perm +111 | while read exe; do
|
||||||
|
strip "$exe"
|
||||||
|
echo "stripped $exe"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
else
|
||||||
|
stripped=$(
|
||||||
|
find "$1" -maxdepth 1 -type f -executable | while read exe; do
|
||||||
|
strip "$exe"
|
||||||
|
echo "stripped $exe"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$stripped" ]; then
|
||||||
|
echo "Could not find any binaries to strip in $1"
|
||||||
|
else
|
||||||
|
did_strip="true"
|
||||||
|
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 "$did_strip" ]; then
|
||||||
|
echo "No binaries were stripped"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -3,4 +3,14 @@ name = "test-project"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
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"
|
||||||
|
|||||||
11
test-project/src/bin2.rs
Normal file
11
test-project/src/bin2.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
#[test]
|
||||||
|
fn test_something() {
|
||||||
|
assert_eq!(1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
7
test-project/subcrate/Cargo.lock
generated
Normal file
7
test-project/subcrate/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 = "subcrate"
|
||||||
|
version = "0.1.0"
|
||||||
8
test-project/subcrate/Cargo.toml
Normal file
8
test-project/subcrate/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
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]
|
||||||
3
test-project/subcrate/src/main.rs
Normal file
3
test-project/subcrate/src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world (subcrate)!");
|
||||||
|
}
|
||||||
113
tests/check-binary.pl
Executable file
113
tests/check-binary.pl
Executable file
@@ -0,0 +1,113 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use v5.30;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
no warnings 'experimental::signatures';
|
||||||
|
use feature 'signatures';
|
||||||
|
use autodie;
|
||||||
|
|
||||||
|
use FindBin qw( $Bin );
|
||||||
|
use File::Spec;
|
||||||
|
use lib File::Spec->catdir( $Bin, 'lib' );
|
||||||
|
|
||||||
|
use Getopt::Long;
|
||||||
|
use IPC::System::Simple qw( capturex );
|
||||||
|
use Path::Tiny qw( path );
|
||||||
|
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-cross-version=s' => \$expect_cross_version,
|
||||||
|
'expect-stripped!' => \$expect_stripped,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_cross(
|
||||||
|
path( $ENV{RUNNER_TEMP} ), $expect_cross,
|
||||||
|
$expect_cross_version
|
||||||
|
);
|
||||||
|
|
||||||
|
for my $bin (
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
|
done_testing();
|
||||||
|
}
|
||||||
|
|
||||||
|
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' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_binary ( $bin, $expect_file_re, $expect_stripped ) {
|
||||||
|
ok( $bin->exists, "Binary at $bin exists" )
|
||||||
|
or return;
|
||||||
|
ok( $bin->is_file, "Binary at $bin is a file" )
|
||||||
|
or return;
|
||||||
|
ok( -x $bin, "Binary at $bin is executable" )
|
||||||
|
or return;
|
||||||
|
|
||||||
|
my $file = capturex( qw( file --brief ), $bin ) // q{};
|
||||||
|
chomp $file;
|
||||||
|
|
||||||
|
like(
|
||||||
|
$file, qr/$expect_file_re/,
|
||||||
|
"`file` output for $bin matches expected output"
|
||||||
|
);
|
||||||
|
|
||||||
|
# The file command on macOS doesn't report whether the binary is stripped
|
||||||
|
# or not.
|
||||||
|
return if $^O eq 'darwin';
|
||||||
|
|
||||||
|
if ($expect_stripped) {
|
||||||
|
unlike(
|
||||||
|
$file, qr/not stripped/,
|
||||||
|
"`file` does not report $bin as not stripped"
|
||||||
|
);
|
||||||
|
like( $file, qr/stripped/, "`file` reports $bin as stripped" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( $^O eq 'MSWin32' || $^O eq 'msys' ) {
|
||||||
|
|
||||||
|
# On Windows, unstripped binaries don't contain the word
|
||||||
|
# "stripped" at all.
|
||||||
|
unlike(
|
||||||
|
$file, qr/stripped/,
|
||||||
|
"`file` does not report $bin as stripped"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
like(
|
||||||
|
$file, qr/not stripped/,
|
||||||
|
"`file` reports $bin as not stripped"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
set -e
|
|
||||||
set -x
|
|
||||||
|
|
||||||
TARGET=$1
|
|
||||||
EXPECT_CROSS=$2
|
|
||||||
EXPECT_FILE_RE=$3
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
set -e
|
|
||||||
set -x
|
|
||||||
|
|
||||||
which protoc
|
|
||||||
1115
tests/lib/IPC/System/Simple.pm
Normal file
1115
tests/lib/IPC/System/Simple.pm
Normal file
File diff suppressed because it is too large
Load Diff
3880
tests/lib/Path/Tiny.pm
Normal file
3880
tests/lib/Path/Tiny.pm
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user