blob: c905c9b501c775c64ac79546400b258f0033b125 [file] [log] [blame]
Kevin Lubicke1b36fe2018-08-02 11:30:33 -04001#!/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
7
8BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd`
9HTML_SHELL=$BASE_DIR/shell.html
10BUILD_DIR="out/pathkit"
11
12# This expects the environment variable EMSDK to be set
13if [[ ! -d $EMSDK ]]; then
14 echo "Be sure to set the EMSDK environment variable."
15 exit 1
16fi
17
18# Navigate to SKIA_HOME from where this file is located.
19pushd $BASE_DIR/../..
20
21# Run this from $SKIA_HOME, not from the directory this file is in.
22if [[ ! -d ./src ]]; then
23 echo "Cannot locate Skia source. Is the source checkout okay? Exiting."
24 exit 1
25fi
26
27if [[ $@ == *help* ]]; then
28 echo "By default, this script builds a production WASM build of PathKit."
29 echo ""
30 echo "This script takes several optional parameters:"
31 echo " dev = Make a build suitable for running tests or debugging"
32 echo " asm.js = Build for asm.js instead of WASM"
33 echo " serve = starts a webserver allowing a user to navigate to"
34 echo " localhost:8000/pathkit.html to view the demo page."
35 exit 0
36fi
37
38
39# Use -O0 for larger builds (but generally quicker)
40# Use -Oz for (much slower, but smaller/faster) production builds
41RELEASE_CONF="-Oz"
42if [[ $@ == *dev* ]]; then
43 echo "Building a Debug/Testing build"
44 RELEASE_CONF="-O0 -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1 -g2 -DPATHKIT_TESTING"
45fi
46
47WASM_CONF="-s WASM=1"
48if [[ $@ == *asm.js* ]]; then
49 echo "Building with asm.js instead of WASM"
50 WASM_CONF="-s WASM=0 -s ALLOW_MEMORY_GROWTH=1 --separate-asm"
51fi
52
53OUTPUT="-o $BUILD_DIR/pathkit.js"
54
55source $EMSDK/emsdk_env.sh
56
57echo "Compiling"
58
59set -e
60
61mkdir -p $BUILD_DIR
62
63em++ $RELEASE_CONF -std=c++14 \
64-Iinclude/config \
65-Iinclude/core \
66-Iinclude/gpu \
67-Iinclude/pathops \
68-Iinclude/private \
69-Iinclude/utils \
70-Isrc/core \
71-Isrc/gpu \
72-Isrc/shaders \
73-Isrc/opts \
74--bind \
75$WASM_CONF \
76-s MODULARIZE=1 \
77-s EXPORT_NAME="PathKitInit" \
78-s NO_EXIT_RUNTIME=1 \
79-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
80-s ERROR_ON_MISSING_LIBRARIES=1 \
81$OUTPUT \
82$BASE_DIR/pathkit_wasm_bindings.cpp \
83src/core/SkAnalyticEdge.cpp \
84src/core/SkArenaAlloc.cpp \
85src/core/SkBlitter.cpp \
86src/core/SkCoverageDelta.cpp \
87src/core/SkEdge.cpp \
88src/core/SkEdgeBuilder.cpp \
89src/core/SkEdgeClipper.cpp \
90src/core/SkFDot6Constants.cpp \
91src/core/SkGeometry.cpp \
92src/core/SkLineClipper.cpp \
93src/core/SkMallocPixelRef.cpp \
94src/core/SkMath.cpp \
95src/core/SkMatrix.cpp \
96src/core/SkOpts.cpp \
97src/core/SkPath.cpp \
98src/core/SkPathRef.cpp \
99src/core/SkPoint.cpp \
100src/core/SkRect.cpp \
101src/core/SkRegion.cpp \
102src/core/SkRegion_path.cpp \
103src/core/SkScan_Path.cpp \
104src/core/SkStream.cpp \
105src/core/SkString.cpp \
106src/core/SkStringUtils.cpp \
107src/core/SkUtils.cpp \
108src/pathops/*.cpp \
109src/ports/SkDebug_stdio.cpp \
110src/ports/SkMemory_malloc.cpp \
111src/utils/SkParse.cpp \
112src/utils/SkParsePath.cpp
113
114if [[ $@ == *serve* ]]; then
115 pushd $BUILD_DIR
116 python serve.py
117fi
118