blob: 39164b851c58b7534a98aaaf025c8245a607aa80 [file] [log] [blame]
[email protected]fc2020f2014-06-04 18:09:391# Copyright 2014 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
[email protected]a3c134352014-07-11 19:23:195import("//build/config/features.gni")
raphael.kubo.da.costa64f52802015-12-16 20:12:486import("//build/config/sysroot.gni")
[email protected]fc2020f2014-06-04 18:09:397import("//build/config/ui.gni")
brettwe5cc5c62016-12-14 05:27:188import("//pdf/features.gni")
Scott Violet318a55f2018-03-30 19:08:199import("//printing/buildflags/buildflags.gni")
qsrfb5251d12015-01-21 15:57:2210import("//testing/test.gni")
[email protected]fc2020f2014-06-04 18:09:3911if (is_mac) {
12 import("//build/config/mac/mac_sdk.gni")
13}
14if (is_android) {
15 import("//build/config/android/rules.gni")
16}
17
brettwe5cc5c62016-12-14 05:27:1818if ((enable_basic_printing && is_win) || enable_print_preview) {
19 # Windows basic printing or print preview requires pdf enabled.
20 assert(enable_pdf,
21 "Windows basic printing or print preview needs pdf: " +
22 "set enable_pdf=true.")
23}
24
[email protected]fc2020f2014-06-04 18:09:3925component("printing") {
26 sources = [
27 "backend/print_backend.cc",
28 "backend/print_backend.h",
29 "backend/print_backend_consts.cc",
30 "backend/print_backend_consts.h",
31 "backend/print_backend_dummy.cc",
32 "backend/printing_info_win.cc",
33 "backend/printing_info_win.h",
34 "emf_win.cc",
35 "emf_win.h",
vitalybuka5d1290582014-09-12 09:19:5936 "metafile.cc",
[email protected]fc2020f2014-06-04 18:09:3937 "metafile.h",
Wei Liab754772018-08-22 22:41:1738 "metafile_skia.cc",
39 "metafile_skia.h",
tfarinac75e1fb2017-05-10 21:21:1340 "native_drawing_context.h",
xloua4288122018-04-14 00:03:3341 "nup_parameters.cc",
42 "nup_parameters.h",
[email protected]fc2020f2014-06-04 18:09:3943 "page_number.cc",
44 "page_number.h",
45 "page_range.cc",
46 "page_range.h",
47 "page_setup.cc",
48 "page_setup.h",
[email protected]fc2020f2014-06-04 18:09:3949 "page_size_margins.h",
50 "pdf_metafile_cg_mac.cc",
51 "pdf_metafile_cg_mac.h",
tfarina4772a462017-03-25 02:26:1852 "pdf_render_settings.h",
[email protected]fc2020f2014-06-04 18:09:3953 "print_dialog_gtk_interface.h",
54 "print_job_constants.cc",
55 "print_job_constants.h",
56 "print_settings.cc",
57 "print_settings.h",
[email protected]c95198b2014-06-12 16:56:5558 "print_settings_conversion.cc",
59 "print_settings_conversion.h",
[email protected]fc2020f2014-06-04 18:09:3960 "print_settings_initializer_mac.cc",
61 "print_settings_initializer_mac.h",
62 "print_settings_initializer_win.cc",
63 "print_settings_initializer_win.h",
64 "printed_document.cc",
65 "printed_document.h",
[email protected]fc2020f2014-06-04 18:09:3966 "printed_document_mac.cc",
67 "printed_document_win.cc",
[email protected]fc2020f2014-06-04 18:09:3968 "printing_context.cc",
69 "printing_context.h",
tfarina4772a462017-03-25 02:26:1870 "printing_export.h",
[email protected]fc2020f2014-06-04 18:09:3971 "printing_utils.cc",
72 "printing_utils.h",
tfarina4772a462017-03-25 02:26:1873 "pwg_raster_settings.h",
[email protected]fc2020f2014-06-04 18:09:3974 "units.cc",
75 "units.h",
76 ]
77
78 cflags = []
79 defines = [ "PRINTING_IMPLEMENTATION" ]
80
Brett Wilson65f951c2016-11-03 22:06:1281 public_deps = [
Scott Violet318a55f2018-03-30 19:08:1982 "//printing/buildflags",
Brett Wilson65f951c2016-11-03 22:06:1283 ]
[email protected]fc2020f2014-06-04 18:09:3984 deps = [
85 "//base",
86 "//base:i18n",
87 "//base/third_party/dynamic_annotations",
enne7b64edf32017-02-16 20:10:0288 "//cc/paint",
weilifabbf7572017-05-22 19:05:1689 "//printing/common",
[email protected]fc2020f2014-06-04 18:09:3990 "//skia",
91 "//third_party/icu",
92 "//ui/gfx",
93 "//ui/gfx/geometry",
94 "//url",
95 ]
96
97 if (use_aura) {
[email protected]55699f392014-08-20 22:16:3098 deps += [ "//ui/aura" ]
[email protected]fc2020f2014-06-04 18:09:3999 }
100
101 if (is_mac) {
102 # Mac-Aura does not support printing.
103 if (use_aura) {
scottmg34fb7e52014-12-03 23:27:24104 sources -= [ "printed_document_mac.cc" ]
[email protected]fc2020f2014-06-04 18:09:39105 } else {
106 sources += [
[email protected]fc2020f2014-06-04 18:09:39107 "printing_context_mac.h",
scottmg7c7296f42015-02-28 02:23:09108 "printing_context_mac.mm",
[email protected]fc2020f2014-06-04 18:09:39109 ]
110 }
rsesek02aa51c2016-05-11 02:13:57111 libs = [
112 "AppKit.framework",
Sidney San Martína1bec15b2018-06-08 18:08:19113 "QuartzCore.framework",
rsesek02aa51c2016-05-11 02:13:57114 "ApplicationServices.framework",
115 "CoreFoundation.framework",
116 "CoreGraphics.framework",
117 ]
[email protected]fc2020f2014-06-04 18:09:39118 }
119
120 if (is_win) {
121 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation of the
122 # print backend and enables a custom implementation instead.
123 defines += [ "PRINT_BACKEND_AVAILABLE" ]
124 sources += [
scottmg7c7296f42015-02-28 02:23:09125 "backend/print_backend_win.cc",
[email protected]fc2020f2014-06-04 18:09:39126 "backend/win_helper.cc",
127 "backend/win_helper.h",
rbpotter80cbe042017-12-08 07:00:52128 "printed_page_win.cc",
129 "printed_page_win.h",
vchigrin52933522014-12-15 20:55:13130 "printing_context_system_dialog_win.cc",
131 "printing_context_system_dialog_win.h",
[email protected]fc2020f2014-06-04 18:09:39132 "printing_context_win.cc",
133 "printing_context_win.h",
134 ]
135 }
136
Jinsuk Kimfc9e3e82019-02-13 06:50:23137 if (is_android) {
138 deps += [ "//ui/android" ]
139 }
140
[email protected]fc2020f2014-06-04 18:09:39141 if (use_cups) {
[email protected]fc2020f2014-06-04 18:09:39142 configs += [ ":cups" ]
143
144 if (is_linux) {
agoodeed229712016-02-07 22:27:38145 # rebase_path does not accept an empty string
146 if (use_sysroot) {
147 cups_sysroot = rebase_path(sysroot)
148 } else {
149 cups_sysroot = ""
150 }
scottmg34fb7e52014-12-03 23:27:24151 cups_version = exec_script("cups_config_helper.py",
raphael.kubo.da.costa64f52802015-12-16 20:12:48152 [
153 "--api-version",
agoodeed229712016-02-07 22:27:38154 cups_sysroot,
raphael.kubo.da.costa64f52802015-12-16 20:12:48155 ],
[email protected]eae20a212014-08-19 23:04:54156 "trim string")
157
[email protected]fc2020f2014-06-04 18:09:39158 if (cups_version == "1.6" || cups_version == "1.7") {
159 cflags += [
160 # CUPS 1.6 deprecated the PPD APIs, but we will stay with this
161 # API for now as supported Linux and Mac OS'es are still using
162 # older versions of CUPS. More info: crbug.com/226176
163 "-Wno-deprecated-declarations",
164 # CUPS 1.7 deprecates httpConnectEncrypt(), see the mac section
165 # below.
166 ]
167 }
168 }
169
thakis6bbe18d2016-07-01 21:39:13170 if (is_mac) {
[email protected]fc2020f2014-06-04 18:09:39171 # The 10.9 SDK includes cups 1.7, which deprecates
172 # httpConnectEncrypt() in favor of httpConnect2(). hhttpConnect2()
173 # is new in 1.7, so it doesn't exist on OS X 10.6-10.8 and we
174 # can't use it until 10.9 is our minimum system version.
175 # (cups_version isn't reliable on OS X, so key the check off of
176 # mac_sdk).
thakis6bbe18d2016-07-01 21:39:13177 # With a 10.8 deployment target, several other APIs are deprecated.
178 # We're still on CUPS 1.4 until Linux no longer needs to support it, see
179 # comment above.
[email protected]fc2020f2014-06-04 18:09:39180 cflags += [ "-Wno-deprecated-declarations" ]
181 }
182
183 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
184 # of the print backend and enables a custom implementation instead.
185 defines += [ "PRINT_BACKEND_AVAILABLE" ]
186
skaub779ce62016-07-22 03:16:40187 if (is_chromeos) {
188 sources += [
189 "backend/cups_connection.cc",
190 "backend/cups_connection.h",
191 "backend/cups_deleters.cc",
192 "backend/cups_deleters.h",
193 "backend/cups_ipp_util.cc",
194 "backend/cups_ipp_util.h",
skaua26877d2017-03-11 00:12:29195 "backend/cups_jobs.cc",
196 "backend/cups_jobs.h",
skaub779ce62016-07-22 03:16:40197 "backend/cups_printer.cc",
198 "backend/cups_printer.h",
199 "backend/print_backend_cups_ipp.cc",
200 "backend/print_backend_cups_ipp.h",
skaub7931952016-07-27 18:04:51201 "printing_context_chromeos.cc",
202 "printing_context_chromeos.h",
skaub779ce62016-07-22 03:16:40203 ]
204 } else {
205 sources += [
206 "backend/cups_helper.cc",
207 "backend/cups_helper.h",
208 "backend/print_backend_cups.cc",
209 "backend/print_backend_cups.h",
210 ]
Luum Habtemariam90f8fec2019-02-26 00:45:56211
212 # We still build the utils for fuzzing.
213 if (use_fuzzing_engine) {
214 sources += [
215 "backend/cups_ipp_util.cc",
216 "backend/cups_ipp_util.h",
217 ]
218 }
skaub779ce62016-07-22 03:16:40219 }
[email protected]fc2020f2014-06-04 18:09:39220 }
221
222 if (is_chromeos) {
[email protected]fc2020f2014-06-04 18:09:39223 defines += [ "PRINT_BACKEND_AVAILABLE" ]
224
skau8ffe7752016-06-29 02:10:28225 sources += [
226 "backend/print_backend_chromeos.cc",
Vladislav Kuzkokov2385af92018-08-28 22:23:30227 "backend/printing_restrictions.cc",
228 "backend/printing_restrictions.h",
skaub7931952016-07-27 18:04:51229 "printed_document_chromeos.cc",
skau8ffe7752016-06-29 02:10:28230 "printing_context_no_system_dialog.cc",
231 "printing_context_no_system_dialog.h",
232 ]
Lei Zhang933d34b2017-11-13 20:59:29233 } else if (is_android) {
234 sources += [
Lei Zhang03f4a532019-01-23 18:46:31235 "printed_document_android.cc",
Lei Zhang933d34b2017-11-13 20:59:29236 "printing_context_android.cc",
237 "printing_context_android.h",
238 ]
239
240 deps += [ ":printing_jni_headers" ]
241 } else if (is_linux) { # Desktop Linux.
[email protected]fc2020f2014-06-04 18:09:39242 sources += [
skaub7931952016-07-27 18:04:51243 "printed_document_linux.cc",
[email protected]fc2020f2014-06-04 18:09:39244 "printing_context_linux.cc",
245 "printing_context_linux.h",
246 ]
247 }
[email protected]fc2020f2014-06-04 18:09:39248}
249
skaua1e0b7a62016-12-22 23:23:14250static_library("test_support") {
251 testonly = true
252 sources = [
253 "backend/test_print_backend.cc",
254 "backend/test_print_backend.h",
Sergey Ulanov6bf7985c2017-12-08 20:07:01255 "image.cc",
256 "image.h",
257 "image_android.cc",
258 "image_linux.cc",
259 "image_mac.cc",
260 "image_win.cc",
skaua1e0b7a62016-12-22 23:23:14261 ]
Sergey Ulanov6bf7985c2017-12-08 20:07:01262 if (is_fuchsia) {
263 sources += [ "image_fuchsia.cc" ]
264 }
265
skaua1e0b7a62016-12-22 23:23:14266 public_deps = [
267 "//printing",
Sergey Ulanov6bf7985c2017-12-08 20:07:01268 "//ui/gfx/geometry",
skaua1e0b7a62016-12-22 23:23:14269 ]
270 deps = [
271 "//base",
Sergey Ulanov6bf7985c2017-12-08 20:07:01272 "//skia",
273 "//ui/gfx",
skaua1e0b7a62016-12-22 23:23:14274 ]
275}
276
[email protected]fc2020f2014-06-04 18:09:39277test("printing_unittests") {
278 sources = [
279 "emf_win_unittest.cc",
Wei Liab754772018-08-22 22:41:17280 "metafile_skia_unittest.cc",
xloua4288122018-04-14 00:03:33281 "nup_parameters_unittest.cc",
[email protected]fc2020f2014-06-04 18:09:39282 "page_number_unittest.cc",
283 "page_range_unittest.cc",
284 "page_setup_unittest.cc",
285 "pdf_metafile_cg_mac_unittest.cc",
Vladislav Kuzkokov48b15002019-01-30 17:13:35286 "print_settings_conversion_unittest.cc",
[email protected]fc2020f2014-06-04 18:09:39287 "printing_context_win_unittest.cc",
288 "printing_test.h",
289 "printing_utils_unittest.cc",
290 "units_unittest.cc",
291 ]
292
[email protected]fc2020f2014-06-04 18:09:39293 deps = [
294 ":printing",
[email protected]fc2020f2014-06-04 18:09:39295 "//base/test:run_all_unittests",
296 "//base/test:test_support",
Wei Li1d345bf2018-08-10 02:52:37297 "//printing/common",
Vladislav Kuzkokovb043f2a2018-09-10 11:15:16298 "//testing/gmock",
[email protected]fc2020f2014-06-04 18:09:39299 "//testing/gtest",
300 "//ui/base",
301 "//ui/gfx",
[email protected]e54a1f522014-07-22 23:26:48302 "//ui/gfx:test_support",
[email protected]fc2020f2014-06-04 18:09:39303 "//ui/gfx/geometry",
304 ]
thestig64c8e262015-10-28 19:04:26305
rbpotter80cbe042017-12-08 07:00:52306 if (is_win || is_mac) {
307 sources += [ "printed_document_unittest.cc" ]
308 }
309
310 if (is_win) {
311 sources += [ "printed_page_win_unittest.cc" ]
312 }
313
thestig64c8e262015-10-28 19:04:26314 if (use_cups) {
315 configs += [ ":cups" ]
skaub779ce62016-07-22 03:16:40316
317 if (is_chromeos) {
318 sources += [ "backend/cups_ipp_util_unittest.cc" ]
319 } else {
320 sources += [ "backend/cups_helper_unittest.cc" ]
321 }
thestig64c8e262015-10-28 19:04:26322 }
[email protected]fc2020f2014-06-04 18:09:39323}
324
325if (use_cups) {
326 config("cups") {
327 defines = [ "USE_CUPS" ]
328
329 if (is_mac) {
dpranke517335e2015-08-01 02:41:14330 libs = [ "cups" ]
331 lib_dirs = [ "$mac_sdk_path/usr/lib" ]
[email protected]fc2020f2014-06-04 18:09:39332 } else {
agoodeed229712016-02-07 22:27:38333 # rebase_path does not accept an empty string
334 if (use_sysroot) {
335 cups_sysroot = rebase_path(sysroot)
336 } else {
337 cups_sysroot = ""
338 }
raphael.kubo.da.costa64f52802015-12-16 20:12:48339 libs = exec_script("cups_config_helper.py",
340 [
341 "--libs-for-gn",
agoodeed229712016-02-07 22:27:38342 cups_sysroot,
raphael.kubo.da.costa64f52802015-12-16 20:12:48343 ],
344 "value")
[email protected]fc2020f2014-06-04 18:09:39345 }
346 }
347}
348
349if (is_android) {
350 generate_jni("printing_jni_headers") {
351 sources = [
352 "android/java/src/org/chromium/printing/PrintingContext.java",
353 ]
354 jni_package = "printing"
355 }
356
cjhopman11a68cb2014-10-13 22:47:54357 android_library("printing_java") {
358 deps = [
scottmg34fb7e52014-12-03 23:27:24359 "//base:base_java",
Jinsuk Kimfc9e3e82019-02-13 06:50:23360 "//ui/android:ui_java",
cjhopman11a68cb2014-10-13 22:47:54361 ]
agrieve696e6a52016-03-23 19:54:45362 java_files = [
363 "android/java/src/org/chromium/printing/PrintDocumentAdapterWrapper.java",
364 "android/java/src/org/chromium/printing/PrintManagerDelegate.java",
365 "android/java/src/org/chromium/printing/PrintManagerDelegateImpl.java",
366 "android/java/src/org/chromium/printing/Printable.java",
367 "android/java/src/org/chromium/printing/PrintingContext.java",
agrieve696e6a52016-03-23 19:54:45368 "android/java/src/org/chromium/printing/PrintingController.java",
369 "android/java/src/org/chromium/printing/PrintingControllerImpl.java",
370 ]
cjhopman11a68cb2014-10-13 22:47:54371 }
[email protected]fc2020f2014-06-04 18:09:39372}