Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / printing / BUILD.gn
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.
4
5 import("//build/config/features.gni")
6 import("//build/config/ui.gni")
7 if (is_mac) {
8   import("//build/config/mac/mac_sdk.gni")
9 }
10 if (is_android) {
11   import("//build/config/android/rules.gni")
12 }
13
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_impl.h",
33     "metafile_skia_wrapper.cc",
34     "metafile_skia_wrapper.h",
35     "page_number.cc",
36     "page_number.h",
37     "page_range.cc",
38     "page_range.h",
39     "page_setup.cc",
40     "page_setup.h",
41     "page_size_margins.h",
42     "pdf_metafile_cg_mac.cc",
43     "pdf_metafile_cg_mac.h",
44     "pdf_metafile_skia.cc",
45     "pdf_metafile_skia.h",
46     "print_destination_interface.h",
47     "print_destination_none.cc",
48     "print_dialog_gtk_interface.h",
49     "print_job_constants.cc",
50     "print_job_constants.h",
51     "print_settings.cc",
52     "print_settings.h",
53     "print_settings_conversion.cc",
54     "print_settings_conversion.h",
55     "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) {
90     # deps += [ "//ui/aura" ]  TODO(GYP)
91   }
92
93   if (is_mac) {
94     # Mac-Aura does not support printing.
95     if (use_aura) {
96       sources -= [
97         "printed_document_mac.cc",
98       ]
99     } else {
100       sources += [
101         "printing_context_mac.mm",
102         "printing_context_mac.h",
103       ]
104     }
105   }
106
107   if (is_win) {
108     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation of the
109     # print backend and enables a custom implementation instead.
110     defines += [ "PRINT_BACKEND_AVAILABLE" ]
111     sources += [
112       "backend/win_helper.cc",
113       "backend/win_helper.h",
114       "backend/print_backend_win.cc",
115       "printing_context_win.cc",
116       "printing_context_win.h",
117     ]
118   }
119
120   if (is_chromeos) {
121     sources += [
122       "printing_context_no_system_dialog.cc",
123       "printing_context_no_system_dialog.h",
124     ]
125   }
126
127   if (use_cups) {
128     cups_version = exec_script("cups_config_helper.py", [ "--api-version" ],
129                                "trim string")
130
131     configs += [ ":cups" ]
132
133     if (is_linux) {
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     }
145
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     }
155
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" ]
159
160     sources += [
161       "backend/cups_helper.cc",
162       "backend/cups_helper.h",
163       "backend/print_backend_cups.cc",
164     ]
165   }
166
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" ]
171
172     sources += [
173       "backend/print_backend_chromeos.cc",
174     ]
175   } else if (is_linux) {  # Non-ChromeOS Linux.
176     sources += [
177       "printing_context_linux.cc",
178       "printing_context_linux.h",
179     ]
180   }
181
182   if (is_android) {
183     sources += [
184       "printing_context_android.cc",
185       "printing_context_android.h",
186     ]
187
188     deps += [ ":printing_jni_headers" ]
189   }
190 }
191
192 test("printing_unittests") {
193   sources = [
194     "emf_win_unittest.cc",
195     "page_number_unittest.cc",
196     "page_range_unittest.cc",
197     "page_setup_unittest.cc",
198     "pdf_metafile_cg_mac_unittest.cc",
199     "printed_page_unittest.cc",
200     "printing_context_win_unittest.cc",
201     "printing_test.h",
202     "printing_utils_unittest.cc",
203     "units_unittest.cc",
204   ]
205
206   if (use_cups) {
207     configs += [ ":cups" ]
208     sources += [ "backend/cups_helper_unittest.cc" ]
209   }
210
211   deps = [
212     ":printing",
213     "//base/allocator",
214     "//base/test:run_all_unittests",
215     "//base/test:test_support",
216     "//testing/gtest",
217     "//ui/base",
218     "//ui/gfx",
219     "//ui/gfx:test_support",
220     "//ui/gfx/geometry",
221   ]
222 }
223
224 if (use_cups) {
225   config("cups") {
226     defines = [ "USE_CUPS" ]
227
228     if (is_mac) {
229       ldflags = [ "$mac_sdk_path/usr/lib/libcups.dylib" ]
230     } else {
231       libs = exec_script("cups_config_helper.py", [ "--libs-for-gn" ], "value")
232     }
233   }
234 }
235
236 if (is_android) {
237   generate_jni("printing_jni_headers") {
238     sources = [
239       "android/java/src/org/chromium/printing/PrintingContext.java",
240     ]
241     jni_package = "printing"
242   }
243
244   # TODO(GYP)
245   #{
246   #  'target_name': 'printing_java',
247   #  'type': 'none',
248   #  'variables': {
249   #    'java_in_dir': '../printing/android/java',
250   #  },
251   #  'dependencies': [
252   #    '../base/base.gyp:base_java',
253   #  ],
254   #  'includes': [ '../build/java.gypi'  ],
255   #}
256 }