Skip to content

fix: switch to cross for cross-compilation #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Install Arm64 toolchain
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand All @@ -43,8 +39,14 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
- name: Build
run: make build
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target aarch64-unknown-linux-gnu
# - name: Build
# run: make build
# TODO: separate integration and unit tests
# - name: Test
# run: make tests
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
STACK_NAME ?= rust-products
FUNCTIONS := get-products get-product put-product delete-product

export CC_aarch64_unknown_linux_gnu = aarch64-linux-gnu-gcc
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = aarch64-linux-gnu-gcc
STRIP := aarch64-linux-gnu-strip
ARCH := aarch64-unknown-linux-gnu

.PHONY: build deploy tests

all: build deploy tests

build:
cargo build --release --target aarch64-unknown-linux-gnu
cross build --release --target $(ARCH)
rm -rf ./build
mkdir -p ./build
${MAKE} ${MAKEOPTS} $(foreach function,${FUNCTIONS}, build-${function})

build-%:
mkdir -p ./build/$*
$(STRIP) ./target/aarch64-unknown-linux-gnu/release/$*
cp -v ./target/aarch64-unknown-linux-gnu/release/$* ./build/$*/bootstrap
cp -v ./target/$(ARCH)/release/$* ./build/$*/bootstrap
cp -v ./otel-config.yaml ./build/$*/collector.yaml

deploy:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This is a simple serverless application using Rust as its main programming langu
### Requirements

* [Rust](https://www.rust-lang.org/)
* [Cross](https://github.com/rust-embedded/cross)
* The [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)

### Usage
Expand Down