GYP Changes and Scripts for Compiling Skia for ChromeOS

For now, this requires having a complete ChromeOS checkout.

R=djsollen@google.com

Review URL: https://codereview.chromium.org/16099011

git-svn-id: http://skia.googlecode.com/svn/trunk@9505 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
borenet@google.com 2013-06-11 15:52:19 +00:00
parent 82f317815e
commit 05d550ed36
22 changed files with 274 additions and 34 deletions

3
DEPS
View File

@ -27,6 +27,9 @@ deps_os = {
"platform_tools/android/third_party/externals/png" : "https://android.googlesource.com/platform/external/libpng.git@android-4.2.2_r1.2",
"platform_tools/android/third_party/externals/jpeg" : "https://android.googlesource.com/platform/external/jpeg.git@android-4.2.2_r1.2",
},
"chromeos": {
"platform_tools/chromeos/third_party/externals/gif" : "https://android.googlesource.com/platform/external/giflib.git@android-4.2.2_r1.2",
},
}
#hooks = [

View File

@ -152,7 +152,7 @@
'lua.gyp:lua',
],
'conditions' : [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
'sources!': [
'../samplecode/SampleDecode.cpp',
],

View File

@ -57,13 +57,13 @@
'../bench/BenchSysTimer_mach.cpp',
],
}],
[ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
[ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "android", "chromeos"]', {
'sources!': [
'../bench/BenchSysTimer_posix.h',
'../bench/BenchSysTimer_posix.cpp',
],
}],
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
'link_settings': {
'libraries': [
'-lrt',

9
gyp/chromeos_deps.gyp Normal file
View File

@ -0,0 +1,9 @@
# This GYP file stores the dependencies necessary to build Skia on the Chrome OS
# platform. The OS doesn't provide many stable libraries as part of the
# distribution so we have to build a few of them ourselves.
{
'includes': [
'../platform_tools/chromeos/gyp/dependencies.gypi',
],
}

View File

@ -37,6 +37,12 @@
[ 'skia_os == "nacl" and OS != "linux"', {
'error': '<!(Skia NaCl build only currently supported on Linux.)',
}],
[ 'skia_os == "chromeos" and OS != "linux"', {
'error': '<!(Skia ChromeOS build is only supported on Linux.)',
}],
[ 'skia_os == "chromeos" and not skia_cros_target', {
'error': '<!(skia_cros_target must be defined for ChromeOS)',
}],
],
},
# Validate the 'skia_os' setting against 'skia_shared_lib', because shared

View File

@ -117,7 +117,7 @@
},
],
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl"]',
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos"]',
{
'defines': [
'SK_SAMPLES_FOR_X',
@ -145,22 +145,6 @@
'-Werror',
],
}],
[ 'skia_arch_width == 64', {
'cflags': [
'-m64',
],
'ldflags': [
'-m64',
],
}],
[ 'skia_arch_width == 32', {
'cflags': [
'-m32',
],
'ldflags': [
'-m32',
],
}],
[ 'skia_os == "nacl"', {
'defines': [
'SK_BUILD_FOR_NACL',
@ -178,6 +162,32 @@
'/usr/include/freetype2',
],
}],
[ 'skia_os == "chromeos"', {
'ldflags': [
'--sysroot=/build/<(skia_cros_target)',
'-lstdc++',
'-lm',
],
}, {
'conditions': [
[ 'skia_arch_width == 64', {
'cflags': [
'-m64',
],
'ldflags': [
'-m64',
],
}],
[ 'skia_arch_width == 32', {
'cflags': [
'-m32',
],
'ldflags': [
'-m32',
],
}],
],
}],
],
},
],

View File

@ -127,6 +127,8 @@
'ios_sdk_version%': '6.0',
'skia_win_debuggers_path%': '<(skia_win_debuggers_path)',
'skia_cros_target%': '',
# These are referenced by our .gypi files that list files (e.g. core.gypi)
#
'skia_src_path%': '../src',

View File

