Skip to content

Commit

Permalink
Merge pull request #24 from fonttools/rsheeter-master
Browse files Browse the repository at this point in the history
build entire libskia; support SkStrokeRec, SkPath::arcTo and ConvertConics2Quads
  • Loading branch information
anthrotype authored Feb 15, 2020
2 parents fd87ef4 + 27f89fe commit 57860f0
Show file tree
Hide file tree
Showing 12 changed files with 565 additions and 218 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
env:
global:
- DOCKER_IMAGE=anthrotype/manylinux:gcc9.2.0
# directory containing the project source
- REPO_DIR=.
# pip dependencies to _test_ project
- TEST_DEPENDS="tox"
- PLAT=x86_64
- UNICODE_WIDTH=32
# use 'manylinux2014' since Skia requires C++14 support
- MB_ML_VER=2014
- TWINE_USERNAME="anthrotype"
- secure: O0cS/1sCRfjuDVdlMihyqyX6b7so3qZ41OhqDC5O5f4bvk87vno9GGk7U0ZfdoUqjnjXLd7QvEnax4vWJx/tvSEh/wJC07U2pcFDNehkYJIEZCf/MQWzESWd905fUSWP1/BbKgCWvfq7WZOH/3iKpDyQP5DKlrnoq3E2H2gYR3xKd7ASAZHtUYariE4bMEnjg4SDANfm7SHnlD5a/S4/IjgxU0DjCKKbkX7HbGUiCAjjr3j3z9amAhxCmoWyOKvNHjKegG2okEb08ERtcbyYWan0Eu5FqCDMkWwhQmACC1lXz0xHyHW4VZWDyQC1cDrSTirN9rNdamTnfqJPP1eURxGNmNqazrem77HAUKIuh5WjXLFZwKzp+KWMb5TTXYWIsh8gx/IAjGfPoi8nKOWd+bxWLeakDM4kka7pLJDsuRnWSWKzDaDDpMuFm76RzDJjTWCsva93l3EZ8/fkXQ3sGrVC7f8MAjaqBEs+vV6YZMv3WZuSfZkv2AVoPLKkPxWB3RDekKjAw/O8qovqDSGHVgV8XU+6AQVEWhEu8dEtEbXn0UPMQ/bSjQeugl5AkmmBC4iIisuP8rtPB+xdV/iQALEM/RdLJHzC76VQNuXMke69roK5+ZhA6TCCix7I3TIq+XtNQ78SnAUGuooND+WHxVVSQ5GK9DGiCMetRlOQkIA=

Expand Down
26 changes: 13 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: Visual Studio 2017
image: Visual Studio 2019
platform: x64
configuration: Release

Expand All @@ -7,31 +7,31 @@ environment:
TWINE_USERNAME: "anthrotype"
TWINE_PASSWORD:
secure: 9L/DdqoIILlN7qCh0lotvA==
PYTHON2_EXE: "C:\\Python27\\python.exe"
matrix:
- PYTHON: "C:\\Python36"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python37-x64"
- PYTHON: "C:\\Python37"
PYTHON_VERSION: "3.7"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python38-x64"
PYTHON_VERSION: "3.8"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python36"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python37"
- PYTHON: "C:\\Python37-x64"
PYTHON_VERSION: "3.7"
PYTHON_ARCH: "32"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python38"
PYTHON_VERSION: "3.8"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python38-x64"
PYTHON_VERSION: "3.8"
PYTHON_ARCH: "64"

init:
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"
Expand All @@ -58,7 +58,7 @@ install:
- pip install --upgrade tox

# build wheel
- pip wheel --no-deps --wheel-dir dist .
- pip wheel -v --no-deps --wheel-dir dist .
# get the full path to the compiled wheel (ugly but works)
- dir /s /b dist\skia_pathops*.whl > wheel.pth
- set /p WHEEL_PATH=<wheel.pth
Expand Down
155 changes: 155 additions & 0 deletions build_skia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/usr/bin/env python2
import sys

py_ver = sys.version_info[:2]
if py_ver > (2, 7):
sys.exit("python 2.7 is required; this is {}.{}".format(*py_ver))

import argparse
import glob
import os
import subprocess


# script to bootstrap virtualenv without requiring pip
GET_VIRTUALENV_URL = "https://asottile.github.io/get-virtualenv.py"

EXE_EXT = ".exe" if sys.platform == "win32" else ""

ROOT_DIR = os.path.abspath(os.path.dirname(__file__))

