Kevin Lubick | e1b36fe | 2018-08-02 11:30:33 -0400 | [diff] [blame^] | 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 | |
| 7 | |
| 8 | BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd` |
| 9 | HTML_SHELL=$BASE_DIR/shell.html |
| 10 | BUILD_DIR="out/pathkit" |
| 11 | |
| 12 | # This expects the environment variable EMSDK to be set |
| 13 | if [[ ! -d $EMSDK ]]; then |
| 14 | echo "Be sure to set the EMSDK environment variable." |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | # Navigate to SKIA_HOME from where this file is located. |
| 19 | pushd $BASE_DIR/../.. |
| 20 | |
| 21 | # Run this from $SKIA_HOME, not from the directory this file is in. |
| 22 | if [[ ! -d ./src ]]; then |
| 23 | echo "Cannot locate Skia source. Is the source checkout okay? Exiting." |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | if [[ $@ == *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 |
| 36 | fi |
| 37 | |
| 38 | |
| 39 | # Use -O0 for larger builds (but generally quicker) |
| 40 | # Use -Oz for (much slower, but smaller/faster) production builds |
| 41 | RELEASE_CONF="-Oz" |
| 42 | if [[ $@ == *dev* ]]; then |
| 43 | echo "Building a Debug/Testing build" |
| 44 | RELEASE_CONF="-O0 -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1 -g2 -DPATHKIT_TESTING" |
| 45 | fi |
| 46 | |
| 47 | WASM_CONF="-s WASM=1" |
| 48 | if [[ $@ == *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" |
| 51 | fi |
| 52 | |
| 53 | OUTPUT="-o $BUILD_DIR/pathkit.js" |
| 54 | |
| 55 | source $EMSDK/emsdk_env.sh |
| 56 | |
| 57 | echo "Compiling" |
| 58 | |
| 59 | set -e |
| 60 | |
| 61 | mkdir -p $BUILD_DIR |
| 62 | |
| 63 | em++ $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 \ |
| 83 | src/core/SkAnalyticEdge.cpp \ |
| 84 | src/core/SkArenaAlloc.cpp \ |
| 85 | src/core/SkBlitter.cpp \ |
| 86 | src/core/SkCoverageDelta.cpp \ |
| 87 | src/core/SkEdge.cpp \ |
| 88 | src/core/SkEdgeBuilder.cpp \ |
| 89 | src/core/SkEdgeClipper.cpp \ |
| 90 | src/core/SkFDot6Constants.cpp \ |
| 91 | src/core/SkGeometry.cpp \ |
| 92 | src/core/SkLineClipper.cpp \ |
| 93 | src/core/SkMallocPixelRef.cpp \ |
| 94 | src/core/SkMath.cpp \ |
| 95 | src/core/SkMatrix.cpp \ |
| 96 | src/core/SkOpts.cpp \ |
| 97 | src/core/SkPath.cpp \ |
| 98 | src/core/SkPathRef.cpp \ |
| 99 | src/core/SkPoint.cpp \ |
| 100 | src/core/SkRect.cpp \ |
| 101 | src/core/SkRegion.cpp \ |
| 102 | src/core/SkRegion_path.cpp \ |
| 103 | src/core/SkScan_Path.cpp \ |
| 104 | src/core/SkStream.cpp \ |
| 105 | src/core/SkString.cpp \ |
| 106 | src/core/SkStringUtils.cpp \ |
| 107 | src/core/SkUtils.cpp \ |
| 108 | src/pathops/*.cpp \ |
| 109 | src/ports/SkDebug_stdio.cpp \ |
| 110 | src/ports/SkMemory_malloc.cpp \ |
| 111 | src/utils/SkParse.cpp \ |
| 112 | src/utils/SkParsePath.cpp |
| 113 | |
| 114 | if [[ $@ == *serve* ]]; then |
| 115 | pushd $BUILD_DIR |
| 116 | python serve.py |
| 117 | fi |
| 118 | |