aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/wasm/compile.sh
diff options
context:
space:
mode:
authorGravatar Kevin Lubick <kjlubick@google.com>2018-07-06 14:31:23 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-11 15:38:08 +0000
commit22647d0e84ec63b76b9d26153c59d9338b761107 (patch)
tree40fcf32a49630a6c4f901a2c11b02b7a4e0287a7 /experimental/wasm/compile.sh
parent1857ddbe218afd8ef32f672619ab13c0f853436c (diff)
Adventures with Skia, WASM and a JS API for Pathkit
See shell.html::entrypoint() for the JS side of things. See wasm_main.cpp for the C++ side of things (EMSCRIPTEN_BINDINGS at the bottom is what glues the two parts together - in general the strings are for JS and the not strings are the C++) To build this yourself, follow the getting started instructions: https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html and download this patch. Then, update compile.sh to point at your sdk and run it (e.g. $SKIA_ROOT/experimental/wasm/compile.sh) Then navigate a browser (e.g. Chrome) to http://localhost:8000/out/wasm/pathkit.html So far, can compile with compile.sh, but not really with GN/ninja (the compilation into many object files and a link at the end seems to mess emscripten up) Bug: skia: Change-Id: If6b300e2b102469e17841265c7866f1a81094d70 Reviewed-on: https://skia-review.googlesource.com/137422 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/wasm/compile.sh')
-rwxr-xr-xexperimental/wasm/compile.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/experimental/wasm/compile.sh b/experimental/wasm/compile.sh
new file mode 100755
index 0000000000..d2e7098a0b
--- /dev/null
+++ b/experimental/wasm/compile.sh
@@ -0,0 +1,72 @@
+#!/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.
+
+
+# Run this from $SKIA_HOME, not from the directory this file is in.
+# This expects the environment variable EMSDK to be set
+HTML_SHELL="./experimental/wasm/shell.html"
+
+if [[ ! -d $EMSDK ]]; then
+ echo "Be sure to set the EMSDK environment variable."
+ exit 1
+fi
+
+source $EMSDK/emsdk_env.sh
+
+echo "Compiling"
+
+set -e
+
+mkdir -p out/wasm
+
+# Use -O0 for larger builds (but generally quicker)
+# Use -Oz for (much slower, but smaller/faster) production builds
+em++ -Oz -std=c++14 \
+-Iinclude/config \
+-Iinclude/core \
+-Iinclude/private \
+-Iinclude/pathops \
+-Iinclude/utils \
+-Isrc/core \
+--bind \
+-s WASM=1 \
+-s NO_EXIT_RUNTIME=1 \
+-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
+-s ERROR_ON_MISSING_LIBRARIES=1 \
+--shell-file $HTML_SHELL \
+-o out/wasm/pathkit.html \
+experimental/wasm/wasm_main.cpp \
+src/core/SkArenaAlloc.cpp \
+src/core/SkGeometry.cpp \
+src/core/SkMallocPixelRef.cpp \
+src/core/SkMath.cpp \
+src/core/SkMatrix.cpp \
+src/core/SkPath.cpp \
+src/core/SkPathRef.cpp \
+src/core/SkPoint.cpp \
+src/core/SkRect.cpp \
+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
+
+# Add the following for debugging (bloats production code size otherwise)
+# list of all (most?) settings: https://github.com/kripken/emscripten/blob/incoming/src/settings.js
+#-s ASSERTIONS=1 \
+#-s DEMANGLE_SUPPORT=1 \
+#-g2
+
+# To build with ASM.js (instead of WASM)
+# This doesn't give the same results as native c++ or wasm....
+#-s WASM=0 \
+#-s ALLOW_MEMORY_GROWTH=1 \
+
+python -m SimpleHTTPServer 8000