skia2/experimental/wasm/compile.sh
Kevin Lubick 22647d0e84 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>
2018-07-11 15:38:08 +00:00

73 lines
1.8 KiB
Bash
Executable File

#!/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