Skip to content

Commit 8b18c8c

Browse files
committed
On bazel: use readline set-up provided by OpenROAD
The bazel compile always happens as submodule in OpenROAD, so we can use the same mechanism provided there to set up the readline library. Signed-off-by: Henner Zeller <h.zeller@acm.org>
1 parent defec0b commit 8b18c8c

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ cc_binary(
296296
visibility = ["//visibility:public"],
297297
deps = [
298298
":opensta_lib",
299+
"//:tcl_readline_setup",
299300
"//bazel:tcl_library_init",
300301
"@rules_cc//cc/runfiles",
301302
"@tcl_lang//:tcl",

app/Main.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#ifdef BAZEL_CURRENT_REPOSITORY
3535
#include "bazel/tcl_library_init.h"
36+
#include "src/tcl_readline_setup.h"
3637
#endif
3738

3839
#if TCL_READLINE
@@ -124,12 +125,18 @@ staTclAppInit(int argc,
124125
if (Tcl_Init(interp) == TCL_ERROR)
125126
return TCL_ERROR;
126127

128+
bool has_readline = false;
129+
#ifdef BAZEL_CURRENT_REPOSITORY
130+
has_readline = (ord::SetupTclReadlineLibrary(interp) == TCL_OK);
131+
#endif
127132
#if TCL_READLINE
128133
if (Tclreadline_Init(interp) == TCL_ERROR)
129134
return TCL_ERROR;
130135
Tcl_StaticPackage(interp, "tclreadline", Tclreadline_Init, Tclreadline_SafeInit);
131136
if (Tcl_EvalFile(interp, TCLRL_LIBRARY "/tclreadlineInit.tcl") != TCL_OK)
132137
printf("Failed to load tclreadline.tcl\n");
138+
else
139+
has_readline = true;
133140
#endif
134141

135142
initStaApp(argc, argv, interp);
@@ -167,11 +174,8 @@ staTclAppInit(int argc,
167174
}
168175
}
169176
}
170-
#if TCL_READLINE
171-
return Tcl_Eval(interp, "::tclreadline::Loop");
172-
#else
173-
return TCL_OK;
174-
#endif
177+
178+
return has_readline ? Tcl_Eval(interp, "::tclreadline::Loop") : TCL_OK;
175179
}
176180

177181
static void

0 commit comments

Comments
 (0)