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 5import("//build/config/ui.gni") 6if (is_mac) { 7 import("//build/config/mac/mac_sdk.gni") 8} 9if (is_android) { 10 import("//build/config/android/rules.gni") 11} 12 13use_cups = ((is_linux && !is_chromeos) || is_mac) 14 15component("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.h", 33 "metafile_impl.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_destination_interface.h", 48 "print_destination_none.cc", 49 "print_dialog_gtk_interface.h", 50 "print_job_constants.cc", 51 "print_job_constants.h", 52 "print_settings.cc", 53 "print_settings.h", 54 "print_settings_conversion.cc", 55 "print_settings_conversion.h", 56 "print_settings_initializer_mac.cc", 57 "print_settings_initializer_mac.h", 58 "print_settings_initializer_win.cc", 59 "print_settings_initializer_win.h", 60 "printed_document.cc", 61 "printed_document.h", 62 "printed_document_linux.cc", 63 "printed_document_mac.cc", 64 "printed_document_win.cc", 65 "printed_page.cc", 66 "printed_page.h", 67 "printed_pages_source.h", 68 "printing_context.cc", 69 "printing_context.h", 70 "printing_utils.cc", 71 "printing_utils.h", 72 "units.cc", 73 "units.h", 74 ] 75 76 cflags = [] 77 defines = [ "PRINTING_IMPLEMENTATION" ] 78 79 deps = [ 80 "//base", 81 "//base:i18n", 82 "//base/third_party/dynamic_annotations", 83 "//skia", 84 "//third_party/icu", 85 "//ui/gfx", 86 "//ui/gfx/geometry", 87 "//url", 88 ] 89 90 if (use_aura) { 91 # deps += [ "//ui/aura" ] TODO(GYP) 92 } 93 94 if (is_mac) { 95 # Mac-Aura does not support printing. 96 if (use_aura) { 97 sources -= [ 98 "printed_document_mac.cc", 99 ] 100 } else { 101 sources += [ 102 "printing_context_mac.mm", 103 "printing_context_mac.h", 104 ] 105 } 106 } 107 108 if (is_win) { 109 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation of the 110 # print backend and enables a custom implementation instead. 111 defines += [ "PRINT_BACKEND_AVAILABLE" ] 112 sources += [ 113 "backend/win_helper.cc", 114 "backend/win_helper.h", 115 "backend/print_backend_win.cc", 116 "printing_context_win.cc", 117 "printing_context_win.h", 118 ] 119 } 120 121 if (is_chromeos) { 122 sources += [ 123 "printing_context_no_system_dialog.cc", 124 "printing_context_no_system_dialog.h", 125 ] 126 } 127 128 if (use_cups) { 129 cups_version = exec_script("cups_config_helper.py", [ "--api-version" ], 130 "trim string") 131 132 configs += [ ":cups" ] 133 134 if (is_linux) { 135 if (cups_version == "1.6" || cups_version == "1.7") { 136 cflags += [ 137 # CUPS 1.6 deprecated the PPD APIs, but we will stay with this 138 # API for now as supported Linux and Mac OS'es are still using 139 # older versions of CUPS. More info: crbug.com/226176 140 "-Wno-deprecated-declarations", 141 # CUPS 1.7 deprecates httpConnectEncrypt(), see the mac section 142 # below. 143 ] 144 } 145 } 146 147 if (is_mac && mac_sdk_version == "10.9") { 148 # The 10.9 SDK includes cups 1.7, which deprecates 149 # httpConnectEncrypt() in favor of httpConnect2(). hhttpConnect2() 150 # is new in 1.7, so it doesn't exist on OS X 10.6-10.8 and we 151 # can't use it until 10.9 is our minimum system version. 152 # (cups_version isn't reliable on OS X, so key the check off of 153 # mac_sdk). 154 cflags += [ "-Wno-deprecated-declarations" ] 155 } 156 157 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation 158 # of the print backend and enables a custom implementation instead. 159 defines += [ "PRINT_BACKEND_AVAILABLE" ] 160 161 sources += [ 162 "backend/cups_helper.cc", 163 "backend/cups_helper.h", 164 "backend/print_backend_cups.cc", 165 ] 166 } 167 168 if (is_chromeos) { 169 # PRINT_BACKEND_AVAILABLE disables the default dummy implementation 170 # of the print backend and enables a custom implementation instead. 171 defines += [ "PRINT_BACKEND_AVAILABLE" ] 172 173 sources += [ 174 "backend/print_backend_chromeos.cc", 175 ] 176 } else if (is_linux) { # Non-ChromeOS Linux. 177 sources += [ 178 "printing_context_linux.cc", 179 "printing_context_linux.h", 180 ] 181 } 182 183 if (is_android) { 184 sources += [ 185 "printing_context_android.cc", 186 "printing_context_android.h", 187 ] 188 189 deps += [ ":printing_jni_headers" ] 190 } 191} 192 193test("printing_unittests") { 194 sources = [ 195 "emf_win_unittest.cc", 196 "page_number_unittest.cc", 197 "page_range_unittest.cc", 198 "page_setup_unittest.cc", 199 "pdf_metafile_cg_mac_unittest.cc", 200 "printed_page_unittest.cc", 201 "printing_context_win_unittest.cc", 202 "printing_test.h", 203 "printing_utils_unittest.cc", 204 "units_unittest.cc", 205 ] 206 207 if (use_cups) { 208 configs += [ ":cups" ] 209 sources += [ "backend/cups_helper_unittest.cc" ] 210 } 211 212 deps = [ 213 ":printing", 214 "//base/allocator", 215 "//base/test:run_all_unittests", 216 "//base/test:test_support", 217 "//testing/gtest", 218 "//ui/base", 219 "//ui/gfx", 220 "//ui/gfx/geometry", 221 ] 222} 223 224if (use_cups) { 225 config("cups") { 226 defines = [ "USE_CUPS" ] 227 228 if (is_mac) { 229 libs = [ "libcups.dylib" ] 230 } else { 231 libs = exec_script("cups_config_helper.py", [ "--libs-for-gn" ], "value") 232 } 233 } 234} 235 236if (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} 257