Skip to content

Commit

Permalink
Merge pull request #2 from fonttools/chrome/m95-py3
Browse files Browse the repository at this point in the history
update libskia to chrome/m95, don't require python 2.7 to build
  • Loading branch information
anthrotype authored Sep 30, 2021
2 parents 3641fe7 + 42a01c2 commit 91dff18
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 26 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Build library
run: ./build.sh
- uses: actions/upload-artifact@v2
Expand All @@ -36,7 +39,7 @@ jobs:
- name: Pull docker image
run: docker pull "${MANYLINUX_DOCKER_IMAGE}"
- name: Build library inside manylinux container
run: docker run --rm -v "${GITHUB_WORKSPACE}":/_w -w /_w -e BUILD_SKIA_OPTIONS="${BUILD_SKIA_OPTIONS}" "${MANYLINUX_DOCKER_IMAGE}" ./build.sh
run: docker run --rm -v "${GITHUB_WORKSPACE}":/_w -w /_w -e BUILD_SKIA_OPTIONS="${BUILD_SKIA_OPTIONS}" -e PYTHON_EXE=/opt/python/cp39-cp39/bin/python -e GN_EXE="/_w/bin/linux64/gn" "${MANYLINUX_DOCKER_IMAGE}" ./build.sh
- uses: actions/upload-artifact@v2
with:
name: libskia-linux
Expand Down
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ environment:
- ARCH: "x86"
- ARCH: "x64"

branches:
only:
- master
- /chrome/

init:
- ECHO %ARCH%

Expand Down
Binary file added bin/linux64/gn
Binary file not shown.
7 changes: 5 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
BUILD_DIR="${SRC_DIR}/build"
DIST_DIR="${SRC_DIR}/dist"

PYTHON2_EXE=${PYTHON2_EXE:-python2}
PYTHON_EXE=${PYTHON_EXE:-python3}
GN_EXE=${GN_EXE:-${SRC_DIR}/skia/bin/gn}

ARCH=${ARCH:-x64}

if [ "$(uname)" == "Darwin" ]; then
Expand All @@ -19,10 +21,11 @@ LIBSKIA_ZIP="${DIST_DIR}/libskia-${PLAT}-${ARCH}.zip"

mkdir -p "${DIST_DIR}"

"${PYTHON2_EXE}" "${SRC_DIR}/build_skia.py" \
"${PYTHON_EXE}" "${SRC_DIR}/build_skia.py" \
--target-cpu ${ARCH} \
${BUILD_SKIA_OPTIONS} \
--archive-file "${LIBSKIA_ZIP}" \
--gn-path "${GN_EXE}" \
"${BUILD_DIR}"

ls "${LIBSKIA_ZIP}"
52 changes: 30 additions & 22 deletions build_skia.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env python2
#!/usr/bin/env python
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
Expand All @@ -13,7 +9,7 @@


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

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

Expand All @@ -25,7 +21,6 @@
"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",
Expand All @@ -36,13 +31,19 @@
"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_libjpeg_turbo_encode=false",
"skia_use_libjpeg_turbo_decode=false",
"skia_use_libpng_encode=false",
"skia_use_libpng_decode=false",
"skia_use_libwebp_encode=false",
"skia_use_libwebp_decode=false",
"skia_use_piex=false",
"skia_use_sfntly=false",
"skia_use_xps=false",
"skia_use_zlib=false",
"skia_enable_spirv_validation=false",
"skia_use_libheif=false",
"skia_use_lua=false",
]
if sys.platform != "win32":
# On Linux, I need this flag otherwise I get undefined symbol upon importing;
Expand All @@ -53,29 +54,35 @@
# 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")

GN_PATH = os.path.join(SKIA_SRC_DIR, "bin", "gn" + EXE_EXT)


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

try:
from urllib2 import urlopen # PY2
except ImportError:
from urllib.request import urlopen # PY3

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:
if not os.path.isdir(venv_bin_dir):
os.makedirs(venv_bin_dir)
virtualenv_pyz = os.path.join(venv_bin_dir, "virtualenv.pyz")
with open(virtualenv_pyz, "wb") as f:
with closing(urlopen(GET_VIRTUALENV_URL)) as response:
f.write(response.read())
returncode = subprocess.Popen(
[sys.executable, virtualenv_pyz, "--no-download", venv_dir]
).wait()
if returncode != 0:
sys.exit("failed to create virtualenv")
assert os.path.exists(python_exe)

Expand Down Expand Up @@ -143,6 +150,7 @@ def _split_archive_base_and_format(parser, fname):
parser.add_argument("-a", "--archive-file", default=None)
parser.add_argument("--no-virtualenv", dest="make_virtualenv", action="store_false")
parser.add_argument("--no-sync-deps", dest="sync_deps", action="store_false")
parser.add_argument("--gn-path", default=GN_PATH, help="default: %(default)s")
args = parser.parse_args()

if args.archive_file is not None:
Expand Down Expand Up @@ -176,7 +184,7 @@ def _split_archive_base_and_format(parser, fname):

subprocess.check_call(
[
os.path.join(SKIA_SRC_DIR, "bin", "gn" + EXE_EXT),
args.gn_path,
"gen",
build_dir,
"--args={}".format(" ".join(build_args)),
Expand Down
2 changes: 1 addition & 1 deletion skia
Submodule skia updated 7723 files

0 comments on commit 91dff18

Please sign in to comment.