# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/linux/pkg_config.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_android) {
import("//build/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")
}
if (enable_printing_tests) {
import("//build/config/ios/bundle_data_from_filelist.gni")
} else {
assert(enable_printing)
}
if (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.")
}
config("strict") {
configs = [ "//build/config/compiler:wexit_time_destructors" ]
}
# Lower-dependency base printing files which are needed by both :printing and
# //printing/backend without incurring deeper UI dependencies (e.g.,
# //ui/accessibility). New files should normally be added to :printing, and
# only be moved here if they are also required by //printing/backend.
component("printing_base") {
sources = [
"print_job_constants.cc",
"print_job_constants.h",
"printing_features.cc",
"printing_features.h",
"printing_utils.cc",
"printing_utils.h",
"units.cc",
"units.h",
]
configs += [ ":strict" ]
if (use_cups_ipp || is_chromeos) {
sources += [
"printer_query_result.h",
"printer_status.cc",
"printer_status.h",
]
}
if (use_cups) {
public_configs = [ ":cups" ]
sources += [
"print_job_constants_cups.cc",
"print_job_constants_cups.h",
]
}
cflags = []
defines = [ "IS_PRINTING_BASE_IMPL" ]
public_deps = [
"//build:chromeos_buildflags",
"//printing/buildflags",
"//printing/mojom",
]
deps = [
"//base",
"//third_party/icu",
"//ui/gfx",
"//ui/gfx/geometry",
]
}
component("settings") {
sources = [
"page_range.cc",
"page_range.h",
"page_setup.cc",
"page_setup.h",
"print_settings.cc",
"print_settings.h",
]
public_deps = [ ":printing_base" ]
deps = [
"//base",
"//ui/gfx/geometry",
]
defines = [ "IS_PRINTING_SETTINGS_IMPL" ]
if (is_chromeos) {
deps += [ "//chromeos/crosapi/mojom" ]
}
}
if (enable_oop_printing && (is_linux || is_chromeos)) {
source_set("printing_sandbox_hook") {
sources = [
"sandbox/print_backend_sandbox_hook_linux.cc",
"sandbox/print_backend_sandbox_hook_linux.h",
]
configs += [ ":strict" ]
deps = [
":printing_base",
"//base",
"//printing/buildflags",
"//sandbox/linux:sandbox_services",
"//sandbox/policy",
"//services/network:network_sandbox_hook",
]
if (use_cups) {
configs += [ ":cups" ]
}
if (is_chromeos && use_cups) {
deps += [ "//printing/backend" ]
}
}
}
source_set("native_drawing_context") {
sources = [ "native_drawing_context.h" ]
configs += [ ":strict" ]
deps = [ "//base" ]
}
component("metafile") {
sources = [
"metafile.cc",
"metafile.h",
"metafile_agent.cc",
"metafile_agent.h",
"metafile_skia.cc",
"metafile_skia.h",
]
configs += [ ":strict" ]
defines = [ "IS_PRINTING_METAFILE_IMPL" ]
public_deps = [
":native_drawing_context",
"//printing/mojom",
]
deps = [
"//cc/paint",
"//printing/common",
"//ui/accessibility",
]
if (is_apple) {
sources += [
"pdf_metafile_cg_mac.cc",
"pdf_metafile_cg_mac.h",
]
frameworks = [
"CoreFoundation.framework",
"CoreGraphics.framework",
]
}
if (is_mac) {
frameworks += [ "ApplicationServices.framework" ]
}
if (is_win) {
sources += [
"emf_win.cc",
"emf_win.h",
]
libs = [ "xpsprint.lib" ]
}
}
component("printing") {
sources = [
"nup_parameters.cc",
"nup_parameters.h",
"page_number.cc",
"page_number.h",
"pdf_render_settings.h",
"print_dialog_linux_interface.h",
"print_settings_conversion.cc",
"print_settings_conversion.h",
"printed_document.cc",
"printed_document.h",
"printing_context.cc",
"printing_context.h",
"printing_context_factory_for_test.h",
"pwg_raster_settings.h",
]
configs += [ ":strict" ]
cflags = []
defines = [ "IS_PRINTING_IMPL" ]
public_deps = [
":metafile",
":native_drawing_context",
":printing_base",
":settings",
]
deps = [
"//base",
"//base:i18n",
"//build:chromeos_buildflags",
"//printing/mojom",
"//skia",
"//third_party/icu",
"//ui/gfx",
"//ui/gfx/geometry",
"//url",
]
if (is_android) {
sources += [
"printing_context_android.cc",
"printing_context_android.h",
]
deps += [
":printing_jni_headers",
"//ui/android",
]
}
if (!enable_basic_print_dialog) {
sources += [
"printing_context_no_system_dialog.cc",
"printing_context_no_system_dialog.h",
]
}
if (is_linux) {
sources += [
"printing_context_linux.cc",
"printing_context_linux.h",
]
deps += [ "//ui/linux:linux_ui" ]
}
if (is_mac) {
sources += [
"print_settings_initializer_mac.cc",
"print_settings_initializer_mac.h",
"printing_context_mac.h",
"printing_context_mac.mm",
]
frameworks = [
"AppKit.framework",
"QuartzCore.framework",
"ApplicationServices.framework",
"CoreFoundation.framework",
"CoreGraphics.framework",
]
}
if (is_win) {
sources += [
"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",
"windows_types.h",
]
deps += [ "//printing/backend" ]
}
if (use_aura) {
deps += [ "//ui/aura" ]
}
if (is_chromeos) {
sources += [
"client_info_helpers.cc",
"client_info_helpers.h",
"print_settings_conversion_chromeos.cc",
"print_settings_conversion_chromeos.h",
]
deps += [
"//chromeos/crosapi/mojom",
"//third_party/re2",
]
}
if (use_cups) {
if (is_chromeos) {
sources += [
"printing_context_chromeos.cc",
"printing_context_chromeos.h",
]
deps += [ "//printing/backend" ]
}
}
if (enable_oop_printing && (is_linux || is_chromeos)) {
deps += [ ":printing_sandbox_hook" ]
}
}
static_library("test_support") {
testonly = true
sources = [
"image.cc",
"image.h",
"test_printing_context.cc",
"test_printing_context.h",
]
public_deps = [
"//printing",
"//printing/backend:test_support",
"//printing/mojom",
"//ui/gfx/geometry",
]
deps = [
"//base",
"//build:chromeos_buildflags",
"//printing/backend",
"//skia",
"//ui/gfx",
]
}
if (enable_printing_tests) {
bundle_data_from_filelist("pdf_metafile_cg_mac_unittest_bundle_data") {
testonly = true
filelist_name = "test/pdf_metafile_cg_mac_unittest_bundle_data.filelist"
}
}
test("printing_unittests") {
sources = [
"backend/print_backend_unittest.cc",
"backend/print_backend_utils_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",
]
deps = [
":printing",
":test_support",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//mojo/core/test:run_all_unittests",
"//mojo/public/cpp/test_support:test_utils",
"//printing/backend",
"//printing/backend:test_support",
"//printing/common",
"//printing/mojom",
"//testing/gmock",
"//testing/gtest",
"//ui/base",
"//ui/gfx",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
]
if (enable_oop_printing) {
sources += [
"backend/mojom/print_backend_mojom_traits_unittest.cc",
"backend/test_print_backend_unittest.cc",
"mojom/printing_context_mojom_traits_unittest.cc",
]
deps += [
"//printing/backend/mojom",
"//printing/mojom:printing_context",
]
}
if (is_apple) {
sources += [ "pdf_metafile_cg_mac_unittest.cc" ]
}
if (is_mac) {
data = [
"test/data/pdf_cg/",
"../pdf/test/data/",
]
} else if (enable_printing_tests) {
deps += [
":pdf_metafile_cg_mac_unittest_bundle_data",
"//pdf:pdf_test_bundle_data",
]
}
if (is_win) {
sources += [
"backend/print_backend_win_unittest.cc",
"backend/win_helper_unittest.cc",
"backend/xps_utils_win_unittest.cc",
"emf_win_unittest.cc",
"printed_page_win_unittest.cc",
"printing_context_win_unittest.cc",
]
data = [ "test/data/emf/" ]
}
if (is_chromeos) {
sources += [
"client_info_helpers_unittest.cc",
"print_settings_conversion_chromeos_unittest.cc",
]
}
if (use_cups) {
if (use_cups_ipp) {
sources += [ "backend/cups_ipp_helper_unittest.cc" ]
}
if (is_chromeos) {
sources += [ "printing_context_chromeos_unittest.cc" ]
}
if (!is_chromeos_ash) {
sources += [
"backend/cups_helper_unittest.cc",
"backend/print_backend_cups_unittest.cc",
]
}
}
}
if (use_cups) {
if (is_chromeos_device) {
pkg_config("cups") {
packages = [ "cups" ]
}
} else {
config("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",
"//build/android:build_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/jni_zero:jni_zero_java",
"//ui/android:ui_java",
]
srcjar_deps = [ ":printing_jni_headers" ]
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",
]
}
}