[SyncFS] Fix unexpected delay on running sync task
[chromium-blink-merge.git] / printing / BUILD.gn
blob2a0d2b5e199b0e005143fac2ad62e5e9f4dfa68d
1 # 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.
5 import("//build/config/features.gni")
6 import("//build/config/ui.gni")
7 if (is_mac) {
8   import("//build/config/mac/mac_sdk.gni")
10 if (is_android) {
11   import("//build/config/android/rules.gni")
14 component("printing") {
15   sources = [
16     "backend/print_backend.cc",
17     "backend/print_backend.h",
18     "backend/print_backend_consts.cc",
19     "backend/print_backend_consts.h",
20     "backend/print_backend_dummy.cc",
21     "backend/printing_info_win.cc",
22     "backend/printing_info_win.h",
23     "emf_win.cc",
24     "emf_win.h",
25     "image.cc",
26     "image.h",
27     "image_android.cc",
28     "image_linux.cc",
29     "image_mac.cc",
30     "image_win.cc",
31     "metafile.h",
32     "metafile_skia_wrapper.cc",
33     "metafile_skia_wrapper.h",
34     "page_number.cc",
35     "page_number.h",
36     "page_range.cc",
37     "page_range.h",
38     "page_setup.cc",
39     "page_setup.h",
40     "page_size_margins.h",
41     "pdf_metafile_cg_mac.cc",
42     "pdf_metafile_cg_mac.h",
43     "pdf_metafile_skia.cc",
44     "pdf_metafile_skia.h",
45     "print_dialog_gtk_interface.h",
46     "print_job_constants.cc",
47     "print_job_constants.h",
48     "print_settings.cc",
49     "print_settings.h",
50     "print_settings_conversion.cc",
51     "print_settings_conversion.h",
52     "print_settings_initializer_mac.cc",
53     "print_settings_initializer_mac.h",
54     "print_settings_initializer_win.cc",
55     "print_settings_initializer_win.h",
56     "printed_document.cc",
57     "printed_document.h",
58     "printed_document_linux.cc",
59     "printed_document_mac.cc",
60     "printed_document_win.cc",
61     "printed_page.cc",
62     "printed_page.h",
63     "printed_pages_source.h",
64     "printing_context.cc",
65     "printing_context.h",
66     "printing_utils.cc",
67     "printing_utils.h",
68     "units.cc",
69     "units.h",
70   ]
72   cflags = []
73   defines = [ "PRINTING_IMPLEMENTATION" ]
75   deps = [
76     "//base",
77     "//base:i18n",
78     "//base/third_party/dynamic_annotations",
79     "//skia",
80     "//third_party/icu",
81     "//ui/gfx",
82     "//ui/gfx/geometry",
83     "//url",
84   ]
86   if (use_aura) {
87     deps += [ "//ui/aura" ]
88   }
90   if (is_mac) {
91     # Mac-Aura does not support printing.
92     if (use_aura) {
93       sources -= [
94         "printed_document_mac.cc",
95       ]
96     } else {
97       sources += [
98         "printing_context_mac.mm",
99         "printing_context_mac.h",
100       ]
101     }
102   }
104   if (is_win) {
105     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation of the
106     # print backend and enables a custom implementation instead.
107     defines += [ "PRINT_BACKEND_AVAILABLE" ]
108     sources += [
109       "backend/win_helper.cc",
110       "backend/win_helper.h",
111       "backend/print_backend_win.cc",
112       "printing_context_win.cc",
113       "printing_context_win.h",
114     ]
115   }
117   if (is_chromeos) {
118     sources += [
119       "printing_context_no_system_dialog.cc",
120       "printing_context_no_system_dialog.h",
121     ]
122   }
124   if (use_cups) {
125     configs += [ ":cups" ]
127     if (is_linux) {
128       cups_version = exec_script("cups_config_helper.py", [ "--api-version" ],
129                                  "trim string")
131       if (cups_version == "1.6" || cups_version == "1.7") {
132         cflags += [
133           # CUPS 1.6 deprecated the PPD APIs, but we will stay with this
134           # API for now as supported Linux and Mac OS'es are still using
135           # older versions of CUPS. More info: crbug.com/226176
136           "-Wno-deprecated-declarations",
137           # CUPS 1.7 deprecates httpConnectEncrypt(), see the mac section
138           # below.
139         ]
140       }
141     }
143     if (is_mac && mac_sdk_version == "10.9") {
144       # The 10.9 SDK includes cups 1.7, which deprecates
145       # httpConnectEncrypt() in favor of httpConnect2(). hhttpConnect2()
146       # is new in 1.7, so it doesn't exist on OS X 10.6-10.8 and we
147       # can't use it until 10.9 is our minimum system version.
148       # (cups_version isn't reliable on OS X, so key the check off of
149       # mac_sdk).
150       cflags += [ "-Wno-deprecated-declarations" ]
151     }
153     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
154     # of the print backend and enables a custom implementation instead.
155     defines += [ "PRINT_BACKEND_AVAILABLE" ]
157     sources += [
158       "backend/cups_helper.cc",
159       "backend/cups_helper.h",
160       "backend/print_backend_cups.cc",
161     ]
162   }
164   if (is_chromeos) {
165     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
166     # of the print backend and enables a custom implementation instead.
167     defines += [ "PRINT_BACKEND_AVAILABLE" ]
169     sources += [
170       "backend/print_backend_chromeos.cc",
171     ]
172   } else if (is_linux) {  # Non-ChromeOS Linux.
173     sources += [
174       "printing_context_linux.cc",
175       "printing_context_linux.h",
176     ]
177   }
179   if (is_android) {
180     sources += [
181       "printing_context_android.cc",
182       "printing_context_android.h",
183     ]
185     deps += [ ":printing_jni_headers" ]
186   }
189 test("printing_unittests") {
190   sources = [
191     "emf_win_unittest.cc",
192     "page_number_unittest.cc",
193     "page_range_unittest.cc",
194     "page_setup_unittest.cc",
195     "pdf_metafile_cg_mac_unittest.cc",
196     "printed_page_unittest.cc",
197     "printing_context_win_unittest.cc",
198     "printing_test.h",
199     "printing_utils_unittest.cc",
200     "units_unittest.cc",
201   ]
203   if (use_cups) {
204     configs += [ ":cups" ]
205     sources += [ "backend/cups_helper_unittest.cc" ]
206   }
208   deps = [
209     ":printing",
210     "//base/allocator",
211     "//base/test:run_all_unittests",
212     "//base/test:test_support",
213     "//testing/gtest",
214     "//ui/base",
215     "//ui/gfx",
216     "//ui/gfx:test_support",
217     "//ui/gfx/geometry",
218   ]
221 if (use_cups) {
222   config("cups") {
223     defines = [ "USE_CUPS" ]
225     if (is_mac) {
226       ldflags = [ "$mac_sdk_path/usr/lib/libcups.dylib" ]
227     } else {
228       libs = exec_script("cups_config_helper.py", [ "--libs-for-gn" ], "value")
229     }
230   }
233 if (is_android) {
234   generate_jni("printing_jni_headers") {
235     sources = [
236       "android/java/src/org/chromium/printing/PrintingContext.java",
237     ]
238     jni_package = "printing"
239   }
241   # TODO(GYP)
242   #{
243   #  'target_name': 'printing_java',
244   #  'type': 'none',
245   #  'variables': {
246   #    'java_in_dir': '../printing/android/java',
247   #  },
248   #  'dependencies': [
249   #    '../base/base.gyp:base_java',
250   #  ],
251   #  'includes': [ '../build/java.gypi'  ],
252   #}