xref: /aosp_15_r20/external/skia/docker/skia-release/Dockerfile (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1# Dockerfile for building Skia in release mode, using 3rd party libs from DEPS, with SwiftShader.
2FROM gcr.io/skia-public/skia-build-tools:latest
3
4# Sometimes update_depot_tools fails (e.g. from a pre-goma-deletion commit).
5RUN cd /tmp/depot_tools && git pull && update_depot_tools
6
7RUN cd /tmp \
8  && git clone https://swiftshader.googlesource.com/SwiftShader swiftshader
9
10# Checkout Skia.
11RUN mkdir -p /tmp/skia \
12  && cd /tmp/skia \
13  && fetch skia
14
15# Set fake identity for git rebase. See thread in
16# https://skia-review.googlesource.com/c/buildbot/+/286537/5/docker/Dockerfile#46
17RUN cd /tmp/skia/skia \
18    && git config user.email "[email protected]" \
19    && git config user.name "Skia"
20
21# HASH must be specified.
22ARG HASH
23RUN if [ -z "${HASH}" ] ; then echo "HASH must be specified as a --build-arg"; exit 1; fi
24
25RUN cd /tmp/skia/skia \
26  && git fetch \
27  && git reset --hard ${HASH}
28
29# If patch ref is specified then update the ref to patch in a CL.
30ARG PATCH_REF
31RUN if [ ! -z "${PATCH_REF}" ] ; then cd /tmp/skia/skia \
32    && git fetch https://skia.googlesource.com/skia ${PATCH_REF} \
33    && git checkout FETCH_HEAD \
34    && git rebase ${HASH}; fi
35
36# Check out skia but delete large third_party checkouts we don't actually need
37# to keep the docker image smaller.
38RUN cd /tmp/skia/skia \
39  && gclient sync \
40  && ./bin/fetch-gn \
41  && ./bin/fetch-ninja \
42  && rm -r third_party/externals/dawn \
43           third_party/externals/icu4x \
44           third_party/externals/opengl-registry \
45           third_party/externals/perfetto \
46           third_party/externals/swiftshader \
47           third_party/externals/unicodetools
48
49# Write args.gn.
50RUN mkdir -p /tmp/skia/skia/out/Static
51RUN echo '  \n\
52cc = "clang"  \n\
53cxx = "clang++"  \n\
54skia_use_egl = true  \n\
55is_debug = false  \n\
56skia_enable_fontmgr_fontconfig = true \n\
57skia_use_perfetto = false \n\
58skia_use_libgrapheme = false \n\
59skia_use_icu4x = false \n\
60skia_use_system_freetype2 = false  \n\
61link_pool_depth=2  \n\
62extra_cflags = [  \n\
63  "-I/tmp/swiftshader/include",  \n\
64  "-DGR_EGL_TRY_GLES3_THEN_GLES2",  \n\
65  "-g0",  \n\
66]  \n\
67extra_ldflags = [  \n\
68  "-L/usr/local/lib",  \n\
69  "-Wl,-rpath",  \n\
70  "-Wl,/usr/local/lib"  \n\
71] ' > /tmp/skia/skia/out/Static/args.gn
72
73WORKDIR /tmp/skia/skia
74# Build Skia.
75RUN ./bin/gn gen out/Static
76RUN git rev-parse HEAD > VERSION
77RUN ./bin/ninja -C out/Static fiddle
78# Cleanup .git directories because they are not needed and take up space.
79RUN find . -name .git -print0 | xargs -0 rm -rf
80RUN chown -R skia:skia .
81# obj is readable only by the skia user. It needs additional
82# permissions to be accessible for CI (see https://review.skia.org/487217).
83RUN chmod 755 -R out/Static/obj
84
85FROM gcr.io/skia-public/skia-build-tools:latest
86COPY --from=0 /tmp/skia/skia /tmp/skia/skia
87WORKDIR /tmp/skia/skia