@ -29,7 +29,7 @@
],
'msvs_disabled_warnings': [4244, 4267,4345, 4390, 4554, 4800],
'conditions': [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
'link_settings': {
'libraries': [
'-lpthread',

View File

@ -1,7 +1,7 @@
{
'variables': {
'conditions': [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
# Use the systemwide Qt libs by default
'variables': {
'qt_sdk%': '/usr',

View File

@ -9,7 +9,7 @@
'sources/': [ ['exclude', '_mac.(h|cpp|m|mm)$'],
],
}],
['skia_os != "linux"', {
['skia_os != "linux" and skia_os != "chromeos"', {
'sources/': [ ['exclude', '_unix.(h|cpp)$'],
],
}],
@ -35,7 +35,7 @@
'GR_MAC_BUILD=1',
],
}],
[ 'skia_os == "linux"', {
[ 'skia_os == "linux" or skia_os == "chromeos"', {
'defines': [
'GR_LINUX_BUILD=1',
],
@ -232,7 +232,7 @@
'GR_ANDROID_PATH_RENDERING=1',
],
}],
[ 'skia_os == "linux"', {
[ 'skia_os == "linux" or skia_os == "chromeos"', {
'sources!': [
'../src/gpu/gl/GrGLDefaultInterface_none.cpp',
'../src/gpu/gl/GrGLCreateNativeInterface_none.cpp',

View File

@ -149,6 +149,16 @@
'../src/images/SkImageRef_ashmem.cpp',
],
}],
[ 'skia_os == "chromeos"', {
'dependencies': [
'chromeos_deps.gyp:gif',
],
'link_settings': {
'libraries': [
'-lpng',
],
},
}],
[ 'skia_os == "ios"', {
'include_dirs': [
'../include/utils/mac',

View File

@ -32,7 +32,7 @@
'conditions': [
[ 'skia_arch_type == "x86" and skia_os != "ios"', {
'conditions': [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos"]', {
'cflags': [
'-msse2',
],
@ -113,7 +113,7 @@
'../src/core',
],
'conditions': [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos"]', {
'cflags': [
'-mssse3',
],

View File

@ -125,7 +125,7 @@
'xml.gyp:xml',
],
'conditions': [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
}],
[ 'skia_os == "win"', {
}],

View File

@ -39,7 +39,7 @@
'../src/ports/SkXMLParser_empty.cpp',
],
'conditions': [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
'defines': [
#The font host requires at least FreeType 2.3.0 at runtime.
'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020300',\

View File

@ -74,7 +74,7 @@
'xml.gyp:xml',
],
'conditions' : [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
}],
[ 'skia_os == "win"', {
}],

View File

@ -146,11 +146,11 @@
'../src/utils/SkThreadUtils_pthread_mach.cpp',
],
}],
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
'sources!': [
'../src/utils/SkThreadUtils_pthread_other.cpp',
],
},{ #else if 'skia_os not in ["linux", "freebsd", "openbsd", "solaris"]'
},{ #else if 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]'
'include_dirs!': [
'../include/utils/unix',
],

View File

@ -98,7 +98,7 @@
'../src/views/mac/skia_mac.mm',
],
}],
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
'link_settings': {
'libraries': [
'-lGL',

View File

@ -32,7 +32,7 @@
'../src/xml/SkXMLPullParser.cpp', #if 0 around class decl in header
],
'conditions': [
[ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris", "android", "ios", "nacl"]', {
[ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris", "android", "ios", "nacl", "chromeos"]', {
'sources!': [
# no jsapi.h by default on system
'../include/xml/SkJS.h',

View File

@ -0,0 +1,39 @@
#!/bin/bash
# This script builds Skia inside of a ChromeOS chroot. It is intended to be run
# either while inside the chroot or indirectly by running chromeos_make which
# enters the chroot and runs this script.
makeVars=""
deviceID=""
while (( "$#" )); do
if [[ $(echo "$1" | grep "^-d$") != "" ]];
then
deviceID="$2"
shift
else
makeVars="$makeVars $1"
fi
shift
done
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/chromeos_setup.sh
setup_device $deviceID
returnVal=$?
if [ $returnVal != 0 ]
then
exit 1;
fi
make ${makeVars}
returnVal=$?
if [ $returnVal != 0 ]
then
exit 1;
fi

View File

@ -0,0 +1,39 @@
#!/bin/bash
# This script builds Skia for ChromeOS by mounting the Skia checkout inside a
# chroot contained within an existing ChromeOS checkout, entering the chroot,
# and running the build_skia_in_chroot script.
MAKE_FLAGS=$@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ $(uname) != "Linux" ]; then
echo "ERROR: Can only build for ChromeOS on Linux."
exit 1
fi
if [ -z "${CHROMEOS_ROOT}" ]; then
echo "ERROR: Please set CHROMEOS_ROOT to the root of your ChromeOS checkout."
exit 1
fi
CHROMEOS_CHROOT="${CHROMEOS_ROOT}/chroot"
# Where the Skia code will pretend to live inside the chroot.
SKIA_CHROOT_PARENT="/usr/local"
SKIA_CHROOT_DIR="${SKIA_CHROOT_PARENT}/skia"
echo "Mounting Skia source at ${SKIA_CHROOT_DIR} in chroot."
sudo mkdir -p ${CHROMEOS_CHROOT}${SKIA_CHROOT_DIR}
sudo mount $(pwd) ${CHROMEOS_CHROOT}${SKIA_CHROOT_DIR} -o bind
echo "Compiling in chroot: ${CHROMEOS_CHROOT}"
sudo ${CHROMEOS_ROOT}/chromite/bin/cros_sdk -- /bin/sh -c "cd ${SKIA_CHROOT_DIR}; platform_tools/chromeos/bin/build_skia_in_chroot $MAKE_FLAGS"
returnVal=$?
sudo umount ${CHROMEOS_CHROOT}${SKIA_CHROOT_DIR}
if [ "${returnVal}" != "0" ]
then
exit 1;
fi

View File

@ -0,0 +1,87 @@
# Set up the environment to build Skia for ChromeOS.
function exportVar {
NAME=$1
VALUE=$2
echo export $NAME=\"$VALUE\"
export $NAME="$VALUE"
}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Helper function to configure the GYP defines to the appropriate values
# based on the target device.
setup_device() {
DEFINES="OS=linux"
DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')"
DEFINES="${DEFINES} skia_os=chromeos"
# TODO(borenet): We have to define skia_warnings_as_errors=0 for the arm
# build, which throws lots of "mangling of va_list has changed" warnings.
DEFINES="${DEFINES} skia_warnings_as_errors=0"
# Setup the build variation depending on the target device
TARGET_DEVICE="$1"
if [ -z "$TARGET_DEVICE" ]; then
echo "INFO: no target device type was specified so using the default 'x86-generic'"
TARGET_DEVICE="x86-generic"
fi
# Toolchain prefixes.
X86_TOOLCHAIN_PREFIX="i686-pc-linux-gnu"
AMD64_TOOLCHAIN_PREFIX="x86_64-cros-linux-gnu"
ARMV7_TOOLCHAIN_PREFIX="armv7a-cros-linux-gnueabi"
case $TARGET_DEVICE in
x86-generic)
DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
CHROMEOS_TOOLCHAIN_TYPE=${X86_TOOLCHAIN_PREFIX}
BOARD_TYPE="x86-generic"
;;
amd64-generic)
DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=64"
CHROMEOS_TOOLCHAIN_TYPE=${AMD64_TOOLCHAIN_PREFIX}
BOARD_TYPE="amd64-generic"
;;
arm-generic)
DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 armv7=1 arm_thumb=0 skia_arch_width=32"
CHROMEOS_TOOLCHAIN_TYPE=${ARMV7_TOOLCHAIN_PREFIX}
BOARD_TYPE="arm-generic"
;;
*)
echo -n "ERROR: unknown device specified ($TARGET_DEVICE), valid values: "
echo "x86-generic amd64-generic arm-generic"
return 1;
;;
esac
DEFINES="${DEFINES} skia_cros_target=${BOARD_TYPE}"
CHROMEOS_TOOLCHAIN_PREFIX="/usr/bin/${CHROMEOS_TOOLCHAIN_TYPE}"
exportVar AR "$CHROMEOS_TOOLCHAIN_PREFIX-ar"
if [[ -z "$CHROMEOS_MAKE_CCACHE" ]]; then
exportVar CC "$CHROMEOS_TOOLCHAIN_PREFIX-gcc"
exportVar CXX "$CHROMEOS_TOOLCHAIN_PREFIX-g++"
exportVar LINK "$CHROMEOS_TOOLCHAIN_PREFIX-gcc"
else
exportVar CC "$CHROMEOS_MAKE_CCACHE $CHROMEOS_TOOLCHAIN_PREFIX-gcc"
exportVar CXX "$CHROMEOS_MAKE_CCACHE $CHROMEOS_TOOLCHAIN_PREFIX-g++"
exportVar LINK "$CHROMEOS_MAKE_CCACHE $CHROMEOS_TOOLCHAIN_PREFIX-gcc"
fi
exportVar RANLIB "$CHROMEOS_TOOLCHAIN_PREFIX-ranlib"
exportVar OBJCOPY "$CHROMEOS_TOOLCHAIN_PREFIX-objcopy"
exportVar STRIP "$CHROMEOS_TOOLCHAIN_PREFIX-strip"
echo "The build is targeting the device: $TARGET_DEVICE"
BUILD_PREFIX="/build/${BOARD_TYPE}"
exportVar C_INCLUDE_PATH "${BUILD_PREFIX}/usr/include"
exportVar CPLUS_INCLUDE_PATH "${BUILD_PREFIX}/usr/include"
exportVar LIBRARY_PATH "${BUILD_PREFIX}/usr/lib"
exportVar LD_LIBRARY_PATH "${BUILD_PREFIX}/usr/lib"
exportVar GYP_DEFINES "$DEFINES"
exportVar SKIA_OUT "out/config/chromeos-${TARGET_DEVICE}"
}

View File

@ -0,0 +1,35 @@
# This GYP file stores the dependencies necessary to build Skia on the Chrome OS
# platform. The OS doesn't provide many stable libraries as part of the
# distribution so we have to build a few of them ourselves.
{
'variables': {
'skia_warnings_as_errors': 0,
},
'targets': [
{
'target_name': 'gif',
'type': 'static_library',
'sources': [
'../third_party/externals/gif/dgif_lib.c',
'../third_party/externals/gif/gifalloc.c',
'../third_party/externals/gif/gif_err.c',
],
'include_dirs': [
'../third_party/externals/gif',
],
'cflags': [
'-Wno-format',
'-DHAVE_CONFIG_H',
],
'cflags!': [
'-Wall',
],
'direct_dependent_settings': {
'include_dirs': [
'../third_party/externals/gif',
],
}
},
]
}