Revert "[pathkit] Reorganize to be more like CanvasKit"
Revert submission 502817
Reason for revert: Failing tests
Reverted Changes:
I64226b571:[pathkit] Reorganize to be more like CanvasKit
Ib403708a8:[pathkit] Increase default memory size and allow g...
Change-Id: I74ebd8cde4a2b60b113574115d353576bd362310
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/503739
Auto-Submit: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
diff --git a/modules/pathkit/.gitignore b/modules/pathkit/.gitignore
index 9f1869c..6e849a1 100644
--- a/modules/pathkit/.gitignore
+++ b/modules/pathkit/.gitignore
@@ -1,4 +1,3 @@
**/bin
node_modules/
-build/
package-lock.json
\ No newline at end of file
diff --git a/modules/pathkit/CHANGELOG.md b/modules/pathkit/CHANGELOG.md
index 715a4f9..4b5ed53 100644
--- a/modules/pathkit/CHANGELOG.md
+++ b/modules/pathkit/CHANGELOG.md
@@ -10,7 +10,6 @@
- Now compile with emsdk 3.1.3
- Internal calls no longer use dynamic dispatch (skbug.com/12795)
- WASM Memory can grow beyond initial 32MB
- - The debug and test builds of PathKit are no longer published to NPM.
## [0.7.0] 2019-07-20
diff --git a/modules/pathkit/Makefile b/modules/pathkit/Makefile
index 48205b6..5260093 100644
--- a/modules/pathkit/Makefile
+++ b/modules/pathkit/Makefile
@@ -1,27 +1,9 @@
-debug:
- ./compile.sh debug
- - rm -rf build/
- mkdir -p ./build/wasm ./build/asmjs
- cp ../../out/pathkit/pathkit.js ./build/wasm/pathkit.js
- cp ../../out/pathkit/pathkit.wasm ./build/wasm/pathkit.wasm
-
- ./compile.sh asm.js debug
- cp ../../out/pathkit/pathkit.js ./build/asmjs/pathkit.js
-
-release:
+build:
./compile.sh
- - rm -rf build/
- mkdir -p ./build/wasm ./build/asmjs
- cp ../../out/pathkit/pathkit.js ./build/wasm/pathkit.js
- cp ../../out/pathkit/pathkit.wasm ./build/wasm/pathkit.wasm
- ./compile.sh asm.js
- cp ../../out/pathkit/pathkit.js ./build/asmjs/pathkit.js
- cp ../../out/pathkit/pathkit.js.mem ./build/asmjs/pathkit.js.mem
-
-npm:
- rm -rf ./npm-wasm/bin ./npm-asmjs/bin
- mkdir -p ./npm-wasm/bin ./npm-asmjs/bin
+npm: npm-test npm-debug
+ mkdir -p ./npm-wasm/bin
+ mkdir -p ./npm-asmjs/bin
./compile.sh
cp ../../out/pathkit/pathkit.js ./npm-wasm/bin
cp ../../out/pathkit/pathkit.wasm ./npm-wasm/bin
@@ -29,17 +11,135 @@
cp ../../out/pathkit/pathkit.js ./npm-asmjs/bin/pathkit.js
cp ../../out/pathkit/pathkit.js.mem ./npm-asmjs/bin/pathkit.js.mem
+publish:
+ cd npm-wasm; npm publish
+ cd npm-asmjs; npm publish
+
+update-major:
+ cd npm-wasm; npm version major
+ cd ../npm-asmjs; npm version major
+ echo "Don't forget to publish."
+
+update-minor:
+ cd npm-wasm; npm version minor
+ cd npm-asmjs; npm version minor
+ echo "Don't forget to publish."
+
+update-patch:
+ cd npm-wasm; npm version patch
+ cd npm-asmjs; npm version patch
+ echo "Don't forget to publish."
+
+# Build the library and run the tests. If developing locally, test-continuous is better
+# suited for that, although if you make changes to the C++/WASM code, you will need
+# to manually call make npm-test to re-build.
+test: npm-test
+ npm install
+ npx karma start ./karma.conf.js --single-run
+ ASM_JS=1 npx karma start ./karma.conf.js --single-run
+
test-continuous:
- echo "Assuming npm ci has been run by user"
- echo "Also assuming make debug or make release has also been run by a user (if needed)"
+ echo "Assuming npm install has been run by user"
+ echo "Also assuming make npm-test has also been run by a user (if needed)"
npx karma start ./karma.conf.js --no-single-run --watch-poll
test-continuous-asmjs:
- echo "Assuming npm ci has been run by user"
- echo "Also assuming make debug or make release has also been run by a user (if needed)"
+ echo "Assuming npm install has been run by user"
+ echo "Also assuming make npm-test has also been run by a user (if needed)"
ASM_JS=1 npx karma start ./karma.conf.js --no-single-run --watch-poll
+# Build the library and run the tests using the docker image. If developing locally,
+# test-docker-continuous is better, although if you make changes to the C++/WASM code,
+# you will need to manually call make npm-test to re-build.
+test-docker:
+ mkdir -p ./npm-wasm/bin/test
+ mkdir -p ./npm-asmjs/bin/test
+ mkdir -p $$SKIA_ROOT/out/dockerbuild
+
+ docker run --rm -v $$SKIA_ROOT:/SRC -v $$SKIA_ROOT/out/dockerbuild:/OUT \
+gcr.io/skia-public/emsdk-base:prod /SRC/infra/pathkit/build_pathkit.sh
+ cp ../../out/dockerbuild/pathkit.js ./npm-wasm/bin/test/pathkit.js
+ cp ../../out/dockerbuild/pathkit.wasm ./npm-wasm/bin/test/pathkit.wasm
+
+ docker run --rm -v $$SKIA_ROOT:/SRC -v $$SKIA_ROOT/out/dockerbuild:/OUT \
+gcr.io/skia-public/emsdk-base:prod /SRC/infra/pathkit/build_pathkit.sh asm.js
+ cp ../../out/dockerbuild/pathkit.js ./npm-asmjs/bin/test/pathkit.js
+ cp ../../out/dockerbuild/pathkit.js.mem ./npm-asmjs/bin/test/pathkit.js.mem
+
+ docker run --shm-size=2gb -v $$SKIA_ROOT:/SRC gcr.io/skia-public/karma-chrome-tests:72.0.3626.121_v1 \
+karma start /SRC/modules/pathkit/karma.conf.js --single-run
+ docker run --shm-size=2gb -v $$SKIA_ROOT:/SRC -e ASM_JS=1 gcr.io/skia-public/karma-chrome-tests:72.0.3626.121_v1 \
+karma start /SRC/modules/pathkit/karma.conf.js --single-run
+
+test-docker-continuous:
+ echo "Assuming make npm-test has also been run by a user (if needed)"
+ docker run --shm-size=2gb -v $$SKIA_ROOT:/SRC gcr.io/skia-public/karma-chrome-tests:72.0.3626.121_v1 \
+karma start /SRC/modules/pathkit/karma.conf.js --no-single-run
+
+test-docker-continuous-asmjs:
+ echo "Assuming make npm-test has also been run by a user (if needed)"
+ docker run --shm-size=2gb -v $$SKIA_ROOT:/SRC -e ASM_JS=1 gcr.io/skia-public/karma-chrome-tests:72.0.3626.121_v1 \
+karma start /SRC/modules/pathkit/karma.conf.js --no-single-run
+
+npm-test:
+ # This compile time is typically faster than release and good for use with
+ # local-example-test
+ mkdir -p ./npm-wasm/bin/test
+ mkdir -p ./npm-asmjs/bin/test
+ ./compile.sh test
+ cp ../../out/pathkit/pathkit.js ./npm-wasm/bin/test/pathkit.js
+ cp ../../out/pathkit/pathkit.wasm ./npm-wasm/bin/test/pathkit.wasm
+ ./compile.sh asm.js test
+ cp ../../out/pathkit/pathkit.js ./npm-asmjs/bin/test/pathkit.js
+ cp ../../out/pathkit/pathkit.js.mem ./npm-asmjs/bin/test/pathkit.js.mem
+
+npm-debug:
+ # This compile time is typically faster than release and good for use with
+ # local-example-test
+ mkdir -p ./npm-wasm/bin/debug
+ mkdir -p ./npm-asmjs/bin/debug
+ ./compile.sh debug
+ cp ../../out/pathkit/pathkit.js ./npm-wasm/bin/debug/pathkit.js
+ cp ../../out/pathkit/pathkit.wasm ./npm-wasm/bin/debug/pathkit.wasm
+
+ ./compile.sh asm.js debug
+ cp ../../out/pathkit/pathkit.js ./npm-asmjs/bin/debug/pathkit.js
+
+
+example:
+ npm install pathkit-asmjs pathkit-wasm
+ echo "Go check out localhost:8000/npm-wasm/example.html"
+ python3 ../../tools/serve_wasm.py
+
local-example:
+ rm -rf node_modules/pathkit-wasm
+ rm -rf node_modules/pathkit-asmjs
+ mkdir -p node_modules
+ ln -s -T ../npm-wasm node_modules/pathkit-wasm
+ ln -s -T ../npm-asmjs node_modules/pathkit-asmjs
echo "Go check out http://localhost:8000/npm-wasm/example.html"
echo "or http://localhost:8000/npm-asmjs/example.html"
python3 ../../tools/serve_wasm.py
+
+local-example-test:
+ rm -rf node_modules/pathkit-wasm
+ rm -rf node_modules/pathkit-asmjs
+ mkdir -p node_modules/pathkit-wasm
+ mkdir -p node_modules/pathkit-asmjs
+ ln -s -T ../../npm-wasm/bin/test node_modules/pathkit-wasm/bin
+ ln -s -T ../../npm-asmjs/bin/test node_modules/pathkit-asmjs/bin
+ echo "Go check out localhost:8000/npm-wasm/example.html"
+ echo "or http://localhost:8000/npm-asmjs/example.html"
+ python3 ../../tools/serve_wasm.py
+
+local-example-debug:
+ rm -rf node_modules/pathkit-wasm
+ rm -rf node_modules/pathkit-asmjs
+ mkdir -p node_modules/pathkit-wasm
+ mkdir -p node_modules/pathkit-asmjs
+ ln -s -T ../../npm-wasm/bin/debug node_modules/pathkit-wasm/bin
+ ln -s -T ../../npm-asmjs/bin/debug node_modules/pathkit-asmjs/bin
+ echo "Go check out localhost:8000/npm-wasm/example.html"
+ echo "or http://localhost:8000/npm-asmjs/example.html"
+ python3 ../../tools/serve_wasm.py
+
diff --git a/modules/pathkit/README.md b/modules/pathkit/README.md
index ab963eb..e3316bf 100644
--- a/modules/pathkit/README.md
+++ b/modules/pathkit/README.md
@@ -14,14 +14,17 @@
Run `./compile.sh` to compile a production, WASM build to `$SKIA_HOME/out/pathkit`.
Add "--help" for more options.
+
Deploying to npm
----------------
- # Build the release version for both asmjs and WASM
+ # Build all 3 versions (release, test, debug) for both asmjs and WASM
# These binaries will be placed in the proper places of npm-*/bin
+ # This takes 5-10 minutes.
make npm
- # In each npm- subdirectory, run:
- npm version minor (or patch or major)
- npm login --registry https://wombat-dressing-room.appspot.com
- npm publish
+ # Update the package.json files of both npm-asmjs and npm-wasm
+ make update-patch # or update-minor or update-major
+
+ # Publish both repos
+ make publish
diff --git a/modules/pathkit/karma.conf.js b/modules/pathkit/karma.conf.js
index 0d84576..04ef023 100644
--- a/modules/pathkit/karma.conf.js
+++ b/modules/pathkit/karma.conf.js
@@ -10,16 +10,16 @@
// list of files / patterns to load in the browser
files: [
- { pattern: 'build/wasm/pathkit.wasm', included:false, served:true},
+ { pattern: 'npm-wasm/bin/test/pathkit.wasm', included:false, served:true},
{ pattern: 'tests/*.json', included:false, served:true},
'tests/testReporter.js',
- 'build/wasm/pathkit.js',
+ 'npm-wasm/bin/test/pathkit.js',
'tests/pathkitinit.js',
'tests/*.spec.js'
],
proxies: {
- '/pathkit/': '/base/build/wasm/'
+ '/pathkit/': '/base/npm-wasm/bin/test/'
},
// test results reporter to use
@@ -79,16 +79,16 @@
if (process.env.ASM_JS) {
console.log('asm.js is under test');
cfg.files = [
- { pattern: 'build/asmjs/pathkit.js.mem', included:false, served:true},
+ { pattern: 'npm-asmjs/bin/test/pathkit.js.mem', included:false, served:true},
{ pattern: 'tests/*.json', included:false, served:true},
'tests/testReporter.js',
- 'build/asmjs/pathkit.js',
+ 'npm-asmjs/bin/test/pathkit.js',
'tests/pathkitinit.js',
'tests/*.spec.js'
];
cfg.proxies = {
- '/pathkit/': '/base/build/asmjs/'
+ '/pathkit/': '/base/npm-asmjs/bin/test/'
};
} else {
console.log('wasm is under test');
diff --git a/modules/pathkit/npm-asmjs/example.html b/modules/pathkit/npm-asmjs/example.html
index e018621..c50c453 100644
--- a/modules/pathkit/npm-asmjs/example.html
+++ b/modules/pathkit/npm-asmjs/example.html
@@ -47,12 +47,12 @@
<h2> Solves Cubics for Y given X </h2>
<canvas class=big id=cubics></canvas>
-<script type="text/javascript" src="/build/asmjs/pathkit.js"></script>
+<script type="text/javascript" src="/node_modules/pathkit-asmjs/bin/pathkit.js"></script>
<script type="text/javascript" charset="utf-8">
PathKitInit({
- locateFile: (file) => '/build/asmjs/'+file,
+ locateFile: (file) => '/node_modules/pathkit-asmjs/bin/'+file,
}).then((PathKit) => {
window.PathKit = PathKit;
OutputsExample(PathKit);
diff --git a/modules/pathkit/npm-wasm/example.html b/modules/pathkit/npm-wasm/example.html
index 6ba64c1..488f6ec 100644
--- a/modules/pathkit/npm-wasm/example.html
+++ b/modules/pathkit/npm-wasm/example.html
@@ -47,12 +47,12 @@
<h2> Solves Cubics for Y given X </h2>
<canvas class=big id=cubics></canvas>
-<script type="text/javascript" src="/build/wasm/pathkit.js"></script>
+<script type="text/javascript" src="/node_modules/pathkit-wasm/bin/pathkit.js"></script>
<script type="text/javascript" charset="utf-8">
PathKitInit({
- locateFile: (file) => '/build/wasm/'+file,
+ locateFile: (file) => '/node_modules/pathkit-wasm/bin/'+file,
}).then((PathKit) => {
window.PathKit = PathKit;
OutputsExample(PathKit);