blob: c19e2227a7449968dc964ff2f1d0235747885b7f [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",
241 "core/fpdfdoc:unittests",
242 "core/fpdftext:unittests",
243 "core/fxcodec:unittests",
244 "core/fxcrt",
245 "core/fxcrt:unittests",
246 "core/fxge",
247 "core/fxge:unittests",
248 "fpdfsdk:unittests",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000249 "testing:test_support",
Lei Zhangf03f7812018-10-15 23:48:29 +0000250 "//testing/gmock",
251 "//testing/gtest",
252 ]
253 configs += [ ":pdfium_core_config" ]
Lei Zhanga996ff42018-10-15 23:49:48 +0000254
255 if (is_android) {
256 use_raw_android_executable = true
257 }
258
259 if (pdf_enable_v8) {
260 configs += [ "//v8:external_startup_data" ]
261 deps += [
262 "fxjs:unittests",
263 "//v8",
264 ]
265 }
266
Tom Sepezd2e023b2015-12-08 14:36:16 -0800267 if (pdf_enable_xfa) {
Lei Zhangf03f7812018-10-15 23:48:29 +0000268 deps += [
269 "fxbarcode:unittests",
270 "xfa/fde:unittests",
271 "xfa/fgas",
272 "xfa/fgas:unittests",
273 "xfa/fwl:unittests",
274 "xfa/fxfa:unittests",
275 "xfa/fxfa/fm2js:unittests",
276 "xfa/fxfa/parser:unittests",
Tom Sepezd2e023b2015-12-08 14:36:16 -0800277 ]
278 }
Tom Sepez04681f32015-01-09 13:59:19 -0800279}
Tom Sepez1b1bb492015-01-22 17:36:32 -0800280
Lei Zhang1929d6e2018-10-15 23:51:28 +0000281group("pdfium_embeddertest_deps") {
282 testonly = true
283 public_deps = [
284 ":pdfium_public_headers",
285 "core/fxcrt",
286 "testing:embedder_test_support",
287 "testing:test_support",
288 "//testing/gmock",
289 "//testing/gtest",
290 ]
291 visibility += [
292 "core/*",
293 "fpdfsdk/*",
294 "fxjs/*",
295 "xfa/*",
296 ]
297}
298
Tom Sepez1b1bb492015-01-22 17:36:32 -0800299test("pdfium_embeddertests") {
Lei Zhangdbaf3b82018-10-11 17:02:43 +0000300 testonly = true
Tom Sepez1b1bb492015-01-22 17:36:32 -0800301 sources = [
Dan Sinclair5553d8b2018-01-03 09:44:28 -0500302 "testing/embedder_test_main.cpp",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800303 ]
304 deps = [
Tom Sepez452b4f32015-10-13 09:27:27 -0700305 ":pdfium",
Lei Zhang1929d6e2018-10-15 23:51:28 +0000306 "core/fpdfapi/edit:embeddertests",
307 "core/fpdfapi/page:embeddertests",
308 "core/fpdfapi/parser:embeddertests",
309 "core/fpdfapi/render:embeddertests",
310 "core/fxcodec:embeddertests",
311 "core/fxge:embeddertests",
312 "fpdfsdk:embeddertests",
313 "fpdfsdk/pwl:embeddertests",
314 "testing:test_support",
Lei Zhang76833a62018-10-12 18:53:17 +0000315 "testing/image_diff",
Dan Sinclairfffc9632016-03-08 08:57:05 -0500316 "//testing/gmock",
317 "//testing/gtest",
Tom Sepez1b1bb492015-01-22 17:36:32 -0800318 ]
dsinclair685bb882016-04-20 07:32:39 -0700319 include_dirs = [ "testing/gmock/include" ]
thestigc65e11e2016-08-30 21:56:33 -0700320 configs += [ ":pdfium_core_config" ]
321
Lei Zhanga996ff42018-10-15 23:49:48 +0000322 if (is_android) {
323 ignore_all_data_deps = true
324 use_raw_android_executable = true
325 }
326
Tom Sepez452b4f32015-10-13 09:27:27 -0700327 if (pdf_enable_v8) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000328 deps += [
329 "fxjs:embeddertests",
330 "//v8",
Lei Zhang1ac47eb2015-12-21 11:04:44 -0800331 ]
Jochen Eisinger7ed503d2015-12-10 14:38:06 +0100332 configs += [ "//v8:external_startup_data" ]
Tom Sepez452b4f32015-10-13 09:27:27 -0700333 }
Lei Zhanga996ff42018-10-15 23:49:48 +0000334
Dan Sinclair14aacd52017-05-18 14:11:29 -0400335 if (pdf_enable_xfa) {
Lei Zhang1929d6e2018-10-15 23:51:28 +0000336 deps += [
337 "xfa/fwl:embeddertests",
338 "xfa/fxfa/parser:embeddertests",
Dan Sinclair14aacd52017-05-18 14:11:29 -0400339 ]
340 }
Tom Sepez1b1bb492015-01-22 17:36:32 -0800341}
dsinclair685bb882016-04-20 07:32:39 -0700342
343if (pdf_is_standalone) {
Lei Zhang0a624272018-10-11 16:58:32 +0000344 jumbo_source_set("samples") {
dsinclair685bb882016-04-20 07:32:39 -0700345 testonly = true
346 deps = [
347 "//samples",
348 ]
349 }
Lei Zhang143959d2017-06-22 12:20:58 -0700350
351 executable("pdfium_diff") {
352 testonly = true
353 sources = [
354 "testing/image_diff/image_diff.cpp",
355 ]
356 deps = [
Lei Zhang143959d2017-06-22 12:20:58 -0700357 ":pdfium",
Lei Zhang76833a62018-10-12 18:53:17 +0000358 "testing/image_diff",
Lei Zhang143959d2017-06-22 12:20:58 -0700359 "//build/win:default_exe_manifest",
360 ]
361 configs -= [ "//build/config/compiler:chromium_code" ]
362 configs += [ "//build/config/compiler:no_chromium_code" ]
Ryan Harrison7b8f88a2017-07-13 16:05:31 -0400363 configs += [ ":pdfium_core_config" ]
Lei Zhang143959d2017-06-22 12:20:58 -0700364 }
365
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 = [
377 ":pdfium_embeddertests",
378 ":pdfium_unittests",
379 ]
380 if (pdf_is_standalone) {
381 deps += [
382 ":fuzzers",
Lei Zhang143959d2017-06-22 12:20:58 -0700383 ":pdfium_diff",
Lei Zhangf02c8bf2017-04-01 01:35:01 -0700384 ":samples",
385 ]
386 }
387}