blob: 62f09e580df60bfa9e3abfee3405b5df240e1b4b [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
Tom Sepeza32f7602015-01-15 09:34:34 -08005import("//testing/test.gni")
dsinclair038bf0b2016-04-30 06:00:05 -07006import("pdfium.gni")
John Abd-El-Malekef4dce42015-02-02 16:52:07 -08007
Dominik Röttsches4b0671a2017-03-30 11:07:43 +03008group("freetype_common") {
9 public_deps = []
10 if (pdf_bundle_freetype) {
11 public_deps += [ "third_party:fx_freetype" ]
12 } else {
13 public_deps += [ "//build/config/freetype" ]
14 }
15}
16
weili0abe6522016-06-06 14:41:22 -070017config("pdfium_common_config") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070018 cflags = []
dsinclair6e162b52017-01-24 11:18:16 -080019 ldflags = []
Dominik Röttsches4b0671a2017-03-30 11:07:43 +030020 include_dirs = [ "." ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070021 defines = [
John Abd-El-Malek385729b2015-02-06 15:51:11 -080022 "PNG_PREFIX",
John Abd-El-Malek385729b2015-02-06 15:51:11 -080023 "PNG_USE_READ_MACROS",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070024 ]
25
Felix Kauselmann8d72a472019-02-13 23:44:56 +000026 if (!use_system_libopenjpeg2) {
27 defines += [ "OPJ_STATIC" ]
28 }
29
Ryan Harrison9ce75b82018-06-06 19:45:14 +000030 if (pdf_enable_click_logging) {
31 defines += [ "PDF_ENABLE_CLICK_LOGGING" ]
32 }
33
Lei Zhang75a486e2018-11-30 00:04:23 +000034 if (pdf_use_skia) {
35 defines += [ "_SKIA_SUPPORT_" ]
36 }
37
38 if (pdf_use_skia_paths) {
39 defines += [ "_SKIA_SUPPORT_PATHS_" ]
40 }
41
42 if (is_win) {
43 # Assume UTF-8 by default to avoid code page dependencies.
44 cflags += [ "/utf-8" ]
45 }
46}
47
Tom Anderson0db20e02019-05-14 22:38:47 +000048config("pdfium_implementation_config") {
49 defines = [ "FPDF_IMPLEMENTATION" ]
50 visibility = [ ":pdfium_public_headers" ]
51}
52
Lei Zhang75a486e2018-11-30 00:04:23 +000053config("pdfium_public_config") {
54 defines = []
55
56 if (pdf_enable_v8) {
57 defines += [ "PDF_ENABLE_V8" ]
Lei Zhang75a486e2018-11-30 00:04:23 +000058
Lei Zhang7b5740a2018-11-30 19:02:59 +000059 if (pdf_enable_xfa) {
60 defines += [ "PDF_ENABLE_XFA" ]
61 if (pdf_enable_xfa_bmp) {
62 defines += [ "PDF_ENABLE_XFA_BMP" ]
63 }
64 if (pdf_enable_xfa_gif) {
65 defines += [ "PDF_ENABLE_XFA_GIF" ]
66 }
67 if (pdf_enable_xfa_png) {
68 defines += [ "PDF_ENABLE_XFA_PNG" ]
69 }
70 if (pdf_enable_xfa_tiff) {
71 defines += [ "PDF_ENABLE_XFA_TIFF" ]
72 }
Tom Sepez73c9f3b2017-02-27 10:12:59 -080073 }
Tom Sepeza8a39e22015-10-12 15:47:07 -070074 }
thestig3e454bf2016-07-29 16:29:04 -070075
76 if (pdf_use_win32_gdi) {
77 defines += [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
78 }
weili0abe6522016-06-06 14:41:22 -070079}
Tom Sepeza8a39e22015-10-12 15:47:07 -070080
weili0abe6522016-06-06 14:41:22 -070081config("pdfium_core_config") {
82 cflags = []
Lei Zhang75a486e2018-11-30 00:04:23 +000083 configs = [
84 ":pdfium_common_config",
85 ":pdfium_public_config",
Lei Zhangf4d4fee2019-12-04 18:06:13 +000086 "//build/config/compiler:noshadowing",
Lei Zhang75a486e2018-11-30 00:04:23 +000087 ]
Lei Zhangd565ca72019-01-10 00:23:55 +000088 defines = []
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070089 if (is_linux) {
Tom Sepez25d5be62015-06-18 17:44:29 -070090 if (current_cpu == "x64") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070091 defines += [ "_FX_CPU_=_FX_X64_" ]
92 cflags += [ "-fPIC" ]
Tom Sepez25d5be62015-06-18 17:44:29 -070093 } else if (current_cpu == "x86") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070094 defines += [ "_FX_CPU_=_FX_X86_" ]
95 }
96 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070097 if (is_win) {
Tom Sepez3bb57512017-03-28 14:09:43 -070098 cflags += [
Tom Sepez5171a272017-06-01 12:29:09 -070099 "/wd4324",
Tom Sepez3bb57512017-03-28 14:09:43 -0700100 "/wd4577",
101 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700102 }
Will Harrisb6dbcb22018-08-29 23:28:23 +0000103 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
weilidcc29b12016-05-27 17:58:23 -0700104}
Lei Zhang476ac132015-11-05 20:07:27 -0800105
Daniel Hosseinian0fab9e62019-11-01 19:31:49 +0000106source_set("pdfium_public_headers_impl") {
Lei Zhang1987bbf2018-10-15 23:12:06 +0000107 sources = [
108 "public/cpp/fpdf_deleters.h",
109 "public/cpp/fpdf_scopers.h",
110 "public/fpdf_annot.h",
111 "public/fpdf_attachment.h",
112 "public/fpdf_catalog.h",
113 "public/fpdf_dataavail.h",
114 "public/fpdf_doc.h",
115 "public/fpdf_edit.h",
116 "public/fpdf_ext.h",
117 "public/fpdf_flatten.h",
118 "public/fpdf_formfill.h",
119 "public/fpdf_fwlevent.h",
Lei Zhang25661d12019-08-01 21:57:23 +0000120 "public/fpdf_javascript.h",
Lei Zhang1987bbf2018-10-15 23:12:06 +0000121 "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 ]
Tom Anderson0db20e02019-05-14 22:38:47 +0000131}
Lei Zhang75a486e2018-11-30 00:04:23 +0000132
Tom Anderson0db20e02019-05-14 22:38:47 +0000133group("pdfium_public_headers") {
Lei Zhang40f9d722020-01-24 00:18:11 +0000134 public_deps = [ ":pdfium_public_headers_impl" ]
Tom Anderson0db20e02019-05-14 22:38:47 +0000135 public_configs = [
136 ":pdfium_public_config",
137 ":pdfium_implementation_config",
138 ]
Lei Zhang1987bbf2018-10-15 23:12:06 +0000139}
140
Daniel Hosseinian0fab9e62019-11-01 19:31:49 +0000141component("pdfium") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700142 libs = []
weili0abe6522016-06-06 14:41:22 -0700143 configs += [ ":pdfium_core_config" ]
Tom Anderson0db20e02019-05-14 22:38:47 +0000144 public_configs = [ ":pdfium_public_config" ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700145
146 deps = [
Lei Zhang76833a62018-10-12 18:53:17 +0000147 "constants",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000148 "core/fpdfapi/page",
149 "core/fpdfapi/parser",
Lei Zhang84600882018-10-12 18:58:21 +0000150 "core/fpdfdoc",
Lei Zhang84600882018-10-12 18:58:21 +0000151 "core/fxcodec",
Lei Zhang995374a2018-10-12 19:52:04 +0000152 "core/fxcrt",
Lei Zhang84600882018-10-12 18:58:21 +0000153 "core/fxge",
Lei Zhangdcab8cf2018-10-12 18:39:56 +0000154 "fpdfsdk",
155 "fpdfsdk/formfiller",
Lei Zhanga7dec322018-10-12 18:36:51 +0000156 "fxjs",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500157 "third_party:pdfium_base",
Dan Sinclair844d79e2018-02-16 03:46:26 +0000158 "third_party:skia_shared",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700159 ]
160
thestig73c48562016-09-06 14:07:17 -0700161 public_deps = [
Tom Anderson0db20e02019-05-14 22:38:47 +0000162 ":pdfium_public_headers_impl",
Lei Zhang995374a2018-10-12 19:52:04 +0000163 "core/fxcrt",
thestig73c48562016-09-06 14:07:17 -0700164 ]
Tom Sepeza8a39e22015-10-12 15:47:07 -0700165
Lei Zhangd7f51c72018-10-15 17:47:57 +0000166 if (pdf_enable_xfa) {
167 deps += [
168 "fpdfsdk/fpdfxfa",
169 "xfa/fxfa",
170 "xfa/fxfa/parser",
171 ]
Lei Zhangd7f51c72018-10-15 17:47:57 +0000172 }
173
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700174 if (is_win) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400175 libs += [
176 "advapi32.lib",
177 "gdi32.lib",
178 "user32.lib",
179 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700180 }
181
182 if (is_mac) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400183 libs += [
184 "AppKit.framework",
185 "CoreFoundation.framework",
186 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700187 }
John Abd-El-Malekef4dce42015-02-02 16:52:07 -0800188
dan sinclairfa171d22017-03-26 22:38:17 -0400189 if (pdf_is_complete_lib) {
Daniel Hosseinian1d0d0be2019-11-04 21:22:24 +0000190 static_component_type = "static_library"
dan sinclairfa171d22017-03-26 22:38:17 -0400191 complete_static_lib = true
Tom Andersonda89ac42018-03-21 03:56:15 +0000192 configs -= [ "//build/config/compiler:thin_archive" ]
dan sinclairfa171d22017-03-26 22:38:17 -0400193 }
Tom Anderson93101062019-05-07 02:08:43 +0000194
195 if (is_component_build) {
196 deps += [ "testing/fuzzers:fuzzer_impls" ]
197 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700198}
199
Tom Sepezd831dc72015-10-19 16:04:22 -0700200# Targets below this are only visible within this file (and to the
201# top-level gn_visibility target used to help gn_all build everything).
202visibility = [
203 ":*",
204 "//:gn_visibility",
205]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700206
Lei Zhangf03f7812018-10-15 23:48:29 +0000207group("pdfium_unittest_deps") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000208 testonly = true
Lei Zhangf03f7812018-10-15 23:48:29 +0000209 public_deps = [
210 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000211 "testing:test_support",
Tom Sepez16b9d772017-04-17 09:07:48 -0700212 "//testing/gmock",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500213 "//testing/gtest",
Tom Sepez04681f32015-01-09 13:59:19 -0800214 ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000215 visibility += [
216 "core/*",
217 "fpdfsdk/*",
218 "fxbarcode/*",
219 "fxjs/*",
220 "xfa/*",
221 ]
222}
223
224test("pdfium_unittests") {
225 testonly = true
Lei Zhang40f9d722020-01-24 00:18:11 +0000226 sources = [ "testing/unit_test_main.cpp" ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000227 deps = [
228 "core/fdrm:unittests",
229 "core/fpdfapi/edit:unittests",
230 "core/fpdfapi/font:unittests",
231 "core/fpdfapi/page:unittests",
232 "core/fpdfapi/parser:unittests",
Lei Zhangac520152018-11-09 22:58:56 +0000233 "core/fpdfapi/render:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000234 "core/fpdfdoc:unittests",
235 "core/fpdftext:unittests",
236 "core/fxcodec:unittests",
237 "core/fxcrt",
238 "core/fxcrt:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000239 "core/fxge:unittests",
240 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000241 "testing:test_support",
Lei Zhang220ef3d2019-02-05 20:40:54 +0000242 "testing:unit_test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000243 "//testing/gmock",
244 "//testing/gtest",
245 ]
246 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000247
248 if (is_android) {
249 use_raw_android_executable = true
250 }
251
252 if (pdf_enable_v8) {
253 configs += [ "//v8:external_startup_data" ]
254 deps += [
255 "fxjs:unittests",
256 "//v8",
257 ]
258 }
259
Tom Sepezd2e023b2015-12-08 14:36:16 -0800260 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000261 deps += [
262 "fxbarcode:unittests",
263 "xfa/fde:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000264 "xfa/fgas:unittests",
Lei Zhanga0c36802018-12-15 01:00:05 +0000265 "xfa/fgas/layout:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000266 "xfa/fxfa:unittests",
267 "xfa/fxfa/fm2js:unittests",
268 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800269 ]
270 }
Tom Sepez04681f32015-01-09 13:59:19 -0800271}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800272
Lei Zhang1929d6e2018-10-15 23:51:28 +0000273group("pdfium_embeddertest_deps") {
274 testonly = true
275 public_deps = [
276 ":pdfium_public_headers",
277 "core/fxcrt",
278 "testing:embedder_test_support",
279 "testing:test_support",
Lei Zhangfc455492019-06-14 17:16:09 +0000280 "third_party:pdfium_base_test_support",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000281 "//testing/gmock",
282 "//testing/gtest",
283 ]
284 visibility += [
285 "core/*",
286 "fpdfsdk/*",
287 "fxjs/*",
288 "xfa/*",
289 ]
290}
291
Tom Sepez1b1bb492015-01-22 17:36:32 -0800292test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000293 testonly = true
Lei Zhang40f9d722020-01-24 00:18:11 +0000294 sources = [ "testing/embedder_test_main.cpp" ]
Tom Sepez1b1bb492015-01-22 17:36:32 -0800295 deps = [
Lei Zhang1929d6e2018-10-15 23:51:28 +0000296 "core/fpdfapi/edit:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000297 "core/fpdfapi/parser:embeddertests",
298 "core/fpdfapi/render:embeddertests",
299 "core/fxcodec:embeddertests",
Tom Anderson0db20e02019-05-14 22:38:47 +0000300 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000301 "core/fxge:embeddertests",
302 "fpdfsdk:embeddertests",
303 "fpdfsdk/pwl:embeddertests",
304 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000305 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500306 "//testing/gmock",
307 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800308 ]
dsinclair685bb882016-04-20 07:32:39 -0700309 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700310 configs += [ ":pdfium_core_config" ]
311
Lei Zhanga996ff42018-10-15 23:49:48 +0000312 if (is_android) {
313 ignore_all_data_deps = true
314 use_raw_android_executable = true
315 }
316
Tom Sepez452b4f32015-10-13 09:27:27 -0700317 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000318 deps += [
319 "fxjs:embeddertests",
320 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800321 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100322 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700323 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000324
Dan Sinclair14aacd52017-05-18 14:11:29 -0400325 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000326 deps += [
Lei Zhang83458252019-03-14 20:07:20 +0000327 "fpdfsdk/fpdfxfa:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000328 "xfa/fwl:embeddertests",
Tom Sepez6e4710a2019-05-08 17:23:18 +0000329 "xfa/fxfa/layout:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000330 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400331 ]
332 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800333}
dsinclair685bb882016-04-20 07:32:39 -0700334
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000335executable("pdfium_diff") {
336 testonly = true
Lei Zhang40f9d722020-01-24 00:18:11 +0000337 sources = [ "testing/image_diff/image_diff.cpp" ]
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000338 deps = [
339 ":pdfium",
Tom Anderson93101062019-05-07 02:08:43 +0000340 "core/fxcrt",
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000341 "testing/image_diff",
342 "//build/win:default_exe_manifest",
343 ]
344 configs -= [ "//build/config/compiler:chromium_code" ]
345 configs += [ "//build/config/compiler:no_chromium_code" ]
346 configs += [ ":pdfium_core_config" ]
347}
348
dsinclair685bb882016-04-20 07:32:39 -0700349if (pdf_is_standalone) {
Daniel Hosseinian0fab9e62019-11-01 19:31:49 +0000350 source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700351 testonly = true
Lei Zhang40f9d722020-01-24 00:18:11 +0000352 deps = [ "//samples" ]
dsinclair685bb882016-04-20 07:32:39 -0700353 }
Lei Zhang143959d2017-06-22 12:20:58 -0700354
thestig62114cf2016-11-08 12:59:30 -0800355 group("fuzzers") {
356 testonly = true
Lei Zhang40f9d722020-01-24 00:18:11 +0000357 deps = [ "//testing/fuzzers" ]
thestig62114cf2016-11-08 12:59:30 -0800358 }
dsinclair685bb882016-04-20 07:32:39 -0700359}
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700360
361group("pdfium_all") {
362 testonly = true
363 deps = [
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000364 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700365 ":pdfium_embeddertests",
366 ":pdfium_unittests",
367 ]
368 if (pdf_is_standalone) {
369 deps += [
370 ":fuzzers",
371 ":samples",
372 ]
373 }
374}