@@ -9,12 +9,68 @@ MULTI_ARCH=${2}
99BUILD_OS=${3}
1010BUILD_ARCH=${4}
1111CURL_VERSION=7.83.1
12- # Registry hosting the base images. Defaults to public.ecr.aws for local and
13- # GitHub-hosted builds; the release workflow overrides it with the ECR
14- # pull-through cache so egress-locked runners don't hit public.ecr.aws.
12+
1513BASE_REGISTRY=" ${BASE_REGISTRY:- public.ecr.aws} "
1614AWS_REGION=" ${AWS_REGION:- ${AWS_DEFAULT_REGION:- } } "
1715
16+ # aws-lambda-cpp is consumed as the prebuilt static library published on the
17+ # upstream GitHub release rather than being compiled from a vendored source
18+ # tree. We fetch and GPG-verify it
19+ ALC_VERSION=" 1.0.1"
20+ ALC_TAG=" v${ALC_VERSION} "
21+ ALC_REPO_URL=" https://github.com/awslabs/aws-lambda-cpp"
22+ ALC_RELEASE_URL=" ${ALC_REPO_URL} /releases/download/${ALC_TAG} "
23+ ALC_SIGNING_KEY_URL=" https://raw.githubusercontent.com/awslabs/aws-lambda-cpp/${ALC_TAG} /signing-public-key.asc"
24+ ALC_STAGE_DIR=" ${SRC_DIR} /deps/aws-lambda-cpp"
25+
26+ function fetch_aws_lambda_cpp() {
27+ arch=$1
28+
29+ release_arch=" ${arch/ aarch_64/ aarch64} "
30+
31+ if [ -f " ${ALC_STAGE_DIR} /.staged-arch" ] && \
32+ [ " $( cat " ${ALC_STAGE_DIR} /.staged-arch" ) " == " ${release_arch} " ]; then
33+ echo " aws-lambda-cpp ${ALC_VERSION} (${release_arch} ) already staged, skipping fetch"
34+ return
35+ fi
36+
37+ echo " Fetching prebuilt aws-lambda-cpp ${ALC_VERSION} for ${release_arch} "
38+ rm -rf " ${ALC_STAGE_DIR} "
39+ mkdir -p " ${ALC_STAGE_DIR} /lib" " ${ALC_STAGE_DIR} /include"
40+
41+ local workdir
42+ workdir=$( mktemp -d)
43+ local lib_asset=" libaws-lambda-runtime-${release_arch} .a"
44+
45+ curl -fsSL -o " ${workdir} /${lib_asset} " " ${ALC_RELEASE_URL} /${lib_asset} "
46+ curl -fsSL -o " ${workdir} /${lib_asset} .asc" " ${ALC_RELEASE_URL} /${lib_asset} .asc"
47+ curl -fsSL -o " ${workdir} /SHA256SUMS" " ${ALC_RELEASE_URL} /SHA256SUMS"
48+ curl -fsSL -o " ${workdir} /SHA256SUMS.asc" " ${ALC_RELEASE_URL} /SHA256SUMS.asc"
49+ curl -fsSL -o " ${workdir} /signing-key.asc" " ${ALC_SIGNING_KEY_URL} "
50+
51+ local gnupg_home
52+ gnupg_home=$( mktemp -d)
53+ chmod 700 " ${gnupg_home} "
54+ GNUPGHOME=" ${gnupg_home} " gpg --batch --import " ${workdir} /signing-key.asc"
55+ GNUPGHOME=" ${gnupg_home} " gpg --batch --verify " ${workdir} /${lib_asset} .asc" " ${workdir} /${lib_asset} "
56+ GNUPGHOME=" ${gnupg_home} " gpg --batch --verify " ${workdir} /SHA256SUMS.asc" " ${workdir} /SHA256SUMS"
57+ rm -rf " ${gnupg_home} "
58+
59+ # Cross-check the checksum too (defence in depth; SHA256SUMS is itself signed).
60+ ( cd " ${workdir} " && grep " ${lib_asset} \$ " SHA256SUMS | sha256sum -c - )
61+
62+ cp " ${workdir} /${lib_asset} " " ${ALC_STAGE_DIR} /lib/libaws-lambda-runtime.a"
63+
64+ # Headers aren't a release asset, so take them from the source at the same
65+ # tag. They are declarations only -- every symbol lives in the prebuilt lib.
66+ curl -fsSL -o " ${workdir} /src.tar.gz" " ${ALC_REPO_URL} /archive/refs/tags/${ALC_TAG} .tar.gz"
67+ tar -xzf " ${workdir} /src.tar.gz" -C " ${workdir} " " aws-lambda-cpp-${ALC_VERSION} /include"
68+ cp -R " ${workdir} /aws-lambda-cpp-${ALC_VERSION} /include/." " ${ALC_STAGE_DIR} /include/"
69+
70+ echo " ${release_arch} " > " ${ALC_STAGE_DIR} /.staged-arch"
71+ rm -rf " ${workdir} "
72+ }
73+
1874function get_docker_platform() {
1975 arch=$1
2076
@@ -44,6 +100,8 @@ function build_for_libc_arch() {
44100 arch=$2
45101 artifact=$3
46102
103+ fetch_aws_lambda_cpp " ${arch} "
104+
47105 docker_platform=$( get_docker_platform ${arch} )
48106
49107 echo " Compiling the native library with libc implementation \` ${libc_impl} \` on architecture \` ${arch} \` using Docker platform \` ${docker_platform} \` "
0 commit comments