Skip to content

Commit bcf0677

Browse files
committed
Create symbolic links in db for devices with identical fabric
Signed-off-by: Tomasz Michalak <[email protected]>
1 parent 18b9201 commit bcf0677

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,18 @@ db-format-$(1):
168168
@$(IN_ENV) cd database/$(1); python3 ../../utils/sort_db.py
169169
@if [ -e database/Info.md ]; then $(IN_ENV) ./utils/info_md.py --keep; fi
170170

171-
.PHONY: db-prepare-$(1) db-$(1) db-check-$(1) db-format-$(1) db-extras-$(1) db-extras-$(1)-parts db-extra-$(1)-roi db-extras-$(1)-harness
171+
db-extras-$(1)-links:
172+
@+source settings/$(1).sh && $(IN_ENV) ./utils/create_db_links.py
172173

173-
db-extras-$(1): db-extras-$(1)-parts db-extras-$(1)-roi db-extras-$(1)-harness
174+
.PHONY: db-prepare-$(1) db-$(1) db-check-$(1) db-format-$(1) db-extras-$(1) db-extras-$(1)-parts db-extra-$(1)-roi db-extras-$(1)-harness db-extras-$(1)-links
175+
176+
db-extras-$(1): db-extras-$(1)-parts db-extras-$(1)-roi db-extras-$(1)-harness db-extras-$(1)-links
174177

175178
db-$(1)-all: db-$(1) db-extras-$(1)-parts
176179
# Build harnesses after database is complete
177180
$$(MAKE) db-extras-$(1)-roi
178181
$$(MAKE) db-extras-$(1)-harness
182+
$$(MAKE) db-extras-$(1)-links
179183

180184
db-check: db-check-$(1)
181185
db-format: db-format-$(1)

utils/create_db_links.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (C) 2022 The SymbiFlow Authors.
5+
#
6+
# Use of this source code is governed by a ISC-style
7+
# license that can be found in the LICENSE file or at
8+
# https://opensource.org/licenses/ISC
9+
#
10+
# SPDX-License-Identifier: ISC
11+
import argparse
12+
import os
13+
from prjxray import util
14+
15+
16+
def main():
17+
"""Script for creating symlinks to device files within the db directory
18+
in case a device has an identical fabric.
19+
20+
"""
21+
parser = argparse.ArgumentParser(
22+
description="Creates symlinks for devices with identical fabric.")
23+
24+
util.db_root_arg(parser)
25+
args = parser.parse_args()
26+
27+
# Create links for all devices listed in the devices.yaml mapping file
28+
devices = util.get_devices(args.db_root)
29+
for device in devices:
30+
dst = os.path.join(args.db_root, device)
31+
if os.path.exists(dst):
32+
continue
33+
fabric = devices[device]['fabric']
34+
src = os.path.join(args.db_root, fabric)
35+
assert os.path.exists(src), "Fabric db files don't exist"
36+
os.symlink(src, dst)
37+
38+
39+
if __name__ == '__main__':
40+
main()

0 commit comments

Comments
 (0)