blob: c346673cfea54229570f25c9d7b2cc7371796fc7 [file] [log] [blame]
mtkleinc04ff472016-06-23 10:29:30 -07001# 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
6declare_args() {
7}
8
9# Skia public API, generally provided by :skia.
10config("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.
28config("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.
52config("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
67skia_library_configs = [
68 ":skia_public",
69 ":skia_private",
70 ":skia_library",
71]
72
mtkleine817ddf2016-07-19 06:03:22 -070073if (!defined(is_fuchsia)) {
74 is_fuchsia = current_os == "fuchsia"
75}
76
abarth6fc8ff02016-07-15 15:15:15 -070077unwanted_configs = []
mtkleinc04ff472016-06-23 10:29:30 -070078
abarth6fc8ff02016-07-15 15:15:15 -070079if (!is_fuchsia) {
80 # Chrome's GN environment is mostly helpful, but a couple default configs tend to get in the way.
81 unwanted_configs += [
82 "//build/config/clang:find_bad_constructs", # Chrome style checks.
83 "//build/config:feature_flags", # A bunch of #defines we don't care about.
84 ]
85}
86
87core_gypi = exec_script("//build/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070088 [
89 rebase_path("gyp/core.gypi"),
90 "--replace=<(skia_include_path)=include",
91 "--replace=<(skia_src_path)=src",
92 ],
93 "scope",
94 [ "gyp/core.gypi" ])
95
abarth6fc8ff02016-07-15 15:15:15 -070096effects_gypi = exec_script("//build/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070097 [
98 rebase_path("gyp/effects.gypi"),
99 "--replace=<(skia_include_path)=include",
100 "--replace=<(skia_src_path)=src",
101 ],
102 "scope",
103 [ "gyp/effects.gypi" ])
104
abarth6fc8ff02016-07-15 15:15:15 -0700105gpu_gypi = exec_script("//build/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700106 [
107 rebase_path("gyp/gpu.gypi"),
108 "--replace=<(skia_include_path)=include",
109 "--replace=<(skia_src_path)=src",
110 ],
111 "scope",
112 [ "gyp/gpu.gypi" ])
113
abarth6fc8ff02016-07-15 15:15:15 -0700114opts_gypi = exec_script("//build/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700115 [
116 rebase_path("gyp/opts.gypi"),
117 "--replace=<(skia_include_path)=include",
118 "--replace=<(skia_src_path)=src",
119 ],
120 "scope",
121 [ "gyp/opts.gypi" ])
122
abarth6fc8ff02016-07-15 15:15:15 -0700123pdf_gypi = exec_script("//build/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700124 [
125 rebase_path("gyp/pdf.gypi"),
126 "--replace=<(skia_include_path)=include",
127 "--replace=<(skia_src_path)=src",
128 ],
129 "scope",
130 [ "gyp/pdf.gypi" ])
131
abarth6fc8ff02016-07-15 15:15:15 -0700132utils_gypi = exec_script("//build/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700133 [
134 rebase_path("gyp/utils.gypi"),
135 "--replace=<(skia_include_path)=include",
136 "--replace=<(skia_src_path)=src",
137 ],
138 "scope",
139 [ "gyp/utils.gypi" ])
140
141source_set("opts_ssse3") {
142 configs += skia_library_configs
143 configs -= unwanted_configs
144
145 sources = opts_gypi.ssse3_sources
146 cflags = [ "-mssse3" ]
147}
148
149source_set("opts_sse41") {
150 configs += skia_library_configs
151 configs -= unwanted_configs
152
153 sources = opts_gypi.sse41_sources
154 cflags = [ "-msse4.1" ]
155}
156
157source_set("opts_avx") {
158 configs += skia_library_configs
159 configs -= unwanted_configs
160
161 sources = opts_gypi.avx_sources
162 cflags = [ "-mavx" ]
163}
164
165component("skia") {
166 public_configs = [ ":skia_public" ]
167 configs += skia_library_configs
168 configs -= unwanted_configs
169
170 deps = [
171 ":opts_avx",
172 ":opts_sse41",
173 ":opts_ssse3",
abarth6fc8ff02016-07-15 15:15:15 -0700174 "//third_party/zlib",
mtkleinc04ff472016-06-23 10:29:30 -0700175 ]
176
177 libs = []
178
179 sources = []
180 sources += core_gypi.sources
181 sources += effects_gypi.sources
182 sources += gpu_gypi.skgpu_sources
183 sources += opts_gypi.sse2_sources
184 sources += pdf_gypi.sources
185 sources += utils_gypi.sources
186 sources += [
187 "src/images/SkImageEncoder.cpp",
188 "src/images/SkImageEncoder_Factory.cpp",
189 "src/ports/SkDiscardableMemory_none.cpp",
190 "src/ports/SkGlobalInitialization_default.cpp",
191 "src/ports/SkImageGenerator_none.cpp",
192 "src/ports/SkMemory_malloc.cpp",
193 "src/ports/SkOSFile_stdio.cpp",
194 "src/sfnt/SkOTTable_name.cpp",
195 "src/sfnt/SkOTUtils.cpp",
196 "src/utils/mac/SkStream_mac.cpp",
197 "third_party/etc1/etc1.cpp",
198 "third_party/ktx/ktx.cpp",
199 ]
200
201 if (is_win) {
202 sources += [
203 "src/ports/SkDebug_win.cpp",
204 "src/ports/SkFontHost_win.cpp",
205 "src/ports/SkFontMgr_win_dw.cpp",
206 "src/ports/SkFontMgr_win_dw_factory.cpp",
207 "src/ports/SkImageEncoder_WIC.cpp",
208 "src/ports/SkImageGeneratorWIC.cpp",
209 "src/ports/SkOSFile_win.cpp",
210 "src/ports/SkScalerContext_win_dw.cpp",
211 "src/ports/SkTLS_win.cpp",
212 "src/ports/SkTypeface_win_dw.cpp",
213 ]
214 } else {
215 sources += [
216 "src/ports/SkDebug_stdio.cpp",
217 "src/ports/SkOSFile_posix.cpp",
218 "src/ports/SkTLS_pthread.cpp",
219 ]
220 }
221
222 if (is_linux) {
223 deps += [
224 "third_party:fontconfig",
225 "third_party:freetype2",
226 "third_party:libjpeg-turbo",
227 "third_party:libpng",
228 ]
229 sources += [
230 "src/fonts/SkFontMgr_fontconfig.cpp",
231 "src/images/SkJPEGImageEncoder.cpp",
232 "src/images/SkJPEGWriteUtility.cpp",
233 "src/images/SkPNGImageEncoder.cpp",
234 "src/ports/SkFontConfigInterface_direct.cpp",
235 "src/ports/SkFontConfigInterface_direct_factory.cpp",
236 "src/ports/SkFontHost_FreeType.cpp",
237 "src/ports/SkFontHost_FreeType_common.cpp",
238 "src/ports/SkFontHost_fontconfig.cpp",
239 ]
240 }
241
242 if (is_mac) {
243 sources += [
244 "src/ports/SkFontHost_mac.cpp",
245 "src/ports/SkImageEncoder_CG.cpp",
246 "src/ports/SkImageGeneratorCG.cpp",
247 ]
248 libs += [ "ApplicationServices.framework" ]
249 }
abarth6fc8ff02016-07-15 15:15:15 -0700250
251 if (is_fuchsia) {
mtkleine817ddf2016-07-19 06:03:22 -0700252 sources += [ "src/ports/SkFontMgr_empty_factory.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700253 }
mtkleinc04ff472016-06-23 10:29:30 -0700254}
255
256executable("example") {
257 configs -= unwanted_configs
258
259 sources = [
260 "cmake/example.cpp",
261 ]
262 deps = [
263 ":skia",
264 ]
265
266 libs = []
267 if (is_mac) {
268 libs += [ "OpenGL.framework" ]
269 }
270}