blob: f27a2f4c1b1d2eec7ef94fca585eba89f2419edd [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") {
134 public_deps = [
135 ":pdfium_public_headers_impl",
136 ]
137 public_configs = [
138 ":pdfium_public_config",
139 ":pdfium_implementation_config",
140 ]
Lei Zhang1987bbf2018-10-15 23:12:06 +0000141}
142
Daniel Hosseinian0fab9e62019-11-01 19:31:49 +0000143component("pdfium") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700144 libs = []
weili0abe6522016-06-06 14:41:22 -0700145 configs += [ ":pdfium_core_config" ]
Tom Anderson0db20e02019-05-14 22:38:47 +0000146 public_configs = [ ":pdfium_public_config" ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700147
148 deps = [
Lei Zhang76833a62018-10-12 18:53:17 +0000149 "constants",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000150 "core/fpdfapi/page",
151 "core/fpdfapi/parser",
Lei Zhang84600882018-10-12 18:58:21 +0000152 "core/fpdfdoc",
Lei Zhang84600882018-10-12 18:58:21 +0000153 "core/fxcodec",
Lei Zhang995374a2018-10-12 19:52:04 +0000154 "core/fxcrt",
Lei Zhang84600882018-10-12 18:58:21 +0000155 "core/fxge",
Lei Zhangdcab8cf2018-10-12 18:39:56 +0000156 "fpdfsdk",
157 "fpdfsdk/formfiller",
Lei Zhanga7dec322018-10-12 18:36:51 +0000158 "fxjs",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500159 "third_party:pdfium_base",
Dan Sinclair844d79e2018-02-16 03:46:26 +0000160 "third_party:skia_shared",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700161 ]
162
thestig73c48562016-09-06 14:07:17 -0700163 public_deps = [
Tom Anderson0db20e02019-05-14 22:38:47 +0000164 ":pdfium_public_headers_impl",
Lei Zhang995374a2018-10-12 19:52:04 +0000165 "core/fxcrt",
thestig73c48562016-09-06 14:07:17 -0700166 ]
Tom Sepeza8a39e22015-10-12 15:47:07 -0700167
Lei Zhangd7f51c72018-10-15 17:47:57 +0000168 if (pdf_enable_xfa) {
169 deps += [
170 "fpdfsdk/fpdfxfa",
171 "xfa/fxfa",
172 "xfa/fxfa/parser",
173 ]
Lei Zhangd7f51c72018-10-15 17:47:57 +0000174 }
175
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700176 if (is_win) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400177 libs += [
178 "advapi32.lib",
179 "gdi32.lib",
180 "user32.lib",
181 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700182 }
183
184 if (is_mac) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400185 libs += [
186 "AppKit.framework",
187 "CoreFoundation.framework",
188 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700189 }
John Abd-El-Malekef4dce42015-02-02 16:52:07 -0800190
dan sinclairfa171d22017-03-26 22:38:17 -0400191 if (pdf_is_complete_lib) {
Daniel Hosseinian1d0d0be2019-11-04 21:22:24 +0000192 static_component_type = "static_library"
dan sinclairfa171d22017-03-26 22:38:17 -0400193 complete_static_lib = true
Tom Andersonda89ac42018-03-21 03:56:15 +0000194 configs -= [ "//build/config/compiler:thin_archive" ]
dan sinclairfa171d22017-03-26 22:38:17 -0400195 }
Tom Anderson93101062019-05-07 02:08:43 +0000196
197 if (is_component_build) {
198 deps += [ "testing/fuzzers:fuzzer_impls" ]
199 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700200}
201
Tom Sepezd831dc72015-10-19 16:04:22 -0700202# Targets below this are only visible within this file (and to the
203# top-level gn_visibility target used to help gn_all build everything).
204visibility = [
205 ":*",
206 "//:gn_visibility",
207]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700208
Lei Zhangf03f7812018-10-15 23:48:29 +0000209group("pdfium_unittest_deps") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000210 testonly = true
Lei Zhangf03f7812018-10-15 23:48:29 +0000211 public_deps = [
212 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000213 "testing:test_support",
Tom Sepez16b9d772017-04-17 09:07:48 -0700214 "//testing/gmock",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500215 "//testing/gtest",
Tom Sepez04681f32015-01-09 13:59:19 -0800216 ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000217 visibility += [
218 "core/*",
219 "fpdfsdk/*",
220 "fxbarcode/*",
221 "fxjs/*",
222 "xfa/*",
223 ]
224}
225
226test("pdfium_unittests") {
227 testonly = true
228 sources = [
229 "testing/unit_test_main.cpp",
230 ]
231 deps = [
232 "core/fdrm:unittests",
233 "core/fpdfapi/edit:unittests",
234 "core/fpdfapi/font:unittests",
235 "core/fpdfapi/page:unittests",
236 "core/fpdfapi/parser:unittests",
Lei Zhangac520152018-11-09 22:58:56 +0000237 "core/fpdfapi/render:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000238 "core/fpdfdoc:unittests",
239 "core/fpdftext:unittests",
240 "core/fxcodec:unittests",
241 "core/fxcrt",
242 "core/fxcrt:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000243 "core/fxge:unittests",
244 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000245 "testing:test_support",
Lei Zhang220ef3d2019-02-05 20:40:54 +0000246 "testing:unit_test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000247 "//testing/gmock",
248 "//testing/gtest",
249 ]
250 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000251
252 if (is_android) {
253 use_raw_android_executable = true
254 }
255
256 if (pdf_enable_v8) {
257 configs += [ "//v8:external_startup_data" ]
258 deps += [
259 "fxjs:unittests",
260 "//v8",
261 ]
262 }
263
Tom Sepezd2e023b2015-12-08 14:36:16 -0800264 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000265 deps += [
266 "fxbarcode:unittests",
267 "xfa/fde:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000268 "xfa/fgas:unittests",
Lei Zhanga0c36802018-12-15 01:00:05 +0000269 "xfa/fgas/layout:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000270 "xfa/fwl:unittests",
271 "xfa/fxfa:unittests",
272 "xfa/fxfa/fm2js:unittests",
273 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800274 ]
275 }
Tom Sepez04681f32015-01-09 13:59:19 -0800276}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800277
Lei Zhang1929d6e2018-10-15 23:51:28 +0000278group("pdfium_embeddertest_deps") {
279 testonly = true
280 public_deps = [
281 ":pdfium_public_headers",
282 "core/fxcrt",
283 "testing:embedder_test_support",
284 "testing:test_support",
Lei Zhangfc455492019-06-14 17:16:09 +0000285 "third_party:pdfium_base_test_support",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000286 "//testing/gmock",
287 "//testing/gtest",
288 ]
289 visibility += [
290 "core/*",
291 "fpdfsdk/*",
292 "fxjs/*",
293 "xfa/*",
294 ]
295}
296
Tom Sepez1b1bb492015-01-22 17:36:32 -0800297test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000298 testonly = true
Tom Sepez1b1bb492015-01-22 17:36:32 -0800299 sources = [
Dan Sinclair5553d8b2018-01-03 09:44:28 -0500300 "testing/embedder_test_main.cpp",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800301 ]
302 deps = [
Lei Zhang1929d6e2018-10-15 23:51:28 +0000303 "core/fpdfapi/edit:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000304 "core/fpdfapi/parser:embeddertests",
305 "core/fpdfapi/render:embeddertests",
306 "core/fxcodec:embeddertests",
Tom Anderson0db20e02019-05-14 22:38:47 +0000307 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000308 "core/fxge:embeddertests",
309 "fpdfsdk:embeddertests",
310 "fpdfsdk/pwl:embeddertests",
311 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000312 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500313 "//testing/gmock",
314 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800315 ]
dsinclair685bb882016-04-20 07:32:39 -0700316 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700317 configs += [ ":pdfium_core_config" ]
318
Lei Zhanga996ff42018-10-15 23:49:48 +0000319 if (is_android) {
320 ignore_all_data_deps = true
321 use_raw_android_executable = true
322 }
323
Tom Sepez452b4f32015-10-13 09:27:27 -0700324 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000325 deps += [
326 "fxjs:embeddertests",
327 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800328 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100329 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700330 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000331
Dan Sinclair14aacd52017-05-18 14:11:29 -0400332 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000333 deps += [
Lei Zhang83458252019-03-14 20:07:20 +0000334 "fpdfsdk/fpdfxfa:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000335 "xfa/fwl:embeddertests",
Tom Sepez6e4710a2019-05-08 17:23:18 +0000336 "xfa/fxfa/layout:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000337 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400338 ]
339 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800340}
dsinclair685bb882016-04-20 07:32:39 -0700341
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000342executable("pdfium_diff") {
343 testonly = true
344 sources = [
345 "testing/image_diff/image_diff.cpp",
346 ]
347 deps = [
348 ":pdfium",
Tom Anderson93101062019-05-07 02:08:43 +0000349 "core/fxcrt",
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000350 "testing/image_diff",
351 "//build/win:default_exe_manifest",
352 ]
353 configs -= [ "//build/config/compiler:chromium_code" ]
354 configs += [ "//build/config/compiler:no_chromium_code" ]
355 configs += [ ":pdfium_core_config" ]
356}
357
dsinclair685bb882016-04-20 07:32:39 -0700358if (pdf_is_standalone) {
Daniel Hosseinian0fab9e62019-11-01 19:31:49 +0000359 source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700360 testonly = true
361 deps = [
362 "//samples",
363 ]
364 }
Lei Zhang143959d2017-06-22 12:20:58 -0700365
thestig62114cf2016-11-08 12:59:30 -0800366 group("fuzzers") {
367 testonly = true
368 deps = [
Lei Zhangfa4d93a2018-05-25 21:47:19 +0000369 "//testing/fuzzers",
thestig62114cf2016-11-08 12:59:30 -0800370 ]
371 }
dsinclair685bb882016-04-20 07:32:39 -0700372}
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700373
374group("pdfium_all") {
375 testonly = true
376 deps = [
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000377 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700378 ":pdfium_embeddertests",
379 ":pdfium_unittests",
380 ]
381 if (pdf_is_standalone) {
382 deps += [
383 ":fuzzers",
384 ":samples",
385 ]
386 }
387}