Skip to content

Commit

Permalink
Delta builds for Linux and MacOSX (build in <2 min with docker)
Browse files Browse the repository at this point in the history
  • Loading branch information
FriwiDev committed Dec 29, 2021
1 parent d7be58e commit c1352b6
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 10 deletions.
8 changes: 6 additions & 2 deletions DockerfileLinux
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM friwidev/jcefdocker:linux-latest AS stage

LABEL jcefbuild=true

#Declare build type argument (Release or Debug)
ARG BUILD_TYPE

Expand Down Expand Up @@ -30,5 +32,7 @@ RUN ./run_linux.sh
#Export built files
FROM scratch AS export-stage
COPY --from=stage /jcef/binary_distrib.tar.gz .


COPY --from=stage /jcef/target .
COPY --from=stage /jcef/third_party third_party
COPY --from=stage /jcef/buildtools buildtools
COPY --from=stage /jcef/jcef_build jcef_build
2 changes: 2 additions & 0 deletions DockerfileLinuxARMPrebuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

FROM friwidev/jcefdocker:linux-latest AS stage

LABEL jcefbuild=true

#Declare build type argument (Release or Debug)
ARG BUILD_TYPE

Expand Down
39 changes: 35 additions & 4 deletions compile_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,51 @@ mkdir out
mkdir out/linux32
touch out/linux32/prebuilt.txt

#Cache build image to not download it again each time (speedup for local builds)
docker pull friwidev/jcefdocker:linux-latest

#Execute buildx with linux dockerfile and output to current directory
if [ $# -eq 2 ]
then
if [ $1 == "arm/v6" ]
then
rm -rf out/linux32
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 .
docker buildx build --no-cache --progress=plain --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 .
docker buildx build --no-cache --progress=plain --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
rm -rf out/linux32
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 .
docker buildx build --no-cache --progress=plain jcefbuild:latest --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 .
docker buildx build --no-cache --progress=plain --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
docker builder prune -f --filter "label=jcefbuild=true"

#Cleanup output dir
rm -rf out/linux32
rm -f out/third_party/cef/*.bz2 out/third_party/cef/*.sha1

# Check if the cef download was performed. If so, move third_party dir to jcef dir
export downloaded=0
for f in out/third_party/cef/cef_binary_*; do
test -d "$f" || continue
#We found a matching dir
export downloaded=1
break
done
if [ "$downloaded" -eq "1" ]; then
rm -rf jcef/third_party
mv out/third_party jcef
fi

# Check if the clang download was performed. If so, move it to jcef dir
if [ -f "out/buildtools/clang-format" ]; then
rm -rf jcef/tools/buildtools/linux64
mv out/buildtools jcef/tools/buildtools/linux64
fi

#Move jcef_build
rm -rf jcef/jcef_build
mv out/jcef_build jcef/jcef_build
5 changes: 4 additions & 1 deletion compile_macosx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ 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
if [ ! -d "jcef_build" ]; then
mkdir jcef_build
fi
cd jcef_build

# MacOS: Generate amd64/arm64 Makefiles.
if [ ${TARGETARCH} == 'amd64' ]; then
Expand Down
28 changes: 26 additions & 2 deletions scripts/run_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,27 @@ if [ ! -f "/jcef/README.md" ]; then
else
echo "Found existing files to build"
cd /jcef
fi
fi

#CMakeLists patching
python3 /builder/patch_cmake.py CMakeLists.txt /builder/CMakeLists.txt.patch

# 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
if [ ! -d "jcef_build" ]; then
mkdir jcef_build
fi
cd jcef_build

# Check if the download was already performed. If so, we wont send it outside of the container at the end
export already_downloaded=0
for f in ../third_party/cef/cef_binary_*; do
test -d "$f" || continue
#We found a matching dir
export already_downloaded=1
break
done

# Linux: Generate 32/64-bit Unix Makefiles.
cmake -G "Ninja" -DPROJECT_ARCH=${TARGETARCH} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..
Expand Down Expand Up @@ -77,4 +89,16 @@ else
#Replace natives on armv6
if [ ${TARGETARCH} == 'arm/v6' ]; then (rm bin/gluegen-rt-natives* && rm bin/jogl-all-natives* && cp /natives/gluegen-rt-natives-linux-armv6hf.jar bin && cp /natives/jogl-all-natives-linux-armv6hf.jar bin) fi
fi

#Export binaries
tar -czvf ../../binary_distrib.tar.gz *
mkdir ../../target
mv * ../../target

#Do not export third_party if already exported (it is quite large)
if [ "$already_downloaded" -eq "1" ]; then
rm -rf ../../third_party/*
fi

#Export clang
mv ../../tools/buildtools/linux64 ../../buildtools
5 changes: 4 additions & 1 deletion scripts/run_linux_prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ 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
if [ ! -d "jcef_build" ]; then
mkdir jcef_build
fi
cd jcef_build

#Compile JCEF java classes
cd ../tools
Expand Down

0 comments on commit c1352b6

Please sign in to comment.