blob: e9a87e03c41aed3211418d290463d6c1545bcbf9 [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
Tom Sepez452b4f32015-10-13 09:27:27 -070028 if (pdf_enable_v8) {
29 defines += [ "PDF_ENABLE_V8" ]
30 }
31
Ryan Harrison9ce75b82018-06-06 19:45:14 +000032 if (pdf_enable_click_logging) {
33 defines += [ "PDF_ENABLE_CLICK_LOGGING" ]
34 }
35
Tom Sepeza8a39e22015-10-12 15:47:07 -070036 if (pdf_enable_xfa) {
37 defines += [ "PDF_ENABLE_XFA" ]
Tom Sepez73c9f3b2017-02-27 10:12:59 -080038 if (pdf_enable_xfa_bmp) {
39 defines += [ "PDF_ENABLE_XFA_BMP" ]
40 }
41 if (pdf_enable_xfa_gif) {
42 defines += [ "PDF_ENABLE_XFA_GIF" ]
43 }
44 if (pdf_enable_xfa_png) {
45 defines += [ "PDF_ENABLE_XFA_PNG" ]
46 }
47 if (pdf_enable_xfa_tiff) {
48 defines += [ "PDF_ENABLE_XFA_TIFF" ]
49 }
Tom Sepeza8a39e22015-10-12 15:47:07 -070050 }
thestig3e454bf2016-07-29 16:29:04 -070051
Lei Zhang360edeb2017-12-19 18:06:35 +000052 if (pdf_use_skia) {
53 defines += [ "_SKIA_SUPPORT_" ]
54 }
55
56 if (pdf_use_skia_paths) {
57 defines += [ "_SKIA_SUPPORT_PATHS_" ]
58 }
59
thestig3e454bf2016-07-29 16:29:04 -070060 if (pdf_use_win32_gdi) {
61 defines += [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
62 }
dsinclair6e162b52017-01-24 11:18:16 -080063
Dan Sinclair77e2a6c2017-03-13 09:35:12 -040064 if (is_win) {
65 # Assume UTF-8 by default to avoid code page dependencies.
66 cflags += [ "/utf-8" ]
67 }
weili0abe6522016-06-06 14:41:22 -070068}
Tom Sepeza8a39e22015-10-12 15:47:07 -070069
weili0abe6522016-06-06 14:41:22 -070070config("pdfium_core_config") {
71 cflags = []
dsinclair8bd9ce02016-06-09 13:24:34 -070072 configs = [ ":pdfium_common_config" ]
73 defines = [ "V8_DEPRECATION_WARNINGS" ]
Ryan Harrison3a3a3692018-08-23 21:12:35 +000074 if (is_clang) {
75 cflags += [ "-Wshadow" ]
76 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070077 if (is_linux) {
Tom Sepez25d5be62015-06-18 17:44:29 -070078 if (current_cpu == "x64") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070079 defines += [ "_FX_CPU_=_FX_X64_" ]
80 cflags += [ "-fPIC" ]
Tom Sepez25d5be62015-06-18 17:44:29 -070081 } else if (current_cpu == "x86") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070082 defines += [ "_FX_CPU_=_FX_X86_" ]
83 }
84 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070085 if (is_win) {
Tom Sepez3bb57512017-03-28 14:09:43 -070086 cflags += [
Tom Sepez5171a272017-06-01 12:29:09 -070087 "/wd4324",
Tom Sepez3bb57512017-03-28 14:09:43 -070088 "/wd4577",
89 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -070090 }
Will Harrisb6dbcb22018-08-29 23:28:23 +000091 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
weilidcc29b12016-05-27 17:58:23 -070092}
Lei Zhang476ac132015-11-05 20:07:27 -080093
Lei Zhang1987bbf2018-10-15 23:12:06 +000094jumbo_source_set("pdfium_public_headers") {
95 sources = [
96 "public/cpp/fpdf_deleters.h",
97 "public/cpp/fpdf_scopers.h",
98 "public/fpdf_annot.h",
99 "public/fpdf_attachment.h",
100 "public/fpdf_catalog.h",
101 "public/fpdf_dataavail.h",
102 "public/fpdf_doc.h",
103 "public/fpdf_edit.h",
104 "public/fpdf_ext.h",
105 "public/fpdf_flatten.h",
106 "public/fpdf_formfill.h",
107 "public/fpdf_fwlevent.h",
108 "public/fpdf_ppo.h",
109 "public/fpdf_progressive.h",
110 "public/fpdf_save.h",
111 "public/fpdf_searchex.h",
112 "public/fpdf_structtree.h",
113 "public/fpdf_sysfontinfo.h",
114 "public/fpdf_text.h",
115 "public/fpdf_transformpage.h",
116 "public/fpdfview.h",
117 ]
118}
119
Lei Zhang81a1ac42017-12-21 21:49:55 -0800120jumbo_static_library("pdfium") {
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700121 sources = [
Dan Sinclair971a6742018-03-28 19:23:25 +0000122 "fpdfsdk/fpdf_annot.cpp",
123 "fpdfsdk/fpdf_attachment.cpp",
124 "fpdfsdk/fpdf_catalog.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400125 "fpdfsdk/fpdf_dataavail.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000126 "fpdfsdk/fpdf_doc.cpp",
127 "fpdfsdk/fpdf_editimg.cpp",
128 "fpdfsdk/fpdf_editpage.cpp",
129 "fpdfsdk/fpdf_editpath.cpp",
130 "fpdfsdk/fpdf_edittext.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400131 "fpdfsdk/fpdf_ext.cpp",
132 "fpdfsdk/fpdf_flatten.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000133 "fpdfsdk/fpdf_formfill.cpp",
Lei Zhangf7c84e92018-02-02 00:01:39 +0000134 "fpdfsdk/fpdf_ppo.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400135 "fpdfsdk/fpdf_progressive.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000136 "fpdfsdk/fpdf_save.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400137 "fpdfsdk/fpdf_searchex.cpp",
thestig9067fd62016-11-23 14:10:06 -0800138 "fpdfsdk/fpdf_structtree.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400139 "fpdfsdk/fpdf_sysfontinfo.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000140 "fpdfsdk/fpdf_text.cpp",
Dan Sinclairf766ad22016-03-14 13:51:24 -0400141 "fpdfsdk/fpdf_transformpage.cpp",
Dan Sinclair971a6742018-03-28 19:23:25 +0000142 "fpdfsdk/fpdf_view.cpp",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700143 ]
144
145 libs = []
weili0abe6522016-06-06 14:41:22 -0700146 configs += [ ":pdfium_core_config" ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700147
148 deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000149 ":pdfium_public_headers",
Lei Zhang76833a62018-10-12 18:53:17 +0000150 "constants",
Lei Zhang84600882018-10-12 18:58:21 +0000151 "core/fdrm",
152 "core/fpdfapi",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000153 "core/fpdfapi/edit",
154 "core/fpdfapi/font",
155 "core/fpdfapi/page",
156 "core/fpdfapi/parser",
157 "core/fpdfapi/render",
Lei Zhang84600882018-10-12 18:58:21 +0000158 "core/fpdfdoc",
159 "core/fpdftext",
160 "core/fxcodec",
Lei Zhang995374a2018-10-12 19:52:04 +0000161 "core/fxcrt",
Lei Zhang84600882018-10-12 18:58:21 +0000162 "core/fxge",
Lei Zhangdcab8cf2018-10-12 18:39:56 +0000163 "fpdfsdk",
164 "fpdfsdk/formfiller",
165 "fpdfsdk/pwl",
Lei Zhanga7dec322018-10-12 18:36:51 +0000166 "fxjs",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500167 "third_party:pdfium_base",
Dan Sinclair844d79e2018-02-16 03:46:26 +0000168 "third_party:skia_shared",
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700169 ]
170
thestig73c48562016-09-06 14:07:17 -0700171 public_deps = [
Lei Zhang1987bbf2018-10-15 23:12:06 +0000172 ":pdfium_public_headers",
Lei Zhang995374a2018-10-12 19:52:04 +0000173 "core/fxcrt",
thestig73c48562016-09-06 14:07:17 -0700174 ]
Tom Sepeza8a39e22015-10-12 15:47:07 -0700175
Lei Zhangd7f51c72018-10-15 17:47:57 +0000176 if (pdf_enable_xfa) {
177 deps += [
178 "fpdfsdk/fpdfxfa",
Lei Zhang21ce4ff2018-10-15 18:30:49 +0000179 "fxbarcode",
Lei Zhangd7f51c72018-10-15 17:47:57 +0000180 "xfa/fxfa",
181 "xfa/fxfa/parser",
182 ]
Lei Zhangd7f51c72018-10-15 17:47:57 +0000183 }
184
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700185 if (is_win) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400186 libs += [
187 "advapi32.lib",
188 "gdi32.lib",
189 "user32.lib",
190 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700191 }
192
193 if (is_mac) {
Dan Sinclairbc6c6722015-10-22 14:58:54 -0400194 libs += [
195 "AppKit.framework",
196 "CoreFoundation.framework",
197 ]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700198 }
John Abd-El-Malekef4dce42015-02-02 16:52:07 -0800199
dan sinclairfa171d22017-03-26 22:38:17 -0400200 if (pdf_is_complete_lib) {
201 complete_static_lib = true
Tom Andersonda89ac42018-03-21 03:56:15 +0000202 configs -= [ "//build/config/compiler:thin_archive" ]
dan sinclairfa171d22017-03-26 22:38:17 -0400203 }
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700204}
205
Tom Sepezd831dc72015-10-19 16:04:22 -0700206# Targets below this are only visible within this file (and to the
207# top-level gn_visibility target used to help gn_all build everything).
208visibility = [
209 ":*",
210 "//:gn_visibility",
211]
John Abd-El-Malekd68f9a32014-06-05 12:45:33 -0700212
Lei Zhangf03f7812018-10-15 23:48:29 +0000213group("pdfium_unittest_deps") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000214 testonly = true
Lei Zhangf03f7812018-10-15 23:48:29 +0000215 public_deps = [
216 "core/fxcrt",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000217 "testing:test_support",
Tom Sepez16b9d772017-04-17 09:07:48 -0700218 "//testing/gmock",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500219 "//testing/gtest",
Tom Sepez04681f32015-01-09 13:59:19 -0800220 ]
Lei Zhangf03f7812018-10-15 23:48:29 +0000221 visibility += [
222 "core/*",
223 "fpdfsdk/*",
224 "fxbarcode/*",
225 "fxjs/*",
226 "xfa/*",
227 ]
228}
229
230test("pdfium_unittests") {
231 testonly = true
232 sources = [
233 "testing/unit_test_main.cpp",
234 ]
235 deps = [
236 "core/fdrm:unittests",
237 "core/fpdfapi/edit:unittests",
238 "core/fpdfapi/font:unittests",
239 "core/fpdfapi/page:unittests",
240 "core/fpdfapi/parser:unittests",
Lei Zhangac520152018-11-09 22:58:56 +0000241 "core/fpdfapi/render:unittests",
Lei Zhangf03f7812018-10-15 23:48:29 +0000242 "core/fpdfdoc:unittests",
243 "core/fpdftext:unittests",
244 "core/fxcodec:unittests",
245 "core/fxcrt",
246 "core/fxcrt:unittests",
247 "core/fxge",
248 "core/fxge:unittests",
249 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000250 "testing:test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000251 "//testing/gmock",
252 "//testing/gtest",
253 ]
254 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000255
256 if (is_android) {
257 use_raw_android_executable = true
258 }
259
260 if (pdf_enable_v8) {
261 configs += [ "//v8:external_startup_data" ]
262 deps += [
263 "fxjs:unittests",
264 "//v8",
265 ]
266 }
267
Tom Sepezd2e023b2015-12-08 14:36:16 -0800268 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000269 deps += [
270 "fxbarcode:unittests",
271 "xfa/fde:unittests",
272 "xfa/fgas",
273 "xfa/fgas:unittests",
274 "xfa/fwl:unittests",
275 "xfa/fxfa:unittests",
276 "xfa/fxfa/fm2js:unittests",
277 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800278 ]
279 }
Tom Sepez04681f32015-01-09 13:59:19 -0800280}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800281
Lei Zhang1929d6e2018-10-15 23:51:28 +0000282group("pdfium_embeddertest_deps") {
283 testonly = true
284 public_deps = [
285 ":pdfium_public_headers",
286 "core/fxcrt",
287 "testing:embedder_test_support",
288 "testing:test_support",
289 "//testing/gmock",
290 "//testing/gtest",
291 ]
292 visibility += [
293 "core/*",
294 "fpdfsdk/*",
295 "fxjs/*",
296 "xfa/*",
297 ]
298}
299
Tom Sepez1b1bb492015-01-22 17:36:32 -0800300test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000301 testonly = true
Tom Sepez1b1bb492015-01-22 17:36:32 -0800302 sources = [
Dan Sinclair5553d8b2018-01-03 09:44:28 -0500303 "testing/embedder_test_main.cpp",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800304 ]
305 deps = [
Tom Sepez452b4f32015-10-13 09:27:27 -0700306 ":pdfium",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000307 "core/fpdfapi/edit:embeddertests",
308 "core/fpdfapi/page:embeddertests",
309 "core/fpdfapi/parser:embeddertests",
310 "core/fpdfapi/render:embeddertests",
311 "core/fxcodec:embeddertests",
312 "core/fxge:embeddertests",
313 "fpdfsdk:embeddertests",
314 "fpdfsdk/pwl:embeddertests",
315 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000316 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500317 "//testing/gmock",
318 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800319 ]
dsinclair685bb882016-04-20 07:32:39 -0700320 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700321 configs += [ ":pdfium_core_config" ]
322
Lei Zhanga996ff42018-10-15 23:49:48 +0000323 if (is_android) {
324 ignore_all_data_deps = true
325 use_raw_android_executable = true
326 }
327
Tom Sepez452b4f32015-10-13 09:27:27 -0700328 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000329 deps += [
330 "fxjs:embeddertests",
331 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800332 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100333 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700334 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000335
Dan Sinclair14aacd52017-05-18 14:11:29 -0400336 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000337 deps += [
338 "xfa/fwl:embeddertests",
339 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400340 ]
341 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800342}
dsinclair685bb882016-04-20 07:32:39 -0700343
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000344executable("pdfium_diff") {
345 testonly = true
346 sources = [
347 "testing/image_diff/image_diff.cpp",
348 ]
349 deps = [
350 ":pdfium",
351 "testing/image_diff",
352 "//build/win:default_exe_manifest",
353 ]
354 configs -= [ "//build/config/compiler:chromium_code" ]
355 configs += [ "//build/config/compiler:no_chromium_code" ]
356 configs += [ ":pdfium_core_config" ]
357}
358
dsinclair685bb882016-04-20 07:32:39 -0700359if (pdf_is_standalone) {
Lei Zhang0a624272018-10-11 16:58:32 +0000360 jumbo_source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700361 testonly = true
362 deps = [
363 "//samples",
364 ]
365 }
Lei Zhang143959d2017-06-22 12:20:58 -0700366
thestig62114cf2016-11-08 12:59:30 -0800367 group("fuzzers") {
368 testonly = true
369 deps = [
Lei Zhangfa4d93a2018-05-25 21:47:19 +0000370 "//testing/fuzzers",
thestig62114cf2016-11-08 12:59:30 -0800371 ]
372 }
dsinclair685bb882016-04-20 07:32:39 -0700373}
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700374
375group("pdfium_all") {
376 testonly = true
377 deps = [
Tom Sepez1d78f4d2018-10-22 20:17:38 +0000378 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700379 ":pdfium_embeddertests",
380 ":pdfium_unittests",
381 ]
382 if (pdf_is_standalone) {
383 deps += [
384 ":fuzzers",
385 ":samples",
386 ]
387 }
388}