2018-07-06 18:31:23 +00:00
|
|
|
#!/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.
|
|
|
|
|
2018-10-09 13:36:35 +00:00
|
|
|
set -ex
|
2018-07-06 18:31:23 +00:00
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd`
|
|
|
|
HTML_SHELL=$BASE_DIR/shell.html
|
2018-08-03 14:26:00 +00:00
|
|
|
BUILD_DIR=${BUILD_DIR:="out/pathkit"}
|
2018-10-09 13:36:35 +00:00
|
|
|
mkdir -p $BUILD_DIR
|
2020-01-28 15:39:56 +00:00
|
|
|
# sometimes the .a files keep old symbols around - cleaning them out makes sure
|
|
|
|
# we get a fresh build.
|
|
|
|
rm -f $BUILD_DIR/*.a
|
2018-07-06 18:31:23 +00:00
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
# This expects the environment variable EMSDK to be set
|
2018-07-06 18:31:23 +00:00
|
|
|
if [[ ! -d $EMSDK ]]; then
|
2018-08-02 15:30:33 +00:00
|
|
|
echo "Be sure to set the EMSDK environment variable."
|
|
|
|
exit 1
|
2018-07-06 18:31:23 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
# Navigate to SKIA_HOME from where this file is located.
|
|
|
|
pushd $BASE_DIR/../..
|
|
|
|
|
2018-08-03 14:26:00 +00:00
|
|
|
echo "Putting output in $BUILD_DIR (pwd = `pwd`)"
|
|
|
|
|
2018-08-02 15:30:33 +00:00
|
|
|
# Run this from $SKIA_HOME, not from the directory this file is in.
|
|
|
|
if [[ ! -d ./src ]]; then
|
|
|
|
echo "Cannot locate Skia source. Is the source checkout okay? Exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $@ == *help* ]]; then
|
|
|
|
echo "By default, this script builds a production WASM build of PathKit."
|
|
|
|
echo ""
|
2018-08-03 14:26:00 +00:00
|
|
|
echo "It is put in ${BUILD_DIR}, configured by the BUILD_DIR environment"
|
|
|
|
echo "variable. Additionally, the EMSDK environment variable must be set."
|
2018-08-02 15:30:33 +00:00
|
|
|
echo "This script takes several optional parameters:"
|
[PathKit] Add more Path2D functionality and move some methods to be members
Adds arc, arcTo, rect and Path2D names for quadTo, cubicTo, close.
Adds conic verb support (approximated with 2 quads).
Breaking changes:
Some functions have been moved to be member functions:
PathKit.Simplify(path) -> path.simplify()
PathKit.ToCanvas(path, ctx) -> path.toCanvas(ctx)
PathKit.ToSVGString(path) -> path.toSVGString()
PathKit.ToPath2D(path) -> path.toPath2D()
PathKit.ToCmds(path) -> path.toCmds()
PathKit.ResolveBuilder(builder) -> builder.resolve()
PathKit.GetBoundaryPathFromRegion(region) -> region.getBoundaryPath()
Pathkit.ApplyPathOp(pathOne, pathTwo, op) still exists, but there's
now also pathOne.op(pathTwo, op) for cases when that's easier.
As per custom with version 0.x.y projects, I'm bumping the
minor version (in npm) for these breaking changes instead of the
major version (which will happen when we are version >= 1.0.0).
This also has some small improvements to the output code size.
The biggest jump was from enabling the closure compiler on the
helper JS, which trimmed it down by about 40%. Using the closure
compiler requires the JRE on the bots, which prompted the emsdk-base
image change.
Bug: skia:8216
Change-Id: I40902d23380093c34d1679df0255bcb0eaa77b01
Reviewed-on: https://skia-review.googlesource.com/145420
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-08-06 18:49:39 +00:00
|
|
|
echo " test = Make a build suitable for running tests or profiling"
|
|
|
|
echo " debug = Make a build suitable for debugging (defines SK_DEBUG)"
|
2018-08-03 14:26:00 +00:00
|
|
|
echo " asm.js = Build for asm.js instead of WASM (very experimental)"
|
2018-08-02 15:30:33 +00:00
|
|
|
echo " serve = starts a webserver allowing a user to navigate to"
|
|
|
|
echo " localhost:8000/pathkit.html to view the demo page."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Use -O0 for larger builds (but generally quicker)
|
|
|
|
# Use -Oz for (much slower, but smaller/faster) production builds
|
[PathKit] Rework API to avoid extra copies unless explicitly called for.
Breaking Changes:
- All method calls that mutate a path now return the same JS path
object to allow chaining (moveTo, lineTo, trim, op, simplify, etc).
Pre-existing code likely will need to have some delete() methods
removed because the path will be deleted multiple times. See
chaining.js for this code (basically, we wrote our own binding code
since the default code wasn't quite flexible enough)
- GetCanvasFillType -> GetFillTypeString (Was in https://skia-review.googlesource.com/c/skia/+/147209)
Since Canvas and SVG use the same strings, it seemed logical to make
them share.
- stroke() now takes a single object instead of 3 params. This object
currently can have up to 4 params, cap, join, width, miter_limit.
This object can be expanded on in future versions as more configuration
options are added.
As per custom with v0 software, we bump the minor version to 0.2.X
to indicate breaking changes in a pre-release software package.
Other changes of note:
- Simple tests added for effects (see effects.specs.js) A follow up
CL will handle the Gold (correctness tests)
- Simple tests added for equals and copy constructors (from https://skia-review.googlesource.com/c/skia/+/147209)
- Added transform() to allow for arbitrary matrix transforms
- Added SimpleMatrix as a value_array, which means users can
provide a 9 element array which will be converted to SimpleMatrix
and then SkMatrix on the C++ side.
- Renamed helpers_externs.js to externs.js and expanded it greatly.
This was necessitated by the code written in chaining.js
- Fixed a few bugs in previous tests (svg gold test race condition,
uncaught exception in svg reporting)
See also https://skia-review.googlesource.com/c/skia/+/147209 which
allows .moveTo .lineTo, etc to chain on the C++ SkPath.
Bug: skia:8216
Change-Id: I7450cd8b7b5377cf15c962b02d161677b62d7e15
Reviewed-on: https://skia-review.googlesource.com/147115
Reviewed-by: Mike Reed <reed@google.com>
2018-08-17 17:52:56 +00:00
|
|
|
export EMCC_CLOSURE_ARGS="--externs $BASE_DIR/externs.js "
|
2020-10-08 16:59:34 +00:00
|
|
|
RELEASE_CONF="-Oz --closure 1 -s EVAL_CTORS=1 -DSK_RELEASE"
|
2018-10-02 13:02:18 +00:00
|
|
|
# It is very important for the -DSK_RELEASE/-DSK_DEBUG to match on the libskia.a, otherwise
|
|
|
|
# things like SKDEBUGCODE are sometimes compiled in and sometimes not, which can cause headaches
|
|
|
|
# like sizeof() mismatching between .cpp files and .h files.
|
|
|
|
EXTRA_CFLAGS="\"-DSK_RELEASE\""
|
[PathKit] Add more Path2D functionality and move some methods to be members
Adds arc, arcTo, rect and Path2D names for quadTo, cubicTo, close.
Adds conic verb support (approximated with 2 quads).
Breaking changes:
Some functions have been moved to be member functions:
PathKit.Simplify(path) -> path.simplify()
PathKit.ToCanvas(path, ctx) -> path.toCanvas(ctx)
PathKit.ToSVGString(path) -> path.toSVGString()
PathKit.ToPath2D(path) -> path.toPath2D()
PathKit.ToCmds(path) -> path.toCmds()
PathKit.ResolveBuilder(builder) -> builder.resolve()
PathKit.GetBoundaryPathFromRegion(region) -> region.getBoundaryPath()
Pathkit.ApplyPathOp(pathOne, pathTwo, op) still exists, but there's
now also pathOne.op(pathTwo, op) for cases when that's easier.
As per custom with version 0.x.y projects, I'm bumping the
minor version (in npm) for these breaking changes instead of the
major version (which will happen when we are version >= 1.0.0).
This also has some small improvements to the output code size.
The biggest jump was from enabling the closure compiler on the
helper JS, which trimmed it down by about 40%. Using the closure
compiler requires the JRE on the bots, which prompted the emsdk-base
image change.
Bug: skia:8216
Change-Id: I40902d23380093c34d1679df0255bcb0eaa77b01
Reviewed-on: https://skia-review.googlesource.com/145420
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-08-06 18:49:39 +00:00
|
|
|
if [[ $@ == *test* ]]; then
|
|
|
|
echo "Building a Testing/Profiling build"
|
|
|
|
RELEASE_CONF="-O2 --profiling -DPATHKIT_TESTING -DSK_RELEASE"
|
|
|
|
elif [[ $@ == *debug* ]]; then
|
|
|
|
echo "Building a Debug build"
|
2018-10-02 13:02:18 +00:00
|
|
|
EXTRA_CFLAGS="\"-DSK_DEBUG\""
|
2020-01-28 18:42:30 +00:00
|
|
|
RELEASE_CONF="-O0 --js-opts 0 -s SAFE_HEAP=1 -s ASSERTIONS=1 -g3 -DPATHKIT_TESTING -DSK_DEBUG"
|
2018-08-02 15:30:33 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
WASM_CONF="-s WASM=1"
|
|
|
|
if [[ $@ == *asm.js* ]]; then
|
|
|
|
echo "Building with asm.js instead of WASM"
|
2018-08-22 13:35:32 +00:00
|
|
|
WASM_CONF="-s WASM=0 -s ALLOW_MEMORY_GROWTH=1"
|
2018-08-02 15:30:33 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
OUTPUT="-o $BUILD_DIR/pathkit.js"
|
2018-10-09 13:36:35 +00:00
|
|
|
|
2018-07-06 18:31:23 +00:00
|
|
|
source $EMSDK/emsdk_env.sh
|
2018-10-02 13:02:18 +00:00
|
|
|
EMCC=`which emcc`
|
|
|
|
EMCXX=`which em++`
|
2020-01-28 15:39:56 +00:00
|
|
|
EMAR=`which emar`
|
2018-07-06 18:31:23 +00:00
|
|
|
|
2018-10-09 13:36:35 +00:00
|
|
|
# Turn off exiting while we check for ninja (which may not be on PATH)
|
|
|
|
set +e
|
|
|
|
NINJA=`which ninja`
|
2018-10-02 13:02:18 +00:00
|
|
|
if [[ -z $NINJA ]]; then
|
|
|
|
git clone "https://chromium.googlesource.com/chromium/tools/depot_tools.git" --depth 1 $BUILD_DIR/depot_tools
|
|
|
|
NINJA=$BUILD_DIR/depot_tools/ninja
|
|
|
|
fi
|
2018-10-09 13:36:35 +00:00
|
|
|
# Re-enable error checking
|
|
|
|
set -e
|
2018-10-02 13:02:18 +00:00
|
|
|
|
|
|
|
echo "Compiling bitcode"
|
|
|
|
|
|
|
|
./bin/fetch-gn
|
|
|
|
./bin/gn gen ${BUILD_DIR} \
|
|
|
|
--args="cc=\"${EMCC}\" \
|
|
|
|
cxx=\"${EMCXX}\" \
|
2020-01-28 15:39:56 +00:00
|
|
|
ar=\"${EMAR}\" \
|
ignore SK_DISABLE_READBUFFER
Its effect is small and we want to rely on SkReadBuffer being available.
Size changes:
- canvaskit uncompressed: 6,864,481 --> 6,864,481 ( no change )
- canvaskit compressed: 2,667,117 --> 2,667,117 ( no change )
- pathkit uncompressed: 329,187 --> 330,679 (+ 1.5K, +0.5%)
- pathkit compressed: 134,158 --> 134,672 (+ 0.5K, +0.4%)
- flutter : 1,302,108 --> 1,322,568 (+20.0K, +1.6%)
The Flutter change is the biggest mystery, as bloaty only pegs
SkReadBuffer as 3.9K. The rest must come from other files including
SkReadBuffer.h not being able to see and inline away SkReadBuffer
routines? Feels like SK_DISABLE_EFFECT_DESERIALIZATION isn't trimming
enough?
PS 4-6 have an idea to push SK_DISABLE_EFFECT_DESERIALIZATION further.
Change-Id: Ifda3ccb82dd0636cfed6bb826fb185a7bca2cbe0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295061
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-06-08 19:10:29 +00:00
|
|
|
extra_cflags=[\"-s\", \"WARN_UNALIGNED=1\",
|
2020-01-28 15:39:56 +00:00
|
|
|
\"-s\", \"MAIN_MODULE=1\",
|
2018-10-10 18:55:01 +00:00
|
|
|
${EXTRA_CFLAGS}
|
|
|
|
] \
|
2018-10-02 13:02:18 +00:00
|
|
|
is_debug=false \
|
|
|
|
is_official_build=true \
|
|
|
|
is_component_build=false \
|
2019-04-23 12:38:07 +00:00
|
|
|
werror=true \
|
2018-10-10 18:55:01 +00:00
|
|
|
target_cpu=\"wasm\" "
|
2018-10-02 13:02:18 +00:00
|
|
|
|
|
|
|
${NINJA} -C ${BUILD_DIR} libpathkit.a
|
|
|
|
|
|
|
|
echo "Generating WASM"
|
|
|
|
|
2020-01-28 15:39:56 +00:00
|
|
|
${EMCXX} $RELEASE_CONF -std=c++17 \
|
2019-04-23 17:05:21 +00:00
|
|
|
-I. \
|
2018-07-06 18:31:23 +00:00
|
|
|
--bind \
|
2020-05-21 13:59:44 +00:00
|
|
|
--no-entry \
|
2018-08-09 17:58:04 +00:00
|
|
|
--pre-js $BASE_DIR/helper.js \
|
[PathKit] Rework API to avoid extra copies unless explicitly called for.
Breaking Changes:
- All method calls that mutate a path now return the same JS path
object to allow chaining (moveTo, lineTo, trim, op, simplify, etc).
Pre-existing code likely will need to have some delete() methods
removed because the path will be deleted multiple times. See
chaining.js for this code (basically, we wrote our own binding code
since the default code wasn't quite flexible enough)
- GetCanvasFillType -> GetFillTypeString (Was in https://skia-review.googlesource.com/c/skia/+/147209)
Since Canvas and SVG use the same strings, it seemed logical to make
them share.
- stroke() now takes a single object instead of 3 params. This object
currently can have up to 4 params, cap, join, width, miter_limit.
This object can be expanded on in future versions as more configuration
options are added.
As per custom with v0 software, we bump the minor version to 0.2.X
to indicate breaking changes in a pre-release software package.
Other changes of note:
- Simple tests added for effects (see effects.specs.js) A follow up
CL will handle the Gold (correctness tests)
- Simple tests added for equals and copy constructors (from https://skia-review.googlesource.com/c/skia/+/147209)
- Added transform() to allow for arbitrary matrix transforms
- Added SimpleMatrix as a value_array, which means users can
provide a 9 element array which will be converted to SimpleMatrix
and then SkMatrix on the C++ side.
- Renamed helpers_externs.js to externs.js and expanded it greatly.
This was necessitated by the code written in chaining.js
- Fixed a few bugs in previous tests (svg gold test race condition,
uncaught exception in svg reporting)
See also https://skia-review.googlesource.com/c/skia/+/147209 which
allows .moveTo .lineTo, etc to chain on the C++ SkPath.
Bug: skia:8216
Change-Id: I7450cd8b7b5377cf15c962b02d161677b62d7e15
Reviewed-on: https://skia-review.googlesource.com/147115
Reviewed-by: Mike Reed <reed@google.com>
2018-08-17 17:52:56 +00:00
|
|
|
--pre-js $BASE_DIR/chaining.js \
|
[PathKit] Add more Path2D functionality and move some methods to be members
Adds arc, arcTo, rect and Path2D names for quadTo, cubicTo, close.
Adds conic verb support (approximated with 2 quads).
Breaking changes:
Some functions have been moved to be member functions:
PathKit.Simplify(path) -> path.simplify()
PathKit.ToCanvas(path, ctx) -> path.toCanvas(ctx)
PathKit.ToSVGString(path) -> path.toSVGString()
PathKit.ToPath2D(path) -> path.toPath2D()
PathKit.ToCmds(path) -> path.toCmds()
PathKit.ResolveBuilder(builder) -> builder.resolve()
PathKit.GetBoundaryPathFromRegion(region) -> region.getBoundaryPath()
Pathkit.ApplyPathOp(pathOne, pathTwo, op) still exists, but there's
now also pathOne.op(pathTwo, op) for cases when that's easier.
As per custom with version 0.x.y projects, I'm bumping the
minor version (in npm) for these breaking changes instead of the
major version (which will happen when we are version >= 1.0.0).
This also has some small improvements to the output code size.
The biggest jump was from enabling the closure compiler on the
helper JS, which trimmed it down by about 40%. Using the closure
compiler requires the JRE on the bots, which prompted the emsdk-base
image change.
Bug: skia:8216
Change-Id: I40902d23380093c34d1679df0255bcb0eaa77b01
Reviewed-on: https://skia-review.googlesource.com/145420
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-08-06 18:49:39 +00:00
|
|
|
-fno-rtti -fno-exceptions -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 \
|
2018-08-02 15:30:33 +00:00
|
|
|
$WASM_CONF \
|
2018-09-20 21:39:31 +00:00
|
|
|
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
|
2018-08-02 15:30:33 +00:00
|
|
|
-s EXPORT_NAME="PathKitInit" \
|
2018-09-20 21:39:31 +00:00
|
|
|
-s MODULARIZE=1 \
|
2018-07-06 18:31:23 +00:00
|
|
|
-s NO_EXIT_RUNTIME=1 \
|
[PathKit] Add more Path2D functionality and move some methods to be members
Adds arc, arcTo, rect and Path2D names for quadTo, cubicTo, close.
Adds conic verb support (approximated with 2 quads).
Breaking changes:
Some functions have been moved to be member functions:
PathKit.Simplify(path) -> path.simplify()
PathKit.ToCanvas(path, ctx) -> path.toCanvas(ctx)
PathKit.ToSVGString(path) -> path.toSVGString()
PathKit.ToPath2D(path) -> path.toPath2D()
PathKit.ToCmds(path) -> path.toCmds()
PathKit.ResolveBuilder(builder) -> builder.resolve()
PathKit.GetBoundaryPathFromRegion(region) -> region.getBoundaryPath()
Pathkit.ApplyPathOp(pathOne, pathTwo, op) still exists, but there's
now also pathOne.op(pathTwo, op) for cases when that's easier.
As per custom with version 0.x.y projects, I'm bumping the
minor version (in npm) for these breaking changes instead of the
major version (which will happen when we are version >= 1.0.0).
This also has some small improvements to the output code size.
The biggest jump was from enabling the closure compiler on the
helper JS, which trimmed it down by about 40%. Using the closure
compiler requires the JRE on the bots, which prompted the emsdk-base
image change.
Bug: skia:8216
Change-Id: I40902d23380093c34d1679df0255bcb0eaa77b01
Reviewed-on: https://skia-review.googlesource.com/145420
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-08-06 18:49:39 +00:00
|
|
|
-s NO_FILESYSTEM=1 \
|
|
|
|
-s STRICT=1 \
|
2018-08-02 15:30:33 +00:00
|
|
|
$OUTPUT \
|
|
|
|
$BASE_DIR/pathkit_wasm_bindings.cpp \
|
2018-10-02 13:02:18 +00:00
|
|
|
${BUILD_DIR}/libpathkit.a
|
2018-07-06 18:31:23 +00:00
|
|
|
|
|
|
|
|