diff --git a/.github/docker_images/ohos-5.0.0/Dockerfile b/.github/docker_images/ohos-5.0.0/Dockerfile new file mode 100644 index 00000000000..884e3f604d3 --- /dev/null +++ b/.github/docker_images/ohos-5.0.0/Dockerfile @@ -0,0 +1,47 @@ +# 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.71-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 + +ENTRYPOINT ["/entry.sh"] diff --git a/.github/docker_images/ohos-5.0.0/aws_lc_rs_build.sh b/.github/docker_images/ohos-5.0.0/aws_lc_rs_build.sh new file mode 100755 index 00000000000..8cfa8faccce --- /dev/null +++ b/.github/docker_images/ohos-5.0.0/aws_lc_rs_build.sh @@ -0,0 +1,23 @@ +#!/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" + +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} +done + +popd # ${SRC_DIR} diff --git a/.github/docker_images/ohos-5.0.0/build_image.sh b/.github/docker_images/ohos-5.0.0/build_image.sh new file mode 100755 index 00000000000..c368af8e2f2 --- /dev/null +++ b/.github/docker_images/ohos-5.0.0/build_image.sh @@ -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[@]}" diff --git a/.github/docker_images/ohos-5.0.0/entry.sh b/.github/docker_images/ohos-5.0.0/entry.sh new file mode 100755 index 00000000000..1857cc127dd --- /dev/null +++ b/.github/docker_images/ohos-5.0.0/entry.sh @@ -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[@]}"