|
| 1 | +ARG ARCH=aarch64 |
| 2 | +ARG VERSION=12.11.0-rc.1 |
| 3 | +ARG UBUNTU_VERSION=24.04 |
| 4 | +ARG REPO=axisecp |
| 5 | +ARG SDK=acap-native-sdk |
| 6 | + |
| 7 | +FROM ${REPO}/${SDK}:${VERSION}-${ARCH}-ubuntu${UBUNTU_VERSION} |
| 8 | + |
| 9 | +ARG BUILD_DIR=/opt/build |
| 10 | +ARG SKIA_VERSION=chrome/m137 |
| 11 | + |
| 12 | +#------------------------------------------------------------------------------- |
| 13 | +# Prepare build environment |
| 14 | +#------------------------------------------------------------------------------- |
| 15 | + |
| 16 | +# Install build dependencies for compiling Skia. Skia is configured with GN |
| 17 | +# (generate-ninja) and built with Ninja. |
| 18 | +RUN DEBIAN_FRONTEND=noninteractive \ |
| 19 | + apt-get update && apt-get install -y --no-install-recommends \ |
| 20 | + generate-ninja ninja-build git && \ |
| 21 | + apt-get clean && \ |
| 22 | + rm -rf /var/lib/apt/lists/* |
| 23 | + |
| 24 | +#------------------------------------------------------------------------------- |
| 25 | +# Download and build the Skia graphics library |
| 26 | +# |
| 27 | +# These layers only depend on SKIA_VERSION, so they are cached and reused across |
| 28 | +# rebuilds as long as the Skia version is unchanged. Editing the application |
| 29 | +# source below does not trigger a Skia rebuild. |
| 30 | +#------------------------------------------------------------------------------- |
| 31 | + |
| 32 | +WORKDIR ${BUILD_DIR}/skia |
| 33 | + |
| 34 | +# Clone Skia, fetch its third-party dependencies, configure with GN and build |
| 35 | +# with Ninja in a single layer. |
| 36 | +# |
| 37 | +# git-sync-deps fetches Skia's third-party dependencies. On a slow or |
| 38 | +# unreliable network this step may fail. git-sync-deps starts one thread per |
| 39 | +# dependency with no concurrency limit, which can overload the connection or |
| 40 | +# trigger server-side rate limiting (HTTP 429). If that happens, serialize the |
| 41 | +# fetches by joining each worker thread right after starting it, for example |
| 42 | +# by prepending: |
| 43 | +# sed -i 's/^\( *\)thread.start()/\1thread.start()\n\1thread.join()/' tools/git-sync-deps |
| 44 | +# git-sync-deps is idempotent and skips already fetched dependencies, so |
| 45 | +# simply re-running it also lets a partial download converge. |
| 46 | +# |
| 47 | +# Minimal Skia GN configuration with most modules disabled. |
| 48 | +# |
| 49 | +# cc, cxx: Force GN to use the SDK-provided cross compilers. |
| 50 | +# extra_cflags: Disable NEON optimisations in Skia's bundled libpng. |
| 51 | +# These are not needed here and cause linking errors. |
| 52 | +# target_cpu: Prevent GN from guessing the target CPU and injecting |
| 53 | +# the wrong -march option. |
| 54 | +# is_component_build: Produce a static Skia library. |
| 55 | +RUN git clone https://skia.googlesource.com/skia.git . \ |
| 56 | + --branch ${SKIA_VERSION} --depth 1 && \ |
| 57 | + python3 tools/git-sync-deps && \ |
| 58 | + . /opt/axis/acapsdk/environment-setup* && \ |
| 59 | + gn gen --root=. --args=" \ |
| 60 | + cc=\"$CC\" \ |
| 61 | + cxx=\"$CXX\" \ |
| 62 | + extra_cflags=[\"-DPNG_ARM_NEON_OPT=0\"] \ |
| 63 | + target_cpu=\"dont_worry_about_it\" \ |
| 64 | + is_official_build=true \ |
| 65 | + is_component_build=false \ |
| 66 | + is_debug=false \ |
| 67 | + skia_enable_ganesh=true \ |
| 68 | + skia_enable_pdf=false \ |
| 69 | + skia_enable_skshaper=false \ |
| 70 | + skia_enable_skunicode=false \ |
| 71 | + skia_enable_svg=false \ |
| 72 | + skia_enable_tools=false \ |
| 73 | + skia_pdf_subset_harfbuzz=false \ |
| 74 | + skia_use_angle=false \ |
| 75 | + skia_use_egl=true \ |
| 76 | + skia_use_expat=false \ |
| 77 | + skia_use_fontconfig=false \ |
| 78 | + skia_use_freetype=false \ |
| 79 | + skia_use_gl=true \ |
| 80 | + skia_use_harfbuzz=false \ |
| 81 | + skia_use_icu=false \ |
| 82 | + skia_use_libjpeg_turbo_decode=false \ |
| 83 | + skia_use_libjpeg_turbo_encode=false \ |
| 84 | + skia_use_lua=false \ |
| 85 | + skia_use_libpng_decode=false \ |
| 86 | + skia_use_libpng_encode=true \ |
| 87 | + skia_use_libwebp_decode=false \ |
| 88 | + skia_use_libwebp_encode=false \ |
| 89 | + skia_use_system_libpng=false \ |
| 90 | + skia_use_system_zlib=false \ |
| 91 | + skia_use_wuffs=false \ |
| 92 | + skia_use_x11=false \ |
| 93 | + skia_use_xps=false \ |
| 94 | + skia_use_zlib=false \ |
| 95 | + " build_skia && \ |
| 96 | + ninja -C build_skia |
| 97 | + |
| 98 | +#------------------------------------------------------------------------------- |
| 99 | +# Build the ACAP application |
| 100 | +#------------------------------------------------------------------------------- |
| 101 | + |
| 102 | +WORKDIR /opt/app |
| 103 | +COPY ./app . |
| 104 | + |
| 105 | +# Point the application Makefile at the prebuilt Skia headers and static |
| 106 | +# library. Skia is statically linked, so it is only needed at build time and is |
| 107 | +# kept outside the application directory to avoid bloating the package. |
| 108 | +ENV SKIA_DIR=${BUILD_DIR}/skia |
| 109 | +ENV SKIA_LIB=${BUILD_DIR}/skia/build_skia/libskia.a |
| 110 | + |
| 111 | +RUN . /opt/axis/acapsdk/environment-setup* && acap-build . |
0 commit comments