Update broken references to image assets
[chromium-blink-merge.git] / printing / BUILD.gn
blobca35327851d53d2e064fed39ee545431292151cf
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 import("//testing/test.gni")
8 if (is_mac) {
9   import("//build/config/mac/mac_sdk.gni")
11 if (is_android) {
12   import("//build/config/android/rules.gni")
15 component("printing") {
16   sources = [
17     "backend/print_backend.cc",
18     "backend/print_backend.h",
19     "backend/print_backend_consts.cc",
20     "backend/print_backend_consts.h",
21     "backend/print_backend_dummy.cc",
22     "backend/printing_info_win.cc",
23     "backend/printing_info_win.h",
24     "emf_win.cc",
25     "emf_win.h",
26     "image.cc",
27     "image.h",
28     "image_android.cc",
29     "image_linux.cc",
30     "image_mac.cc",
31     "image_win.cc",
32     "metafile.cc",
33     "metafile.h",
34     "metafile_skia_wrapper.cc",
35     "metafile_skia_wrapper.h",
36     "page_number.cc",
37     "page_number.h",
38     "page_range.cc",
39     "page_range.h",
40     "page_setup.cc",
41     "page_setup.h",
42     "page_size_margins.h",
43     "pdf_metafile_cg_mac.cc",
44     "pdf_metafile_cg_mac.h",
45     "pdf_metafile_skia.cc",
46     "pdf_metafile_skia.h",
47     "print_dialog_gtk_interface.h",
48     "print_job_constants.cc",
49     "print_job_constants.h",
50     "print_settings.cc",
51     "print_settings.h",
52     "print_settings_conversion.cc",
53     "print_settings_conversion.h",
54     "print_settings_initializer_mac.cc",
55     "print_settings_initializer_mac.h",
56     "print_settings_initializer_win.cc",
57     "print_settings_initializer_win.h",
58     "printed_document.cc",
59     "printed_document.h",
60     "printed_document_linux.cc",
61     "printed_document_mac.cc",
62     "printed_document_win.cc",
63     "printed_page.cc",
64     "printed_page.h",
65     "printed_pages_source.h",
66     "printing_context.cc",
67     "printing_context.h",
68     "printing_utils.cc",
69     "printing_utils.h",
70     "units.cc",
71     "units.h",
72   ]
74   cflags = []
75   defines = [ "PRINTING_IMPLEMENTATION" ]
77   deps = [
78     "//base",
79     "//base:i18n",
80     "//base/third_party/dynamic_annotations",
81     "//skia",
82     "//third_party/icu",
83     "//ui/gfx",
84     "//ui/gfx/geometry",
85     "//url",
86   ]
88   if (use_aura) {
89     deps += [ "//ui/aura" ]
90   }
92   if (is_mac) {
93     # Mac-Aura does not support printing.
94     if (use_aura) {
95       sources -= [ "printed_document_mac.cc" ]
96     } else {
97       sources += [
98         "printing_context_mac.h",
99         "printing_context_mac.mm",
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/print_backend_win.cc",
110       "backend/win_helper.cc",
111       "backend/win_helper.h",
112       "printing_context_system_dialog_win.cc",
113       "printing_context_system_dialog_win.h",
114       "printing_context_win.cc",
115       "printing_context_win.h",
116     ]
117   }
119   if (is_chromeos) {
120     sources += [
121       "printing_context_no_system_dialog.cc",
122       "printing_context_no_system_dialog.h",
123     ]
124   }
126   if (use_cups) {
127     configs += [ ":cups" ]
129     if (is_linux) {
130       cups_version = exec_script("cups_config_helper.py",
131                                  [ "--api-version" ],
132                                  "trim string")
134       if (cups_version == "1.6" || cups_version == "1.7") {
135         cflags += [
136           # CUPS 1.6 deprecated the PPD APIs, but we will stay with this
137           # API for now as supported Linux and Mac OS'es are still using
138           # older versions of CUPS. More info: crbug.com/226176
139           "-Wno-deprecated-declarations",
140           # CUPS 1.7 deprecates httpConnectEncrypt(), see the mac section
141           # below.
142         ]
143       }
144     }
146     if (is_mac && mac_sdk_version == "10.9") {
147       # The 10.9 SDK includes cups 1.7, which deprecates
148       # httpConnectEncrypt() in favor of httpConnect2(). hhttpConnect2()
149       # is new in 1.7, so it doesn't exist on OS X 10.6-10.8 and we
150       # can't use it until 10.9 is our minimum system version.
151       # (cups_version isn't reliable on OS X, so key the check off of
152       # mac_sdk).
153       cflags += [ "-Wno-deprecated-declarations" ]
154     }
156     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
157     # of the print backend and enables a custom implementation instead.
158     defines += [ "PRINT_BACKEND_AVAILABLE" ]
160     sources += [
161       "backend/cups_helper.cc",
162       "backend/cups_helper.h",
163       "backend/print_backend_cups.cc",
164     ]
165   }
167   if (is_chromeos) {
168     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
169     # of the print backend and enables a custom implementation instead.
170     defines += [ "PRINT_BACKEND_AVAILABLE" ]
172     sources += [ "backend/print_backend_chromeos.cc" ]
173   } else if (is_linux) {  # Non-ChromeOS Linux.
174     sources += [
175       "printing_context_linux.cc",
176       "printing_context_linux.h",
177     ]
178   }
180   if (is_android) {
181     sources += [
182       "printing_context_android.cc",
183       "printing_context_android.h",
184     ]
186     deps += [ ":printing_jni_headers" ]
187   }
190 # TODO(GYP): Delete this after we've converted everything to GN.
191 # The _run targets exist only for compatibility w/ GYP.
192 group("printing_unittests_run") {
193   testonly = true
194   deps = [
195     ":printing_unittests",
196   ]
199 test("printing_unittests") {
200   sources = [
201     "emf_win_unittest.cc",
202     "page_number_unittest.cc",
203     "page_range_unittest.cc",
204     "page_setup_unittest.cc",
205     "pdf_metafile_cg_mac_unittest.cc",
206     "printed_page_unittest.cc",
207     "printing_context_win_unittest.cc",
208     "printing_test.h",
209     "printing_utils_unittest.cc",
210     "units_unittest.cc",
211   ]
213   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
215   if (use_cups) {
216     configs += [ ":cups" ]
217     sources += [ "backend/cups_helper_unittest.cc" ]
218   }
220   deps = [
221     ":printing",
222     "//base/allocator",
223     "//base/test:run_all_unittests",
224     "//base/test:test_support",
225     "//testing/gtest",
226     "//ui/base",
227     "//ui/gfx",
228     "//ui/gfx:test_support",
229     "//ui/gfx/geometry",
230   ]
233 if (use_cups) {
234   config("cups") {
235     defines = [ "USE_CUPS" ]
237     if (is_mac) {
238       libs = [ "cups" ]
239       lib_dirs = [ "$mac_sdk_path/usr/lib" ]
240     } else {
241       libs = exec_script("cups_config_helper.py", [ "--libs-for-gn" ], "value")
242     }
243   }
246 if (is_android) {
247   # GYP: //printing/printing.gyp:printing_jni_headers
248   generate_jni("printing_jni_headers") {
249     sources = [
250       "android/java/src/org/chromium/printing/PrintingContext.java",
251     ]
252     jni_package = "printing"
253   }
255   # GYP: //printing/printing.gyp:printing_java
256   android_library("printing_java") {
257     deps = [
258       "//base:base_java",
259     ]
260     DEPRECATED_java_in_dir = "android/java/src"
261   }