Skip to content

Commit

Permalink
Create symbolic links in db for devices with identical fabric
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Michalak <[email protected]>
  • Loading branch information
tmichalak committed Mar 31, 2022
1 parent 18b9201 commit bcf0677
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,18 @@ db-format-$(1):
@$(IN_ENV) cd database/$(1); python3 ../../utils/sort_db.py
@if [ -e database/Info.md ]; then $(IN_ENV) ./utils/info_md.py --keep; fi

.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:
@+source settings/$(1).sh && $(IN_ENV) ./utils/create_db_links.py

db-extras-$(1): db-extras-$(1)-parts db-extras-$(1)-roi db-extras-$(1)-harness
.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

db-extras-$(1): db-extras-$(1)-parts db-extras-$(1)-roi db-extras-$(1)-harness db-extras-$(1)-links

db-$(1)-all: db-$(1) db-extras-$(1)-parts
# Build harnesses after database is complete
$$(MAKE) db-extras-$(1)-roi
$$(MAKE) db-extras-$(1)-harness
$$(MAKE) db-extras-$(1)-links

db-check: db-check-$(1)
db-format: db-format-$(1)
Expand Down
40 changes: 40 additions & 0 deletions utils/create_db_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 The SymbiFlow Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
import argparse
import os
from prjxray import util


def main():
"""Script for creating symlinks to device files within the db directory
in case a device has an identical fabric.
"""
parser = argparse.ArgumentParser(
description="Creates symlinks for devices with identical fabric.")

util.db_root_arg(parser)
args = parser.parse_args()

# Create links for all devices listed in the devices.yaml mapping file
devices = util.get_devices(args.db_root)
for device in devices:
dst = os.path.join(args.db_root, device)
if os.path.exists(dst):
continue
fabric = devices[device]['fabric']
src = os.path.join(args.db_root, fabric)
assert os.path.exists(src), "Fabric db files don't exist"
os.symlink(src, dst)


if __name__ == '__main__':
main()

0 comments on commit bcf0677

Please sign in to comment.