blob: 4046dc4f4b9385a6f76e84f0362e67cb471a42e4 [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")
qsrfb5251d12015-01-21 15:57:228import("//testing/test.gni")
[email protected]fc2020f2014-06-04 18:09:399if (is_mac) {
10 import("//build/config/mac/mac_sdk.gni")
11}
12if (is_android) {
13 import("//build/config/android/rules.gni")
14}
15
[email protected]fc2020f2014-06-04 18:09:3916component("printing") {
17 sources = [
18 "backend/print_backend.cc",
19 "backend/print_backend.h",
20 "backend/print_backend_consts.cc",
21 "backend/print_backend_consts.h",
22 "backend/print_backend_dummy.cc",
23 "backend/printing_info_win.cc",
24 "backend/printing_info_win.h",
25 "emf_win.cc",
26 "emf_win.h",
27 "image.cc",
28 "image.h",
29 "image_android.cc",
30 "image_linux.cc",
31 "image_mac.cc",
32 "image_win.cc",
vitalybuka5d1290582014-09-12 09:19:5933 "metafile.cc",
[email protected]fc2020f2014-06-04 18:09:3934 "metafile.h",
[email protected]fc2020f2014-06-04 18:09:3935 "metafile_skia_wrapper.cc",
36 "metafile_skia_wrapper.h",
37 "page_number.cc",
38 "page_number.h",
39 "page_range.cc",
40 "page_range.h",
41 "page_setup.cc",
42 "page_setup.h",
[email protected]fc2020f2014-06-04 18:09:3943 "page_size_margins.h",
44 "pdf_metafile_cg_mac.cc",
45 "pdf_metafile_cg_mac.h",
46 "pdf_metafile_skia.cc",
47 "pdf_metafile_skia.h",
[email protected]fc2020f2014-06-04 18:09:3948 "print_dialog_gtk_interface.h",
49 "print_job_constants.cc",
50 "print_job_constants.h",
51 "print_settings.cc",
52 "print_settings.h",
[email protected]c95198b2014-06-12 16:56:5553 "print_settings_conversion.cc",
54 "print_settings_conversion.h",
[email protected]fc2020f2014-06-04 18:09:3955 "print_settings_initializer_mac.cc",
56 "print_settings_initializer_mac.h",
57 "print_settings_initializer_win.cc",
58 "print_settings_initializer_win.h",
59 "printed_document.cc",
60 "printed_document.h",
61 "printed_document_linux.cc",
62 "printed_document_mac.cc",
63 "printed_document_win.cc",
64 "printed_page.cc",
65 "printed_page.h",
66 "printed_pages_source.h",
67 "printing_context.cc",
68 "printing_context.h",
69 "printing_utils.cc",
70 "printing_utils.h",
71 "units.cc",
72 "units.h",
73 ]
74
75 cflags = []
76 defines = [ "PRINTING_IMPLEMENTATION" ]
77
78 deps = [
79 "//base",
80 "//base:i18n",
81 "//base/third_party/dynamic_annotations",
82 "//skia",
83 "//third_party/icu",
84 "//ui/gfx",
85 "//ui/gfx/geometry",
86 "//url",
87 ]
88
89 if (use_aura) {
[email protected]55699f392014-08-20 22:16:3090 deps += [ "//ui/aura" ]
[email protected]fc2020f2014-06-04 18:09:3991 }
92
93 if (is_mac) {
94 # Mac-Aura does not support printing.
95 if (use_aura) {
scottmg34fb7e52014-12-03 23:27:2496 sources -= [ "printed_document_mac.cc" ]
[email protected]fc2020f2014-06-04 18:09:3997 } else {
98 sources += [
[email protected]fc2020f2014-06-04 18:09:3999 "printing_context_mac.h",
scottmg7c7296f42015-02-28 02:23:09100 "printing_context_mac.mm",
[email protected]fc2020f2014-06-04 18:09:39101 ]
102 }
rsesek02aa51c2016-05-11 02:13:57103 libs = [
104 "AppKit.framework",
105 "ApplicationServices.framework",
106 "CoreFoundation.framework",
107 "CoreGraphics.framework",
108 ]
[email protected]fc2020f2014-06-04 18:09:39109 }
110
111 if (is_win) {
112 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation of the
113 # print backend and enables a custom implementation instead.
114 defines += [ "PRINT_BACKEND_AVAILABLE" ]
115 sources += [
scottmg7c7296f42015-02-28 02:23:09116 "backend/print_backend_win.cc",
[email protected]fc2020f2014-06-04 18:09:39117 "backend/win_helper.cc",
118 "backend/win_helper.h",
vchigrin52933522014-12-15 20:55:13119 "printing_context_system_dialog_win.cc",
120 "printing_context_system_dialog_win.h",
[email protected]fc2020f2014-06-04 18:09:39121 "printing_context_win.cc",
122 "printing_context_win.h",
123 ]
124 }
125
126 if (is_chromeos) {
127 sources += [
128 "printing_context_no_system_dialog.cc",
129 "printing_context_no_system_dialog.h",
130 ]
131 }
132
133 if (use_cups) {
[email protected]fc2020f2014-06-04 18:09:39134 configs += [ ":cups" ]
135
136 if (is_linux) {
agoodeed229712016-02-07 22:27:38137 # rebase_path does not accept an empty string
138 if (use_sysroot) {
139 cups_sysroot = rebase_path(sysroot)
140 } else {
141 cups_sysroot = ""
142 }
scottmg34fb7e52014-12-03 23:27:24143 cups_version = exec_script("cups_config_helper.py",
raphael.kubo.da.costa64f52802015-12-16 20:12:48144 [
145 "--api-version",
agoodeed229712016-02-07 22:27:38146 cups_sysroot,
raphael.kubo.da.costa64f52802015-12-16 20:12:48147 ],
[email protected]eae20a212014-08-19 23:04:54148 "trim string")
149
[email protected]fc2020f2014-06-04 18:09:39150 if (cups_version == "1.6" || cups_version == "1.7") {
151 cflags += [
152 # CUPS 1.6 deprecated the PPD APIs, but we will stay with this
153 # API for now as supported Linux and Mac OS'es are still using
154 # older versions of CUPS. More info: crbug.com/226176
155 "-Wno-deprecated-declarations",
156 # CUPS 1.7 deprecates httpConnectEncrypt(), see the mac section
157 # below.
158 ]
159 }
160 }
161
162 if (is_mac && mac_sdk_version == "10.9") {
163 # The 10.9 SDK includes cups 1.7, which deprecates
164 # httpConnectEncrypt() in favor of httpConnect2(). hhttpConnect2()
165 # is new in 1.7, so it doesn't exist on OS X 10.6-10.8 and we
166 # can't use it until 10.9 is our minimum system version.
167 # (cups_version isn't reliable on OS X, so key the check off of
168 # mac_sdk).
169 cflags += [ "-Wno-deprecated-declarations" ]
170 }
171
172 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
173 # of the print backend and enables a custom implementation instead.
174 defines += [ "PRINT_BACKEND_AVAILABLE" ]
175
176 sources += [
177 "backend/cups_helper.cc",
178 "backend/cups_helper.h",
179 "backend/print_backend_cups.cc",
180 ]
181 }
182
183 if (is_chromeos) {
184 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
185 # of the print backend and enables a custom implementation instead.
186 defines += [ "PRINT_BACKEND_AVAILABLE" ]
187
scottmg34fb7e52014-12-03 23:27:24188 sources += [ "backend/print_backend_chromeos.cc" ]
[email protected]fc2020f2014-06-04 18:09:39189 } else if (is_linux) { # Non-ChromeOS Linux.
190 sources += [
191 "printing_context_linux.cc",
192 "printing_context_linux.h",
193 ]
194 }
195
196 if (is_android) {
197 sources += [
198 "printing_context_android.cc",
199 "printing_context_android.h",
200 ]
201
202 deps += [ ":printing_jni_headers" ]
thestig64c8e262015-10-28 19:04:26203 } else {
204 sources += [
205 "pdf_transform.cc",
206 "pdf_transform.h",
207 ]
[email protected]fc2020f2014-06-04 18:09:39208 }
209}
210
211test("printing_unittests") {
212 sources = [
213 "emf_win_unittest.cc",
214 "page_number_unittest.cc",
215 "page_range_unittest.cc",
216 "page_setup_unittest.cc",
217 "pdf_metafile_cg_mac_unittest.cc",
218 "printed_page_unittest.cc",
219 "printing_context_win_unittest.cc",
220 "printing_test.h",
221 "printing_utils_unittest.cc",
222 "units_unittest.cc",
223 ]
224
dpranke8ec93a3a2015-02-20 23:36:08225 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
226
[email protected]fc2020f2014-06-04 18:09:39227 deps = [
228 ":printing",
[email protected]fc2020f2014-06-04 18:09:39229 "//base/test:run_all_unittests",
230 "//base/test:test_support",
231 "//testing/gtest",
232 "//ui/base",
233 "//ui/gfx",
[email protected]e54a1f522014-07-22 23:26:48234 "//ui/gfx:test_support",
[email protected]fc2020f2014-06-04 18:09:39235 "//ui/gfx/geometry",
236 ]
thestig64c8e262015-10-28 19:04:26237
238 if (!is_android) {
239 sources += [ "pdf_transform_unittest.cc" ]
240 }
241
242 if (use_cups) {
243 configs += [ ":cups" ]
244 sources += [ "backend/cups_helper_unittest.cc" ]
245 }
[email protected]fc2020f2014-06-04 18:09:39246}
247
248if (use_cups) {
249 config("cups") {
250 defines = [ "USE_CUPS" ]
251
252 if (is_mac) {
dpranke517335e2015-08-01 02:41:14253 libs = [ "cups" ]
254 lib_dirs = [ "$mac_sdk_path/usr/lib" ]
[email protected]fc2020f2014-06-04 18:09:39255 } else {
agoodeed229712016-02-07 22:27:38256 # rebase_path does not accept an empty string
257 if (use_sysroot) {
258 cups_sysroot = rebase_path(sysroot)
259 } else {
260 cups_sysroot = ""
261 }
raphael.kubo.da.costa64f52802015-12-16 20:12:48262 libs = exec_script("cups_config_helper.py",
263 [
264 "--libs-for-gn",
agoodeed229712016-02-07 22:27:38265 cups_sysroot,
raphael.kubo.da.costa64f52802015-12-16 20:12:48266 ],
267 "value")
[email protected]fc2020f2014-06-04 18:09:39268 }
269 }
270}
271
272if (is_android) {
cjhopman11a68cb2014-10-13 22:47:54273 # GYP: //printing/printing.gyp:printing_jni_headers
[email protected]fc2020f2014-06-04 18:09:39274 generate_jni("printing_jni_headers") {
275 sources = [
276 "android/java/src/org/chromium/printing/PrintingContext.java",
277 ]
278 jni_package = "printing"
279 }
280
cjhopman11a68cb2014-10-13 22:47:54281 # GYP: //printing/printing.gyp:printing_java
282 android_library("printing_java") {
283 deps = [
scottmg34fb7e52014-12-03 23:27:24284 "//base:base_java",
cjhopman11a68cb2014-10-13 22:47:54285 ]
agrieve696e6a52016-03-23 19:54:45286 java_files = [
287 "android/java/src/org/chromium/printing/PrintDocumentAdapterWrapper.java",
288 "android/java/src/org/chromium/printing/PrintManagerDelegate.java",
289 "android/java/src/org/chromium/printing/PrintManagerDelegateImpl.java",
290 "android/java/src/org/chromium/printing/Printable.java",
291 "android/java/src/org/chromium/printing/PrintingContext.java",
292 "android/java/src/org/chromium/printing/PrintingContextInterface.java",
293 "android/java/src/org/chromium/printing/PrintingController.java",
294 "android/java/src/org/chromium/printing/PrintingControllerImpl.java",
295 ]
cjhopman11a68cb2014-10-13 22:47:54296 }
[email protected]fc2020f2014-06-04 18:09:39297}