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
|
--- a/ui/qt/qt.gni
+++ b/ui/qt/qt.gni
@@ -12,9 +12,21 @@ declare_args() {
use_qt = is_linux && !is_castos && !is_msan
}
+declare_args() {
+ if(!use_sysroot && use_qt) {
+ moc_qt5_path = ""
+ }
+}
+
declare_args() {
use_qt6 = use_qt && use_sysroot
}
+declare_args() {
+ if(!use_sysroot && use_qt6) {
+ moc_qt6_path = ""
+ }
+}
+
# use_qt6 => use_qt
assert(!use_qt6 || use_qt)
--- a/ui/qt/BUILD.gn
+++ b/ui/qt/BUILD.gn
@@ -41,16 +41,19 @@ source_set("qt_interface") {
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)
+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 ]
+ }
+ }
}
-}
-template("qt_shim") {
pkg_config("qt" + invoker.qt_version + "_config") {
packages = [
"Qt" + invoker.qt_version + "Core",
@@ -90,17 +93,23 @@ template("qt_shim") {
# 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")
- deps += [ ":generate_moc" ]
+ sources += get_target_outputs(":generate_moc" + invoker.qt_version)
+ deps += [ ":generate_moc" + invoker.qt_version ]
}
}
}
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"
+ }
}
}
--- a/ui/qt/moc_wrapper.py
+++ b/ui/qt/moc_wrapper.py
@@ -3,8 +3,21 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import argparse
import subprocess
-import sys
+parser = argparse.ArgumentParser()
+parser.add_argument(
+ 'input', type=str, help='Input header file.')
+parser.add_argument(
+ 'output', type=str, help='Output file.')
+parser.add_argument(
+ '--path', required=False, type=str, default=None,
+ help='Path to moc binary.')
-subprocess.check_call(["moc", sys.argv[1], "-o", sys.argv[2]])
+args = parser.parse_args()
+
+if args.path is None:
+ subprocess.check_call(["moc", args.input, "-o", args.output])
+else:
+ subprocess.check_call([args.path + "/moc", args.input, "-o", args.output])
|