blob: 97dfbd6ad0941da3964a05db05edf9df2e5fb7fa [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" ]
86 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070087 if (is_linux) {
Tom Sepez25d5be62015-06-18 17:44:29 -070088 if (current_cpu == "x64") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070089 defines += [ "_FX_CPU_=_FX_X64_" ]
90 cflags += [ "-fPIC" ]
Tom Sepez25d5be62015-06-18 17:44:29 -070091 } else if (current_cpu == "x86") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070092 defines += [ "_FX_CPU_=_FX_X86_" ]
93 }
94 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070095 if (is_win) {
Tom Sepez3bb57512017-03-28 14:09:43 -070096 cflags += [
Tom Sepez5171a272017-06-01 12:29:09 -070097 "/wd4324",
Tom Sepez3bb57512017-03-28 14:09:43 -070098 "/wd4577",
99 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700100 }
Will Harrisb6dbcb22018-08-29 23:28:23 +0000101 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
weilidcc29b12016-05-27 17:58:23 -0700102}
Lei Zhang476ac132015-11-05 20:07:27 -0800103
Lei Zhang1987bbf2018-10-15 23:12:06 +0000104jumbo_source_set("pdfium_public_headers") {
105 sources = [
106 "public/cpp/fpdf_deleters.h",
107 "public/cpp/fpdf_scopers.h",
108 "public/fpdf_annot.h",
109 "public/fpdf_attachment.h",
110 "public/fpdf_catalog.h",
111 "public/fpdf_dataavail.h",
112 "public/fpdf_doc.h",
113 "public/fpdf_edit.h",
114 "public/fpdf_ext.h",
115 "public/fpdf_flatten.h",
116 "public/fpdf_formfill.h",
117 "public/fpdf_fwlevent.h",
118 "public/fpdf_ppo.h",
119 "public/fpdf_progressive.h",
120 "public/fpdf_save.h",
121 "public/fpdf_searchex.h",
122 "public/fpdf_structtree.h",
123 "public/fpdf_sysfontinfo.h",
124 "public/fpdf_text.h",
125 "public/fpdf_transformpage.h",
126 "public/fpdfview.h",
127 ]
Lei Zhang75a486e2018-11-30 00:04:23 +0000128
129 public_configs = [ ":pdfium_public_config" ]
Lei Zhang1987bbf2018-10-15 23:12:06 +0000130}
131
Tom Anderson93101062019-05-07 02:08:43 +0000132jumbo_component("pdfium") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700133 sources = [
Dan Sinclair971a6742018-03-28 19:23:25 +0000134 "fpdfsdk/fpdf_annot.cpp",
135 "fpdfsdk/fpdf_attachment.cpp",
136 "fpdfsdk/fpdf_catalog.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400137 "fpdfsdk/fpdf_dataavail.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000138 "fpdfsdk/fpdf_doc.cpp",
139 "fpdfsdk/fpdf_editimg.cpp",
140 "fpdfsdk/fpdf_editpage.cpp",
141 "fpdfsdk/fpdf_editpath.cpp",
142 "fpdfsdk/fpdf_edittext.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400143 "fpdfsdk/fpdf_ext.cpp",
144 "fpdfsdk/fpdf_flatten.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000145 "fpdfsdk/fpdf_formfill.cpp",
Lei Zhangf7c84e92018-02-02 00:01:39 +0000146 "fpdfsdk/fpdf_ppo.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400147 "fpdfsdk/fpdf_progressive.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000148 "fpdfsdk/fpdf_save.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400149 "fpdfsdk/fpdf_searchex.cpp",
thestig9067fd62016-11-23 14:10:06 -0800150 "fpdfsdk/fpdf_structtree.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400151 "fpdfsdk/fpdf_sysfontinfo.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000152 "fpdfsdk/fpdf_text.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400153 "fpdfsdk/fpdf_transformpage.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000154 "fpdfsdk/fpdf_view.cpp",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700155 ]
156
157 libs = []
weili0abe6522016-06-06 14:41:22 -0700158 configs += [ ":pdfium_core_config" ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700159
160 deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000161 ":pdfium_public_headers",
Lei Zhang76833a62018-10-12 18:53:17 +0000162 "constants",
Lei Zhang84600882018-10-12 18:58:21 +0000163 "core/fdrm",
164 "core/fpdfapi",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000165 "core/fpdfapi/edit",
166 "core/fpdfapi/font",
167 "core/fpdfapi/page",
168 "core/fpdfapi/parser",
169 "core/fpdfapi/render",
Lei Zhang84600882018-10-12 18:58:21 +0000170 "core/fpdfdoc",
171 "core/fpdftext",
172 "core/fxcodec",
Lei Zhang995374a2018-10-12 19:52:04 +0000173 "core/fxcrt",
Lei Zhang84600882018-10-12 18:58:21 +0000174 "core/fxge",
Lei Zhangdcab8cf2018-10-12 18:39:56 +0000175 "fpdfsdk",
176 "fpdfsdk/formfiller",
Lei Zhanga7dec322018-10-12 18:36:51 +0000177 "fxjs",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500178 "third_party:pdfium_base",
Dan Sinclair844d79e2018-02-16 03:46:26 +0000179 "third_party:skia_shared",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700180 ]
181
thestig73c48562016-09-06 14:07:17 -0700182 public_deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000183 ":pdfium_public_headers",
Lei Zhang995374a2018-10-12 19:52:04 +0000184 "core/fxcrt",
thestig73c48562016-09-06 14:07:17 -0700185 ]
Tom Sepeza8a39e22015-10-12 15:47:07 -0700186
Tom Anderson93101062019-05-07 02:08:43 +0000187 defines = [ "FPDF_IMPLEMENTATION" ]
188
Lei Zhangd7f51c72018-10-15 17:47:57 +0000189 if (pdf_enable_xfa) {
190 deps += [
191 "fpdfsdk/fpdfxfa",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000192 "fxbarcode",
Lei Zhangd7f51c72018-10-15 17:47:57 +0000193 "xfa/fxfa",
194 "xfa/fxfa/parser",
195 ]
Lei Zhangd7f51c72018-10-15 17:47:57 +0000196 }
197
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700198 if (is_win) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400199 libs += [
200 "advapi32.lib",
201 "gdi32.lib",
202 "user32.lib",
203 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700204 }
205
206 if (is_mac) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400207 libs += [
208 "AppKit.framework",
209 "CoreFoundation.framework",
210 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700211 }
John Abd-El-Malekef4dce42015-02-02 16:52:07 -0800212
dan sinclairfa171d22017-03-26 22:38:17 -0400213 if (pdf_is_complete_lib) {
214 complete_static_lib = true
Tom Andersonda89ac42018-03-21 03:56:15 +0000215 configs -= [ "//build/config/compiler:thin_archive" ]
dan sinclairfa171d22017-03-26 22:38:17 -0400216 }
Tom Anderson93101062019-05-07 02:08:43 +0000217
218 if (is_component_build) {
219 deps += [ "testing/fuzzers:fuzzer_impls" ]
220 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700221}
222
Tom Sepezd831dc72015-10-19 16:04:22 -0700223# Targets below this are only visible within this file (and to the
224# top-level gn_visibility target used to help gn_all build everything).
225visibility = [
226 ":*",
227 "//:gn_visibility",
228]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700229
Lei Zhangf03f7812018-10-15 23:48:29 +0000230group("pdfium_unittest_deps") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000231 testonly = true
Lei Zhangf03f7812018-10-15 23:48:29 +0000232 public_deps = [
233 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000234 "testing:test_support",
Tom Sepez16b9d772017-04-17 09:07:48 -0700235 "//testing/gmock",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500236 "//testing/gtest",
Tom Sepez04681f32015-01-09 13:59:19 -0800237 ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000238 visibility += [
239 "core/*",
240 "fpdfsdk/*",
241 "fxbarcode/*",
242 "fxjs/*",
243 "xfa/*",
244 ]
245}
246
247test("pdfium_unittests") {
248 testonly = true
249 sources = [
250 "testing/unit_test_main.cpp",
251 ]
252 deps = [
253 "core/fdrm:unittests",
254 "core/fpdfapi/edit:unittests",
255 "core/fpdfapi/font:unittests",
256 "core/fpdfapi/page:unittests",
257 "core/fpdfapi/parser:unittests",
Lei Zhangac520152018-11-09 22:58:56 +0000258 "core/fpdfapi/render:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000259 "core/fpdfdoc:unittests",
260 "core/fpdftext:unittests",
261 "core/fxcodec:unittests",
262 "core/fxcrt",
263 "core/fxcrt:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000264 "core/fxge:unittests",
265 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000266 "testing:test_support",
Lei Zhang220ef3d2019-02-05 20:40:54 +0000267 "testing:unit_test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000268 "//testing/gmock",
269 "//testing/gtest",
270 ]
271 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000272
273 if (is_android) {
274 use_raw_android_executable = true
275 }
276
277 if (pdf_enable_v8) {
278 configs += [ "//v8:external_startup_data" ]
279 deps += [
280 "fxjs:unittests",
281 "//v8",
282 ]
283 }
284
Tom Sepezd2e023b2015-12-08 14:36:16 -0800285 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000286 deps += [
287 "fxbarcode:unittests",
288 "xfa/fde:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000289 "xfa/fgas:unittests",
Lei Zhanga0c36802018-12-15 01:00:05 +0000290 "xfa/fgas/layout:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000291 "xfa/fwl:unittests",
292 "xfa/fxfa:unittests",
293 "xfa/fxfa/fm2js:unittests",
294 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800295 ]
296 }
Tom Sepez04681f32015-01-09 13:59:19 -0800297}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800298
Lei Zhang1929d6e2018-10-15 23:51:28 +0000299group("pdfium_embeddertest_deps") {
300 testonly = true
301 public_deps = [
302 ":pdfium_public_headers",
303 "core/fxcrt",
304 "testing:embedder_test_support",
305 "testing:test_support",
306 "//testing/gmock",
307 "//testing/gtest",
308 ]
309 visibility += [
310 "core/*",
311 "fpdfsdk/*",
312 "fxjs/*",
313 "xfa/*",
314 ]
315}
316
Tom Sepez1b1bb492015-01-22 17:36:32 -0800317test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000318 testonly = true
Tom Sepez1b1bb492015-01-22 17:36:32 -0800319 sources = [
Dan Sinclair5553d8b2018-01-03 09:44:28 -0500320 "testing/embedder_test_main.cpp",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800321 ]
322 deps = [
Tom Sepez452b4f32015-10-13 09:27:27 -0700323 ":pdfium",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000324 "core/fpdfapi/edit:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000325 "core/fpdfapi/parser:embeddertests",
326 "core/fpdfapi/render:embeddertests",
327 "core/fxcodec:embeddertests",
328 "core/fxge:embeddertests",
329 "fpdfsdk:embeddertests",
330 "fpdfsdk/pwl:embeddertests",
331 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000332 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500333 "//testing/gmock",
334 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800335 ]
dsinclair685bb882016-04-20 07:32:39 -0700336 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700337 configs += [ ":pdfium_core_config" ]
338
Lei Zhanga996ff42018-10-15 23:49:48 +0000339 if (is_android) {
340 ignore_all_data_deps = true
341 use_raw_android_executable = true
342 }
343
Tom Sepez452b4f32015-10-13 09:27:27 -0700344 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000345 deps += [
346 "fxjs:embeddertests",
347 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800348 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100349 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700350 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000351
Dan Sinclair14aacd52017-05-18 14:11:29 -0400352 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000353 deps += [
Lei Zhang83458252019-03-14 20:07:20 +0000354 "fpdfsdk/fpdfxfa:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000355 "xfa/fwl:embeddertests",
Tom Sepez6e4710a2019-05-08 17:23:18 +0000356 "xfa/fxfa/layout:embeddertests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000357 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400358 ]
359 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800360}
dsinclair685bb882016-04-20 07:32:39 -0700361
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000362executable("pdfium_diff") {
363 testonly = true
364 sources = [
365 "testing/image_diff/image_diff.cpp",
366 ]
367 deps = [
368 ":pdfium",
Tom Anderson93101062019-05-07 02:08:43 +0000369 "core/fxcrt",
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000370 "testing/image_diff",
371 "//build/win:default_exe_manifest",
372 ]
373 configs -= [ "//build/config/compiler:chromium_code" ]
374 configs += [ "//build/config/compiler:no_chromium_code" ]
375 configs += [ ":pdfium_core_config" ]
376}
377
dsinclair685bb882016-04-20 07:32:39 -0700378if (pdf_is_standalone) {
Lei Zhang0a624272018-10-11 16:58:32 +0000379 jumbo_source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700380 testonly = true
381 deps = [
382 "//samples",
383 ]
384 }
Lei Zhang143959d2017-06-22 12:20:58 -0700385
thestig62114cf2016-11-08 12:59:30 -0800386 group("fuzzers") {
387 testonly = true
388 deps = [
Lei Zhangfa4d93a2018-05-25 21:47:19 +0000389 "//testing/fuzzers",
thestig62114cf2016-11-08 12:59:30 -0800390 ]
391 }
dsinclair685bb882016-04-20 07:32:39 -0700392}
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700393
394group("pdfium_all") {
395 testonly = true
396 deps = [
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000397 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700398 ":pdfium_embeddertests",
399 ":pdfium_unittests",
400 ]
401 if (pdf_is_standalone) {
402 deps += [
403 ":fuzzers",
404 ":samples",
405 ]
406 }
407}