blob: 6885fc27d2ea9e2f4d0eff58d997c961089f3ea5 [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
49config("pdfium_public_config") {
50 defines = []
51
52 if (pdf_enable_v8) {
53 defines += [ "PDF_ENABLE_V8" ]
Lei Zhang75a486e2018-11-30 00:04:23 +000054
Lei Zhang7b5740a2018-11-30 19:02:59 +000055 if (pdf_enable_xfa) {
56 defines += [ "PDF_ENABLE_XFA" ]
57 if (pdf_enable_xfa_bmp) {
58 defines += [ "PDF_ENABLE_XFA_BMP" ]
59 }
60 if (pdf_enable_xfa_gif) {
61 defines += [ "PDF_ENABLE_XFA_GIF" ]
62 }
63 if (pdf_enable_xfa_png) {
64 defines += [ "PDF_ENABLE_XFA_PNG" ]
65 }
66 if (pdf_enable_xfa_tiff) {
67 defines += [ "PDF_ENABLE_XFA_TIFF" ]
68 }
Tom Sepez73c9f3b2017-02-27 10:12:59 -080069 }
Tom Sepeza8a39e22015-10-12 15:47:07 -070070 }
thestig3e454bf2016-07-29 16:29:04 -070071
72 if (pdf_use_win32_gdi) {
73 defines += [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
74 }
weili0abe6522016-06-06 14:41:22 -070075}
Tom Sepeza8a39e22015-10-12 15:47:07 -070076
weili0abe6522016-06-06 14:41:22 -070077config("pdfium_core_config") {
78 cflags = []
Lei Zhang75a486e2018-11-30 00:04:23 +000079 configs = [
80 ":pdfium_common_config",
81 ":pdfium_public_config",
82 ]
Lei Zhangd565ca72019-01-10 00:23:55 +000083 defines = []
Ryan Harrison3a3a3692018-08-23 21:12:35 +000084 if (is_clang) {
85 cflags += [ "-Wshadow" ]
Nico Weber563f62a2019-02-12 18:47:12 +000086
87 # TODO(thakis): Remove once this is on globally, https://crbug.com/926235
88 cflags += [ "-Wextra-semi" ]
Ryan Harrison3a3a3692018-08-23 21:12:35 +000089 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070090 if (is_linux) {
Tom Sepez25d5be62015-06-18 17:44:29 -070091 if (current_cpu == "x64") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070092 defines += [ "_FX_CPU_=_FX_X64_" ]
93 cflags += [ "-fPIC" ]
Tom Sepez25d5be62015-06-18 17:44:29 -070094 } else if (current_cpu == "x86") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070095 defines += [ "_FX_CPU_=_FX_X86_" ]
96 }
97 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070098 if (is_win) {
Tom Sepez3bb57512017-03-28 14:09:43 -070099 cflags += [
Tom Sepez5171a272017-06-01 12:29:09 -0700100 "/wd4324",
Tom Sepez3bb57512017-03-28 14:09:43 -0700101 "/wd4577",
102 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700103 }
Will Harrisb6dbcb22018-08-29 23:28:23 +0000104 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
weilidcc29b12016-05-27 17:58:23 -0700105}
Lei Zhang476ac132015-11-05 20:07:27 -0800106
Lei Zhang1987bbf2018-10-15 23:12:06 +0000107jumbo_source_set("pdfium_public_headers") {
108 sources = [
109 "public/cpp/fpdf_deleters.h",
110 "public/cpp/fpdf_scopers.h",
111 "public/fpdf_annot.h",
112 "public/fpdf_attachment.h",
113 "public/fpdf_catalog.h",
114 "public/fpdf_dataavail.h",
115 "public/fpdf_doc.h",
116 "public/fpdf_edit.h",
117 "public/fpdf_ext.h",
118 "public/fpdf_flatten.h",
119 "public/fpdf_formfill.h",
120 "public/fpdf_fwlevent.h",
121 "public/fpdf_ppo.h",
122 "public/fpdf_progressive.h",
123 "public/fpdf_save.h",
124 "public/fpdf_searchex.h",
125 "public/fpdf_structtree.h",
126 "public/fpdf_sysfontinfo.h",
127 "public/fpdf_text.h",
128 "public/fpdf_transformpage.h",
129 "public/fpdfview.h",
130 ]
Lei Zhang75a486e2018-11-30 00:04:23 +0000131
132 public_configs = [ ":pdfium_public_config" ]
Lei Zhang1987bbf2018-10-15 23:12:06 +0000133}
134
Lei Zhang81a1ac42017-12-21 21:49:55 -0800135jumbo_static_library("pdfium") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700136 sources = [
Dan Sinclair971a6742018-03-28 19:23:25 +0000137 "fpdfsdk/fpdf_annot.cpp",
138 "fpdfsdk/fpdf_attachment.cpp",
139 "fpdfsdk/fpdf_catalog.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400140 "fpdfsdk/fpdf_dataavail.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000141 "fpdfsdk/fpdf_doc.cpp",
142 "fpdfsdk/fpdf_editimg.cpp",
143 "fpdfsdk/fpdf_editpage.cpp",
144 "fpdfsdk/fpdf_editpath.cpp",
145 "fpdfsdk/fpdf_edittext.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400146 "fpdfsdk/fpdf_ext.cpp",
147 "fpdfsdk/fpdf_flatten.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000148 "fpdfsdk/fpdf_formfill.cpp",
Lei Zhangf7c84e92018-02-02 00:01:39 +0000149 "fpdfsdk/fpdf_ppo.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400150 "fpdfsdk/fpdf_progressive.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000151 "fpdfsdk/fpdf_save.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400152 "fpdfsdk/fpdf_searchex.cpp",
thestig9067fd62016-11-23 14:10:06 -0800153 "fpdfsdk/fpdf_structtree.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400154 "fpdfsdk/fpdf_sysfontinfo.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000155 "fpdfsdk/fpdf_text.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400156 "fpdfsdk/fpdf_transformpage.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000157 "fpdfsdk/fpdf_view.cpp",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700158 ]
159
160 libs = []
weili0abe6522016-06-06 14:41:22 -0700161 configs += [ ":pdfium_core_config" ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700162
163 deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000164 ":pdfium_public_headers",
Lei Zhang76833a62018-10-12 18:53:17 +0000165 "constants",
Lei Zhang84600882018-10-12 18:58:21 +0000166 "core/fdrm",
167 "core/fpdfapi",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000168 "core/fpdfapi/edit",
169 "core/fpdfapi/font",
170 "core/fpdfapi/page",
171 "core/fpdfapi/parser",
172 "core/fpdfapi/render",
Lei Zhang84600882018-10-12 18:58:21 +0000173 "core/fpdfdoc",
174 "core/fpdftext",
175 "core/fxcodec",
Lei Zhang995374a2018-10-12 19:52:04 +0000176 "core/fxcrt",
Lei Zhang84600882018-10-12 18:58:21 +0000177 "core/fxge",
Lei Zhangdcab8cf2018-10-12 18:39:56 +0000178 "fpdfsdk",
179 "fpdfsdk/formfiller",
Lei Zhanga7dec322018-10-12 18:36:51 +0000180 "fxjs",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500181 "third_party:pdfium_base",
Dan Sinclair844d79e2018-02-16 03:46:26 +0000182 "third_party:skia_shared",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700183 ]
184
thestig73c48562016-09-06 14:07:17 -0700185 public_deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000186 ":pdfium_public_headers",
Lei Zhang995374a2018-10-12 19:52:04 +0000187 "core/fxcrt",
thestig73c48562016-09-06 14:07:17 -0700188 ]
Tom Sepeza8a39e22015-10-12 15:47:07 -0700189
Lei Zhangd7f51c72018-10-15 17:47:57 +0000190 if (pdf_enable_xfa) {
191 deps += [
192 "fpdfsdk/fpdfxfa",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000193 "fxbarcode",
Lei Zhangd7f51c72018-10-15 17:47:57 +0000194 "xfa/fxfa",
195 "xfa/fxfa/parser",
196 ]
Lei Zhangd7f51c72018-10-15 17:47:57 +0000197 }
198
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700199 if (is_win) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400200 libs += [
201 "advapi32.lib",
202 "gdi32.lib",
203 "user32.lib",
204 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700205 }
206
207 if (is_mac) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400208 libs += [
209 "AppKit.framework",
210 "CoreFoundation.framework",
211 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700212 }
John Abd-El-Malekef4dce42015-02-02 16:52:07 -0800213
dan sinclairfa171d22017-03-26 22:38:17 -0400214 if (pdf_is_complete_lib) {
215 complete_static_lib = true
Tom Andersonda89ac42018-03-21 03:56:15 +0000216 configs -= [ "//build/config/compiler:thin_archive" ]
dan sinclairfa171d22017-03-26 22:38:17 -0400217 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700218}
219
Tom Sepezd831dc72015-10-19 16:04:22 -0700220# Targets below this are only visible within this file (and to the
221# top-level gn_visibility target used to help gn_all build everything).
222visibility = [
223 ":*",
224 "//:gn_visibility",
225]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700226
Lei Zhangf03f7812018-10-15 23:48:29 +0000227group("pdfium_unittest_deps") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000228 testonly = true
Lei Zhangf03f7812018-10-15 23:48:29 +0000229 public_deps = [
230 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000231 "testing:test_support",
Tom Sepez16b9d772017-04-17 09:07:48 -0700232 "//testing/gmock",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500233 "//testing/gtest",
Tom Sepez04681f32015-01-09 13:59:19 -0800234 ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000235 visibility += [
236 "core/*",
237 "fpdfsdk/*",
238 "fxbarcode/*",
239 "fxjs/*",
240 "xfa/*",
241 ]
242}
243
244test("pdfium_unittests") {
245 testonly = true
246 sources = [
247 "testing/unit_test_main.cpp",
248 ]
249 deps = [
250 "core/fdrm:unittests",
251 "core/fpdfapi/edit:unittests",
252 "core/fpdfapi/font:unittests",
253 "core/fpdfapi/page:unittests",
254 "core/fpdfapi/parser:unittests",
Lei Zhangac520152018-11-09 22:58:56 +0000255 "core/fpdfapi/render:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000256 "core/fpdfdoc:unittests",
257 "core/fpdftext:unittests",
258 "core/fxcodec:unittests",
259 "core/fxcrt",
260 "core/fxcrt:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000261 "core/fxge:unittests",
262 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000263 "testing:test_support",
Lei Zhang220ef3d2019-02-05 20:40:54 +0000264 "testing:unit_test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000265 "//testing/gmock",
266 "//testing/gtest",
267 ]
268 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000269
270 if (is_android) {
271 use_raw_android_executable = true
272 }
273
274 if (pdf_enable_v8) {
275 configs += [ "//v8:external_startup_data" ]
276 deps += [
277 "fxjs:unittests",
278 "//v8",
279 ]
280 }
281
Tom Sepezd2e023b2015-12-08 14:36:16 -0800282 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000283 deps += [
284 "fxbarcode:unittests",
285 "xfa/fde:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000286 "xfa/fgas:unittests",
Lei Zhanga0c36802018-12-15 01:00:05 +0000287 "xfa/fgas/layout:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000288 "xfa/fwl:unittests",
289 "xfa/fxfa:unittests",
290 "xfa/fxfa/fm2js:unittests",
291 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800292 ]
293 }
Tom Sepez04681f32015-01-09 13:59:19 -0800294}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800295
Lei Zhang1929d6e2018-10-15 23:51:28 +0000296group("pdfium_embeddertest_deps") {
297 testonly = true
298 public_deps = [
299 ":pdfium_public_headers",
300 "core/fxcrt",
301 "testing:embedder_test_support",
302 "testing:test_support",
303 "//testing/gmock",
304 "//testing/gtest",
305 ]
306 visibility += [
307 "core/*",
308 "fpdfsdk/*",
309 "fxjs/*",
310 "xfa/*",
311 ]
312}
313
Tom Sepez1b1bb492015-01-22 17:36:32 -0800314test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000315 testonly = true
Tom Sepez1b1bb492015-01-22 17:36:32 -0800316 sources = [
Dan Sinclair5553d8b2018-01-03 09:44:28 -0500317 "testing/embedder_test_main.cpp",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800318 ]
319 deps = [
Tom Sepez452b4f32015-10-13 09:27:27 -0700320 ":pdfium",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000321 "core/fpdfapi/edit:embeddertests",
322 "core/fpdfapi/page:embeddertests",
323 "core/fpdfapi/parser:embeddertests",
324 "core/fpdfapi/render:embeddertests",
325 "core/fxcodec:embeddertests",
326 "core/fxge:embeddertests",
327 "fpdfsdk:embeddertests",
328 "fpdfsdk/pwl:embeddertests",
329 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000330 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500331 "//testing/gmock",
332 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800333 ]
dsinclair685bb882016-04-20 07:32:39 -0700334 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700335 configs += [ ":pdfium_core_config" ]
336
Lei Zhanga996ff42018-10-15 23:49:48 +0000337 if (is_android) {
338 ignore_all_data_deps = true
339 use_raw_android_executable = true
340 }
341
Tom Sepez452b4f32015-10-13 09:27:27 -0700342 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000343 deps += [
344 "fxjs:embeddertests",
345 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800346 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100347 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700348 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000349
Dan Sinclair14aacd52017-05-18 14:11:29 -0400350 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000351 deps += [
352 "xfa/fwl:embeddertests",
353 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400354 ]
355 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800356}
dsinclair685bb882016-04-20 07:32:39 -0700357
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000358executable("pdfium_diff") {
359 testonly = true
360 sources = [
361 "testing/image_diff/image_diff.cpp",
362 ]
363 deps = [
364 ":pdfium",
365 "testing/image_diff",
366 "//build/win:default_exe_manifest",
367 ]
368 configs -= [ "//build/config/compiler:chromium_code" ]
369 configs += [ "//build/config/compiler:no_chromium_code" ]
370 configs += [ ":pdfium_core_config" ]
371}
372
dsinclair685bb882016-04-20 07:32:39 -0700373if (pdf_is_standalone) {
Lei Zhang0a624272018-10-11 16:58:32 +0000374 jumbo_source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700375 testonly = true
376 deps = [
377 "//samples",
378 ]
379 }
Lei Zhang143959d2017-06-22 12:20:58 -0700380
thestig62114cf2016-11-08 12:59:30 -0800381 group("fuzzers") {
382 testonly = true
383 deps = [
Lei Zhangfa4d93a2018-05-25 21:47:19 +0000384 "//testing/fuzzers",
thestig62114cf2016-11-08 12:59:30 -0800385 ]
386 }
dsinclair685bb882016-04-20 07:32:39 -0700387}
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700388
389group("pdfium_all") {
390 testonly = true
391 deps = [
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000392 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700393 ":pdfium_embeddertests",
394 ":pdfium_unittests",
395 ]
396 if (pdf_is_standalone) {
397 deps += [
398 ":fuzzers",
399 ":samples",
400 ]
401 }
402}