mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 1 | # Copyright 2016 Google Inc. |
| 2 | # |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | declare_args() { |
| 7 | } |
| 8 | |
| 9 | # Skia public API, generally provided by :skia. |
| 10 | config("skia_public") { |
| 11 | include_dirs = [ |
| 12 | "include/c", |
| 13 | "include/config", |
| 14 | "include/core", |
| 15 | "include/effects", |
| 16 | "include/gpu", |
| 17 | "include/images", |
| 18 | "include/lazy", |
| 19 | "include/pathops", |
| 20 | "include/ports", |
| 21 | "include/utils", |
| 22 | "include/utils/mac", |
| 23 | ] |
| 24 | defines = [ "SKIA_DLL" ] |
| 25 | } |
| 26 | |
| 27 | # Skia internal APIs, used by Skia itself and a few test tools. |
| 28 | config("skia_private") { |
| 29 | visibility = [ ":*" ] |
| 30 | |
| 31 | include_dirs = [ |
| 32 | "include/private", |
| 33 | "src/c", |
| 34 | "src/config", |
| 35 | "src/core", |
| 36 | "src/effects", |
| 37 | "src/gpu", |
| 38 | "src/image", |
| 39 | "src/images", |
| 40 | "src/lazy", |
| 41 | "src/opts", |
| 42 | "src/pathops", |
| 43 | "src/ports", |
| 44 | "src/sfnt", |
| 45 | "src/utils", |
| 46 | "third_party/etc1", |
| 47 | "third_party/ktx", |
| 48 | ] |
| 49 | } |
| 50 | |
| 51 | # Any code that's linked into Skia-the-library should use this config via += skia_library_configs. |
| 52 | config("skia_library") { |
| 53 | visibility = [ ":*" ] |
| 54 | |
| 55 | cflags = [ |
| 56 | "-Winit-self", |
| 57 | "-Wpointer-arith", |
| 58 | "-Wsign-compare", |
| 59 | "-Wvla", |
| 60 | "-fstrict-aliasing", |
| 61 | ] |
| 62 | cflags_cc = [ "-Wnon-virtual-dtor" ] |
| 63 | |
| 64 | defines = [ "SKIA_IMPLEMENTATION=1" ] |
| 65 | } |
| 66 | |
| 67 | skia_library_configs = [ |
| 68 | ":skia_public", |
| 69 | ":skia_private", |
| 70 | ":skia_library", |
| 71 | ] |
| 72 | |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 73 | unwanted_configs = [] |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 74 | |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 75 | if (!is_fuchsia) { |
| 76 | # Chrome's GN environment is mostly helpful, but a couple default configs tend to get in the way. |
| 77 | unwanted_configs += [ |
| 78 | "//build/config/clang:find_bad_constructs", # Chrome style checks. |
| 79 | "//build/config:feature_flags", # A bunch of #defines we don't care about. |
| 80 | ] |
| 81 | } |
| 82 | |
| 83 | core_gypi = exec_script("//build/gypi_to_gn.py", |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 84 | [ |
| 85 | rebase_path("gyp/core.gypi"), |
| 86 | "--replace=<(skia_include_path)=include", |
| 87 | "--replace=<(skia_src_path)=src", |
| 88 | ], |
| 89 | "scope", |
| 90 | [ "gyp/core.gypi" ]) |
| 91 | |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 92 | effects_gypi = exec_script("//build/gypi_to_gn.py", |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 93 | [ |
| 94 | rebase_path("gyp/effects.gypi"), |
| 95 | "--replace=<(skia_include_path)=include", |
| 96 | "--replace=<(skia_src_path)=src", |
| 97 | ], |
| 98 | "scope", |
| 99 | [ "gyp/effects.gypi" ]) |
| 100 | |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 101 | gpu_gypi = exec_script("//build/gypi_to_gn.py", |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 102 | [ |
| 103 | rebase_path("gyp/gpu.gypi"), |
| 104 | "--replace=<(skia_include_path)=include", |
| 105 | "--replace=<(skia_src_path)=src", |
| 106 | ], |
| 107 | "scope", |
| 108 | [ "gyp/gpu.gypi" ]) |
| 109 | |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 110 | opts_gypi = exec_script("//build/gypi_to_gn.py", |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 111 | [ |
| 112 | rebase_path("gyp/opts.gypi"), |
| 113 | "--replace=<(skia_include_path)=include", |
| 114 | "--replace=<(skia_src_path)=src", |
| 115 | ], |
| 116 | "scope", |
| 117 | [ "gyp/opts.gypi" ]) |
| 118 | |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 119 | pdf_gypi = exec_script("//build/gypi_to_gn.py", |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 120 | [ |
| 121 | rebase_path("gyp/pdf.gypi"), |
| 122 | "--replace=<(skia_include_path)=include", |
| 123 | "--replace=<(skia_src_path)=src", |
| 124 | ], |
| 125 | "scope", |
| 126 | [ "gyp/pdf.gypi" ]) |
| 127 | |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 128 | utils_gypi = exec_script("//build/gypi_to_gn.py", |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 129 | [ |
| 130 | rebase_path("gyp/utils.gypi"), |
| 131 | "--replace=<(skia_include_path)=include", |
| 132 | "--replace=<(skia_src_path)=src", |
| 133 | ], |
| 134 | "scope", |
| 135 | [ "gyp/utils.gypi" ]) |
| 136 | |
| 137 | source_set("opts_ssse3") { |
| 138 | configs += skia_library_configs |
| 139 | configs -= unwanted_configs |
| 140 | |
| 141 | sources = opts_gypi.ssse3_sources |
| 142 | cflags = [ "-mssse3" ] |
| 143 | } |
| 144 | |
| 145 | source_set("opts_sse41") { |
| 146 | configs += skia_library_configs |
| 147 | configs -= unwanted_configs |
| 148 | |
| 149 | sources = opts_gypi.sse41_sources |
| 150 | cflags = [ "-msse4.1" ] |
| 151 | } |
| 152 | |
| 153 | source_set("opts_avx") { |
| 154 | configs += skia_library_configs |
| 155 | configs -= unwanted_configs |
| 156 | |
| 157 | sources = opts_gypi.avx_sources |
| 158 | cflags = [ "-mavx" ] |
| 159 | } |
| 160 | |
| 161 | component("skia") { |
| 162 | public_configs = [ ":skia_public" ] |
| 163 | configs += skia_library_configs |
| 164 | configs -= unwanted_configs |
| 165 | |
| 166 | deps = [ |
| 167 | ":opts_avx", |
| 168 | ":opts_sse41", |
| 169 | ":opts_ssse3", |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 170 | "//third_party/zlib", |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 171 | ] |
| 172 | |
| 173 | libs = [] |
| 174 | |
| 175 | sources = [] |
| 176 | sources += core_gypi.sources |
| 177 | sources += effects_gypi.sources |
| 178 | sources += gpu_gypi.skgpu_sources |
| 179 | sources += opts_gypi.sse2_sources |
| 180 | sources += pdf_gypi.sources |
| 181 | sources += utils_gypi.sources |
| 182 | sources += [ |
| 183 | "src/images/SkImageEncoder.cpp", |
| 184 | "src/images/SkImageEncoder_Factory.cpp", |
| 185 | "src/ports/SkDiscardableMemory_none.cpp", |
| 186 | "src/ports/SkGlobalInitialization_default.cpp", |
| 187 | "src/ports/SkImageGenerator_none.cpp", |
| 188 | "src/ports/SkMemory_malloc.cpp", |
| 189 | "src/ports/SkOSFile_stdio.cpp", |
| 190 | "src/sfnt/SkOTTable_name.cpp", |
| 191 | "src/sfnt/SkOTUtils.cpp", |
| 192 | "src/utils/mac/SkStream_mac.cpp", |
| 193 | "third_party/etc1/etc1.cpp", |
| 194 | "third_party/ktx/ktx.cpp", |
| 195 | ] |
| 196 | |
| 197 | if (is_win) { |
| 198 | sources += [ |
| 199 | "src/ports/SkDebug_win.cpp", |
| 200 | "src/ports/SkFontHost_win.cpp", |
| 201 | "src/ports/SkFontMgr_win_dw.cpp", |
| 202 | "src/ports/SkFontMgr_win_dw_factory.cpp", |
| 203 | "src/ports/SkImageEncoder_WIC.cpp", |
| 204 | "src/ports/SkImageGeneratorWIC.cpp", |
| 205 | "src/ports/SkOSFile_win.cpp", |
| 206 | "src/ports/SkScalerContext_win_dw.cpp", |
| 207 | "src/ports/SkTLS_win.cpp", |
| 208 | "src/ports/SkTypeface_win_dw.cpp", |
| 209 | ] |
| 210 | } else { |
| 211 | sources += [ |
| 212 | "src/ports/SkDebug_stdio.cpp", |
| 213 | "src/ports/SkOSFile_posix.cpp", |
| 214 | "src/ports/SkTLS_pthread.cpp", |
| 215 | ] |
| 216 | } |
| 217 | |
| 218 | if (is_linux) { |
| 219 | deps += [ |
| 220 | "third_party:fontconfig", |
| 221 | "third_party:freetype2", |
| 222 | "third_party:libjpeg-turbo", |
| 223 | "third_party:libpng", |
| 224 | ] |
| 225 | sources += [ |
| 226 | "src/fonts/SkFontMgr_fontconfig.cpp", |
| 227 | "src/images/SkJPEGImageEncoder.cpp", |
| 228 | "src/images/SkJPEGWriteUtility.cpp", |
| 229 | "src/images/SkPNGImageEncoder.cpp", |
| 230 | "src/ports/SkFontConfigInterface_direct.cpp", |
| 231 | "src/ports/SkFontConfigInterface_direct_factory.cpp", |
| 232 | "src/ports/SkFontHost_FreeType.cpp", |
| 233 | "src/ports/SkFontHost_FreeType_common.cpp", |
| 234 | "src/ports/SkFontHost_fontconfig.cpp", |
| 235 | ] |
| 236 | } |
| 237 | |
| 238 | if (is_mac) { |
| 239 | sources += [ |
| 240 | "src/ports/SkFontHost_mac.cpp", |
| 241 | "src/ports/SkImageEncoder_CG.cpp", |
| 242 | "src/ports/SkImageGeneratorCG.cpp", |
| 243 | ] |
| 244 | libs += [ "ApplicationServices.framework" ] |
| 245 | } |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame^] | 246 | |
| 247 | if (is_fuchsia) { |
| 248 | sources += [ |
| 249 | "src/ports/SkFontMgr_empty_factory.cpp", |
| 250 | ] |
| 251 | } |
mtklein | c04ff47 | 2016-06-23 10:29:30 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | executable("example") { |
| 255 | configs -= unwanted_configs |
| 256 | |
| 257 | sources = [ |
| 258 | "cmake/example.cpp", |
| 259 | ] |
| 260 | deps = [ |
| 261 | ":skia", |
| 262 | ] |
| 263 | |
| 264 | libs = [] |
| 265 | if (is_mac) { |
| 266 | libs += [ "OpenGL.framework" ] |
| 267 | } |
| 268 | } |