Skip to content

Commit d088e22

Browse files
authored
Merge pull request #10465 from oharboe/openroad-qt-v2
bazel: split Qt GUI into separate :openroad-qt target (field-tested respin of #10384)
2 parents c067f25 + 7442cee commit d088e22

13 files changed

Lines changed: 287 additions & 72 deletions

File tree

BUILD.bazel

Lines changed: 101 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025-2025, The OpenROAD Authors
33

4+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
45
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
56
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
67
load("@rules_cc//cc:cc_library.bzl", "cc_library")
@@ -98,6 +99,7 @@ OPENROAD_LIBRARY_DEPS = [
9899
"//src/exa:ui",
99100
"//src/fin",
100101
"//src/gpl",
102+
"//src/gpl:ui",
101103
"//src/grt",
102104
"//src/grt:ui",
103105
"//src/ifp",
@@ -138,12 +140,7 @@ OPENROAD_LIBRARY_DEPS = [
138140
"//src/web:ui",
139141
"@abc",
140142
":ord",
141-
] + select(
142-
{
143-
":platform_cli": ["//src/gui"],
144-
":platform_gui": ["//src/gui:gui_qt"],
145-
},
146-
)
143+
]
147144

148145
# Flags applied to top-level OpenROAD targets only. Flags that apply
149146
# globally to every cc_* target (-Wall, -Wextra, -Wno-sign-compare,
@@ -190,46 +187,113 @@ cc_library(
190187
],
191188
)
192189

190+
# Deps shared by :openroad and :openroad-qt. Kept as a Starlark list
191+
# rather than a cc_library wrapper because layering_check is enabled
192+
# package-wide: a deps-only cc_library does not re-export its deps'
193+
# headers to consumers, so direct binary deps are what each Main.cc
194+
# include needs to see.
195+
OPENROAD_MAIN_DEPS = [
196+
":openroad_version",
197+
":opt_notification",
198+
":ord",
199+
":tcl_readline_setup",
200+
"//bazel:tcl_library_init",
201+
"//src/cut",
202+
"//src/sta:opensta_lib",
203+
"//src/utl",
204+
"//src/web",
205+
"@abseil-cpp//absl/base:no_destructor",
206+
"@boost.stacktrace",
207+
"@rules_cc//cc/runfiles", # sets BAZEL_CURRENT_REPOSITORY
208+
"@tcl_lang//:tcl",
209+
]
210+
193211
cc_binary(
194212
name = "openroad",
195213
srcs = [
196214
"src/Main.cc",
197215
],
198216
copts = OPENROAD_COPTS,
217+
defines = OPENROAD_DEFINES,
199218
features = ["-use_header_modules"],
200219
malloc = select({
201220
"@platforms//os:linux": "@tcmalloc//tcmalloc",
202221
"@platforms//os:macos": "@bazel_tools//tools/cpp:malloc",
203222
}),
204223
visibility = ["//visibility:public"],
224+
deps = OPENROAD_MAIN_DEPS + select(
225+
{
226+
":platform_cli": [
227+
":openroad_lib",
228+
"//src/gui",
229+
"//src/gui:gui_stub",
230+
],
231+
":platform_gui": [
232+
":openroad_lib_qt",
233+
"//src/gui:gui_qt",
234+
],
235+
},
236+
),
237+
)
238+
239+
# Qt GUI variant. Build explicitly when the interactive GUI is wanted:
240+
# bazelisk build //:openroad-qt
241+
# Additive to the existing `--//:platform=gui //:openroad` flag path —
242+
# this target is preferable for ad-hoc GUI builds because it does not
243+
# invalidate `:openroad`'s cache the way flipping the flag does.
244+
cc_binary(
245+
name = "openroad-qt",
246+
srcs = [
247+
"src/Main.cc",
248+
],
249+
copts = OPENROAD_COPTS,
250+
defines = OPENROAD_DEFINES,
251+
features = ["-use_header_modules"],
252+
malloc = select({
253+
"@platforms//os:linux": "@tcmalloc//tcmalloc",
254+
"@platforms//os:macos": "@bazel_tools//tools/cpp:malloc",
255+
}),
256+
visibility = ["//visibility:public"],
257+
deps = OPENROAD_MAIN_DEPS + [
258+
":openroad_lib_qt",
259+
"//src/gui:gui_qt",
260+
],
261+
)
262+
263+
# CLI variant: the default. What downstream rule libraries pull as a
264+
# build-time tool, and what `bazelisk build //:openroad` produces.
265+
cc_library(
266+
name = "openroad_lib",
267+
srcs = [
268+
"src/Design.cc",
269+
"src/OpenRoad.cc",
270+
"src/Tech.cc",
271+
"src/Timing.cc",
272+
":openroad_swig",
273+
":openroad_tcl",
274+
],
275+
copts = OPENROAD_COPTS,
276+
defines = OPENROAD_DEFINES + ["BUILD_GUI=false"],
277+
features = ["-use_header_modules"],
278+
includes = [
279+
"include",
280+
],
281+
visibility = ["//:__subpackages__"],
205282
deps = [
206-
":openroad_lib",
207-
":openroad_version",
208-
":opt_notification",
209-
":ord",
210-
":tcl_readline_setup",
211-
"//bazel:tcl_library_init",
212-
"//src/cut",
213283
"//src/gui",
214284
"//src/sta:opensta_lib",
215-
"//src/utl",
216-
"//src/web",
217-
"@abseil-cpp//absl/base:no_destructor",
285+
"@abseil-cpp//absl/base:core_headers",
286+
"@abseil-cpp//absl/synchronization",
218287
"@boost.stacktrace",
219-
"@rules_cc//cc/runfiles", # sets BAZEL_CURRENT_REPOSITORY
220288
"@tcl_lang//:tcl",
221-
],
222-
)
223-
224-
GUI_BUILD_FLAGS = select(
225-
{
226-
":platform_cli": ["BUILD_GUI=false"],
227-
":platform_gui": ["BUILD_GUI=true"],
228-
},
289+
] + OPENROAD_LIBRARY_DEPS,
229290
)
230291

