skia2/BUILD.gn
mtklein 38925aa37c Build tools on NoGPU bots.
I was just lazy disabling this before.  It turns out to not be difficult.

This gets us slightly better testing out of the NoGPU bot, as we now know
not only that Skia compiles, but also that DM and nanobench can link (and
thus that Skia's got enough compiled in it to be a coherent library).

skpbench requires GPU support.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2356283002

Review-Url: https://codereview.chromium.org/2356283002
2016-09-21 10:11:25 -07:00

921 lines
22 KiB
Plaintext

# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("gn/shared_sources.gni")
if (!defined(is_skia_standalone)) {
is_skia_standalone = false
}
declare_args() {
skia_use_expat = true
skia_use_fontconfig = is_linux
skia_use_freetype = is_android || is_fuchsia || is_linux
skia_use_giflib = !is_fuchsia
skia_use_libjpeg_turbo = true
skia_use_libpng = true
skia_use_libwebp = !is_fuchsia
skia_use_mesa = false
skia_use_sfntly = !is_fuchsia
skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
skia_use_zlib = true
skia_enable_android_framework_defines = false
skia_enable_gpu = true
skia_enable_tools = is_skia_standalone
skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
}
# Our tools require static linking (they use non-exported symbols).
skia_enable_tools = skia_enable_tools && !is_component_build
fontmgr_android_enabled = skia_use_expat && skia_use_freetype
skia_public_includes = [
"include/android",
"include/c",
"include/codec",
"include/config",
"include/core",
"include/effects",
"include/gpu",
"include/gpu/gl",
"include/images",
"include/pathops",
"include/ports",
"include/svg",
"include/utils",
"include/utils/mac",
"include/xml",
]
# Skia public API, generally provided by :skia.
config("skia_public") {
include_dirs = skia_public_includes
defines = [ "SKIA_DLL" ]
if (is_linux) {
defines += [ "SK_SAMPLES_FOR_X" ]
}
if (skia_enable_android_framework_defines) {
defines += skia_android_framework_defines
}
if (!skia_enable_gpu) {
defines += [ "SK_SUPPORT_GPU=0" ]
}
}
# Skia internal APIs, used by Skia itself and a few test tools.
config("skia_private") {
visibility = [ ":*" ]
include_dirs = [
"include/private",
"src/c",
"src/codec",
"src/config",
"src/core",
"src/effects",
"src/effects/gradients",
"src/fonts",
"src/gpu",
"src/image",
"src/images",
"src/lazy",
"src/opts",
"src/pathops",
"src/pdf",
"src/ports",
"src/sfnt",
"src/sksl",
"src/utils",
"src/utils/win",
"third_party/etc1",
"third_party/ktx",
]
defines = [ "SK_GAMMA_APPLY_TO_A8" ]
if (is_android) {
defines += [
"SK_GAMMA_EXPONENT=1.4",
"SK_GAMMA_CONTRAST=0.0",
]
}
if (is_official_build || is_android) {
# TODO(bsalomon): it'd be nice to make Android normal.
defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
}
}
# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
config("skia_library") {
visibility = [ ":*" ]
defines = [ "SKIA_IMPLEMENTATION=1" ]
}
skia_library_configs = [
":skia_public",
":skia_private",
":skia_library",
]
# Use for CPU-specific Skia code that needs particular compiler flags.
template("opts") {
if (invoker.enabled) {
source_set(target_name) {
forward_variables_from(invoker, "*")
configs += skia_library_configs
}
} else {
# If not enabled, a phony empty target that swallows all otherwise unused variables.
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"sources",
"cflags",
])
}
}
}
is_x86 = current_cpu == "x64" || current_cpu == "x86"
opts("none") {
enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
sources = skia_opts.none_sources
cflags = []
}
opts("armv7") {
enabled = current_cpu == "arm"
sources = skia_opts.armv7_sources + skia_opts.neon_sources
cflags = []
}
opts("arm64") {
enabled = current_cpu == "arm64"
sources = skia_opts.arm64_sources
cflags = []
}
opts("crc32") {
enabled = current_cpu == "arm64"
sources = skia_opts.crc32_sources
cflags = [ "-march=armv8-a+crc" ]
}
opts("sse2") {
enabled = is_x86
sources = skia_opts.sse2_sources
cflags = [ "-msse2" ]
}
opts("ssse3") {
enabled = is_x86
sources = skia_opts.ssse3_sources
cflags = [ "-mssse3" ]
}
opts("sse41") {
enabled = is_x86
sources = skia_opts.sse41_sources
cflags = [ "-msse4.1" ]
}
opts("sse42") {
enabled = is_x86
sources = skia_opts.sse42_sources
cflags = [ "-msse4.2" ]
}
opts("avx") {
enabled = is_x86
sources = skia_opts.avx_sources
cflags = [ "-mavx" ]
}
opts("dsp") {
enabled = current_cpu == "mipsel"
sources = skia_opts.mips_dsp_sources
cflags = []
}
# Any feature of Skia that requires third-party code should be optional and use this template.
template("optional") {
if (invoker.enabled) {
config(target_name + "_public") {
if (defined(invoker.public_defines)) {
defines = invoker.public_defines
}
}
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"public_defines",
"sources_when_disabled",
])
all_dependent_configs = [ ":" + target_name + "_public" ]
configs += skia_library_configs
}
} else {
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"public_defines",
"deps",
"libs",
"sources",
"sources_when_disabled",
])
if (defined(invoker.sources_when_disabled)) {
sources = invoker.sources_when_disabled
}
configs += skia_library_configs
}
}
}
optional("fontmgr_android") {
enabled = fontmgr_android_enabled
deps = [
"//third_party/expat",
"//third_party/freetype2",
]
sources = [
"src/ports/SkFontMgr_android.cpp",
"src/ports/SkFontMgr_android_factory.cpp",
"src/ports/SkFontMgr_android_parser.cpp",
]
}
optional("fontmgr_custom") {
enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
deps = [
"//third_party/freetype2",
]
sources = [
"src/ports/SkFontMgr_custom.cpp",
"src/ports/SkFontMgr_custom_directory_factory.cpp",
]
}
optional("fontmgr_fontconfig") {
enabled = skia_use_freetype && skia_use_fontconfig
deps = [
"//third_party:fontconfig",
"//third_party/freetype2",
]
sources = [
"src/ports/SkFontConfigInterface.cpp",
"src/ports/SkFontConfigInterface_direct.cpp",
"src/ports/SkFontConfigInterface_direct_factory.cpp",
"src/ports/SkFontMgr_FontConfigInterface.cpp",
"src/ports/SkFontMgr_fontconfig.cpp",
"src/ports/SkFontMgr_fontconfig_factory.cpp",
]
}
optional("fontmgr_fuchsia") {
enabled = is_fuchsia && skia_use_freetype
deps = [
"//third_party/freetype2",
]
sources = [
"src/ports/SkFontMgr_custom.cpp",
"src/ports/SkFontMgr_custom_empty_factory.cpp",
]
}
optional("gif") {
enabled = skia_use_giflib
public_defines = [ "SK_HAS_GIF_LIBRARY" ]
deps = [
"//third_party/giflib",
]
sources = [
"src/codec/SkGifCodec.cpp",
]
}
optional("gpu") {
enabled = skia_enable_gpu
public_defines = []
sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
# These paths need to be absolute to match the ones produced by shared_sources.gni.
sources -= get_path_info([
"src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
"src/gpu/gl/GrGLDefaultInterface_none.cpp",
],
"abspath")
if (is_android) {
sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
} else if (is_linux) {
sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
} else if (is_mac) {
sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
} else {
sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
}
libs = []
if (skia_use_vulkan) {
public_defines += [ "SK_VULKAN" ]
sources += skia_vk_sources
libs += [ "vulkan" ]
if (skia_enable_vulkan_debug_layers) {
public_defines += [ "SK_ENABLE_VK_LAYERS" ]
}
}
}
optional("jpeg") {
enabled = skia_use_libjpeg_turbo
public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
deps = [
"//third_party/libjpeg-turbo:libjpeg",
]
sources = [
"src/codec/SkJpegCodec.cpp",
"src/codec/SkJpegDecoderMgr.cpp",
"src/codec/SkJpegUtility.cpp",
"src/images/SkJPEGImageEncoder.cpp",
"src/images/SkJPEGWriteUtility.cpp",
]
}
optional("pdf") {
enabled = skia_use_zlib
deps = [
"//third_party/zlib",
]
sources = skia_pdf_sources
sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
if (skia_use_sfntly) {
deps += [ "//third_party/sfntly" ]
public_defines = [ "SK_PDF_USE_SFNTLY" ]
}
}
optional("png") {
enabled = skia_use_libpng
public_defines = [ "SK_HAS_PNG_LIBRARY" ]
deps = [
"//third_party/libpng",
]
sources = [
"src/codec/SkIcoCodec.cpp",
"src/codec/SkPngCodec.cpp",
"src/images/SkPNGImageEncoder.cpp",
]
}
optional("typeface_freetype") {
enabled = skia_use_freetype
deps = [
"//third_party/freetype2",
]
sources = [
"src/ports/SkFontHost_FreeType.cpp",
"src/ports/SkFontHost_FreeType_common.cpp",
]
}
optional("webp") {
enabled = skia_use_libwebp
public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
deps = [
"//third_party/libwebp",
]
sources = [
"src/codec/SkWebpAdapterCodec.cpp",
"src/codec/SkWebpCodec.cpp",
"src/images/SkWEBPImageEncoder.cpp",
]
}
optional("xml") {
enabled = skia_use_expat
deps = [
"//third_party/expat",
]
sources = [
"src/xml/SkDOM.cpp",
"src/xml/SkXMLParser.cpp",
"src/xml/SkXMLWriter.cpp",
]
}
component("skia") {
public_configs = [ ":skia_public" ]
configs += skia_library_configs
deps = [
":arm64",
":armv7",
":avx",
":crc32",
":dsp",
":fontmgr_android",
":fontmgr_custom",
":fontmgr_fontconfig",
":fontmgr_fuchsia",
":gif",
":gpu",
":jpeg",
":none",
":pdf",
":png",
":sse2",
":sse41",
":sse42",
":ssse3",
":typeface_freetype",
":webp",
":xml",
]
sources = []
sources += skia_core_sources
sources += skia_effects_sources
sources += skia_sksl_sources
sources += skia_utils_sources
sources += [
"src/android/SkBitmapRegionCodec.cpp",
"src/android/SkBitmapRegionDecoder.cpp",
"src/codec/SkAndroidCodec.cpp",
"src/codec/SkBmpCodec.cpp",
"src/codec/SkBmpMaskCodec.cpp",
"src/codec/SkBmpRLECodec.cpp",
"src/codec/SkBmpStandardCodec.cpp",
"src/codec/SkCodec.cpp",
"src/codec/SkCodecImageGenerator.cpp",
"src/codec/SkMaskSwizzler.cpp",
"src/codec/SkMasks.cpp",
"src/codec/SkSampledCodec.cpp",
"src/codec/SkSampler.cpp",
"src/codec/SkSwizzler.cpp",
"src/codec/SkWbmpCodec.cpp",
"src/images/SkImageEncoder.cpp",
"src/images/SkImageEncoder_Factory.cpp",
"src/images/SkKTXImageEncoder.cpp",
"src/ports/SkDiscardableMemory_none.cpp",
"src/ports/SkGlobalInitialization_default.cpp",
"src/ports/SkImageGenerator_skia.cpp",
"src/ports/SkMemory_malloc.cpp",
"src/ports/SkOSFile_stdio.cpp",
"src/sfnt/SkOTTable_name.cpp",
"src/sfnt/SkOTUtils.cpp",
"src/svg/SkSVGCanvas.cpp",
"src/svg/SkSVGDevice.cpp",
"src/utils/mac/SkStream_mac.cpp",
"third_party/etc1/etc1.cpp",
"third_party/ktx/ktx.cpp",
]
libs = []
if (is_win) {
sources += [
"src/ports/SkDebug_win.cpp",
"src/ports/SkFontHost_win.cpp",
"src/ports/SkFontMgr_win_dw.cpp",
"src/ports/SkFontMgr_win_dw_factory.cpp",
"src/ports/SkImageEncoder_WIC.cpp",
"src/ports/SkImageGeneratorWIC.cpp",
"src/ports/SkOSFile_win.cpp",
"src/ports/SkScalerContext_win_dw.cpp",
"src/ports/SkTLS_win.cpp",
"src/ports/SkTypeface_win_dw.cpp",
"src/xps/SkDocument_XPS.cpp",
]
sources -=
[ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
} else {
sources += [
"src/ports/SkOSFile_posix.cpp",
"src/ports/SkTLS_pthread.cpp",
"src/xps/SkDocument_XPS_None.cpp",
]
}
if (is_android) {
deps += [
"//third_party/cpu-features",
"//third_party/expat",
]
sources += [ "src/ports/SkDebug_android.cpp" ]
libs += [
"EGL",
"GLESv2",
"log",
]
}
if (is_linux) {
libs += [
"GL",
"GLU",
"X11",
]
sources += [ "src/ports/SkDebug_stdio.cpp" ]
}
if (is_mac) {
sources += [
"src/ports/SkDebug_stdio.cpp",
"src/ports/SkFontHost_mac.cpp",
"src/ports/SkImageEncoder_CG.cpp",
"src/ports/SkImageGeneratorCG.cpp",
]
libs += [
"ApplicationServices.framework",
"OpenGL.framework",
]
}
if (is_fuchsia) {
sources += [ "src/ports/SkDebug_stdio.cpp" ]
}
}
skia_h_headers = exec_script("gyp/find.py",
[ "*.h" ] + rebase_path(skia_public_includes),
"list lines",
[]) -
[
rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
rebase_path("include/gpu/vk/GrVkBackendContext.h"),
rebase_path("include/gpu/vk/GrVkDefines.h"),
rebase_path("include/gpu/vk/GrVkInterface.h"),
rebase_path("include/gpu/vk/GrVkTypes.h"),
rebase_path("include/ports/SkFontMgr_fontconfig.h"),
]
action("skia.h") {
script = "gn/echo_headers.py"
args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
rebase_path(skia_h_headers, target_gen_dir)
outputs = [
"$target_gen_dir/skia.h",
]
}
if (skia_enable_gpu && target_cpu == "x64") {
# Our bots only have 64-bit libOSMesa installed.
# TODO: worth fixing?
executable("fiddle") {
include_dirs = [ "$target_gen_dir" ]
libs = []
if (is_linux) {
libs += [ "OSMesa" ]
}
sources = [
"src/images/SkForceLinking.cpp",
"tools/fiddle/draw.cpp",
"tools/fiddle/fiddle_main.cpp",
]
deps = [
":skia",
":skia.h",
]
}
}
# Targets guarded by skia_enable_tools may use //third_party freely.
if (skia_enable_tools) {
template("test_lib") {
config(target_name + "_config") {
include_dirs = invoker.public_include_dirs
if (defined(invoker.public_defines)) {
defines = invoker.public_defines
}
}
source_set(target_name) {
forward_variables_from(invoker, "*", [ "public_include_dirs" ])
public_configs = [
":" + target_name + "_config",
":skia_private",
]
if (!defined(deps)) {
deps = []
}
deps += [ ":skia" ]
testonly = true
}
}
test_lib("gpu_tool_utils") {
public_include_dirs = []
if (skia_enable_gpu) {
public_defines = []
public_include_dirs += [ "tools/gpu" ]
sources = [
"tools/gpu/GrContextFactory.cpp",
"tools/gpu/GrTest.cpp",
"tools/gpu/TestContext.cpp",
"tools/gpu/gl/GLTestContext.cpp",
"tools/gpu/gl/debug/DebugGLTestContext.cpp",
"tools/gpu/gl/debug/GrBufferObj.cpp",
"tools/gpu/gl/debug/GrFrameBufferObj.cpp",
"tools/gpu/gl/debug/GrProgramObj.cpp",
"tools/gpu/gl/debug/GrShaderObj.cpp",
"tools/gpu/gl/debug/GrTextureObj.cpp",
"tools/gpu/gl/debug/GrTextureUnitObj.cpp",
"tools/gpu/gl/null/NullGLTestContext.cpp",
]
libs = []
if (is_android) {
sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
} else if (is_linux) {
sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
} else if (is_mac) {
sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
}
if (skia_use_vulkan) {
sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
}
if (skia_use_mesa) {
public_defines += [ "SK_MESA" ]
sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
libs += [ "OSMesa" ]
}
}
}
test_lib("flags") {
public_include_dirs = [ "tools/flags" ]
sources = [
"tools/flags/SkCommandLineFlags.cpp",
]
}
test_lib("common_flags") {
public_include_dirs = [ "tools/flags" ]
sources = [
"tools/flags/SkCommonFlags.cpp",
"tools/flags/SkCommonFlagsConfig.cpp",
]
deps = [
":flags",
":gpu_tool_utils",
]
}
test_lib("tool_utils") {
public_include_dirs = [
"tools",
"tools/debugger",
"tools/timer",
]
sources = [
"src/images/SkForceLinking.cpp",
"src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
"tools/AndroidSkDebugToStdOut.cpp",
"tools/CrashHandler.cpp",
"tools/LsanSuppressions.cpp",
"tools/ProcStats.cpp",
"tools/Resources.cpp",
"tools/ThermalManager.cpp",
"tools/UrlDataManager.cpp",
"tools/debugger/SkDebugCanvas.cpp",
"tools/debugger/SkDrawCommand.cpp",
"tools/debugger/SkJsonWriteBuffer.cpp",
"tools/debugger/SkObjectParser.cpp",
"tools/debugger/SkOverdrawMode.cpp",
"tools/picture_utils.cpp",
"tools/random_parse_path.cpp",
"tools/sk_tool_utils.cpp",
"tools/sk_tool_utils_font.cpp",
"tools/timer/Timer.cpp",
]
deps = [
":common_flags",
":flags",
"//third_party/libpng",
]
public_deps = [
"//third_party/jsoncpp",
]
}
gm_sources = exec_script("gyp/find.py",
[
"*.c*",
rebase_path("gm"),
],
"list lines",
[])
test_lib("gm") {
public_include_dirs = [ "gm" ]
sources = gm_sources
deps = [
":gpu_tool_utils",
":skia",
":tool_utils",
]
}
tests_sources = exec_script("gyp/find.py",
[
"*.c*",
rebase_path("tests"),
],
"list lines",
[])
test_lib("tests") {
public_include_dirs = [ "tests" ]
sources = tests_sources - [
rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
rebase_path("tests/skia_test.cpp"), # alternate main
]
if (!fontmgr_android_enabled) {
sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
}
deps = [
":experimental_svg_model",
":flags",
":gpu_tool_utils",
":skia",
":tool_utils",
"//third_party/libpng",
"//third_party/zlib",
]
}
bench_sources = exec_script("gyp/find.py",
[
"*.c*",
rebase_path("bench"),
],
"list lines",
[])
test_lib("bench") {
public_include_dirs = [ "bench" ]
sources = bench_sources
sources -= [
rebase_path("bench/nanobench.cpp"),
rebase_path("bench/nanobenchAndroid.cpp"),
]
deps = [
":flags",
":gm",
":gpu_tool_utils",
":skia",
":tool_utils",
]
}
test_lib("experimental_svg_model") {
public_include_dirs = [ "experimental/svg/model" ]
sources = [
"experimental/svg/model/SkSVGAttribute.cpp",
"experimental/svg/model/SkSVGAttributeParser.cpp",
"experimental/svg/model/SkSVGCircle.cpp",
"experimental/svg/model/SkSVGContainer.cpp",
"experimental/svg/model/SkSVGDOM.cpp",
"experimental/svg/model/SkSVGEllipse.cpp",
"experimental/svg/model/SkSVGLine.cpp",
"experimental/svg/model/SkSVGLinearGradient.cpp",
"experimental/svg/model/SkSVGNode.cpp",
"experimental/svg/model/SkSVGPath.cpp",
"experimental/svg/model/SkSVGPoly.cpp",
"experimental/svg/model/SkSVGRect.cpp",
"experimental/svg/model/SkSVGRenderContext.cpp",
"experimental/svg/model/SkSVGSVG.cpp",
"experimental/svg/model/SkSVGShape.cpp",
"experimental/svg/model/SkSVGStop.cpp",
"experimental/svg/model/SkSVGTransformableNode.cpp",
"experimental/svg/model/SkSVGValue.cpp",
]
deps = [
":skia",
]
}
executable("dm") {
sources = [
"dm/DM.cpp",
"dm/DMJsonWriter.cpp",
"dm/DMSrcSink.cpp",
]
include_dirs = [ "tests" ]
deps = [
":common_flags",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":skia",
":tests",
":tool_utils",
"//third_party/jsoncpp",
"//third_party/libpng",
]
testonly = true
}
executable("monobench") {
sources = [
"tools/monobench.cpp",
]
deps = [
":bench",
":skia",
]
testonly = true
}
executable("nanobench") {
sources = [
"bench/nanobench.cpp",
]
deps = [
":bench",
":common_flags",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":skia",
":tool_utils",
"//third_party/jsoncpp",
]
testonly = true
}
if (skia_enable_gpu) {
executable("skpbench") {
sources = [
"tools/skpbench/skpbench.cpp",
]
deps = [
":flags",
":gpu_tool_utils",
":skia",
":tool_utils",
]
testonly = true
}
}
if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
executable("sktexttopdf-hb") {
sources = [
"tools/SkShaper_harfbuzz.cpp",
"tools/using_skia_and_harfbuzz.cpp",
]
deps = [
":skia",
"//third_party/harfbuzz",
]
testonly = true
}
}
executable("sktexttopdf") {
sources = [
"tools/SkShaper_primitive.cpp",
"tools/using_skia_and_harfbuzz.cpp",
]
deps = [
":skia",
]
testonly = true
}
executable("get_images_from_skps") {
sources = [
"tools/get_images_from_skps.cpp",
]
deps = [
":flags",
":skia",
"//third_party/jsoncpp",
]
testonly = true
}
}