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