2018-07-06 18:31:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2018 Google LLC
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd`
|
|
|
|
HTML_SHELL=$BASE_DIR/shell.html
|
|
|
|
BUILD_DIR="out/pathkit"
|
2018-07-06 18:31:23 +00:00
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
# This expects the environment variable EMSDK to be set
|
2018-07-06 18:31:23 +00:00
|
|
|
if [[ ! -d $EMSDK ]]; then
|
2018-08-02 15:30:33 +00:00
|
|
|
echo "Be sure to set the EMSDK environment variable."
|
|
|
|
exit 1
|
2018-07-06 18:31:23 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
# Navigate to SKIA_HOME from where this file is located.
|
|
|
|
pushd $BASE_DIR/../..
|
|
|
|
|
|
|
|
# Run this from $SKIA_HOME, not from the directory this file is in.
|
|
|
|
if [[ ! -d ./src ]]; then
|
|
|
|
echo "Cannot locate Skia source. Is the source checkout okay? Exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $@ == *help* ]]; then
|
|
|
|
echo "By default, this script builds a production WASM build of PathKit."
|
|
|
|
echo ""
|
|
|
|
echo "This script takes several optional parameters:"
|
|
|
|
echo " dev = Make a build suitable for running tests or debugging"
|
|
|
|
echo " asm.js = Build for asm.js instead of WASM"
|
|
|
|
echo " serve = starts a webserver allowing a user to navigate to"
|
|
|
|
echo " localhost:8000/pathkit.html to view the demo page."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Use -O0 for larger builds (but generally quicker)
|
|
|
|
# Use -Oz for (much slower, but smaller/faster) production builds
|
|
|
|
RELEASE_CONF="-Oz"
|
|
|
|
if [[ $@ == *dev* ]]; then
|
|
|
|
echo "Building a Debug/Testing build"
|
|
|
|
RELEASE_CONF="-O0 -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1 -g2 -DPATHKIT_TESTING"
|
|
|
|
fi
|
|
|
|
|
|
|
|
WASM_CONF="-s WASM=1"
|
|
|
|
if [[ $@ == *asm.js* ]]; then
|
|
|
|
echo "Building with asm.js instead of WASM"
|
|
|
|
WASM_CONF="-s WASM=0 -s ALLOW_MEMORY_GROWTH=1 --separate-asm"
|
|
|
|
fi
|
|
|
|
|
|
|
|
OUTPUT="-o $BUILD_DIR/pathkit.js"
|
|
|
|
|
2018-07-06 18:31:23 +00:00
|
|
|
source $EMSDK/emsdk_env.sh
|
|
|
|
|
|
|
|
echo "Compiling"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
mkdir -p $BUILD_DIR
|
2018-07-06 18:31:23 +00:00
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
em++ $RELEASE_CONF -std=c++14 \
|
2018-07-06 18:31:23 +00:00
|
|
|
-Iinclude/config \
|
|
|
|
-Iinclude/core \
|
2018-07-17 01:00:52 +00:00
|
|
|
-Iinclude/gpu \
|
2018-07-06 18:31:23 +00:00
|
|
|
-Iinclude/pathops \
|
2018-07-17 01:00:52 +00:00
|
|
|
-Iinclude/private \
|
2018-07-06 18:31:23 +00:00
|
|
|
-Iinclude/utils \
|
|
|
|
-Isrc/core \
|
2018-07-17 01:00:52 +00:00
|
|
|
-Isrc/gpu \
|
|
|
|
-Isrc/shaders \
|
|
|
|
-Isrc/opts \
|
2018-07-06 18:31:23 +00:00
|
|
|
--bind \
|
2018-08-02 15:30:33 +00:00
|
|
|
$WASM_CONF \
|
|
|
|
-s MODULARIZE=1 \
|
|
|
|
-s EXPORT_NAME="PathKitInit" \
|
2018-07-06 18:31:23 +00:00
|
|
|
-s NO_EXIT_RUNTIME=1 \
|
|
|
|
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
|
|
|
|
-s ERROR_ON_MISSING_LIBRARIES=1 \
|
2018-08-02 15:30:33 +00:00
|
|
|
$OUTPUT \
|
|
|
|
$BASE_DIR/pathkit_wasm_bindings.cpp \
|
2018-07-17 01:00:52 +00:00
|
|
|
src/core/SkAnalyticEdge.cpp \
|
2018-07-06 18:31:23 +00:00
|
|
|
src/core/SkArenaAlloc.cpp \
|
2018-07-17 01:00:52 +00:00
|
|
|
src/core/SkBlitter.cpp \
|
|
|
|
src/core/SkCoverageDelta.cpp \
|
|
|
|
src/core/SkEdge.cpp \
|
|
|
|
src/core/SkEdgeBuilder.cpp \
|
|
|
|
src/core/SkEdgeClipper.cpp \
|
|
|
|
src/core/SkFDot6Constants.cpp \
|
2018-07-06 18:31:23 +00:00
|
|
|
src/core/SkGeometry.cpp \
|
2018-07-17 01:00:52 +00:00
|
|
|
src/core/SkLineClipper.cpp \
|
2018-07-06 18:31:23 +00:00
|
|
|
src/core/SkMallocPixelRef.cpp \
|
|
|
|
src/core/SkMath.cpp \
|
|
|
|
src/core/SkMatrix.cpp \
|
2018-07-17 01:00:52 +00:00
|
|
|
src/core/SkOpts.cpp \
|
2018-07-06 18:31:23 +00:00
|
|
|
src/core/SkPath.cpp \
|
|
|
|
src/core/SkPathRef.cpp \
|
|
|
|
src/core/SkPoint.cpp \
|
|
|
|
src/core/SkRect.cpp \
|
2018-07-17 01:00:52 +00:00
|
|
|
src/core/SkRegion.cpp \
|
|
|
|
src/core/SkRegion_path.cpp \
|
|
|
|
src/core/SkScan_Path.cpp \
|
2018-07-06 18:31:23 +00:00
|
|
|
src/core/SkStream.cpp \
|
|
|
|
src/core/SkString.cpp \
|
|
|
|
src/core/SkStringUtils.cpp \
|
|
|
|
src/core/SkUtils.cpp \
|
|
|
|
src/pathops/*.cpp \
|
|
|
|
src/ports/SkDebug_stdio.cpp \
|
|
|
|
src/ports/SkMemory_malloc.cpp \
|
|
|
|
src/utils/SkParse.cpp \
|
|
|
|
src/utils/SkParsePath.cpp
|
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
if [[ $@ == *serve* ]]; then
|
|
|
|
pushd $BUILD_DIR
|
|
|
|
python serve.py
|
|
|
|
fi
|
2018-07-06 18:31:23 +00:00
|
|
|
|