SKIA_SRC_DIR = os.path.join(ROOT_DIR, "src", "cpp", "skia")
SKIA_BUILD_ARGS = [
"is_official_build=true",
"is_debug=false",
"skia_enable_pdf=false",
"skia_enable_discrete_gpu=false",
"skia_enable_nvpr=false",
"skia_enable_skottie=false",
"skia_enable_skshaper=false",
"skia_use_dng_sdk=false",
"skia_use_expat=false",
"skia_use_freetype=false",
"skia_use_fontconfig=false",
"skia_use_fonthost_mac=false",
"skia_use_harfbuzz=false",
"skia_use_icu=false",
"skia_use_libgifcodec=false",
"skia_use_libjpeg_turbo=false",
"skia_use_libpng=false",
"skia_use_libwebp=false",
"skia_use_piex=false",
"skia_use_sfntly=false",
"skia_use_xps=false",
"skia_use_zlib=false",
]
if sys.platform != "win32":
# On Linux, I need this flag otherwise I get undefined symbol upon importing;
# on Windows, defining this flag creates other linker issues (SkFontMgr being
# redefined by SkFontMgr_win_dw_factory.obj)...
SKIA_BUILD_ARGS.append("skia_enable_fontmgr_empty=true")
# We don't need GPU or GL support, but disabling this on Windows creates lots
# of undefined symbols upon linking the skia.dll, so I keep them for Windows...
SKIA_BUILD_ARGS.append("skia_enable_gpu=false")
SKIA_BUILD_ARGS.append("skia_use_gl=false")
SKIA_BUILD_ARGS.append("skia_enable_ccpr=false")


def make_virtualenv(venv_dir):
from contextlib import closing
import io
from urllib2 import urlopen

bin_dir = "Scripts" if sys.platform == "win32" else "bin"
venv_bin_dir = os.path.join(venv_dir, bin_dir)
python_exe = os.path.join(venv_bin_dir, "python" + EXE_EXT)

# bootstrap virtualenv if not already present
if not os.path.exists(python_exe):
tmp = io.BytesIO()
with closing(urlopen(GET_VIRTUALENV_URL)) as response:
tmp.write(response.read())

p = subprocess.Popen(
[sys.executable, "-", "--no-download", venv_dir], stdin=subprocess.PIPE
)
p.communicate(tmp.getvalue())
if p.returncode != 0:
sys.exit("failed to create virtualenv")
assert os.path.exists(python_exe)

# pip install ninja
ninja_exe = os.path.join(venv_bin_dir, "ninja" + EXE_EXT)
if not os.path.exists(ninja_exe):
subprocess.check_call(
[
os.path.join(venv_bin_dir, "pip" + EXE_EXT),
"install",
"--only-binary=ninja",
"ninja",
]
)

# place virtualenv bin in front of $PATH, like 'source venv/bin/activate'
env = os.environ.copy()
env["PATH"] = os.pathsep.join([venv_bin_dir, env.get("PATH", "")])

return env


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"build_dir",
default=os.path.join("build", "skia"),
nargs="?",
help="directory where to build libskia (default: %(default)s)",
)
parser.add_argument(
"-s",
"--shared-lib",
action="store_true",
help="build a shared library (default: static)"
)
parser.add_argument(
"--target-cpu",
default=None,
help="The desired CPU architecture for the build (default: host)",
choices=["x86", "x64", "arm", "arm64", "mipsel"]
)
args = parser.parse_args()

build_dir = os.path.abspath(args.build_dir)
venv_dir = os.path.join(build_dir, "venv2")

env = make_virtualenv(venv_dir)

subprocess.check_call(
["python", os.path.join("tools", "git-sync-deps")], env=env, cwd=SKIA_SRC_DIR
)

build_args = list(SKIA_BUILD_ARGS)
if args.shared_lib:
build_args.append("is_component_build=true")
if args.target_cpu:
build_args.append('target_cpu="{}"'.format(args.target_cpu))

subprocess.check_call(
[
os.path.join(SKIA_SRC_DIR, "bin", "gn" + EXE_EXT),
"gen",
build_dir,
"--args={}".format(" ".join(build_args)),
],
env=env,
cwd=SKIA_SRC_DIR,
)

subprocess.check_call(["ninja", "-C", build_dir], env=env)

# when building skia.dll on windows with gn and ninja, the DLL import file
# is written as 'skia.dll.lib'; however, when linking it with the extension
# module, setuptools expects it to be named 'skia.lib'.
if sys.platform == "win32" and args.shared_lib:
for f in glob.glob(os.path.join(build_dir, "skia.dll.*")):
os.rename(f, f.replace(".dll", ""))
6 changes: 1 addition & 5 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
function pre_build {
# Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository.
if [ -z "$IS_OSX" ]; then
export CFLAGS="-static-libstdc++"
export CC=/usr/local/gcc-9.2.0/bin/gcc-9.2.0
export CXX=/usr/local/gcc-9.2.0/bin/g++-9.2.0
fi
:
}

function run_tests {
Expand Down
Loading

0 comments on commit 57860f0

Please sign in to comment.