2018-08-03 14:26:00 +00:00
|
|
|
# Copyright 2018 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
[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
|
|
|
DOCKER_IMAGE = 'gcr.io/skia-public/emsdk-release:1.38.6_jre'
|
[PathKit] Adding test infrastructure to support Gold output
To get the gold images out of the browser tests, this adds
testReporter.js and pathkit_aggregator.go. testReporter bundles
up the output as a base64 encoded PNG and sends it over the local
network to pathkit_aggregator. pathkit_aggregator will keep
a list of test results reported in this way and write the PNGs
to /OUT of the container (which is the swarming output directory).
Finally, after all the tests are run, the helper script "test_pathkit.sh"
makes a POST request that creates the JSON file that gold expects
(following the schema https://github.com/google/skia-buildbot/blob/master/golden/docs/INGESTION.md)
pathkit_aggregator takes many command line arguments which control
the keys that Gold needs in order to ingest and handle the data.
Of note, this creates a new set (i.e. source_type) of gold images
called "pathkit", which will distinguish it from "gm", "image", etc.
There will be at least 2 sub-sets of "pathkit" images, "canvas" and "svg",
(representing the 2 output types of PathKit). This CL doesn't
quite handle SVG yet, as it needs a way to convert SVG to PNG in the
browser and will be addressed in a follow up CL.
A "standard" gm is sized at 600x600. This was arbitrarily picked.
Note that the functions in testReporter.js return Promises based
on the fetch requests to post the data. This eliminates the race
condition between the /report_gold_data and /dump_json since
running the karma tests won't return until all reports are done.
Other changes of note:
- Adds go to karma-chrome-tests container.
- renames recipe_modules/build/wasm.py -> pathkit.py to be consistent with
the name of test_pathkit.py and make for easier grepping.
- Increases the JS test timeout to 10s (up from 5) to hopefully avoid
the flakes seen in the Debug Test.
Bug: skia:8216
Change-Id: Ic2cad54f3d19cc16601cf2e9a87798db1e6887a2
Reviewed-on: https://skia-review.googlesource.com/147042
Reviewed-by: Stephan Altmueller <stephana@google.com>
2018-08-15 17:45:28 +00:00
|
|
|
INNER_BUILD_SCRIPT = '/SRC/skia/infra/pathkit/docker/build_pathkit.sh'
|
2018-08-03 14:26:00 +00:00
|
|
|
|
|
|
|
BUILD_PRODUCTS_ISOLATE_WHITELIST_WASM = [
|
|
|
|
'pathkit.*'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def compile_fn(api, checkout_root, _ignore):
|
|
|
|
out_dir = api.vars.cache_dir.join('docker', 'wasm')
|
2018-08-03 16:24:06 +00:00
|
|
|
configuration = api.vars.builder_cfg.get('configuration', '')
|
2018-08-03 14:26:00 +00:00
|
|
|
|
|
|
|
# We want to make sure the directories exist and were created by chrome-bot,
|
[PathKit] Adding test infrastructure to support Gold output
To get the gold images out of the browser tests, this adds
testReporter.js and pathkit_aggregator.go. testReporter bundles
up the output as a base64 encoded PNG and sends it over the local
network to pathkit_aggregator. pathkit_aggregator will keep
a list of test results reported in this way and write the PNGs
to /OUT of the container (which is the swarming output directory).
Finally, after all the tests are run, the helper script "test_pathkit.sh"
makes a POST request that creates the JSON file that gold expects
(following the schema https://github.com/google/skia-buildbot/blob/master/golden/docs/INGESTION.md)
pathkit_aggregator takes many command line arguments which control
the keys that Gold needs in order to ingest and handle the data.
Of note, this creates a new set (i.e. source_type) of gold images
called "pathkit", which will distinguish it from "gm", "image", etc.
There will be at least 2 sub-sets of "pathkit" images, "canvas" and "svg",
(representing the 2 output types of PathKit). This CL doesn't
quite handle SVG yet, as it needs a way to convert SVG to PNG in the
browser and will be addressed in a follow up CL.
A "standard" gm is sized at 600x600. This was arbitrarily picked.
Note that the functions in testReporter.js return Promises based
on the fetch requests to post the data. This eliminates the race
condition between the /report_gold_data and /dump_json since
running the karma tests won't return until all reports are done.
Other changes of note:
- Adds go to karma-chrome-tests container.
- renames recipe_modules/build/wasm.py -> pathkit.py to be consistent with
the name of test_pathkit.py and make for easier grepping.
- Increases the JS test timeout to 10s (up from 5) to hopefully avoid
the flakes seen in the Debug Test.
Bug: skia:8216
Change-Id: Ic2cad54f3d19cc16601cf2e9a87798db1e6887a2
Reviewed-on: https://skia-review.googlesource.com/147042
Reviewed-by: Stephan Altmueller <stephana@google.com>
2018-08-15 17:45:28 +00:00
|
|
|
# because if that isn't the case, docker will make them and they will be
|
2018-08-03 14:26:00 +00:00
|
|
|
# owned by root, which causes mysterious failures. To mitigate this risk
|
|
|
|
# further, we don't use the same out_dir as everyone else (thus the _ignore)
|
|
|
|
# param. Instead, we use a "wasm" subdirectory in the "docker" named_cache.
|
|
|
|
api.file.ensure_directory('mkdirs out_dir', out_dir)
|
|
|
|
|
|
|
|
# This uses the emscriptem sdk docker image and says "run the
|
|
|
|
# build_pathkit.sh helper script in there". Additionally, it binds two
|
|
|
|
# folders: the skia checkout to /SRC and the output directory to /OUT
|
|
|
|
# The called helper script will make the compile happen and put the
|
|
|
|
# output in the right spot. The neat thing is that since the Skia checkout
|
|
|
|
# (and, by extension, the build script) is not a part of the image, but
|
|
|
|
# bound in at runtime, we don't have to re-build the image, except when the
|
|
|
|
# toolchain changes.
|
|
|
|
# Of note, the wasm build doesn't re-use any intermediate steps from the
|
|
|
|
# previous builds, so it's essentially a build from scratch every time.
|
2018-08-03 16:24:06 +00:00
|
|
|
cmd = ['docker', 'run', '--rm', '-v', '%s:/SRC' % checkout_root,
|
|
|
|
'-v', '%s:/OUT' % out_dir,
|
|
|
|
DOCKER_IMAGE, INNER_BUILD_SCRIPT]
|
|
|
|
if configuration == 'Debug':
|
[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
|
|
|
cmd += ['debug']
|
2018-08-03 14:26:00 +00:00
|
|
|
api.run(
|
|
|
|
api.step,
|
|
|
|
'Build PathKit with Docker',
|
2018-08-03 16:24:06 +00:00
|
|
|
cmd=cmd)
|
2018-08-03 14:26:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
def copy_extra_build_products(api, _ignore, dst):
|
|
|
|
out_dir = api.vars.cache_dir.join('docker', 'wasm')
|
|
|
|
# We don't use the normal copy_build_products because it uses
|
|
|
|
# shutil.move, which attempts to delete the previous file, which
|
|
|
|
# doesn't work because the docker created outputs are read-only and
|
|
|
|
# owned by root (aka only docker images). It's likely safe to change
|
|
|
|
# the shutil.move in the original script to a non-deleting thing
|
|
|
|
# (like copy or copyfile), but there's some subtle behavior differences
|
|
|
|
# especially with directories, that kjlubick felt it best not to risk it.
|
|
|
|
api.python.inline(
|
|
|
|
name='copy wasm output',
|
|
|
|
program='''import errno
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
|
|
|
|
src = sys.argv[1]
|
|
|
|
dst = sys.argv[2]
|
|
|
|
build_products_whitelist = %s
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.makedirs(dst)
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno != errno.EEXIST:
|
|
|
|
raise
|
|
|
|
|
|
|
|
for pattern in build_products_whitelist:
|
|
|
|
path = os.path.join(src, pattern)
|
|
|
|
for f in glob.glob(path):
|
|
|
|
dst_path = os.path.join(dst, os.path.relpath(f, src))
|
|
|
|
if not os.path.isdir(os.path.dirname(dst_path)):
|
|
|
|
os.makedirs(os.path.dirname(dst_path))
|
|
|
|
print 'Copying build product %%s to %%s' %% (f, dst_path)
|
|
|
|
# Because Docker usually has some strange permissions (like root
|
|
|
|
# ownership), we'd rather not keep those around. copyfile doesn't
|
|
|
|
# keep the metadata around, so that helps us.
|
|
|
|
shutil.copyfile(f, dst_path)
|
|
|
|
''' % str(BUILD_PRODUCTS_ISOLATE_WHITELIST_WASM),
|
|
|
|
args=[out_dir, dst],
|
|
|
|
infra_step=True)
|
|
|
|
|