292+
# Qt variant: same sources, linked against the Qt GUI implementation.
293+
# Used by :openroad-qt, and by :openroad when --//:platform=gui is set.
294+
# Compiled separately (different `BUILD_GUI` define + different gui dep).
231295
cc_library(
232-
name = "openroad_lib",
296+
name = "openroad_lib_qt",
233297
srcs = [
234298
"src/Design.cc",
235299
"src/OpenRoad.cc",
@@ -239,13 +303,14 @@ cc_library(
239303
":openroad_tcl",
240304
],
241305
copts = OPENROAD_COPTS,
242-
defines = OPENROAD_DEFINES + GUI_BUILD_FLAGS,
306+
defines = OPENROAD_DEFINES + ["BUILD_GUI=true"],
243307
features = ["-use_header_modules"],
244308
includes = [
245309
"include",
246310
],
247311
visibility = ["//:__subpackages__"],
248312
deps = [
313+
"//src/gui:gui_qt",
249314
"//src/sta:opensta_lib",
250315
"@abseil-cpp//absl/base:core_headers",
251316
"@abseil-cpp//absl/synchronization",
@@ -347,6 +412,7 @@ cc_binary(
347412
"//src/gpl",
348413
"//src/grt",
349414
"//src/gui",
415+
"//src/gui:gui_stub",
350416
"//src/ifp",
351417
"//src/odb/src/db",
352418
"//src/par",
@@ -478,6 +544,14 @@ sh_test(
478544
tags = ["local"],
479545
)
480546

547+
# Make sure the Qt GUI variant keeps building. :openroad is exercised by
548+
# downstream rule libraries that pull it as a tool; :openroad-qt has no
549+
# such consumer in CI, so a build_test pins its compilability.
550+
build_test(
551+
name = "openroad_qt_build_test",
552+
targets = [":openroad-qt"],
553+
)
554+
481555
# ---------------------------------------------------------------------------
482556
# Lint & tidy targets
483557
#

src/gpl/BUILD

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,49 @@ package(
1414
features = ["layering_check"],
1515
)
1616

17+
# Headers owned by :gpl but also consumed by :ui. Kept package-private so
18+
# nothing outside //src/gpl can depend on them.
19+
cc_library(
20+
name = "gpl_private_hdrs",
21+
hdrs = [
22+
"src/nesterovBase.h",
23+
"src/nesterovPlace.h",
24+
"src/placerBase.h",
25+
"src/point.h",
26+
"src/routeBase.h",
27+
],
28+
includes = ["src"],
29+
visibility = ["//visibility:private"],
30+
deps = [
31+
"//src/odb/src/db",
32+
"//src/utl",
33+
"@boost.unordered",
34+
],
35+
)
36+
1737
cc_library(
1838
name = "gpl",
1939
srcs = [
2040
"src/AbstractGraphics.cpp",
21-
"src/MakeReplace.cpp",
2241
"src/fft.cpp",
2342
"src/fft.h",
2443
"src/fftsg.cpp",
2544
"src/fftsg2d.cpp",
26-
"src/graphicsImpl.cpp",
27-
"src/graphicsImpl.h",
2845
"src/graphicsNone.cpp",
2946
"src/initialPlace.cpp",
3047
"src/initialPlace.h",
3148
"src/mbff.cpp",
3249
"src/nesterovBase.cpp",
33-
"src/nesterovBase.h",
3450
"src/nesterovPlace.cpp",
35-
"src/nesterovPlace.h",
3651
"src/placerBase.cpp",
37-
"src/placerBase.h",
38-
"src/point.h",
3952
"src/replace.cpp",
4053
"src/routeBase.cpp",
41-
"src/routeBase.h",
4254
"src/solver.cpp",
4355
"src/solver.h",
4456
"src/timingBase.cpp",
4557
"src/timingBase.h",
46-
":swig",
47-
":tcl",
4858
],
4959
hdrs = [
50-
"include/gpl/MakeReplace.h",
5160
"include/gpl/Replace.h",
5261
"src/AbstractGraphics.h",
5362
"src/graphicsNone.h",
@@ -60,11 +69,10 @@ cc_library(
6069
"include",
6170
],
6271
deps = [
63-
"//:ord",
72+
":gpl_private_hdrs",
6473
"//src/dbSta",
6574
"//src/dbSta:dbNetwork",
6675
"//src/grt",
67-
"//src/gui",
6876
"//src/odb/src/db",
6977
"//src/rsz",
7078
"//src/sta:opensta_lib",
@@ -80,6 +88,37 @@ cc_library(
8088
"@or-tools//ortools/linear_solver:linear_solver_base",
8189
"@or-tools//ortools/sat:cp_model",
8290
"@or-tools//ortools/util:sorted_interval_list",
91+
],
92+
)
93+
94+
cc_library(
95+
name = "ui",
96+
srcs = [
97+
"src/MakeReplace.cpp",
98+
"src/graphicsImpl.cpp",
99+
"src/graphicsImpl.h",
100+
":swig",
101+
":tcl",
102+
],
103+
hdrs = [
104+
"include/gpl/MakeReplace.h",
105+
],
106+
copts = [
107+
"-Wno-missing-braces", # from TCL swigging
108+
],
109+
includes = [
110+
"include",
111+
"src",
112+
],
113+
deps = [
114+
":gpl",
115+
":gpl_private_hdrs",
116+
"//:ord",
117+
"//src/gui",
118+
"//src/odb/src/db",
119+
"//src/sta:opensta_lib",
120+
"//src/utl",
121+
"@boost.stacktrace",
83122
"@tcl_lang//:tcl",
84123
],
85124
)

src/gpl/test/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ cc_test(
155155
"library/test/test0.lib",
156156
],
157157
deps = [
158-
"//:openroad_lib",
159158
"//src/ant",
160159
"//src/dbSta",
161160
"//src/dbSta:dbReadVerilog",

src/grt/BUILD

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ cc_library(
3939
name = "fastroute",
4040
srcs = [
4141
"src/fastroute/src/FastRoute.cpp",
42-
"src/fastroute/src/FastRouteRenderer.cpp",
4342
"src/fastroute/src/RSMT.cpp",
4443
"src/fastroute/src/RipUp.cpp",
4544
"src/fastroute/src/graph2d.cpp",
@@ -50,7 +49,6 @@ cc_library(
5049
],
5150
hdrs = [
5251
"src/fastroute/include/FastRoute.h",
53-
"src/fastroute/include/FastRouteRenderer.h",
5452
"src/fastroute/include/Graph2D.h",
5553
],
5654
copts = [
@@ -66,7 +64,6 @@ cc_library(
6664
"//src/dbSta",
6765
"//src/dbSta:dbNetwork",
6866
"//src/est:parasitics_service",
69-
"//src/gui",
7067
"//src/odb/src/db",
7168
"//src/sta:opensta_lib",
7269
"//src/stt",
@@ -162,7 +159,6 @@ cc_library(
162159
"//src/dbSta:dbNetwork",
163160
"//src/dpl",
164161
"//src/drt:pin_access_service",
165-
"//src/gui",
166162
"//src/odb/src/db",
167163
"//src/sta:opensta_lib",
168164
"//src/stt",
@@ -186,6 +182,7 @@ cc_library(
186182
"src/MakeGlobalRouter.cpp",
187183
"src/Net.h",
188184
"src/Pin.h",
185+
"src/fastroute/src/FastRouteRenderer.cpp",
189186
"src/heatMap.cpp",
190187
"src/heatMap.h",
191188
"src/heatMapRudy.cpp",
@@ -195,6 +192,7 @@ cc_library(
195192
],
196193
hdrs = [
197194
"include/grt/MakeGlobalRouter.h",
195+
"src/fastroute/include/FastRouteRenderer.h",
198196
],
199197
copts = [
200198
"-Wno-missing-braces", # from TCL swigging
@@ -205,13 +203,15 @@ cc_library(
205203
"src",
206204
],
207205
deps = [
206+
":abstract-fastroute",
208207
":fastroute",
209208
":groute",
210209
":grt",
211210
"//:ord",
212211
"//src/gui",
213212
"//src/odb/src/db",
214213
"//src/sta:opensta_lib",
214+
"//src/stt",
215215
"//src/utl",
216216
"@boost.stacktrace",
217217
"@tcl_lang//:tcl",
@@ -239,6 +239,9 @@ tcl_wrap_cc(
239239
swig_includes = [
240240
"src",
241241
],
242+
deps = [
243+
"//src/odb:swig",
244+
],
242245
)
243246

244247
python_wrap_cc(

0 commit comments

Comments
 (0)