blob: 3a2cf0a8fd91611fab1533eeda03b60f5ec4274b [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-Malekef4dce42015-02-02 16:52:07 -080023 "OPJ_STATIC",
John Abd-El-Malek385729b2015-02-06 15:51:11 -080024 "PNG_PREFIX",
John Abd-El-Malek385729b2015-02-06 15:51:11 -080025 "PNG_USE_READ_MACROS",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070026 ]
27
Ryan Harrison9ce75b82018-06-06 19:45:14 +000028 if (pdf_enable_click_logging) {
29 defines += [ "PDF_ENABLE_CLICK_LOGGING" ]
30 }
31
Lei Zhang75a486e2018-11-30 00:04:23 +000032 if (pdf_use_skia) {
33 defines += [ "_SKIA_SUPPORT_" ]
34 }
35
36 if (pdf_use_skia_paths) {
37 defines += [ "_SKIA_SUPPORT_PATHS_" ]
38 }
39
40 if (is_win) {
41 # Assume UTF-8 by default to avoid code page dependencies.
42 cflags += [ "/utf-8" ]
43 }
44}
45
46config("pdfium_public_config") {
47 defines = []
48
49 if (pdf_enable_v8) {
50 defines += [ "PDF_ENABLE_V8" ]
Lei Zhang75a486e2018-11-30 00:04:23 +000051
Lei Zhang7b5740a2018-11-30 19:02:59 +000052 if (pdf_enable_xfa) {
53 defines += [ "PDF_ENABLE_XFA" ]
54 if (pdf_enable_xfa_bmp) {
55 defines += [ "PDF_ENABLE_XFA_BMP" ]
56 }
57 if (pdf_enable_xfa_gif) {
58 defines += [ "PDF_ENABLE_XFA_GIF" ]
59 }
60 if (pdf_enable_xfa_png) {
61 defines += [ "PDF_ENABLE_XFA_PNG" ]
62 }
63 if (pdf_enable_xfa_tiff) {
64 defines += [ "PDF_ENABLE_XFA_TIFF" ]
65 }
Tom Sepez73c9f3b2017-02-27 10:12:59 -080066 }
Tom Sepeza8a39e22015-10-12 15:47:07 -070067 }
thestig3e454bf2016-07-29 16:29:04 -070068
69 if (pdf_use_win32_gdi) {
70 defines += [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
71 }
weili0abe6522016-06-06 14:41:22 -070072}
Tom Sepeza8a39e22015-10-12 15:47:07 -070073
weili0abe6522016-06-06 14:41:22 -070074config("pdfium_core_config") {
75 cflags = []
Lei Zhang75a486e2018-11-30 00:04:23 +000076 configs = [
77 ":pdfium_common_config",
78 ":pdfium_public_config",
79 ]
dsinclair8bd9ce02016-06-09 13:24:34 -070080 defines = [ "V8_DEPRECATION_WARNINGS" ]
Ryan Harrison3a3a3692018-08-23 21:12:35 +000081 if (is_clang) {
82 cflags += [ "-Wshadow" ]
83 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070084 if (is_linux) {
Tom Sepez25d5be62015-06-18 17:44:29 -070085 if (current_cpu == "x64") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070086 defines += [ "_FX_CPU_=_FX_X64_" ]
87 cflags += [ "-fPIC" ]
Tom Sepez25d5be62015-06-18 17:44:29 -070088 } else if (current_cpu == "x86") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070089 defines += [ "_FX_CPU_=_FX_X86_" ]
90 }
91 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070092 if (is_win) {
Tom Sepez3bb57512017-03-28 14:09:43 -070093 cflags += [
Tom Sepez5171a272017-06-01 12:29:09 -070094 "/wd4324",
Tom Sepez3bb57512017-03-28 14:09:43 -070095 "/wd4577",
96 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070097 }
Will Harrisb6dbcb22018-08-29 23:28:23 +000098 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
weilidcc29b12016-05-27 17:58:23 -070099}
Lei Zhang476ac132015-11-05 20:07:27 -0800100
Lei Zhang1987bbf2018-10-15 23:12:06 +0000101jumbo_source_set("pdfium_public_headers") {
102 sources = [
103 "public/cpp/fpdf_deleters.h",
104 "public/cpp/fpdf_scopers.h",
105 "public/fpdf_annot.h",
106 "public/fpdf_attachment.h",
107 "public/fpdf_catalog.h",
108 "public/fpdf_dataavail.h",
109 "public/fpdf_doc.h",
110 "public/fpdf_edit.h",
111 "public/fpdf_ext.h",
112 "public/fpdf_flatten.h",
113 "public/fpdf_formfill.h",
114 "public/fpdf_fwlevent.h",
115 "public/fpdf_ppo.h",
116 "public/fpdf_progressive.h",
117 "public/fpdf_save.h",
118 "public/fpdf_searchex.h",
119 "public/fpdf_structtree.h",
120 "public/fpdf_sysfontinfo.h",
121 "public/fpdf_text.h",
122 "public/fpdf_transformpage.h",
123 "public/fpdfview.h",
124 ]
Lei Zhang75a486e2018-11-30 00:04:23 +0000125
126 public_configs = [ ":pdfium_public_config" ]
Lei Zhang1987bbf2018-10-15 23:12:06 +0000127}
128
Lei Zhang81a1ac42017-12-21 21:49:55 -0800129jumbo_static_library("pdfium") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700130 sources = [
Dan Sinclair971a6742018-03-28 19:23:25 +0000131 "fpdfsdk/fpdf_annot.cpp",
132 "fpdfsdk/fpdf_attachment.cpp",
133 "fpdfsdk/fpdf_catalog.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400134 "fpdfsdk/fpdf_dataavail.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000135 "fpdfsdk/fpdf_doc.cpp",
136 "fpdfsdk/fpdf_editimg.cpp",
137 "fpdfsdk/fpdf_editpage.cpp",
138 "fpdfsdk/fpdf_editpath.cpp",
139 "fpdfsdk/fpdf_edittext.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400140 "fpdfsdk/fpdf_ext.cpp",
141 "fpdfsdk/fpdf_flatten.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000142 "fpdfsdk/fpdf_formfill.cpp",
Lei Zhangf7c84e92018-02-02 00:01:39 +0000143 "fpdfsdk/fpdf_ppo.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400144 "fpdfsdk/fpdf_progressive.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000145 "fpdfsdk/fpdf_save.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400146 "fpdfsdk/fpdf_searchex.cpp",
thestig9067fd62016-11-23 14:10:06 -0800147 "fpdfsdk/fpdf_structtree.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400148 "fpdfsdk/fpdf_sysfontinfo.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000149 "fpdfsdk/fpdf_text.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400150 "fpdfsdk/fpdf_transformpage.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000151 "fpdfsdk/fpdf_view.cpp",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700152 ]
153
154 libs = []
weili0abe6522016-06-06 14:41:22 -0700155 configs += [ ":pdfium_core_config" ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700156
157 deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000158 ":pdfium_public_headers",
Lei Zhang76833a62018-10-12 18:53:17 +0000159 "constants",
Lei Zhang84600882018-10-12 18:58:21 +0000160 "core/fdrm",
161 "core/fpdfapi",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000162 "core/fpdfapi/edit",
163 "core/fpdfapi/font",
164 "core/fpdfapi/page",
165 "core/fpdfapi/parser",
166 "core/fpdfapi/render",
Lei Zhang84600882018-10-12 18:58:21 +0000167 "core/fpdfdoc",
168 "core/fpdftext",
169 "core/fxcodec",
Lei Zhang995374a2018-10-12 19:52:04 +0000170 "core/fxcrt",
Lei Zhang84600882018-10-12 18:58:21 +0000171 "core/fxge",
Lei Zhangdcab8cf2018-10-12 18:39:56 +0000172 "fpdfsdk",
173 "fpdfsdk/formfiller",
Lei Zhanga7dec322018-10-12 18:36:51 +0000174 "fxjs",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500175 "third_party:pdfium_base",
Dan Sinclair844d79e2018-02-16 03:46:26 +0000176 "third_party:skia_shared",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700177 ]
178
thestig73c48562016-09-06 14:07:17 -0700179 public_deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000180 ":pdfium_public_headers",
Lei Zhang995374a2018-10-12 19:52:04 +0000181 "core/fxcrt",
thestig73c48562016-09-06 14:07:17 -0700182 ]
Tom Sepeza8a39e22015-10-12 15:47:07 -0700183
Lei Zhangd7f51c72018-10-15 17:47:57 +0000184 if (pdf_enable_xfa) {
185 deps += [
186 "fpdfsdk/fpdfxfa",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000187 "fxbarcode",
Lei Zhangd7f51c72018-10-15 17:47:57 +0000188 "xfa/fxfa",
189 "xfa/fxfa/parser",
190 ]
Lei Zhangd7f51c72018-10-15 17:47:57 +0000191 }
192
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700193 if (is_win) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400194 libs += [
195 "advapi32.lib",
196 "gdi32.lib",
197 "user32.lib",
198 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700199 }
200
201 if (is_mac) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400202 libs += [
203 "AppKit.framework",
204 "CoreFoundation.framework",
205 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700206 }
John Abd-El-Malekef4dce42015-02-02 16:52:07 -0800207
dan sinclairfa171d22017-03-26 22:38:17 -0400208 if (pdf_is_complete_lib) {
209 complete_static_lib = true
Tom Andersonda89ac42018-03-21 03:56:15 +0000210 configs -= [ "//build/config/compiler:thin_archive" ]
dan sinclairfa171d22017-03-26 22:38:17 -0400211 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700212}
213
Tom Sepezd831dc72015-10-19 16:04:22 -0700214# Targets below this are only visible within this file (and to the
215# top-level gn_visibility target used to help gn_all build everything).
216visibility = [
217 ":*",
218 "//:gn_visibility",
219]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700220
Lei Zhangf03f7812018-10-15 23:48:29 +0000221group("pdfium_unittest_deps") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000222 testonly = true
Lei Zhangf03f7812018-10-15 23:48:29 +0000223 public_deps = [
224 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000225 "testing:test_support",
Tom Sepez16b9d772017-04-17 09:07:48 -0700226 "//testing/gmock",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500227 "//testing/gtest",
Tom Sepez04681f32015-01-09 13:59:19 -0800228 ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000229 visibility += [
230 "core/*",
231 "fpdfsdk/*",
232 "fxbarcode/*",
233 "fxjs/*",
234 "xfa/*",
235 ]
236}
237
238test("pdfium_unittests") {
239 testonly = true
240 sources = [
241 "testing/unit_test_main.cpp",
242 ]
243 deps = [
244 "core/fdrm:unittests",
245 "core/fpdfapi/edit:unittests",
246 "core/fpdfapi/font:unittests",
247 "core/fpdfapi/page:unittests",
248 "core/fpdfapi/parser:unittests",
Lei Zhangac520152018-11-09 22:58:56 +0000249 "core/fpdfapi/render:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000250 "core/fpdfdoc:unittests",
251 "core/fpdftext:unittests",
252 "core/fxcodec:unittests",
253 "core/fxcrt",
254 "core/fxcrt:unittests",
255 "core/fxge",
256 "core/fxge:unittests",
257 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000258 "testing:test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000259 "//testing/gmock",
260 "//testing/gtest",
261 ]
262 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000263
264 if (is_android) {
265 use_raw_android_executable = true
266 }
267
268 if (pdf_enable_v8) {
269 configs += [ "//v8:external_startup_data" ]
270 deps += [
271 "fxjs:unittests",
272 "//v8",
273 ]
274 }
275
Tom Sepezd2e023b2015-12-08 14:36:16 -0800276 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000277 deps += [
278 "fxbarcode:unittests",
279 "xfa/fde:unittests",
280 "xfa/fgas",
281 "xfa/fgas:unittests",
Lei Zhanga0c36802018-12-15 01:00:05 +0000282 "xfa/fgas/layout:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000283 "xfa/fwl:unittests",
284 "xfa/fxfa:unittests",
285 "xfa/fxfa/fm2js:unittests",
286 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800287 ]
288 }
Tom Sepez04681f32015-01-09 13:59:19 -0800289}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800290
Lei Zhang1929d6e2018-10-15 23:51:28 +0000291group("pdfium_embeddertest_deps") {
292 testonly = true
293 public_deps = [
294 ":pdfium_public_headers",
295 "core/fxcrt",
296 "testing:embedder_test_support",
297 "testing:test_support",
298 "//testing/gmock",
299 "//testing/gtest",
300 ]
301 visibility += [
302 "core/*",
303 "fpdfsdk/*",
304 "fxjs/*",
305 "xfa/*",
306 ]
307}
308
Tom Sepez1b1bb492015-01-22 17:36:32 -0800309test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000310 testonly = true
Tom Sepez1b1bb492015-01-22 17:36:32 -0800311 sources = [
Dan Sinclair5553d8b2018-01-03 09:44:28 -0500312 "testing/embedder_test_main.cpp",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800313 ]
314 deps = [
Tom Sepez452b4f32015-10-13 09:27:27 -0700315 ":pdfium",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000316 "core/fpdfapi/edit:embeddertests",
317 "core/fpdfapi/page:embeddertests",
318 "core/fpdfapi/parser:embeddertests",
319 "core/fpdfapi/render:embeddertests",
320 "core/fxcodec:embeddertests",
321 "core/fxge:embeddertests",
322 "fpdfsdk:embeddertests",
323 "fpdfsdk/pwl:embeddertests",
324 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000325 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500326 "//testing/gmock",
327 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800328 ]
dsinclair685bb882016-04-20 07:32:39 -0700329 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700330 configs += [ ":pdfium_core_config" ]
331
Lei Zhanga996ff42018-10-15 23:49:48 +0000332 if (is_android) {
333 ignore_all_data_deps = true
334 use_raw_android_executable = true
335 }
336
Tom Sepez452b4f32015-10-13 09:27:27 -0700337 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000338 deps += [
339 "fxjs:embeddertests",
340 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800341 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100342 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700343 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000344
Dan Sinclair14aacd52017-05-18 14:11:29 -0400345 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000346 deps += [
347 "xfa/fwl:embeddertests",
348 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400349 ]
350 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800351}
dsinclair685bb882016-04-20 07:32:39 -0700352
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000353executable("pdfium_diff") {
354 testonly = true
355 sources = [
356 "testing/image_diff/image_diff.cpp",
357 ]
358 deps = [
359 ":pdfium",
360 "testing/image_diff",
361 "//build/win:default_exe_manifest",
362 ]
363 configs -= [ "//build/config/compiler:chromium_code" ]
364 configs += [ "//build/config/compiler:no_chromium_code" ]
365 configs += [ ":pdfium_core_config" ]
366}
367
dsinclair685bb882016-04-20 07:32:39 -0700368if (pdf_is_standalone) {
Lei Zhang0a624272018-10-11 16:58:32 +0000369 jumbo_source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700370 testonly = true
371 deps = [
372 "//samples",
373 ]
374 }
Lei Zhang143959d2017-06-22 12:20:58 -0700375
thestig62114cf2016-11-08 12:59:30 -0800376 group("fuzzers") {
377 testonly = true
378 deps = [
Lei Zhangfa4d93a2018-05-25 21:47:19 +0000379 "//testing/fuzzers",
thestig62114cf2016-11-08 12:59:30 -0800380 ]
381 }
dsinclair685bb882016-04-20 07:32:39 -0700382}
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700383
384group("pdfium_all") {
385 testonly = true
386 deps = [
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000387 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700388 ":pdfium_embeddertests",
389 ":pdfium_unittests",
390 ]
391 if (pdf_is_standalone) {
392 deps += [
393 ":fuzzers",
394 ":samples",
395 ]
396 }
397}