• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//testing/test.gni")
6import("pdfium.gni")
7
8group("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
17config("pdfium_common_config") {
18  cflags = []
19  ldflags = []
20  include_dirs = [ "." ]
21  defines = [
22    "PNG_PREFIX",
23    "PNG_USE_READ_MACROS",
24  ]
25
26  if (!use_system_libopenjpeg2) {
27    defines += [ "OPJ_STATIC" ]
28  }
29
30  if (pdf_enable_click_logging) {
31    defines += [ "PDF_ENABLE_CLICK_LOGGING" ]
32  }
33
34  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
48config("pdfium_implementation_config") {
49  defines = [ "FPDF_IMPLEMENTATION" ]
50  visibility = [ ":pdfium_public_headers" ]
51}
52
53config("pdfium_public_config") {
54  defines = []
55
56  if (pdf_enable_v8) {
57    defines += [ "PDF_ENABLE_V8" ]
58
59    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      }
73    }
74  }
75
76  if (pdf_use_win32_gdi) {
77    defines += [ "PDFIUM_PRINT_TEXT_WITH_GDI" ]
78  }
79}
80
81config("pdfium_core_config") {
82  cflags = []
83  configs = [
84    ":pdfium_common_config",
85    ":pdfium_public_config",
86    "//build/config/compiler:noshadowing",
87  ]
88  defines = []
89  if (is_linux) {
90    if (current_cpu == "x64") {
91      defines += [ "_FX_CPU_=_FX_X64_" ]
92      cflags += [ "-fPIC" ]
93    } else if (current_cpu == "x86") {
94      defines += [ "_FX_CPU_=_FX_X86_" ]
95    }
96  }
97  if (is_win) {
98    cflags += [
99      "/wd4324",
100      "/wd4577",
101    ]
102  }
103  configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
104}
105
106source_set("pdfium_public_headers_impl") {
107  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",
120    "public/fpdf_javascript.h",
121    "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  ]
131}
132
133group("pdfium_public_headers") {
134  public_deps = [ ":pdfium_public_headers_impl" ]
135  public_configs = [
136    ":pdfium_public_config",
137    ":pdfium_implementation_config",
138  ]
139}
140
141component("pdfium") {
142  libs = []
143  configs += [ ":pdfium_core_config" ]
144  public_configs = [ ":pdfium_public_config" ]
145
146  deps = [
147    "constants",
148    "core/fpdfapi/page",
149    "core/fpdfapi/parser",
150    "core/fpdfdoc",
151    "core/fxcodec",
152    "core/fxcrt",
153    "core/fxge",
154    "fpdfsdk",
155    "fpdfsdk/formfiller",
156    "fxjs",
157    "third_party:pdfium_base",
158    "third_party:skia_shared",
159  ]
160
161  public_deps = [
162    ":pdfium_public_headers_impl",
163    "core/fxcrt",
164  ]
165
166  if (pdf_enable_xfa) {
167    deps += [
168      "fpdfsdk/fpdfxfa",
169      "xfa/fxfa",
170      "xfa/fxfa/parser",
171    ]
172  }
173
174  if (is_win) {
175    libs += [
176      "advapi32.lib",
177      "gdi32.lib",
178      "user32.lib",
179    ]
180  }
181
182  if (is_mac) {
183    libs += [
184      "AppKit.framework",
185      "CoreFoundation.framework",
186    ]
187  }
188
189  if (pdf_is_complete_lib) {
190    static_component_type = "static_library"
191    complete_static_lib = true
192    configs -= [ "//build/config/compiler:thin_archive" ]
193  }
194
195  if (is_component_build) {
196    deps += [ "testing/fuzzers:fuzzer_impls" ]
197  }
198}
199
200# Targets below this are only visible within this file (and to the
201# top-level gn_visibility target used to help gn_all build everything).
202visibility = [
203  ":*",
204  "//:gn_visibility",
205]
206
207group("pdfium_unittest_deps") {
208  testonly = true
209  public_deps = [
210    "core/fxcrt",
211    "testing:test_support",
212    "//testing/gmock",
213    "//testing/gtest",
214  ]
215  visibility += [
216    "core/*",
217    "fpdfsdk/*",
218    "fxbarcode/*",
219    "fxjs/*",
220    "xfa/*",
221  ]
222}
223
224test("pdfium_unittests") {
225  testonly = true
226  sources = [ "testing/unit_test_main.cpp" ]
227  deps = [
228    "core/fdrm:unittests",
229    "core/fpdfapi/edit:unittests",
230    "core/fpdfapi/font:unittests",
231    "core/fpdfapi/page:unittests",
232    "core/fpdfapi/parser:unittests",
233    "core/fpdfapi/render:unittests",
234    "core/fpdfdoc:unittests",
235    "core/fpdftext:unittests",
236    "core/fxcodec:unittests",
237    "core/fxcrt",
238    "core/fxcrt:unittests",
239    "core/fxge:unittests",
240    "fpdfsdk:unittests",
241    "testing:test_support",
242    "testing:unit_test_support",
243    "//testing/gmock",
244    "//testing/gtest",
245  ]
246  configs += [ ":pdfium_core_config" ]
247
248  if (is_android) {
249    use_raw_android_executable = true
250  }
251
252  if (pdf_enable_v8) {
253    configs += [ "//v8:external_startup_data" ]
254    deps += [
255      "fxjs:unittests",
256      "//v8",
257    ]
258  }
259
260  if (pdf_enable_xfa) {
261    deps += [
262      "fxbarcode:unittests",
263      "xfa/fde:unittests",
264      "xfa/fgas:unittests",
265      "xfa/fgas/layout:unittests",
266      "xfa/fxfa:unittests",
267      "xfa/fxfa/fm2js:unittests",
268      "xfa/fxfa/parser:unittests",
269    ]
270  }
271}
272
273group("pdfium_embeddertest_deps") {
274  testonly = true
275  public_deps = [
276    ":pdfium_public_headers",
277    "core/fxcrt",
278    "testing:embedder_test_support",
279    "testing:test_support",
280    "third_party:pdfium_base_test_support",
281    "//testing/gmock",
282    "//testing/gtest",
283  ]
284  visibility += [
285    "core/*",
286    "fpdfsdk/*",
287    "fxjs/*",
288    "xfa/*",
289  ]
290}
291
292test("pdfium_embeddertests") {
293  testonly = true
294  sources = [ "testing/embedder_test_main.cpp" ]
295  deps = [
296    "core/fpdfapi/edit:embeddertests",
297    "core/fpdfapi/parser:embeddertests",
298    "core/fpdfapi/render:embeddertests",
299    "core/fxcodec:embeddertests",
300    "core/fxcrt",
301    "core/fxge:embeddertests",
302    "fpdfsdk:embeddertests",
303    "fpdfsdk/pwl:embeddertests",
304    "testing:test_support",
305    "testing/image_diff",
306    "//testing/gmock",
307    "//testing/gtest",
308  ]
309  include_dirs = [ "testing/gmock/include" ]
310  configs += [ ":pdfium_core_config" ]
311
312  if (is_android) {
313    ignore_all_data_deps = true
314    use_raw_android_executable = true
315  }
316
317  if (pdf_enable_v8) {
318    deps += [
319      "fxjs:embeddertests",
320      "//v8",
321    ]
322    configs += [ "//v8:external_startup_data" ]
323  }
324
325  if (pdf_enable_xfa) {
326    deps += [
327      "fpdfsdk/fpdfxfa:embeddertests",
328      "xfa/fwl:embeddertests",
329      "xfa/fxfa/layout:embeddertests",
330      "xfa/fxfa/parser:embeddertests",
331    ]
332  }
333}
334
335executable("pdfium_diff") {
336  testonly = true
337  sources = [ "testing/image_diff/image_diff.cpp" ]
338  deps = [
339    ":pdfium",
340    "core/fxcrt",
341    "testing/image_diff",
342    "//build/win:default_exe_manifest",
343  ]
344  configs -= [ "//build/config/compiler:chromium_code" ]
345  configs += [ "//build/config/compiler:no_chromium_code" ]
346  configs += [ ":pdfium_core_config" ]
347}
348
349if (pdf_is_standalone) {
350  source_set("samples") {
351    testonly = true
352    deps = [ "//samples" ]
353  }
354
355  group("fuzzers") {
356    testonly = true
357    deps = [ "//testing/fuzzers" ]
358  }
359}
360
361group("pdfium_all") {
362  testonly = true
363  deps = [
364    ":pdfium_diff",
365    ":pdfium_embeddertests",
366    ":pdfium_unittests",
367  ]
368  if (pdf_is_standalone) {
369    deps += [
370      ":fuzzers",
371      ":samples",
372    ]
373  }
374}
375