2019-04-01 18:21:05 +00:00
|
|
|
#!/bin/bash
|
2019-03-05 15:45:40 +00:00
|
|
|
# Copyright 2019 Google LLC
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd`
|
|
|
|
# This expects the environment variable EMSDK to be set
|
|
|
|
if [[ ! -d $EMSDK ]]; then
|
|
|
|
echo "Be sure to set the EMSDK environment variable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Navigate to SKIA_HOME from where this file is located.
|
|
|
|
pushd $BASE_DIR/../..
|
|
|
|
|
|
|
|
source $EMSDK/emsdk_env.sh
|
|
|
|
EMCC=`which emcc`
|
|
|
|
EMCXX=`which em++`
|
2020-01-28 19:50:52 +00:00
|
|
|
EMAR=`which emar`
|
2019-03-05 15:45:40 +00:00
|
|
|
|
2019-04-05 17:39:31 +00:00
|
|
|
if [[ $@ == *debug* ]]; then
|
|
|
|
echo "Building a Debug build"
|
|
|
|
EXTRA_CFLAGS="\"-DSK_DEBUG\","
|
2021-05-27 13:06:15 +00:00
|
|
|
RELEASE_CONF="-O0 --js-opts 0 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=1 -s GL_ASSERTIONS=1 -g3 \
|
2019-04-05 17:39:31 +00:00
|
|
|
--source-map-base /node_modules/debugger/bin/ -DSK_DEBUG"
|
|
|
|
BUILD_DIR=${BUILD_DIR:="out/debugger_wasm_debug"}
|
|
|
|
else
|
|
|
|
echo "Building a Release build"
|
2020-11-17 20:30:44 +00:00
|
|
|
EXTRA_CFLAGS="\"-DSK_RELEASE\","
|
|
|
|
RELEASE_CONF="-Oz --closure 1 --llvm-lto 3 -DSK_RELEASE"
|
2019-04-05 17:39:31 +00:00
|
|
|
BUILD_DIR=${BUILD_DIR:="out/debugger_wasm"}
|
|
|
|
fi
|
|
|
|
|
2019-03-05 15:45:40 +00:00
|
|
|
mkdir -p $BUILD_DIR
|
2020-09-02 19:40:37 +00:00
|
|
|
# sometimes the .a files keep old symbols around - cleaning them out makes sure
|
|
|
|
# we get a fresh build.
|
|
|
|
rm -f $BUILD_DIR/*.a
|
2019-03-05 15:45:40 +00:00
|
|
|
|
|
|
|
BUILTIN_FONT="$BASE_DIR/fonts/NotoMono-Regular.ttf.cpp"
|
|
|
|
# Generate the font's binary file (which is covered by .gitignore)
|
|
|
|
python tools/embed_resources.py \
|
|
|
|
--name SK_EMBEDDED_FONTS \
|
|
|
|
--input $BASE_DIR/fonts/NotoMono-Regular.ttf \
|
|
|
|
--output $BASE_DIR/fonts/NotoMono-Regular.ttf.cpp \
|
|
|
|
--align 4
|
|
|
|
|
2019-03-28 16:46:40 +00:00
|
|
|
GN_GPU_FLAGS="\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\","
|
2020-08-20 14:47:34 +00:00
|
|
|
WASM_GPU="-lEGL -lGL -lGLESv2 -DSK_SUPPORT_GPU=1 -DSK_GL \
|
2019-03-15 14:58:31 +00:00
|
|
|
-DSK_DISABLE_LEGACY_SHADERCONTEXT --pre-js $BASE_DIR/cpu.js --pre-js $BASE_DIR/gpu.js"
|
|
|
|
|
2019-04-01 18:21:05 +00:00
|
|
|
# Turn off exiting while we check for ninja (which may not be on PATH)
|
|
|
|
set +e
|
2019-03-05 15:45:40 +00:00
|
|
|
NINJA=`which ninja`
|
2019-04-01 18:21:05 +00:00
|
|
|
if [[ -z $NINJA ]]; then
|
|
|
|
git clone "https://chromium.googlesource.com/chromium/tools/depot_tools.git" --depth 1 $BUILD_DIR/depot_tools
|
|
|
|
NINJA=$BUILD_DIR/depot_tools/ninja
|
|
|
|
fi
|
|
|
|
# Re-enable error checking
|
|
|
|
set -e
|
2019-03-05 15:45:40 +00:00
|
|
|
|
|
|
|
./bin/fetch-gn
|
|
|
|
|
|
|
|
echo "Compiling bitcode"
|
|
|
|
|
|
|
|
./bin/gn gen ${BUILD_DIR} \
|
|
|
|
--args="cc=\"${EMCC}\" \
|
|
|
|
cxx=\"${EMCXX}\" \
|
2020-01-28 19:50:52 +00:00
|
|
|
ar=\"${EMAR}\" \
|
2019-03-05 15:45:40 +00:00
|
|
|
extra_cflags_cc=[\"-frtti\"] \
|
2020-10-08 18:07:29 +00:00
|
|
|
extra_cflags=[\"-s\", \"MAIN_MODULE=1\",
|
2021-06-02 16:34:07 +00:00
|
|
|
\"-DSKNX_NO_SIMD\", \"-DSK_DISABLE_AAA\",
|
2020-08-20 16:33:46 +00:00
|
|
|
\"-DSK_FORCE_8_BYTE_ALIGNMENT\",
|
2019-03-15 14:58:31 +00:00
|
|
|
${GN_GPU_FLAGS}
|
2019-04-05 17:39:31 +00:00
|
|
|
${EXTRA_CFLAGS}
|
2019-03-05 15:45:40 +00:00
|
|
|
] \
|
2019-03-06 17:56:54 +00:00
|
|
|
is_debug=false \
|
|
|
|
is_official_build=true \
|
2019-03-05 15:45:40 +00:00
|
|
|
is_component_build=false \
|
2019-04-23 12:38:07 +00:00
|
|
|
werror=true \
|
2019-03-05 15:45:40 +00:00
|
|
|
target_cpu=\"wasm\" \
|
|
|
|
\
|
2020-08-20 16:33:46 +00:00
|
|
|
skia_use_angle=false \
|
2019-03-05 15:45:40 +00:00
|
|
|
skia_use_dng_sdk=false \
|
2021-06-02 16:34:07 +00:00
|
|
|
skia_use_webgl=true \
|
2019-03-05 15:45:40 +00:00
|
|
|
skia_use_expat=false \
|
|
|
|
skia_use_fontconfig=false \
|
|
|
|
skia_use_freetype=true \
|
|
|
|
skia_use_libheif=false \
|
2020-03-09 18:23:30 +00:00
|
|
|
skia_use_libjpeg_turbo_decode=true \
|
|
|
|
skia_use_libjpeg_turbo_encode=false \
|
|
|
|
skia_use_libpng_decode=true \
|
|
|
|
skia_use_libpng_encode=false \
|
|
|
|
skia_use_libwebp_decode=true \
|
|
|
|
skia_use_libwebp_encode=false \
|
2019-03-05 15:45:40 +00:00
|
|
|
skia_use_wuffs=true \
|
|
|
|
skia_use_lua=false \
|
|
|
|
skia_use_piex=false \
|
2020-01-17 20:18:21 +00:00
|
|
|
skia_use_system_libpng=false \
|
|
|
|
skia_use_system_freetype2=false \
|
2019-03-05 15:45:40 +00:00
|
|
|
skia_use_system_libjpeg_turbo = false \
|
|
|
|
skia_use_system_libwebp=false \
|
2020-01-17 20:18:21 +00:00
|
|
|
skia_use_system_zlib=false\
|
2019-03-05 15:45:40 +00:00
|
|
|
skia_use_vulkan=false \
|
|
|
|
skia_use_zlib=true \
|
2021-05-27 13:06:15 +00:00
|
|
|
skia_enable_gpu=true \
|
|
|
|
skia_gl_standard=\"webgl\" \
|
2019-03-05 15:45:40 +00:00
|
|
|
skia_enable_tools=false \
|
|
|
|
skia_enable_skshaper=false \
|
|
|
|
skia_enable_ccpr=false \
|
2021-05-03 15:42:40 +00:00
|
|
|
skia_enable_nga=false \
|
2020-06-16 14:02:34 +00:00
|
|
|
skia_enable_fontmgr_custom_directory=false \
|
|
|
|
skia_enable_fontmgr_custom_embedded=true \
|
|
|
|
skia_enable_fontmgr_custom_empty=false \
|
2019-03-05 15:45:40 +00:00
|
|
|
skia_enable_pdf=false"
|
|
|
|
|
|
|
|
# Build all the libs, we'll link the appropriate ones down below
|
|
|
|
${NINJA} -C ${BUILD_DIR} libskia.a libdebugcanvas.a
|
|
|
|
|
|
|
|
export EMCC_CLOSURE_ARGS="--externs $BASE_DIR/externs.js "
|
|
|
|
|
2020-09-02 19:40:37 +00:00
|
|
|
echo "Generating final wasm"
|
2019-03-05 15:45:40 +00:00
|
|
|
|
|
|
|
# Emscripten prefers that the .a files go last in order, otherwise, it
|
|
|
|
# may drop symbols that it incorrectly thinks aren't used. One day,
|
|
|
|
# Emscripten will use LLD, which may relax this requirement.
|
2020-09-02 19:40:37 +00:00
|
|
|
EMCC_DEBUG=1 ${EMCXX} \
|
2019-04-05 17:39:31 +00:00
|
|
|
$RELEASE_CONF \
|
2019-04-23 17:05:21 +00:00
|
|
|
-I. \
|
2019-03-05 15:45:40 +00:00
|
|
|
-Ithird_party/icu \
|
2019-04-22 18:24:54 +00:00
|
|
|
-Ithird_party/skcms \
|
2019-03-05 15:45:40 +00:00
|
|
|
-DSK_DISABLE_AAA \
|
2020-09-02 19:40:37 +00:00
|
|
|
-DSK_FORCE_8_BYTE_ALIGNMENT \
|
2019-03-13 17:31:13 +00:00
|
|
|
-std=c++17 \
|
2019-03-15 14:58:31 +00:00
|
|
|
$WASM_GPU \
|
2019-04-05 17:39:31 +00:00
|
|
|
--pre-js $BASE_DIR/helper.js \
|
2019-03-05 15:45:40 +00:00
|
|
|
--bind \
|
2020-05-21 18:14:18 +00:00
|
|
|
--no-entry \
|
2019-03-05 15:45:40 +00:00
|
|
|
$BASE_DIR/fonts/NotoMono-Regular.ttf.cpp \
|
|
|
|
$BASE_DIR/debugger_bindings.cpp \
|
|
|
|
$BUILD_DIR/libdebugcanvas.a \
|
|
|
|
$BUILD_DIR/libskia.a \
|
|
|
|
-s ALLOW_MEMORY_GROWTH=1 \
|
|
|
|
-s EXPORT_NAME="DebuggerInit" \
|
|
|
|
-s FORCE_FILESYSTEM=0 \
|
2020-09-02 19:40:37 +00:00
|
|
|
-s FILESYSTEM=0 \
|
2019-03-05 15:45:40 +00:00
|
|
|
-s MODULARIZE=1 \
|
|
|
|
-s NO_EXIT_RUNTIME=1 \
|
|
|
|
-s STRICT=1 \
|
2020-05-21 18:14:18 +00:00
|
|
|
-s INITIAL_MEMORY=128MB \
|
2019-03-05 15:45:40 +00:00
|
|
|
-s WASM=1 \
|
2019-03-15 14:58:31 +00:00
|
|
|
-s USE_WEBGL2=1 \
|
2019-03-06 17:56:54 +00:00
|
|
|
-o $BUILD_DIR/debugger.js
|