Skip to content

Commit

Permalink
[#64310] docker.BUILD.bazel: openroad.bzl: Fixed final stage environm…
Browse files Browse the repository at this point in the history
…ent variables

Signed-off-by: Jan Bylicki <[email protected]>
  • Loading branch information
jbylicki committed Sep 4, 2024
1 parent 2bb24e8 commit 3a0efaa
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docker.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ filegroup(
srcs = ["lib64/ld-linux-x86-64.so.2"],
)

filegroup(
name = "libstdbuf.so",
srcs = ["usr/libexec/coreutils/libstdbuf.so"],
visibility = ["//visibility:public"],
)

filegroup(
name = "openroad",
data = [
Expand Down Expand Up @@ -71,6 +77,7 @@ filegroup(
name = "klayout",
data = [
":ld.so",
":libstdbuf.so",
],
srcs = ["usr/bin/klayout"],
visibility = ["//visibility:public"],
Expand Down
47 changes: 46 additions & 1 deletion openroad.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,44 @@ def commonpath(files):
path, _, _ = prefix.rpartition("/")
return path

def preloadwrap(command, library):
"""
Return `command` wrapped in an `LD_PRELOAD` statement.
Args:
command: The command to be wrapped.
library: The library to be preloaded.
Returns:
The wrapped command.
"""
return "LD_PRELOAD=" + library + " " + command

def envwrap(command):
"""
Return `command` argument wrapped in an `env -S` statement.
Args:
command: The command to be wrapped.
Returns:
The wrapped command.
"""
return "env -S " + command

def pathatlevel(path, level):
"""
Return `path` argument, `level` directories back.
Args:
path: Path to be prepended.
level: The level of the parent directory to go to.
Returns:
The edited path.
"""
return "/".join([".." for _ in range(level)] + [path])

def flow_substitutions(ctx):
return {
"${MAKEFILE_PATH}": ctx.file._makefile.path,
Expand All @@ -218,6 +256,7 @@ def openroad_substitutions(ctx):
"${TCL_LIBRARY}": commonpath(ctx.files._tcl),
"${LIBGL_DRIVERS_PATH}": commonpath(ctx.files._opengl),
"${QT_PLUGIN_PATH}": commonpath(ctx.files._qt_plugins),
"${QT_QPA_PLATFORM_PLUGIN_PATH}": commonpath(ctx.files._qt_plugins),
"${GIO_MODULE_DIR}": commonpath(ctx.files._gio_modules),
}

Expand Down Expand Up @@ -265,6 +304,10 @@ def flow_attrs():
default = ":make.tpl",
allow_single_file = True,
),
"_libstdbuf": attr.label(
allow_single_file = ["libstdbuf.so"],
default = Label("@docker_orfs//:libstdbuf.so"),
),
}

def yosys_only_attrs():
Expand Down Expand Up @@ -684,8 +727,10 @@ def _make_impl(ctx, stage, steps, result_names = [], object_names = [], log_name
"DESIGN_CONFIG": config.path,
"FLOW_HOME": ctx.file._makefile.dirname,
"OPENROAD_EXE": ctx.executable._openroad.path,
"KLAYOUT_CMD": ctx.executable._klayout.path,
"KLAYOUT_CMD": envwrap(preloadwrap(ctx.executable._klayout.path, ctx.file._libstdbuf.path)),
"TCL_LIBRARY": commonpath(ctx.files._tcl),
"QT_QPA_PLATFORM_PLUGIN_PATH": pathatlevel(commonpath(ctx.files._qt_plugins), 5),
"QT_PLUGIN_PATH": commonpath(ctx.files._qt_plugins),
},
inputs = depset(
ctx.files.src +
Expand Down

0 comments on commit 3a0efaa

Please sign in to comment.