Skip to content

Commit

Permalink
Merge pull request #34 from siliconcompiler/sdc-copy
Browse files Browse the repository at this point in the history
add output directory to sdc copy to ensure it works for external gall…
  • Loading branch information
gadfort committed Apr 19, 2024
2 parents 7f0c8c2 + 602bcb7 commit 02b9d15
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scripts/convert_sdc.py
Expand Up @@ -16,11 +16,13 @@ def _find_sources(source):
return sources


def __process_file(source, target, subs):
def __process_file(source, target, subs, output_dir):
print(f'Processing {source}')
with open(source, 'r') as f_in:
dir_root = os.path.dirname(source)
with open(os.path.join(dir_root, f'{target}.sdc'), 'w') as f_out:
dir_root = os.path.relpath(os.path.dirname(source), root())
design_path = os.path.join(output_dir, dir_root)
os.makedirs(design_path, exist_ok=True)
with open(os.path.join(design_path, f'{target}.sdc'), 'w') as f_out:
for line in f_in:
for sub_in, sub_out in subs:
line = _process_text(line, sub_in, sub_out)
Expand All @@ -43,6 +45,8 @@ def _process_text(source, sub_in, sub_out):

parser.add_argument('--source', type=str, help='Source main library', required=True)
parser.add_argument('--target', type=str, help='Target main library', required=True)
parser.add_argument('--output_dir', type=str, default=root(),
help='Output designs directory')

parser.add_argument(
'--sub', type=str, nargs='+',
Expand All @@ -56,4 +60,4 @@ def _process_text(source, sub_in, sub_out):
subs.append(sub.split(":"))

for src in _find_sources(args.source):
__process_file(src, args.target, subs)
__process_file(src, args.target, subs, args.output_dir)

0 comments on commit 02b9d15

Please sign in to comment.