From b07f47aeb431ee554d555fc1b187957f105543ed Mon Sep 17 00:00:00 2001 From: FriwiDev Date: Tue, 23 Nov 2021 22:55:37 +0100 Subject: [PATCH] Attempt prebuilding for ARM/v6 --- DockerfileLinux | 2 ++ DockerfileLinuxARMPrebuild | 29 ++++++++++++++++++++++++++ compile_linux.sh | 8 +++++++ scripts/run_linux.sh | 3 ++- scripts/run_linux_prebuild.sh | 39 +++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 DockerfileLinuxARMPrebuild create mode 100644 scripts/run_linux_prebuild.sh diff --git a/DockerfileLinux b/DockerfileLinux index 263d38b..742ce4d 100644 --- a/DockerfileLinux +++ b/DockerfileLinux @@ -13,6 +13,8 @@ ARG REF WORKDIR /builder #Copy existing sources, if any COPY jcef /jcef +#Copy prebuild classes, if any +COPY out/linux* /prebuild #Copy and launch run script COPY scripts/run_linux.sh . diff --git a/DockerfileLinuxARMPrebuild b/DockerfileLinuxARMPrebuild new file mode 100644 index 0000000..adf12f6 --- /dev/null +++ b/DockerfileLinuxARMPrebuild @@ -0,0 +1,29 @@ +#This file is used to build java classes for ARMv6 distributions before actually running on ARMv6 +#This is needed as compilation fails on ARMv6 for some yet unknown reasons (libraries do not get detected there) + +FROM friwidev/jcefdocker:linux-latest AS stage + +#Declare build type argument (Release or Debug) +ARG BUILD_TYPE + +#Declare architecture argument (arm64, 386 or amd64) +ARG TARGETARCH + +#Declare git args +ARG REPO +ARG REF + +WORKDIR /builder +#Copy existing sources, if any +COPY jcef /jcef + +#Copy and launch run script +COPY scripts/run_linux_prebuild.sh . +RUN chmod +x run_linux_prebuild.sh +RUN ./run_linux_prebuild.sh + +#Export built files +FROM scratch AS export-stage +COPY --from=stage /jcef/out/linux32 linux32 + + diff --git a/compile_linux.sh b/compile_linux.sh index f4a8c30..3f7a826 100755 --- a/compile_linux.sh +++ b/compile_linux.sh @@ -14,7 +14,15 @@ fi #Execute buildx with linux dockerfile and output to current directory if [ $# -eq 2 ] then + if [ $1 == "arm/v6" ] + then + docker buildx build --platform=linux/386 --build-arg TARGETARCH=386 --build-arg BUILD_TYPE=$2 --build-arg REPO=https://bitbucket.org/chromiumembedded/java-cef.git --build-arg REF=master --file DockerfileLinuxARMPrebuild --output out . + fi docker buildx build --platform=linux/$1 --build-arg TARGETARCH=$1 --build-arg BUILD_TYPE=$2 --build-arg REPO=https://bitbucket.org/chromiumembedded/java-cef.git --build-arg REF=master --file DockerfileLinux --output out . else + if [ $1 == "arm/v6" ] + then + docker buildx build --platform=linux/386 --build-arg TARGETARCH=386 --build-arg BUILD_TYPE=$2 --build-arg REPO=$3 --build-arg REF=$4 --file DockerfileLinuxARMPrebuild --output out . + fi docker buildx build --platform=linux/$1 --build-arg TARGETARCH=$1 --build-arg BUILD_TYPE=$2 --build-arg REPO=$3 --build-arg REF=$4 --file DockerfileLinux --output out . fi diff --git a/scripts/run_linux.sh b/scripts/run_linux.sh index 3858f78..dbb2b5c 100644 --- a/scripts/run_linux.sh +++ b/scripts/run_linux.sh @@ -49,7 +49,8 @@ if [ ${TARGETARCH} == 'amd64' ] || [ ${TARGETARCH} == 'arm64' ]; then elif [ ${TARGETARCH} == '386' ]; then ./compile.sh linux32 else - echo "Can not compile java classes under arm/v6 currently. WIP" + echo "Can not compile java classes under arm/v6 currently. So we copy from prebuild directory." + cp -r /prebuild/linux32 /jcef/out fi #Generate distribution diff --git a/scripts/run_linux_prebuild.sh b/scripts/run_linux_prebuild.sh new file mode 100644 index 0000000..0d7cfec --- /dev/null +++ b/scripts/run_linux_prebuild.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# This file prebuilds the java classes for arm/v6 under another architecture, as compilation of those fails +# on arm/v6. They can be used on the platform nontheless. + +# Determine architecture +echo "Prebuilding java classes with $TARGETARCH" + +# Print some debug info +echo "-------------------------------------" +echo "JAVA_HOME: $JAVA_HOME" +echo "PATH: $PATH" +java -version +echo "-------------------------------------" + +# Fetch sources +if [ ! -f "/jcef/README.md" ]; then + echo "Did not find existing files to build - cloning..." + rm -rf /jcef + git clone ${REPO} /jcef + cd /jcef + git checkout ${REF} + #Temporary CMakeLists patching - beautify in the future + rm CMakeLists.txt + curl -o CMakeLists.txt https://raw.githubusercontent.com/jcefmaven/jcefbuild/master/CMakeLists.txt +else + echo "Found existing files to build" + cd /jcef +fi + +# Create and enter the `jcef_build` directory. +# The `jcef_build` directory name is required by other JCEF tooling +# and should not be changed. +mkdir jcef_build && cd jcef_build + +#Compile JCEF java classes +cd ../tools +chmod +x compile.sh +./compile.sh linux32