Skip to content

Build and load arm64 native libraries of java-runtime-interface-client #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
class NativeClient {
private static final String nativeLibPath = "/tmp/.aws-lambda-runtime-interface-client";
private static final String[] libsToTry = {
"/aws-lambda-runtime-interface-client.glibc.so",
"/aws-lambda-runtime-interface-client.musl.so",
"/aws-lambda-runtime-interface-client.x86_64.glibc.so",
"/aws-lambda-runtime-interface-client.arm64.glibc.so",
"/aws-lambda-runtime-interface-client.x86_64.musl.so",
"/aws-lambda-runtime-interface-client.arm64.musl.so",
};
private static final Throwable[] exceptions = new Throwable[libsToTry.length];
static {
Expand All @@ -25,9 +27,7 @@ class NativeClient {
Files.copy(lib, Paths.get(nativeLibPath), StandardCopyOption.REPLACE_EXISTING);
System.load(nativeLibPath);
loaded = true;
} catch (UnsatisfiedLinkError e) {
exceptions[i] = e;
} catch (Exception e) {
} catch (UnsatisfiedLinkError | Exception e) {
exceptions[i] = e;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# we use centos 7 to build against glibc 2.17
FROM centos:7

ARG IMAGE_SOURCE=centos:7
FROM ${IMAGE_SOURCE}

ARG CURL_VERSION

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM alpine:3
ARG IMAGE_SOURCE=alpine:3
FROM ${IMAGE_SOURCE}

ARG CURL_VERSION

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ DST_DIR=${1}
CURL_VERSION=7.77.0

# compile the native library
docker build -f "${SRC_DIR}/Dockerfile.glibc" --build-arg CURL_VERSION=${CURL_VERSION} -t lambda-java-jni-lib-glibc "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-glibc /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.glibc.so
docker build -f "${SRC_DIR}/Dockerfile.glibc" --build-arg CURL_VERSION="${CURL_VERSION}" --build-arg IMAGE_SOURCE=centos:7 -t lambda-java-jni-lib-glibc-x86_64 "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-glibc-x86_64 /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.x86_64.glibc.so

docker build -f "${SRC_DIR}/Dockerfile.musl" --build-arg CURL_VERSION=${CURL_VERSION} -t lambda-java-jni-lib-musl "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-musl /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.musl.so
docker build -f "${SRC_DIR}/Dockerfile.glibc" --build-arg CURL_VERSION="${CURL_VERSION}" --build-arg IMAGE_SOURCE=arm64v8/centos:7 -t lambda-java-jni-lib-glibc-arm64 "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-glibc-arm64 /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.arm64.glibc.so

docker build -f "${SRC_DIR}/Dockerfile.musl" --build-arg CURL_VERSION="${CURL_VERSION}" --build-arg IMAGE_SOURCE=alpine:3.12 -t lambda-java-jni-lib-musl-x86_64 "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-musl-x86_64 /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.x86_64.musl.so

docker build -f "${SRC_DIR}/Dockerfile.musl" --build-arg CURL_VERSION="${CURL_VERSION}" --build-arg IMAGE_SOURCE=arm64v8/alpine:3 -t lambda-java-jni-lib-musl-arm64 "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-musl-arm64 /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.arm64.musl.so