Skip to content

Commit 5b9b002

Browse files
authored
Merge pull request #7725 from QuantamHD/enable_gui_bazel
gui: Enable gui with bazel
2 parents c04b952 + 3077792 commit 5b9b002

17 files changed

Lines changed: 304 additions & 29 deletions

BUILD.bazel

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ string_flag(
2525
build_setting_default = "cli",
2626
values = [
2727
"cli",
28+
"gui",
2829
],
2930
)
3031

@@ -35,6 +36,13 @@ config_setting(
3536
},
3637
)
3738

39+
config_setting(
40+
name = "platform_gui",
41+
flag_values = {
42+
":platform": "gui",
43+
},
44+
)
45+
3846
# TODO: once project is properly decomposed, we don't
3947
# need these blanked dependencies in multiple places anymore.
4048
OPENROAD_LIBRARY_DEPS = [
@@ -60,7 +68,6 @@ OPENROAD_LIBRARY_DEPS = [
6068
"//src/gpl",
6169
"//src/grt",
6270
"//src/grt:ui",
63-
"//src/gui",
6471
"//src/ifp",
6572
"//src/ifp:ui",
6673
"//src/mpl",
@@ -86,7 +93,12 @@ OPENROAD_LIBRARY_DEPS = [
8693
"//src/utl",
8794
"//src/utl:ui",
8895
"@edu_berkeley_abc//:abc-lib",
89-
]
96+
] + select(
97+
{
98+
":platform_gui": ["//src/gui:gui_qt"],
99+
":platform_cli": ["//src/gui"],
100+
},
101+
)
90102

91103
OPENROAD_COPTS = [
92104
"-Wno-error",
@@ -121,14 +133,9 @@ cc_binary(
121133
":rmp_swig",
122134
":rmp_tcl",
123135
"//bazel:runfiles",
124-
] + select({
125-
":platform_cli": [],
126-
}),
136+
],
127137
copts = OPENROAD_COPTS,
128138
features = ["-use_header_modules"],
129-
linkopts = select({
130-
":platform_cli": [],
131-
}),
132139
malloc = "@tcmalloc//tcmalloc",
133140
visibility = ["//visibility:public"],
134141
deps = [
@@ -143,6 +150,13 @@ cc_binary(
143150
],
144151
)
145152

153+
GUI_BUILD_FLAGS = select(
154+
{
155+
":platform_gui": ["BUILD_GUI=true"],
156+
":platform_cli": ["BUILD_GUI=false"],
157+
},
158+
)
159+
146160
cc_library(
147161
name = "openroad_lib_private",
148162
srcs = [
@@ -157,9 +171,7 @@ cc_library(
157171
"src/rmp/include/rmp/*.h",
158172
]),
159173
copts = OPENROAD_COPTS,
160-
defines = OPENROAD_DEFINES + [
161-
"BUILD_GUI=false",
162-
],
174+
defines = OPENROAD_DEFINES + GUI_BUILD_FLAGS,
163175
features = ["-use_header_modules"],
164176
includes = [
165177
"include",
@@ -185,9 +197,7 @@ cc_library(
185197
]),
186198
hdrs = glob(["src/rmp/include/rmp/*.h"]),
187199
copts = OPENROAD_COPTS,
188-
defines = OPENROAD_DEFINES + [
189-
"BUILD_GUI=false",
190-
],
200+
defines = OPENROAD_DEFINES + GUI_BUILD_FLAGS,
191201
features = ["-use_header_modules"],
192202
includes = [
193203
"include",

MODULE.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ bazel_dep(name = "spdlog", version = "1.15.1")
9090
bazel_dep(name = "tcmalloc", version = "0.0.0-20250331-43fcf6e")
9191
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
9292

93+
# A from source build of QT that allows it to link into OpenROAD.
94+
# Building like any other bazel project. scripts in the docker folder
95+
# of this project generate stubs .ifso for things like X11 that will
96+
# allow openroad to link, but will search on the system at runtime for
97+
# the correct system libs.
98+
bazel_dep(name = "qt-bazel")
99+
git_override(
100+
module_name = "qt-bazel",
101+
commit = "90cfbab79df93960c5493f8a75df6199fb80fe26",
102+
remote = "https://github.com/The-OpenROAD-Project/qt_bazel_prebuilts",
103+
)
104+
93105
bazel_dep(name = "googletest", version = "1.16.0", dev_dependency = True)
94106

95107
# Dependencies needed by one of the rules_hdl repos. Once they are on

MODULE.bazel.lock

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/InitRunFiles.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ class BazelInitializer
4141
using rules_cc::cc::runfiles::Runfiles;
4242

4343
std::string error;
44-
std::unique_ptr<Runfiles> runfiles(Runfiles::Create(
45-
getProgramLocation().value(), BAZEL_CURRENT_REPOSITORY, &error));
44+
std::string program_location = getProgramLocation().value();
45+
std::unique_ptr<Runfiles> runfiles(
46+
Runfiles::Create(program_location, BAZEL_CURRENT_REPOSITORY, &error));
4647
if (!runfiles) {
4748
std::cerr << "Error initializing Bazel runfiles: " << error << std::endl;
4849
std::exit(1);
@@ -57,6 +58,12 @@ class BazelInitializer
5758
<< std::endl;
5859
std::exit(1);
5960
}
61+
62+
// Setup env variables for any other libraries that use runfiles
63+
std::string manifest = program_location + ".runfiles/MANIFEST";
64+
std::string runfiles_dir = program_location + ".runfiles";
65+
setenv("RUNFILES_MANIFEST_FILE", manifest.c_str(), /*__replace=*/true);
66+
setenv("RUNFILES_DIR", runfiles_dir.c_str(), /*__replace=*/true);
6067
}
6168
};
6269

bazel/tcl_wrap_cc.bzl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,27 @@ def _tcl_wrap_cc_impl(ctx):
8686
tools = ctx.files._swig,
8787
executable = ([file for file in ctx.files._swig if file.basename == "swig"][0]),
8888
)
89+
90+
output_files = [output_file]
91+
92+
if ctx.attr.runtime_header:
93+
runtime_header = ctx.actions.declare_file(ctx.attr.runtime_header)
94+
runtime_args = ctx.actions.args()
95+
runtime_args.add("-tcl8")
96+
runtime_args.add("-external-runtime")
97+
runtime_args.add(runtime_header)
98+
ctx.actions.run(
99+
outputs = [runtime_header],
100+
inputs = [],
101+
arguments = [runtime_args],
102+
tools = [ctx.attr._swig.files_to_run],
103+
executable = ([file for file in ctx.files._swig if file.basename == "swig"][0]),
104+
toolchain = None,
105+
)
106+
output_files.append(runtime_header)
107+
89108
return [
90-
DefaultInfo(files = depset([output_file])),
109+
DefaultInfo(files = depset(output_files)),
91110
TclSwigInfo(
92111
transitive_srcs = src_inputs,
93112
includes = includes_paths,
@@ -133,6 +152,7 @@ tcl_wrap_cc = rule(
133152
"swig_options": attr.string_list(
134153
doc = "args to pass directly to the swig binary",
135154
),
155+
"runtime_header": attr.string(),
136156
"_swig": attr.label(
137157
default = "@org_swig//:swig_stable",
138158
allow_files = True,

src/dbSta/include/db_sta/dbSta.hh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,57 @@ class Logger;
2222

2323
namespace sta {
2424

25+
// std::any and typeid do not work on incomplete types
26+
// talking to the OpenSTA author about implementing these
27+
// upstream instead. https://github.com/llvm/llvm-project/issues/36746
28+
// for llvm bug.
29+
//
30+
// Deleting all the constructors to preserve behavior as opaque pointers.
31+
// This should let RTTI based constructs like std::any to work on these
32+
// types. See
33+
// https://github.com/The-OpenROAD-Project/OpenROAD/pull/7725#discussion_r2201423922
34+
// for more information.
35+
class Library
36+
{
37+
public:
38+
Library() = delete;
39+
};
40+
class Cell
41+
{
42+
public:
43+
Cell() = delete;
44+
};
45+
class Port
46+
{
47+
public:
48+
Port() = delete;
49+
};
50+
class Instance
51+
{
52+
public:
53+
Instance() = delete;
54+
};
55+
class Pin
56+
{
57+
public:
58+
Pin() = delete;
59+
};
60+
class Term
61+
{
62+
public:
63+
Term() = delete;
64+
};
65+
class Net
66+
{
67+
public:
68+
Net() = delete;
69+
};
70+
class ViewType
71+
{
72+
public:
73+
ViewType() = delete;
74+
};
75+
2576
class dbSta;
2677
class dbNetwork;
2778
class dbStaReport;

0 commit comments

Comments
 (0)