Skip to content

Commit

Permalink
orfs_flow: fix rename inputs
Browse files Browse the repository at this point in the history
Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Oct 18, 2024
1 parent 7214650 commit 8b65a95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions openroad.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,9 @@ def yosys_only_attrs():

def renamed_inputs_attrs(outputs):
return {
"renamed_inputs": attr.string_dict(
default = {out: out for out in outputs},
"renamed_inputs": attr.string_keyed_label_dict(
default = {out.basename: out for out in outputs},
allow_files = True,
),
}

Expand Down Expand Up @@ -497,6 +498,8 @@ def _generation_commands(optional_files):
def _input_commands(ctx, inputs):
"""Move inputs to the expected input locations"""
reverse = {v: k for k, v in ctx.attr.renamed_inputs.items() if k != v}
print(reverse)
print(inputs)
categories = ["results", "reports"]
output_folders = ["/".join([
_work_home(ctx),
Expand All @@ -512,15 +515,15 @@ def _input_commands(ctx, inputs):
return (["mkdir -p {}".format(folder) for folder in output_folders] +
["mv {} {}".format(
input.path,
"/".join(_pick_output_folder(input), reverse[input.basename]),
) for input in inputs if input.basename in reverse] +
"/".join([_pick_output_folder(input), reverse[input]]),
) for input in inputs if input in reverse] +
[
"mv {} {}".format(
input.path,
"/".join([_pick_output_folder(input), input.basename]),
)
for input in inputs
if input.basename not in reverse and _pick_output_folder(input) != input.dirname
if input not in reverse and _pick_output_folder(input) != input.dirname
])

def _work_home(ctx):
Expand Down Expand Up @@ -814,6 +817,7 @@ def _make_impl(ctx, stage, steps, forwarded_names = [], result_names = [], objec
info[file.extension] = file

commands = _input_commands(ctx, ctx.files.src) + [ctx.executable._make.path + " $@"] + _generation_commands(reports + logs)
print(commands)

ctx.actions.run_shell(
arguments = ["--file", ctx.file._makefile.path] + steps,
Expand Down Expand Up @@ -1030,8 +1034,7 @@ orfs_route = rule(
"5_route.sdc",
],
),
attrs = openroad_attrs() | renamed_inputs_attrs([
]),
attrs = openroad_attrs() | renamed_inputs_attrs([]),
provides = flow_provides(),
executable = True,
)
Expand Down
2 changes: 1 addition & 1 deletion sram/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FAST_SETTINGS = {
},
mock_area = 0.95,
renamed_inputs = {
"floorplan": {"1_synth.v": "naja.v"},
"floorplan": {"1_synth.v": ":naja.v"},
} if variant == "naja" else {},
stage_sources = {
"synth": [":fakeram/constraints-sram.sdc"],
Expand Down

0 comments on commit 8b65a95

Please sign in to comment.