Skip to content

Commit c1352b6

Browse files
committedDec 29, 2021
Delta builds for Linux and MacOSX (build in <2 min with docker)
1 parent d7be58e commit c1352b6

6 files changed

+77
-10
lines changed
 

‎DockerfileLinux

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM friwidev/jcefdocker:linux-latest AS stage
22

3+
LABEL jcefbuild=true
4+
35
#Declare build type argument (Release or Debug)
46
ARG BUILD_TYPE
57

@@ -30,5 +32,7 @@ RUN ./run_linux.sh
3032
#Export built files
3133
FROM scratch AS export-stage
3234
COPY --from=stage /jcef/binary_distrib.tar.gz .
33-
34-
35+
COPY --from=stage /jcef/target .
36+
COPY --from=stage /jcef/third_party third_party
37+
COPY --from=stage /jcef/buildtools buildtools
38+
COPY --from=stage /jcef/jcef_build jcef_build

‎DockerfileLinuxARMPrebuild

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
FROM friwidev/jcefdocker:linux-latest AS stage
55

6+
LABEL jcefbuild=true
7+
68
#Declare build type argument (Release or Debug)
79
ARG BUILD_TYPE
810

‎compile_linux.sh

+35-4
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,51 @@ mkdir out
1919
mkdir out/linux32
2020
touch out/linux32/prebuilt.txt
2121

22+
#Cache build image to not download it again each time (speedup for local builds)
23+
docker pull friwidev/jcefdocker:linux-latest
24+
2225
#Execute buildx with linux dockerfile and output to current directory
2326
if [ $# -eq 2 ]
2427
then
2528
if [ $1 == "arm/v6" ]
2629
then
2730
rm -rf out/linux32
28-
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 .
31+
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 .
2932
fi
30-
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 .
33+
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 .
3134
else
3235
if [ $1 == "arm/v6" ]
3336
then
3437
rm -rf out/linux32
35-
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 .
38+
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 .
3639
fi
37-
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 .
40+
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 .
41+
fi
42+
docker builder prune -f --filter "label=jcefbuild=true"
43+
44+
#Cleanup output dir
45+
rm -rf out/linux32
46+
rm -f out/third_party/cef/*.bz2 out/third_party/cef/*.sha1
47+
48+
# Check if the cef download was performed. If so, move third_party dir to jcef dir
49+
export downloaded=0
50+
for f in out/third_party/cef/cef_binary_*; do
51+
test -d "$f" || continue
52+
#We found a matching dir
53+
export downloaded=1
54+
break
55+
done
56+
if [ "$downloaded" -eq "1" ]; then
57+
rm -rf jcef/third_party
58+
mv out/third_party jcef
3859
fi
60+
61+
# Check if the clang download was performed. If so, move it to jcef dir
62+
if [ -f "out/buildtools/clang-format" ]; then
63+
rm -rf jcef/tools/buildtools/linux64
64+
mv out/buildtools jcef/tools/buildtools/linux64
65+
fi
66+
67+
#Move jcef_build
68+
rm -rf jcef/jcef_build
69+
mv out/jcef_build jcef/jcef_build

‎compile_macosx.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ fi
4242
# Create and enter the `jcef_build` directory.
4343
# The `jcef_build` directory name is required by other JCEF tooling
4444
# and should not be changed.
45-
mkdir jcef_build && cd jcef_build
45+
if [ ! -d "jcef_build" ]; then
46+
mkdir jcef_build
47+
fi
48+
cd jcef_build
4649

4750
# MacOS: Generate amd64/arm64 Makefiles.
4851
if [ ${TARGETARCH} == 'amd64' ]; then

‎scripts/run_linux.sh

+26-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,27 @@ if [ ! -f "/jcef/README.md" ]; then
2626
else
2727
echo "Found existing files to build"
2828
cd /jcef
29-
fi
29+
fi
3030

3131
#CMakeLists patching
3232
python3 /builder/patch_cmake.py CMakeLists.txt /builder/CMakeLists.txt.patch
3333

3434
# Create and enter the `jcef_build` directory.
3535
# The `jcef_build` directory name is required by other JCEF tooling
3636
# and should not be changed.
37-
mkdir jcef_build && cd jcef_build
37+
if [ ! -d "jcef_build" ]; then
38+
mkdir jcef_build
39+
fi
40+
cd jcef_build
41+
42+
# Check if the download was already performed. If so, we wont send it outside of the container at the end
43+
export already_downloaded=0
44+
for f in ../third_party/cef/cef_binary_*; do
45+
test -d "$f" || continue
46+
#We found a matching dir
47+
export already_downloaded=1
48+
break
49+
done
3850

3951
# Linux: Generate 32/64-bit Unix Makefiles.
4052
cmake -G "Ninja" -DPROJECT_ARCH=${TARGETARCH} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..
@@ -77,4 +89,16 @@ else
7789
#Replace natives on armv6
7890
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
7991
fi
92+
93+
#Export binaries
8094
tar -czvf ../../binary_distrib.tar.gz *
95+
mkdir ../../target
96+
mv * ../../target
97+
98+
#Do not export third_party if already exported (it is quite large)
99+
if [ "$already_downloaded" -eq "1" ]; then
100+
rm -rf ../../third_party/*
101+
fi
102+
103+
#Export clang
104+
mv ../../tools/buildtools/linux64 ../../buildtools

‎scripts/run_linux_prebuild.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ fi
2828
# Create and enter the `jcef_build` directory.
2929
# The `jcef_build` directory name is required by other JCEF tooling
3030
# and should not be changed.
31-
mkdir jcef_build && cd jcef_build
31+
if [ ! -d "jcef_build" ]; then
32+
mkdir jcef_build
33+
fi
34+
cd jcef_build
3235

3336
#Compile JCEF java classes
3437
cd ../tools

0 commit comments

Comments
 (0)
Please sign in to comment.