blob: 99a77da29f415d29c661d5c3725a7253799797f9 [file] [log] [blame]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 The SkyWater PDK Authors.
#
# Use of this source code is governed by the Apache 2.0
# license that can be found in the LICENSE file or at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
import os
import pprint
import sys
import traceback
from skywater_pdk import base, corners, drives
def process(cellpath):
assert os.path.exists(cellpath), cellpath
assert os.path.isdir(cellpath), cellpath
files = [
(f, os.path.abspath(os.path.join(cellpath, f)))
for f in os.listdir(cellpath)]
files.sort()
dcell, fname = base.parse_pathname(cellpath)
assert isinstance(dcell, base.Cell), (cellpath, dcell, fname)
assert fname is None, (cellpath, dcell, fname)
extensions = set()
dcorners = set()
ddrives = set()
errors = []
for fname, fpath in files:
print("Processing:", fname)
if fname in ('README.rst',):
continue
try:
fcell, fextra, fext = base.parse_filename(fpath)
except Exception as e:
traceback.print_exc()
errors.append(e)
assert isinstance(fcell, base.Cell), (fpath, fcell, fextra, ext)
extensions.add(fext)
assert fcell.library == dcell.library, (fcell, dcell)
if not fextra:
continue
try:
fcorner = corners.parse_filename(fextra)
except Exception as e:
traceback.print_exc()
errors.append(e)
try:
assert fcell.name.startswith(dcell.name), (fcell, dcell)
fdrive = fcell.name[len(dcell.name):]
ddrives.add(drives.parse_drive(fdrive))
except Exception as e:
traceback.print_exc()
errors.append(e)
dcorners.add(fcorner)
dcorners = list(sorted(dcorners))
ddrives = list(sorted(ddrives))
print()
print(cellpath)
print('-'*75)
print('Cell:', dcell)
print('Cell drives:', ddrives)
print('Cell corners:')
pprint.pprint(dcorners)
print('File types:', extensions)
if errors:
raise ValueError("\n".join(errors))
def main(args):
for a in args:
print()
print()
process(os.path.abspath(a))
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))