# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/config/features.gni") import("//build/config/sysroot.gni") import("//build/config/ui.gni") import("//pdf/features.gni") import("//printing/buildflags/buildflags.gni") import("//testing/test.gni") if (is_mac) { import("//build/config/mac/mac_sdk.gni") } if (is_android) { import("//build/config/android/rules.gni") } if (use_cups && is_chromeos) { import("//printing/backend/tools/code_generator.gni") } if ((enable_basic_printing && is_win) || enable_print_preview) { # Windows basic printing or print preview requires pdf enabled. assert(enable_pdf, "Windows basic printing or print preview needs pdf: " + "set enable_pdf=true.") } # Enable the CUPS IPP printing backend. # TODO(crbug.com/226176): Remove this after CUPS PPD API calls are removed. declare_args() { use_cups_ipp = use_cups && !is_linux } # Several targets want to include this header file. We separate it out # here so multiple targets can depend on it. source_set("printing_export") { sources = [ "printing_export.h" ] } if (use_cups_ipp && is_chromeos) { ipp_handler_map_path = "$target_gen_dir/backend/ipp_handler_map.cc" ipp_code_generate("ipp_handlers_generate") { outputs = [ ipp_handler_map_path ] args = [ "--ipp-handler-map=" + rebase_path(ipp_handler_map_path, root_build_dir) ] } } component("printing") { sources = [ "backend/print_backend.cc", "backend/print_backend.h", "backend/print_backend_consts.cc", "backend/print_backend_consts.h", "backend/print_backend_dummy.cc", "backend/printing_restrictions.cc", "backend/printing_restrictions.h", "metafile.cc", "metafile.h", "metafile_skia.cc", "metafile_skia.h", "native_drawing_context.h", "nup_parameters.cc", "nup_parameters.h", "page_number.cc", "page_number.h", "page_range.cc", "page_range.h", "page_setup.cc", "page_setup.h", "pdf_render_settings.h", "print_dialog_gtk_interface.h", "print_job_constants.cc", "print_job_constants.h", "print_settings.cc", "print_settings.h", "print_settings_conversion.cc", "print_settings_conversion.h", "printed_document.cc", "printed_document.h", "printing_context.cc", "printing_context.h", "printing_features.cc", "printing_features.h", "printing_utils.cc", "printing_utils.h", "pwg_raster_settings.h", "units.cc", "units.h", ] configs += [ "//build/config/compiler:noshadowing" ] cflags = [] defines = [ "PRINTING_IMPLEMENTATION" ] public_deps = [ "//printing/buildflags" ] deps = [ ":printing_export", "//base", "//base:i18n", "//base/third_party/dynamic_annotations", "//build:chromeos_buildflags", "//cc/paint", "//printing/common", "//printing/mojom", "//skia", "//third_party/icu", "//ui/accessibility", "//ui/gfx", "//ui/gfx/geometry", "//url", ] if (is_android) { sources += [ "printed_document_android.cc", "printing_context_android.cc", "printing_context_android.h", ] deps += [ ":printing_jni_headers", "//ui/android", ] } if (is_chromeos) { defines += [ "PRINT_BACKEND_AVAILABLE" ] sources += [ "backend/print_backend_chromeos.cc", "printed_document_chromeos.cc", "printing_context_no_system_dialog.cc", "printing_context_no_system_dialog.h", ] } if (is_linux) { sources += [ "printed_document_linux.cc", "printing_context_linux.cc", "printing_context_linux.h", ] } if (is_mac) { sources += [ "pdf_metafile_cg_mac.cc", "pdf_metafile_cg_mac.h", "print_settings_initializer_mac.cc", "print_settings_initializer_mac.h", ] # Mac-Aura does not support printing. if (!use_aura) { sources += [ "printed_document_mac.cc", "printing_context_mac.h", "printing_context_mac.mm", ] } frameworks = [ "AppKit.framework", "QuartzCore.framework", "ApplicationServices.framework", "CoreFoundation.framework", "CoreGraphics.framework", ] } if (is_win) { # PRINT_BACKEND_AVAILABLE disables the default dummy implementation of the # print backend and enables a custom implementation instead. defines += [ "PRINT_BACKEND_AVAILABLE" ] sources += [ "backend/print_backend_win.cc", "backend/printing_info_win.cc", "backend/printing_info_win.h", "backend/win_helper.cc", "backend/win_helper.h", "emf_win.cc", "emf_win.h", "print_settings_initializer_win.cc", "print_settings_initializer_win.h", "printed_document_win.cc", "printed_page_win.cc", "printed_page_win.h", "printing_context_system_dialog_win.cc", "printing_context_system_dialog_win.h", "printing_context_win.cc", "printing_context_win.h", ] } if (use_aura) { deps += [ "//ui/aura" ] } if (use_cups) { configs += [ ":cups" ] if (is_linux || is_chromeos) { # CUPS 1.6 deprecated the PPD APIs, but we will stay with this API # for now as the suitability of the replacement is unclear. # More info: crbug.com/226176 cflags += [ "-Wno-deprecated-declarations" ] } if (is_mac) { # CUPS 1.6 deprecated the PPD APIs. We need to evaluate the # effect of migrating Mac. More info: crbug.com/226176 cflags += [ "-Wno-deprecated-declarations" ] } # PRINT_BACKEND_AVAILABLE disables the default dummy implementation # of the print backend and enables a custom implementation instead. defines += [ "PRINT_BACKEND_AVAILABLE" ] if (use_cups_ipp) { sources += [ "backend/cups_connection.cc", "backend/cups_connection.h", "backend/cups_deleters.cc", "backend/cups_deleters.h", "backend/cups_ipp_constants.cc", "backend/cups_ipp_constants.h", "backend/cups_ipp_helper.cc", "backend/cups_ipp_helper.h", "backend/cups_ipp_utils.cc", "backend/cups_ipp_utils.h", "backend/cups_jobs.cc", "backend/cups_jobs.h", "backend/cups_printer.cc", "backend/cups_printer.h", "backend/print_backend_cups_ipp.cc", "backend/print_backend_cups_ipp.h", ] } if (is_chromeos) { deps += [ ":ipp_handlers_generate" ] sources += [ "backend/ipp_handler_map.h", "backend/ipp_handlers.cc", "backend/ipp_handlers.h", "printing_context_chromeos.cc", "printing_context_chromeos.h", ipp_handler_map_path, ] } else { # TODO(crbug.com/1062136): Remove the original CUPS backend for macOS # when Cloud Print support is terminated. Follow up after Jan 1, 2021. sources += [ "backend/cups_helper.cc", "backend/cups_helper.h", "backend/print_backend_cups.cc", "backend/print_backend_cups.h", ] # We still build the utils for fuzzing if not already built. if (use_fuzzing_engine && !use_cups_ipp) { sources += [ "backend/cups_ipp_constants.cc", "backend/cups_ipp_constants.h", "backend/cups_ipp_helper.cc", "backend/cups_ipp_helper.h", ] } } } if (use_cups_ipp || is_chromeos) { sources += [ "printer_query_result.h", "printer_status.cc", "printer_status.h", ] } } static_library("test_support") { testonly = true sources = [ "backend/test_print_backend.cc", "backend/test_print_backend.h", "image.cc", "image.h", ] configs += [ "//build/config/compiler:noshadowing" ] public_deps = [ "//printing", "//ui/gfx/geometry", ] deps = [ "//base", "//build:chromeos_buildflags", "//skia", "//ui/gfx", ] if (is_android) { sources += [ "image_android.cc" ] } if (is_fuchsia) { sources += [ "image_fuchsia.cc" ] } if (is_linux || is_chromeos) { sources += [ "image_linux.cc" ] } if (is_mac) { sources += [ "image_mac.cc" ] } if (is_win) { sources += [ "image_win.cc" ] } } test("printing_unittests") { sources = [ "backend/mojom/print_backend_mojom_traits_unittest.cc", "metafile_skia_unittest.cc", "nup_parameters_unittest.cc", "page_number_unittest.cc", "page_range_unittest.cc", "page_setup_unittest.cc", "print_settings_conversion_unittest.cc", "print_settings_unittest.cc", "printing_test.h", "printing_utils_unittest.cc", "units_unittest.cc", ] configs += [ "//build/config/compiler:noshadowing" ] deps = [ ":printing", "//base/test:test_support", "//build:chromeos_buildflags", "//mojo/core/test:run_all_unittests", "//mojo/public/cpp/test_support:test_utils", "//printing/backend/mojom", "//printing/common", "//printing/mojom", "//testing/gmock", "//testing/gtest", "//ui/base", "//ui/gfx", "//ui/gfx:test_support", "//ui/gfx/geometry", ] if (is_mac) { sources += [ "pdf_metafile_cg_mac_unittest.cc" ] data = [ "test/data/pdf_cg/", "../pdf/test/data/", ] } if (is_win) { sources += [ "emf_win_unittest.cc", "printed_document_unittest.cc", "printed_page_win_unittest.cc", "printing_context_win_unittest.cc", ] data = [ "test/data/emf/" ] } if (use_cups) { configs += [ ":cups" ] if (use_cups_ipp) { sources += [ "backend/cups_ipp_helper_unittest.cc" ] } if (is_chromeos) { sources += [ "printing_context_chromeos_unittest.cc" ] } else { sources += [ "backend/cups_helper_unittest.cc", "backend/print_backend_cups_unittest.cc", ] } } } if (use_cups) { config("cups") { defines = [ "USE_CUPS" ] if (is_mac) { libs = [ "cups" ] lib_dirs = [ "$mac_sdk_path/usr/lib" ] } else { # rebase_path does not accept an empty string if (use_sysroot) { cups_sysroot = rebase_path(sysroot) } else { cups_sysroot = "" } libs = exec_script("cups_config_helper.py", [ "--libs-for-gn", cups_sysroot, ], "value") } } } if (is_android) { generate_jni("printing_jni_headers") { sources = [ "android/java/src/org/chromium/printing/PrintingContext.java" ] } android_library("printing_java") { deps = [ "//base:base_java", "//base:jni_java", "//third_party/android_deps:androidx_annotation_annotation_java", "//ui/android:ui_java", ] sources = [ "android/java/src/org/chromium/printing/PrintDocumentAdapterWrapper.java", "android/java/src/org/chromium/printing/PrintManagerDelegate.java", "android/java/src/org/chromium/printing/PrintManagerDelegateImpl.java", "android/java/src/org/chromium/printing/Printable.java", "android/java/src/org/chromium/printing/PrintingContext.java", "android/java/src/org/chromium/printing/PrintingController.java", "android/java/src/org/chromium/printing/PrintingControllerImpl.java", ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] } }