Skip to content

Commit

Permalink
Add CI docker image for ohos
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jan 9, 2025
1 parent eba2db4 commit 19006b1
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 18 deletions.
48 changes: 48 additions & 0 deletions .github/docker_images/ohos-5.0.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:24.04

SHELL ["/bin/bash", "-c"]
VOLUME ["/aws_lc_rs"]

WORKDIR /

RUN apt-get update && \
apt-get install -y ca-certificates build-essential cmake git wget curl jq unzip clang sudo && \
apt-get autoremove --purge -y && \
apt-get clean && \
apt-get autoclean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*

RUN mkdir /ohos && \
wget --progress=dot:giga https://repo.huaweicloud.com/openharmony/os/5.0.0-Release/ohos-sdk-windows_linux-public.tar.gz && \
wget https://repo.huaweicloud.com/openharmony/os/5.0.0-Release/ohos-sdk-windows_linux-public.tar.gz.sha256 && \
diff <(sha256sum ohos-sdk-windows_linux-public.tar.gz | cut -d ' ' -f 1) ohos-sdk-windows_linux-public.tar.gz.sha256 && \
tar zxvf ohos-sdk-windows_linux-public.tar.gz -C /ohos && \
cd /ohos/linux && \
unzip native-linux-x64-5.0.0.*-Release.zip && \
rm -rf /ohos/windows /ohos/linux/*.zip

RUN useradd -m docker
USER docker
RUN cd "${HOME}" && \
git config --global --add safe.directory '*' && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > ./rustup.sh && \
chmod +x ./rustup.sh && \
./rustup.sh -y && \
. "${HOME}/.cargo/env" && \
cargo install --locked bindgen-cli && \
rustup component add rustfmt clippy && \
rustup target add aarch64-unknown-linux-ohos armv7-unknown-linux-ohos x86_64-unknown-linux-ohos && \
rm ./rustup.sh

COPY aws_lc_rs_build.sh /
COPY entry.sh /

ENV CMAKE_TOOLCHAIN_FILE=/ohos/linux/native/build/cmake/ohos.toolchain.cmake
ENV OHOS_NDK_HOME=/ohos/linux
ENV OHOS_SDK_NATIVE=/ohos/linux/native

ENTRYPOINT ["/entry.sh"]
33 changes: 33 additions & 0 deletions .github/docker_images/ohos-5.0.0/aws_lc_rs_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex -o pipefail

. "${HOME}/.cargo/env"
SRC_DIR="${SRC_DIR:-/aws_lc_rs}"

pushd "${SRC_DIR}"

declare -A target_map
target_map[aarch64-unknown-linux-ohos]="aarch64-linux-ohos"
target_map[armv7-unknown-linux-ohos]="arm-linux-ohos"
target_map[x86_64-unknown-linux-ohos]="x86_64-linux-ohos"

function build_ohos_targets() {
for target in aarch64-unknown-linux-ohos armv7-unknown-linux-ohos x86_64-unknown-linux-ohos
do
export CPATH=/ohos/linux/native/sysroot/usr/include/:/ohos/linux/native/sysroot/usr/include/${target_map[${target}]}
cargo build -p aws-lc-rs --target ${target}
cargo clean
done
}

cargo clean
build_ohos_targets
unset CMAKE_TOOLCHAIN_FILE
build_ohos_targets
unset OHOS_NDK_HOME
build_ohos_targets

popd # ${SRC_DIR}
22 changes: 22 additions & 0 deletions .github/docker_images/ohos-5.0.0/build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Ubuntu:
# sudo apt-get install jq

# Amazon Linux:
# sudo yum install jq

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

EXTRA_ARGS=()
if [[ -n "${GOPROXY:+x}" ]]; then
EXTRA_ARGS=("--build-arg" "GOPROXY=${GOPROXY}" "${EXTRA_ARGS[@]}")
fi

docker build -t ohos:5.0.0 . --load "${EXTRA_ARGS[@]}"
7 changes: 7 additions & 0 deletions .github/docker_images/ohos-5.0.0/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex -o pipefail

/aws_lc_rs_build.sh "${argv[@]}"
49 changes: 31 additions & 18 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ jobs:
fail-fast: false
matrix:
target:
- [aarch64-linux-android, 0]
- [aarch64-unknown-linux-gnu, 1]
- [aarch64-unknown-linux-musl, 1]
- [arm-linux-androideabi, 0]
- [arm-unknown-linux-gnueabihf, 0]
- [arm-unknown-linux-musleabi, 1]
- [arm-unknown-linux-musleabihf, 1]
- [armv7-linux-androideabi, 0]
- [armv7-unknown-linux-gnueabihf, 0]
- [i686-unknown-linux-gnu, 0]
- [powerpc-unknown-linux-gnu, 1]
- [powerpc64-unknown-linux-gnu, 1]
- [powerpc64le-unknown-linux-gnu, 1]
- [riscv64gc-unknown-linux-gnu, 0]
- [s390x-unknown-linux-gnu, 0]
- [x86_64-pc-windows-gnu, 0]
- [x86_64-unknown-linux-musl, 0]
- [ aarch64-linux-android, 0 ]
- [ aarch64-unknown-linux-gnu, 1 ]
- [ aarch64-unknown-linux-musl, 1 ]
- [ arm-linux-androideabi, 0 ]
- [ arm-unknown-linux-gnueabihf, 0 ]
- [ arm-unknown-linux-musleabi, 1 ]
- [ arm-unknown-linux-musleabihf, 1 ]
- [ armv7-linux-androideabi, 0 ]
- [ armv7-unknown-linux-gnueabihf, 0 ]
- [ i686-unknown-linux-gnu, 0 ]
- [ powerpc-unknown-linux-gnu, 1 ]
- [ powerpc64-unknown-linux-gnu, 1 ]
- [ powerpc64le-unknown-linux-gnu, 1 ]
- [ riscv64gc-unknown-linux-gnu, 0 ]
- [ s390x-unknown-linux-gnu, 0 ]
- [ x86_64-pc-windows-gnu, 0 ]
- [ x86_64-unknown-linux-musl, 0 ]
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [13.4, 14.1]
target: [ 13.4, 14.1 ]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -294,3 +294,16 @@ jobs:
run: sudo apt-get update && sudo apt-get install --assume-yes mingw-w64
- name: Run cargo test
run: cargo build -p aws-lc-rs --features prebuilt-nasm --target x86_64-pc-windows-gnu
open-harmony:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
working-directory: .github/docker_images/ohos-5.0.0
run: |
./build_image.sh
- name: Build
run: |
docker run -v "${{ github.workspace }}:/aws_lc_rs" ohos-5.0.0

0 comments on commit 19006b1

Please sign in to comment.