1#!/bin/bash 2# Copyright 2018 Google LLC 3# 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7set -ex 8 9# Navigate to SKIA_HOME from where this file is located. 10BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd` 11pushd $BASE_DIR/../.. 12./bin/fetch-gn 13 14IS_OFFICIAL_BUILD="true" 15IS_DEBUG="false" 16FORCE_TRACING="false" 17PROFILE_BUILD="false" 18# Tracing will be disabled in release/profiling unless this flag is seen. Tracing will 19# be on debug builds always. 20if [[ $@ != *force_tracing* ]] ; then 21 FORCE_TRACING="true" 22fi 23 24if [[ $@ == *debug_build* ]]; then 25 echo "Building a Debug build" 26 IS_DEBUG="true" 27 IS_OFFICIAL_BUILD="false" 28 BUILD_DIR=${BUILD_DIR:="out/canvaskit_wasm_debug"} 29elif [[ $@ == *profiling* ]]; then 30 echo "Building a build for profiling" 31 PROFILE_BUILD="true" 32 BUILD_DIR=${BUILD_DIR:="out/canvaskit_wasm_profile"} 33else 34 BUILD_DIR=${BUILD_DIR:="out/canvaskit_wasm"} 35fi 36 37mkdir -p $BUILD_DIR 38# sometimes the .a files keep old symbols around - cleaning them out makes sure 39# we get a fresh build. 40rm -f $BUILD_DIR/*.a 41 42ENABLE_GANESH="true" 43ENABLE_GRAPHITE="false" 44ENABLE_WEBGL="false" 45ENABLE_WEBGPU="false" 46if [[ $@ == *cpu* ]]; then 47 echo "Using the CPU backend instead of the GPU backend" 48 ENABLE_GANESH="false" 49elif [[ $@ == *webgpu* ]]; then 50 echo "Using WebGPU instead of WebGL" 51 ENABLE_WEBGPU="true" 52 ENABLE_GRAPHITE="true" 53 ENABLE_GANESH="false" 54else 55 ENABLE_WEBGL="true" 56fi 57 58SERIALIZE_SKP="true" 59if [[ $@ == *no_skp_serialization* ]]; then 60 # This saves about 20kb compressed. 61 echo "disabling SKP serialization" 62 SERIALIZE_SKP="false" 63fi 64DESERIALIZE_EFFECTS="true" 65if [[ $@ == *no_effects_deserialization* ]]; then 66 # This saves about 60kb compressed. 67 echo "disabling effects deserialization" 68 DESERIALIZE_EFFECTS="false" 69fi 70 71ENABLE_SKOTTIE="true" 72if [[ $@ == *no_skottie* ]]; then 73 echo "Omitting Skottie" 74 ENABLE_SKOTTIE="false" 75fi 76 77INCLUDE_VIEWER="false" 78USE_EXPAT="false" 79if [[ $@ == *viewer* ]]; then 80 echo "Including viewer" 81 INCLUDE_VIEWER="true" 82 USE_EXPAT="true" 83 IS_OFFICIAL_BUILD="false" 84fi 85 86ENABLE_PATHOPS="true" 87if [[ $@ == *no_pathops* ]] ; then 88 # This saves about 2kb compressed. 89 echo "Omitting PathOps" 90 ENABLE_PATHOPS="false" 91fi 92 93ENABLE_MATRIX="true" 94if [[ $@ == *no_matrix* ]]; then 95 echo "Omitting matrix helper code" 96 ENABLE_MATRIX="false" 97fi 98 99ENABLE_CANVAS="true" 100if [[ $@ == *no_canvas* || $@ == *no_matrix* ]]; then 101 # Note: HTML Canvas bindings depend on the matrix helpers. 102 echo "Omitting bindings for HTML Canvas API" 103 ENABLE_CANVAS="false" 104fi 105 106GN_FONT="skia_enable_fontmgr_custom_directory=false " 107WOFF2_FONT="skia_use_freetype_woff2=true" 108ENABLE_FONT="true" 109ENABLE_EMBEDDED_FONT="true" 110if [[ $@ == *no_font* ]]; then 111 echo "Omitting the built-in font(s), font manager and all code dealing with fonts" 112 ENABLE_FONT="false" 113 ENABLE_EMBEDDED_FONT="false" 114 GN_FONT+="skia_enable_fontmgr_custom_embedded=false skia_enable_fontmgr_custom_empty=false " 115else 116 if [[ $@ == *no_embedded_font* ]]; then 117 echo "Omitting the built-in font(s)" 118 ENABLE_EMBEDDED_FONT="false" 119 fi 120 # Generate the font's binary file (which is covered by .gitignore) 121 GN_FONT+="skia_enable_fontmgr_custom_embedded=true skia_enable_fontmgr_custom_empty=true " 122fi 123 124if [[ $@ == *no_woff2* ]]; then 125 WOFF2_FONT="skia_use_freetype_woff2=false" 126fi 127 128ENABLE_ALIAS_FONT="true" 129if [[ $@ == *no_alias_font* ]]; then 130 ENABLE_ALIAS_FONT="false" 131fi 132 133LEGACY_DRAW_VERTICES="false" 134if [[ $@ == *legacy_draw_vertices* ]]; then 135 LEGACY_DRAW_VERTICES="true" 136fi 137 138DEBUGGER_ENABLED="false" 139if [[ $@ == *enable_debugger* ]]; then 140 DEBUGGER_ENABLED="true" 141fi 142 143GN_SHAPER="skia_use_icu=true skia_use_client_icu=false skia_use_libgrapheme=false skia_use_icu4x=false skia_use_system_icu=false skia_use_harfbuzz=true skia_use_system_harfbuzz=false" 144if [[ $@ == *primitive_shaper* ]] || [[ $@ == *no_font* ]]; then 145 echo "Using the primitive shaper instead of the harfbuzz/icu one" 146 GN_SHAPER="skia_use_icu=false skia_use_harfbuzz=false" 147fi 148 149if [[ $@ == *client_unicode* ]] ; then 150 echo "Using the client-provided skunicode data and harfbuz instead of the icu-provided data" 151 GN_SHAPER="skia_use_icu=false skia_use_client_icu=true skia_use_bidi=false skia_use_libgrapheme=false skia_use_icu4x=false skia_use_harfbuzz=true skia_use_system_harfbuzz=false" 152fi 153 154ENABLE_BIDI="false" 155if [[ $@ == *client_bidi* ]] ; then 156 echo "Using the bidi skunicode data only" 157 GN_SHAPER="skia_use_icu=false skia_use_client_icu=false skia_use_bidi=true skia_use_libgrapheme=false skia_use_icu4x=false skia_use_harfbuzz=false" 158 ENABLE_BIDI="true" 159fi 160 161ENABLE_PARAGRAPH="true" 162if [[ $@ == *no_paragraph* ]] || [[ $@ == *primitive_shaper* ]] || [[ $@ == *no_font* ]]; then 163 echo "Omitting paragraph (must have fonts and non-primitive shaper)" 164 ENABLE_PARAGRAPH="false" 165fi 166 167DO_DECODE="true" 168if [[ $@ == *no_codecs* ]]; then 169 echo "Omitting codecs" 170 DO_DECODE="false" 171 ENCODE_JPEG="false" 172 ENCODE_PNG="false" 173 ENCODE_WEBP="false" 174 NO_ENCODE_JPEG="true" 175 NO_ENCODE_PNG="true" 176 NO_ENCODE_WEBP="true" 177else 178 179 ENCODE_PNG="true" 180 NO_ENCODE_PNG="false" 181 if [[ $@ == *no_encode_png* ]]; then 182 ENCODE_PNG="false" 183 NO_ENCODE_PNG="true" 184 fi 185 186 ENCODE_JPEG="true" 187 NO_ENCODE_JPEG="false" 188 if [[ $@ == *no_encode_jpeg* ]]; then 189 ENCODE_JPEG="false" 190 NO_ENCODE_JPEG="true" 191 fi 192 193 ENCODE_WEBP="true" 194 NO_ENCODE_WEBP="false" 195 if [[ $@ == *no_encode_webp* ]]; then 196 ENCODE_WEBP="false" 197 NO_ENCODE_WEBP="true" 198 fi 199 200fi # no_codecs 201 202./bin/fetch-ninja 203NINJA=third_party/ninja/ninja 204 205echo "Compiling" 206 207./bin/gn gen ${BUILD_DIR} \ 208 --args="is_debug=${IS_DEBUG} \ 209 is_official_build=${IS_OFFICIAL_BUILD} \ 210 is_component_build=false \ 211 is_trivial_abi=true \ 212 werror=true \ 213 target_cpu=\"wasm\" \ 214 \ 215 skia_use_angle=false \ 216 skia_use_dng_sdk=false \ 217 skia_use_dawn=${ENABLE_WEBGPU} \ 218 skia_use_webgl=${ENABLE_WEBGL} \ 219 skia_use_webgpu=${ENABLE_WEBGPU} \ 220 skia_use_expat=${USE_EXPAT} \ 221 skia_use_fontconfig=false \ 222 skia_use_freetype=true \ 223 skia_use_libheif=false \ 224 skia_use_libjpeg_turbo_decode=${DO_DECODE} \ 225 skia_use_libjpeg_turbo_encode=${ENCODE_JPEG} \ 226 skia_use_no_jpeg_encode=${NO_ENCODE_JPEG} \ 227 skia_use_libpng_decode=${DO_DECODE} \ 228 skia_use_libpng_encode=${ENCODE_PNG} \ 229 skia_use_no_png_encode=${NO_ENCODE_PNG} \ 230 skia_use_libwebp_decode=${DO_DECODE} \ 231 skia_use_libwebp_encode=${ENCODE_WEBP} \ 232 skia_use_no_webp_encode=${NO_ENCODE_WEBP} \ 233 skia_use_lua=false \ 234 skia_use_piex=false \ 235 skia_use_system_freetype2=false \ 236 skia_use_system_libjpeg_turbo=false \ 237 skia_use_system_libpng=false \ 238 skia_use_system_libwebp=false \ 239 skia_use_system_zlib=false\ 240 skia_use_vulkan=false \ 241 skia_use_wuffs=true \ 242 skia_use_zlib=true \ 243 skia_enable_ganesh=${ENABLE_GANESH} \ 244 skia_enable_graphite=${ENABLE_GRAPHITE} \ 245 skia_build_for_debugger=${DEBUGGER_ENABLED} \ 246 skia_enable_skottie=${ENABLE_SKOTTIE} \ 247 \ 248 ${GN_SHAPER} \ 249 ${GN_FONT} \ 250 ${WOFF2_FONT} \ 251 \ 252 skia_enable_skshaper=true \ 253 skia_enable_skparagraph=true \ 254 skia_enable_pdf=false \ 255 skia_canvaskit_enable_rt_shader=true \ 256 skia_canvaskit_force_tracing=${FORCE_TRACING} \ 257 skia_canvaskit_profile_build=${PROFILE_BUILD} \ 258 skia_canvaskit_enable_skp_serialization=${SERIALIZE_SKP} \ 259 skia_canvaskit_enable_effects_deserialization=${DESERIALIZE_EFFECTS} \ 260 skia_canvaskit_include_viewer=${INCLUDE_VIEWER} \ 261 skia_canvaskit_enable_pathops=${ENABLE_PATHOPS} \ 262 skia_canvaskit_enable_matrix_helper=${ENABLE_MATRIX} \ 263 skia_canvaskit_enable_canvas_bindings=${ENABLE_CANVAS} \ 264 skia_canvaskit_enable_font=${ENABLE_FONT} \ 265 skia_canvaskit_enable_embedded_font=${ENABLE_EMBEDDED_FONT} \ 266 skia_canvaskit_enable_alias_font=${ENABLE_ALIAS_FONT} \ 267 skia_canvaskit_legacy_draw_vertices_blend_mode=${LEGACY_DRAW_VERTICES} \ 268 skia_canvaskit_enable_debugger=${DEBUGGER_ENABLED} \ 269 skia_canvaskit_enable_paragraph=${ENABLE_PARAGRAPH} \ 270 skia_canvaskit_enable_bidi=${ENABLE_BIDI} \ 271 skia_canvaskit_enable_webgl=${ENABLE_WEBGL} \ 272 skia_canvaskit_enable_webgpu=${ENABLE_WEBGPU}" 273 274${NINJA} -C ${BUILD_DIR} canvaskit.js 275