Skip to content

Commit

Permalink
ci: add aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo committed Nov 18, 2022
1 parent 8011da9 commit 38b7cf6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
60 changes: 34 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,47 +241,44 @@ jobs:
- save-buildx-cache
build-binaries:
machine:
image: ubuntu-2204:2022.04.1
image: << parameters.image >>
resource_class: << parameters.resource_class >>
parameters:
target:
description: "Linux target to build for"
type: string
image:
description: "Machine image to use"
type: string
resource_class:
description: "The resource type to use for the machine"
type: string
steps:
- checkout
- run: sudo apt update && sudo DEBIAN_FRONTEND=noninteractive apt install -y libssl-dev musl-tools p7zip-full
- run:
name: Build openssl with musl
command: |
# Inspired by https://qiita.com/liubin/items/6c94f0b61f746c08b74c
# and https://github.com/clux/muslrust/blob/main/Dockerfile
export SSL_VER="1.1.1q"
export PREFIX=/musl
sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm
sudo ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic
sudo ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux
curl -sSL https://www.openssl.org/source/openssl-$SSL_VER.tar.gz | tar xz && cd openssl-$SSL_VER
CC="musl-gcc -fPIE -pie" ./Configure no-zlib no-shared --prefix=$PREFIX --openssldir=$PREFIX/ssl linux-x86_64
make depend
make -j$(nproc)
sudo make install
- run: sudo apt update && sudo DEBIAN_FRONTEND=noninteractive apt install -y libssl-dev musl-tools clang p7zip-full
- run:
name: Install Rust
command: curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.63.0 --target x86_64-unknown-linux-musl
command: curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.63.0 --target << parameters.target >>
- run:
name: Build
command: |
# export TARGET_CC=clang
# export CFLAGS_aarch64_unknown_linux_musl=--sysroot=/usr/aarch64-linux-gnu
# export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/usr/aarch64-linux-gnu/bin/ld
export OPENSSL_DIR=/musl
cargo build --release --package cargo-shuttle --target x86_64-unknown-linux-musl
# export OPENSSL_DIR=/musl
export CC_aarch64_unknown_linux_musl=clang
cargo build --release --package cargo-shuttle --features vendored-openssl --target << parameters.target >>
- run:
name: Make artifact
command: |
mkdir artifacts
mv target/x86_64-unknown-linux-musl/release/cargo-shuttle artifacts/shuttle
mv target/<< parameters.target >>/release/cargo-shuttle artifacts/shuttle
mv README.md LICENSE artifacts/
7z a -ttar -so -an artifacts | 7z a -si artifacts/shuttle-version-x86_64-unknown-linux-musl.tar.gz
7z a -ttar -so -an artifacts | 7z a -si artifacts/shuttle-version-<< parameters.target >>.tar.gz
- persist_to_workspace:
root: artifacts
paths:
- shuttle-version-x86_64-unknown-linux-musl.tar.gz
- shuttle-version-<< parameters.target >>.tar.gz
publish-github-release:
docker:
- image: cimg/go:1.19.3
Expand Down Expand Up @@ -340,10 +337,21 @@ workflows:
# filters:
# branches:
# only: production
- build-binaries
# - build-binaries:
- build-binaries:
name: build-binaries-x86_64
image: ubuntu-2204:2022.04.1
target: x86_64-unknown-linux-musl
resource_class: medium
# requires:
# - build-and-push
- build-binaries:
name: build-binaries-aarch64
image: ubuntu-2004:202101-01
target: aarch64-unknown-linux-musl
resource_class: arm.medium
# requires:
# - build-and-push
- publish-github-release:
requires:
- build-binaries
- build-binaries-x86_64
- build-binaries-aarch64
4 changes: 4 additions & 0 deletions cargo-shuttle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ futures = "0.3.23"
headers = "0.3.8"
indoc = "1.0.7"
log = "0.4.17"
openssl = { version = '0.10', optional = true }
portpicker = "0.1.1"
reqwest = { version = "0.11.11", features = ["json"] }
reqwest-middleware = "0.1.6"
Expand Down Expand Up @@ -55,6 +56,9 @@ version = "0.7.2"
path = "../service"
features = ["loader"]

[features]
vendored-openssl = ["openssl/vendored"]

[dev-dependencies]
tempfile = "3.3.0"
test-context = "0.1.4"
Expand Down

0 comments on commit 38b7cf6

Please sign in to comment.