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