blob: 91a2ccbaf69496680c7a09542224ee72c6aa964f [file] [log] [blame]
Tom Sepezb5451592016-02-22 16:48:02 -08001# Copyright 2016 The Chromium Authors. All rights reserved.
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -07002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Lei Zhang81a1ac42017-12-21 21:49:55 -08005import("//build/config/jumbo.gni")
Tom Sepeza32f7602015-01-15 09:34:34 -08006import("//testing/test.gni")
dsinclair038bf0b2016-04-30 06:00:05 -07007import("pdfium.gni")
John Abd-El-Malekef4dce42015-02-02 16:52:07 -08008
Dominik Röttsches4b0671a2017-03-30 11:07:43 +03009group("freetype_common") {
10 public_deps = []
11 if (pdf_bundle_freetype) {
12 public_deps += [ "third_party:fx_freetype" ]
13 } else {
14 public_deps += [ "//build/config/freetype" ]
15 }
16}
17
weili0abe6522016-06-06 14:41:22 -070018config("pdfium_common_config") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070019 cflags = []
dsinclair6e162b52017-01-24 11:18:16 -080020 ldflags = []
Dominik Röttsches4b0671a2017-03-30 11:07:43 +030021 include_dirs = [ "." ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070022 defines = [
John Abd-El-Malek385729b2015-02-06 15:51:11 -080023 "PNG_PREFIX",
John Abd-El-Malek385729b2015-02-06 15:51:11 -080024 "PNG_USE_READ_MACROS",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070025 ]
26
Felix Kauselmann8d72a472019-02-13 23:44:56 +000027 if (!use_system_libopenjpeg2) {
28 defines += [ "OPJ_STATIC" ]
29 }
30
Ryan Harrison9ce75b82018-06-06 19:45:14 +000031 if (pdf_enable_click_logging) {
32 defines += [ "PDF_ENABLE_CLICK_LOGGING" ]
33 }
34
Lei Zhang75a486e2018-11-30 00:04:23 +000035 if (pdf_use_skia) {
36 defines += [ "_SKIA_SUPPORT_" ]
37 }
38
39 if (pdf_use_skia_paths) {
40 defines += [ "_SKIA_SUPPORT_PATHS_" ]
41 }
42
43 if (is_win) {
44 # Assume UTF-8 by default to avoid code page dependencies.
45 cflags += [ "/utf-8" ]
46 }
47}
48
Tom Anderson0db20e02019-05-14 22:38:47 +000049config("pdfium_implementation_config") {
50 defines = [ "FPDF_IMPLEMENTATION" ]
51 visibility = [ ":pdfium_public_headers" ]
52}
53
Lei Zhang75a486e2018-11-30 00:04:23 +000054config("pdfium_public_config") {
55 defines = []
56
57 if (pdf_enable_v8) {
58 defines += [ "PDF_ENABLE_V8" ]
Lei Zhang75a486e2018-11-30 00:04:23 +000059
Lei Zhang7b5740a2018-11-30 19:02:59 +000060 if (pdf_enable_xfa) {
61 defines += [ "PDF_ENABLE_XFA" ]
62 if (pdf_enable_xfa_bmp) {
63 defines += [ "PDF_ENABLE_XFA_BMP" ]
64 }
65 if (pdf_enable_xfa_gif) {
66 defines += [ "PDF_ENABLE_XFA_GIF" ]
67 }
68 if (pdf_enable_xfa_png) {
69 defines += [ "PDF_ENABLE_XFA_PNG" ]
70 }
71 if (pdf_enable_xfa_tiff) {
72 defines += [ "PDF_ENABLE_XFA_TIFF" ]
73 }
Tom Sepez73c9f3b2017-02-27 10:12:59 -080074 }
Tom Sepeza8a39e22015-10-12 15:47:07 -070075 }
thestig3e454bf2016-07-29 16:29:04 -070076
77 if (pdf_use_win32_gdi) {
78 defines += [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
79 }
weili0abe6522016-06-06 14:41:22 -070080}
Tom Sepeza8a39e22015-10-12 15:47:07 -070081
weili0abe6522016-06-06 14:41:22 -070082config("pdfium_core_config") {
83 cflags = []
Lei Zhang75a486e2018-11-30 00:04:23 +000084 configs = [
85 ":pdfium_common_config",
86 ":pdfium_public_config",
87 ]
Lei Zhangd565ca72019-01-10 00:23:55 +000088 defines = []
Ryan Harrison3a3a3692018-08-23 21:12:35 +000089 if (is_clang) {
90 cflags += [ "-Wshadow" ]
91 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070092 if (is_linux) {
Tom Sepez25d5be62015-06-18 17:44:29 -070093 if (current_cpu == "x64") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070094 defines += [ "_FX_CPU_=_FX_X64_" ]
95 cflags += [ "-fPIC" ]
Tom Sepez25d5be62015-06-18 17:44:29 -070096 } else if (current_cpu == "x86") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070097 defines += [ "_FX_CPU_=_FX_X86_" ]
98 }
99 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700100 if (is_win) {
Tom Sepez3bb57512017-03-28 14:09:43 -0700101 cflags += [
Tom Sepez5171a272017-06-01 12:29:09 -0700102 "/wd4324",
Tom Sepez3bb57512017-03-28 14:09:43 -0700103 "/wd4577",
104 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700105 }
Will Harrisb6dbcb22018-08-29 23:28:23 +0000106 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
weilidcc29b12016-05-27 17:58:23 -0700107}
Lei Zhang476ac132015-11-05 20:07:27 -0800108
Tom Anderson0db20e02019-05-14 22:38:47 +0000109jumbo_source_set("pdfium_public_headers_impl") {
Lei Zhang1987bbf2018-10-15 23:12:06 +0000110 sources = [
111 "public/cpp/fpdf_deleters.h",
112 "public/cpp/fpdf_scopers.h",
113 "public/fpdf_annot.h",
114 "public/fpdf_attachment.h",
115 "public/fpdf_catalog.h",
116 "public/fpdf_dataavail.h",
117 "public/fpdf_doc.h",
118 "public/fpdf_edit.h",
119 "public/fpdf_ext.h",
120 "public/fpdf_flatten.h",
121 "public/fpdf_formfill.h",
122 "public/fpdf_fwlevent.h",
123 "public/fpdf_ppo.h",
124 "public/fpdf_progressive.h",
125 "public/fpdf_save.h",
126 "public/fpdf_searchex.h",
127 "public/fpdf_structtree.h",
128 "public/fpdf_sysfontinfo.h",
129 "public/fpdf_text.h",
130 "public/fpdf_transformpage.h",
131 "public/fpdfview.h",
132 ]
Tom Anderson0db20e02019-05-14 22:38:47 +0000133}
Lei Zhang75a486e2018-11-30 00:04:23 +0000134
Tom Anderson0db20e02019-05-14 22:38:47 +0000135group("pdfium_public_headers") {
136 public_deps = [
137 ":pdfium_public_headers_impl",
138 ]
139 public_configs = [
140 ":pdfium_public_config",
141 ":pdfium_implementation_config",
142 ]
Lei Zhang1987bbf2018-10-15 23:12:06 +0000143}
144
Tom Anderson93101062019-05-07 02:08:43 +0000145jumbo_component("pdfium") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700146 libs = []
weili0abe6522016-06-06 14:41:22 -0700147 configs += [ ":pdfium_core_config" ]
Tom Anderson0db20e02019-05-14 22:38:47 +0000148 public_configs = [ ":pdfium_public_config" ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700149
150 deps = [
Lei Zhang76833a62018-10-12 18:53:17 +0000151 "constants",
Lei Zhang84600882018-10-12 18:58:21 +0000152 "core/fpdfapi",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000153 "core/fpdfapi/page",
154 "core/fpdfapi/parser",
Lei Zhang84600882018-10-12 18:58:21 +0000155 "core/fpdfdoc",
Lei Zhang84600882018-10-12 18:58:21 +0000156 "core/fxcodec",
Lei Zhang995374a2018-10-12 19:52:04 +0000157 "core/fxcrt",
Lei Zhang84600882018-10-12 18:58:21 +0000158 "core/fxge",
Lei Zhangdcab8cf2018-10-12 18:39:56 +0000159 "fpdfsdk",
160 "fpdfsdk/formfiller",
Lei Zhanga7dec322018-10-12 18:36:51 +0000161 "fxjs",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500162 "third_party:pdfium_base",
Dan Sinclair844d79e2018-02-16 03:46:26 +0000163 "third_party:skia_shared",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700164 ]
165
thestig73c48562016-09-06 14:07:17 -0700166 public_deps = [
Tom Anderson0db20e02019-05-14 22:38:47 +0000167 ":pdfium_public_headers_impl",
Lei Zhang995374a2018-10-12 19:52:04 +0000168 "core/fxcrt",
thestig73c48562016-09-06 14:07:17 -0700169 ]
Tom Sepeza8a39e22015-10-12 15:47:07 -0700170
Lei Zhangd7f51c72018-10-15 17:47:57 +0000171 if (pdf_enable_xfa) {
172 deps += [
173 "fpdfsdk/fpdfxfa",
174 "xfa/fxfa",
175 "xfa/fxfa/parser",
176 ]
Lei Zhangd7f51c72018-10-15 17:47:57 +0000177 }
178
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700179 if (is_win) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400180 libs += [
181 "advapi32.lib",
182 "gdi32.lib",
183 "user32.lib",
184 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700185 }
186
187 if (is_mac) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400188 libs += [
189 "AppKit.framework",
190 "CoreFoundation.framework",
191 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700192 }
John Abd-El-Malekef4dce42015-02-02 16:52:07 -0800193
dan sinclairfa171d22017-03-26 22:38:17 -0400194 if (pdf_is_complete_lib) {
195 complete_static_lib = true
Tom Andersonda89ac42018-03-21 03:56:15 +0000196 configs -= [ "//build/config/compiler:thin_archive" ]
dan sinclairfa171d22017-03-26 22:38:17 -0400197 }
Tom Anderson93101062019-05-07 02:08:43 +0000198
199 if (is_component_build) {
200 deps += [ "testing/fuzzers:fuzzer_impls" ]
201 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700202}
203
Tom Sepezd831dc72015-10-19 16:04:22 -0700204# Targets below this are only visible within this file (and to the
205# top-level gn_visibility target used to help gn_all build everything).
206visibility = [
207 ":*",
208 "//:gn_visibility",
209]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700210
Lei Zhangf03f7812018-10-15 23:48:29 +0000211group("pdfium_unittest_deps") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000212 testonly = true
Lei Zhangf03f7812018-10-15 23:48:29 +0000213 public_deps = [
214 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000215 "testing:test_support",
Tom Sepez16b9d772017-04-17 09:07:48 -0700216 "//testing/gmock",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500217 "//testing/gtest",
Tom Sepez04681f32015-01-09 13:59:19 -0800218 ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000219 visibility += [
220 "core/*",
221 "fpdfsdk/*",
222 "fxbarcode/*",
223 "fxjs/*",
224 "xfa/*",
225 ]
226}
227
228test("pdfium_unittests") {
229 testonly = true
230 sources = [
231 "testing/unit_test_main.cpp",
232 ]
233 deps = [
234 "core/fdrm:unittests",
235 "core/fpdfapi/edit:unittests",
236 "core/fpdfapi/font:unittests",
237 "core/fpdfapi/page:unittests",
238 "core/fpdfapi/parser:unittests",
Lei Zhangac520152018-11-09 22:58:56 +0000239 "core/fpdfapi/render:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000240 "core/fpdfdoc:unittests",
241 "core/fpdftext:unittests",
242 "core/fxcodec:unittests",
243 "core/fxcrt",
244 "core/fxcrt:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000245 "core/fxge:unittests",
246 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000247 "testing:test_support",
Lei Zhang220ef3d2019-02-05 20:40:54 +0000248 "testing:unit_test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000249 "//testing/gmock",
250 "//testing/gtest",
251 ]
252 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000253
254 if (is_android) {
255 use_raw_android_executable = true
256 }
257
258 if (pdf_enable_v8) {
259 configs += [ "//v8:external_startup_data" ]
260 deps += [
261 "fxjs:unittests",
262 "//v8",
263 ]
264 }
265
Tom Sepezd2e023b2015-12-08 14:36:16 -0800266 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000267 deps += [
268 "fxbarcode:unittests",
269 "xfa/fde:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000270 "xfa/fgas:unittests",
Lei Zhanga0c36802018-12-15 01:00:05 +0000271 "xfa/fgas/layout:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000272 "xfa/fwl:unittests",
273 "xfa/fxfa:unittests",
274 "xfa/fxfa/fm2js:unittests",
275 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800276 ]
277 }
Tom Sepez04681f32015-01-09 13:59:19 -0800278}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800279
Lei Zhang1929d6e2018-10-15 23:51:28 +0000280group("pdfium_embeddertest_deps") {
281 testonly = true
282 public_deps = [
283 ":pdfium_public_headers",
284 "core/fxcrt",
285 "testing:embedder_test_support",
286 "testing:test_support",
Lei Zhangfc455492019-06-14 17:16:09 +0000287 "third_party:pdfium_base_test_support",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000288 "//testing/gmock",
289 "//testing/gtest",
290 ]
291 visibility += [
292 "core/*",
293 "fpdfsdk/*",
294 "fxjs/*",
295 "xfa/*",
296 ]
297}
298
Tom Sepez1b1bb492015-01-22 17:36:32 -0800299test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000300 testonly = true
Tom Sepez1b1bb492015-01-22 17:36:32 -0800301 sources = [
Dan Sinclair5553d8b2018-01-03 09:44:28 -0500302 "testing/embedder_test_main.cpp",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800303 ]
304 deps = [
Lei Zhang1929d6e2018-10-15 23:51:28 +0000305 "core/fpdfapi/edit:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000306 "core/fpdfapi/parser:embeddertests",
307 "core/fpdfapi/render:embeddertests",
308 "core/fxcodec:embeddertests",
Tom Anderson0db20e02019-05-14 22:38:47 +0000309 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000310 "core/fxge:embeddertests",
311 "fpdfsdk:embeddertests",
312 "fpdfsdk/pwl:embeddertests",
313 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000314 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500315 "//testing/gmock",
316 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800317 ]
dsinclair685bb882016-04-20 07:32:39 -0700318 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700319 configs += [ ":pdfium_core_config" ]
320
Lei Zhanga996ff42018-10-15 23:49:48 +0000321 if (is_android) {
322 ignore_all_data_deps = true
323 use_raw_android_executable = true
324 }
325
Tom Sepez452b4f32015-10-13 09:27:27 -0700326 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000327 deps += [
328 "fxjs:embeddertests",
329 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800330 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100331 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700332 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000333
Dan Sinclair14aacd52017-05-18 14:11:29 -0400334 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000335 deps += [
Lei Zhang83458252019-03-14 20:07:20 +0000336 "fpdfsdk/fpdfxfa:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000337 "xfa/fwl:embeddertests",
Tom Sepez6e4710a2019-05-08 17:23:18 +0000338 "xfa/fxfa/layout:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000339 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400340 ]
341 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800342}
dsinclair685bb882016-04-20 07:32:39 -0700343
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000344executable("pdfium_diff") {
345 testonly = true
346 sources = [
347 "testing/image_diff/image_diff.cpp",
348 ]
349 deps = [
350 ":pdfium",
Tom Anderson93101062019-05-07 02:08:43 +0000351 "core/fxcrt",
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000352 "testing/image_diff",
353 "//build/win:default_exe_manifest",
354 ]
355 configs -= [ "//build/config/compiler:chromium_code" ]
356 configs += [ "//build/config/compiler:no_chromium_code" ]
357 configs += [ ":pdfium_core_config" ]
358}
359
dsinclair685bb882016-04-20 07:32:39 -0700360if (pdf_is_standalone) {
Lei Zhang0a624272018-10-11 16:58:32 +0000361 jumbo_source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700362 testonly = true
363 deps = [
364 "//samples",
365 ]
366 }
Lei Zhang143959d2017-06-22 12:20:58 -0700367
thestig62114cf2016-11-08 12:59:30 -0800368 group("fuzzers") {
369 testonly = true
370 deps = [
Lei Zhangfa4d93a2018-05-25 21:47:19 +0000371 "//testing/fuzzers",
thestig62114cf2016-11-08 12:59:30 -0800372 ]
373 }
dsinclair685bb882016-04-20 07:32:39 -0700374}
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700375
376group("pdfium_all") {
377 testonly = true
378 deps = [
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000379 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700380 ":pdfium_embeddertests",
381 ":pdfium_unittests",
382 ]
383 if (pdf_is_standalone) {
384 deps += [
385 ":fuzzers",
386 ":samples",
387 ]
388 }
389}