File: BUILD.gn

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (164 lines) | stat: -rw-r--r-- 4,257 bytes parent folder | download | duplicates (4)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# 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/cast.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/sysroot.gni")
import("//printing/buildflags/buildflags.gni")
import("//ui/qt/qt.gni")

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

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" ]

  # Don't use libc++ modules as this depends on libstdc++.
  use_libcxx_modules = false
}

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

  pkg_config("qt" + invoker.qt_version + "_config") {
    packages = [
      "Qt" + invoker.qt_version + "Core",
      "Qt" + invoker.qt_version + "Widgets",
    ]
  }

  shared_library(target_name) {
    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",
      ":qt" + invoker.qt_version + "_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" + invoker.qt_version + "_shim_moc.cc" ]
    } else {
      sources += get_target_outputs(":generate_moc" + invoker.qt_version)
      deps += [ ":generate_moc" + invoker.qt_version ]
    }

    # Don't depend on libcxx modules. This binary doesn't depend on the standard
    # library in libcxx. Instead it depends on the libcxx in the sysroot, so
    # using libcxx will just confuse it with duplicate definitions.
    use_libcxx_modules = false
  }
}
if (use_qt5) {
  qt_shim("qt5_shim") {
    qt_version = "5"
    if (!use_sysroot) {
      moc_qt_path = "$moc_qt5_path"
    }
  }
}
if (use_qt6) {
  qt_shim("qt6_shim") {
    qt_version = "6"
    if (!use_sysroot) {
      moc_qt_path = "$moc_qt6_path"
    }
  }
}

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 = []
  if (use_qt5) {
    data_deps += [ ":qt5_shim" ]
  }
  if (use_qt6) {
    data_deps += [ ":qt6_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" ]
  if (enable_printing) {
    public_deps += [ "//printing" ]
  }

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