Skip to content
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
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ STACK_NAME ?= rust-products
FUNCTIONS := get-products get-product put-product delete-product dynamodb-streams

ARCH := aarch64-unknown-linux-gnu
ARCH_SPLIT = $(subst -, ,$(ARCH))

.PHONY: build deploy tests

Expand All @@ -15,7 +16,10 @@ endif
ifeq (,$(shell which cargo))
$(error "Could not found Cargo, please install it")
endif
cargo install cross
ifeq (,$(shell which zig))
$(error "Could not found Zig compiler, please install it")
endif
cargo install cargo-zigbuild
ifeq (,$(shell which sam))
$(error "Could not found SAM CLI, please install it")
endif
Expand All @@ -24,7 +28,14 @@ ifeq (,$(shell which artillery))
endif

build:
cross build --release --target $(ARCH)
ifeq ("$(shell zig targets | jq -r .native.cpu.arch)-$(shell zig targets | jq -r .native.os)-$(shell zig targets | jq -r .native.abi)", "$(word 1,$(ARCH_SPLIT))-$(word 3,$(ARCH_SPLIT))-$(word 4,$(ARCH_SPLIT))")
@echo "Same host and target. Using native build"
cargo build --release --target $(ARCH)
else
@echo "Different host and target. Using zigbuild"
cargo zigbuild --release --target $(ARCH)
endif

rm -rf ./build
mkdir -p ./build
${MAKE} ${MAKEOPTS} $(foreach function,${FUNCTIONS}, build-${function})
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ This single crate will create [five different binaries](./src/bin), one for each
### Requirements

* [Rust](https://www.rust-lang.org/) 1.56.0 or higher
* [Cross](https://github.com/rust-embedded/cross) for cross-compilation to Arm64
* [cargo-zigbuild](https://github.com/messense/cargo-zigbuild) and [Zig](https://ziglang.org/) for cross-compilation
* [jq](https://stedolan.github.io/jq/) for tooling specific to this project
* The [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) 1.33.0 or higher for deploying to the cloud
* [Artillery](https://artillery.io/) for load-testing the application

Expand Down