summaryrefslogtreecommitdiff
path: root/chromium/ui/qt/BUILD.gn
blob: bbede00daa4d09cdfc4a5a11220b02551387b81b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright 2022 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/chromecast_build.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/sysroot.gni")
import("//ui/qt/qt.gni")

assert(use_qt)
assert(is_linux)
assert(!is_castos)

pkg_config("qt5_config") {
  packages = [
    "Qt5Core",
    "Qt5Widgets",
  ]
}

config("qt_internal_config") {
  if (is_clang) {
    # libstdc++ headers are incompatible with -fcomplete-member-pointers.
    cflags = [ "-fno-complete-member-pointers" ]
  }

  # It's OK to depend on the system libstdc++ since it's a dependency of QT, so
  # it will get loaded into the process anyway.
  libs = [ "stdc++" ]

  configs = [
    "//build/config/linux:runtime_library",
    "//build/config/posix:runtime_library",
  ]
}

source_set("qt_interface") {
  visibility = [ ":*" ]

  configs -= [ "//build/config/compiler:runtime_library" ]
  configs += [ ":qt_internal_config" ]

  # Since `:qt` depends on `qt_shim` via data_deps, gn check would error-out
  # if qt_interface.h was placed in `qt_shim`, so it's placed in a separate
  # target instead.
  public = [ "qt_interface.h" ]
  sources = [ "qt_interface.cc" ]
}

if (!use_sysroot) {
  action("generate_moc") {
    script = "moc_wrapper.py"
    inputs = [ "//ui/qt/qt_shim.h" ]
    outputs = [ "$root_gen_dir/qt_shim_moc.cc" ]
    args = rebase_path(inputs + outputs, root_build_dir)
  }
}

shared_library("qt5_shim") {
  visibility = [
    ":qt",
    "//chrome/installer/linux:*",
  ]

  # Since qt_shim is a shared library even in non-component builds, it shouldn't
  # depend on any other targets since that would duplicate code between binaries
  # leading to increased size and potential issues from duplicated global state.
  no_default_deps = true
  assert_no_deps = [
    "//base",
    "//buildtools/third_party/libc++",
  ]
  deps = [ ":qt_interface" ]

  configs -= [ "//build/config/compiler:runtime_library" ]
  configs += [
    ":qt_internal_config",
    ":qt5_config",
  ]

  public = []
  sources = [
    "qt_shim.cc",
    "qt_shim.h",
  ]
  if (use_sysroot) {
    # This file is generated with gen_qt_shim_moc.sh on an amd64 system to
    # avoid a build-time dependency on `moc` when using the sysroot.
    sources += [ "qt_shim_moc.cc" ]
  } else {
    sources += get_target_outputs(":generate_moc")
    deps += [ ":generate_moc" ]
  }
}

component("qt") {
  visibility = [ "//ui/linux:linux_ui_factory" ]

  defines = [ "IS_QT_IMPL" ]

  # qt_shim is in data_deps since we want to load it manually.
  data_deps = [ ":qt5_shim" ]
  deps = [
    ":qt_interface",
    "//base",
    "//printing/buildflags",
    "//ui/base/ime/linux",
    "//ui/color",
    "//ui/color:mixers",
    "//ui/gfx",
    "//ui/linux:linux_ui",
    "//ui/native_theme",
    "//ui/shell_dialogs",
    "//ui/views",
  ]
  public_deps = [ "//skia" ]

  sources = [
    "qt_ui.cc",
    "qt_ui.h",
  ]
}