# Use an Ubuntu base image FROM ubuntu:22.04 as builder # Set the working directory WORKDIR /usr/src/app # Install required packages and add multiarch support RUN apt-get update && apt-get install -y \ software-properties-common \ && dpkg --add-architecture arm64 \ && apt-get update # Install cross-compilation tools and libraries for ARM RUN apt-get install -y \ cmake \ ninja-build \ g++-aarch64-linux-gnu \ libicu-dev:arm64 \ libc6-dev:arm64 \ libatomic1:arm64 \ libstdc++-11-dev:arm64 \ make \ python3 \ ruby \ bison \ flex \ perl \ file # Set environment variables for cross-compilation ENV CC=aarch64-linux-gnu-gcc ENV CXX=aarch64-linux-gnu-g++ # Clone the WebKit repository COPY ./WebKit ./WebKit # Set the working directory to the WebKit directory WORKDIR /usr/src/app/WebKit # Ensure the build-webkit script is executable RUN chmod +x Tools/Scripts/build-webkit # Build JavaScriptCore only as a static library for aarch64 RUN Tools/Scripts/build-webkit --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DUSE_THIN_ARCHIVES=OFF -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DENABLE_REMOTE_INSPECTOR=ON" # Move back to the main working directory WORKDIR /usr/src/app # Extract static libraries from JavaScriptCore RUN mkdir libs && \ cp /usr/src/app/WebKit/WebKitBuild/JSCOnly/Release/lib/*.a libs/ # Combine all static libraries into one # RUN cd libs && \ # ar -x /usr/lib/gcc-cross/aarch64-linux-gnu/11/libstdc++.a && \ # ar -x /usr/lib/aarch64-linux-gnu/libicui18n.a && \ # ar -x /usr/lib/aarch64-linux-gnu/libmvec.a && \ # ar -x /usr/lib/aarch64-linux-gnu/libdl.a && \ # ar -x /usr/lib/aarch64-linux-gnu/libicuuc.a && \ # ar -x /usr/lib/aarch64-linux-gnu/libicudata.a && \ # ar -x /usr/lib/gcc-cross/aarch64-linux-gnu/11/libatomic.a && \ # ar -x libJavaScriptCore.a && \ # ar -x libWTF.a && \ # ar -x libbmalloc.a && \ # ar -rcs ../librustjsc.a *.o && ranlib ../librustjsc.a # Clean up object files # RUN rm -rf libs FROM scratch # COPY --from=builder /usr/src/app/librustjsc.a / COPY --from=builder /usr/src/app/libs/libJavaScriptCore.a / COPY --from=builder /usr/src/app/libs/libWTF.a / COPY --from=builder /usr/src/app/libs/libbmalloc.a / COPY --from=builder /usr/lib/gcc-cross/aarch64-linux-gnu/11/libstdc++.a / # COPY --from=builder /usr/lib/aarch64-linux-gnu/libmvec.a / COPY --from=builder /usr/lib/aarch64-linux-gnu/libdl.a / COPY --from=builder /usr/lib/aarch64-linux-gnu/libicui18n.a / COPY --from=builder /usr/lib/aarch64-linux-gnu/libicuuc.a / COPY --from=builder /usr/lib/aarch64-linux-gnu/libicudata.a / COPY --from=builder /usr/lib/gcc-cross/aarch64-linux-gnu/11/libatomic.a /