coriolis/cumulus/src/designflow/druc.py

54 lines
1.7 KiB
Python
Raw Normal View History

import os
import subprocess
from pathlib import Path
from doit.exceptions import TaskFailed
from .task import FlowTask, ShellEnv
class MissingTarget ( Exception ): pass
class Druc ( FlowTask ):
Verbose = 0x0001
@staticmethod
def mkRule ( rule, depends=[], flags=0 ):
return Druc( rule, depends, flags )
def __init__ ( self, rule, depends, flags ):
super().__init__( rule, [], depends )
self.flags = flags
self.referenceFile = Path( self.file_depend(0) )
self.targets = [ self.referenceFile.stem + '.drc'
, self.referenceFile.stem + '_drc.gds'
, self.referenceFile.stem + '_rng.gds' ]
self.command = [ 'druc', self.referenceFile.stem ]
if flags & Druc.Verbose: self.command.append( '-v' )
self.addClean( self.targets )
def __repr__ ( self ):
return '<{}>'.format( ' '.join(self.command) )
def doTask ( self ):
Comprehensive reorganisation of the Python part of Coriolis. * Move all Python stuff under a common Python namespace "coriolis". * Instead of having a series subtrees for each tool, integrate everything in one common tree. So now, all components can be located either with an absolute path from "coriolis" or, inside cross-reference themselves through relatives imports. * As a consequence, we only need to add ".../site-packages/coriolis/" to the PYTHONPATH, and not a whole bunch of subdirectories. And nothing, if installed in-system. * The tree of free technologies configuration files is also moved below "coriolis/technos" instead of "/etc". * Supressed "cumulus" level for the plugins. * All python modules are rewritten using relative imports except for the configuration files that uses absolute import as they can be cloned outside of the tree to serve as templates. * Change: In boostrap/FindPythonSitePackages, include "/coriolis" in Python_CORIOLISARCH and Python_CORIOLISLIB. Provide a Python_SITELIB *without* "/coriolis" appended. * Change: In cumulus/plugins/__init__.loadPlugins(), must prefix modules read in the plugins directory by "coriolis.plugins.". No longer need to add their path to sys.path. * Change: In crlcore/python/technos/nodeX/*/devices.py, the scripts of the layouts generators must be prefixed by "coriolis.oroshi.". * Change: In CRL::System CTOR, no longer add the pathes of the various plugins to sys.path. Only "site-packages/coriolis/". * New: In Utilities::Path::toPyModePath(), new method to convert a filesystem path into a python module path. Examples: "coriolis/plugins/block" --> "coriolis.plugins.block". "coriolis/plugins/rsave.py" --> "coriolis.plugins.rsave". * Change: In katanaEngine::_runKatanaEngine(), rename the hook script initHook.py. No longer need to modify sys.path. * Change: In BoraEngine::_runBoraEngine(), rename the hook script initHook.py. No longer need to modify sys.path. * Change: In UnicornGui::_runUnicornInit(), rename the hook script initHook.py. No longer need to modify sys.path. * Change: In cumulus.plugins.chip.constants, put the constants outside __init__.py to avoid a loop at initialization.
2023-02-27 15:14:32 -06:00
from ..CRL import AllianceFramework
from ..helpers.io import ErrorMessage
shellEnv = ShellEnv()
shellEnv.export()
state = subprocess.run( self.command )
if state.returncode:
e = ErrorMessage( 1, 'Druc.doTask(): UNIX command failed ({}).' \
.format( state.returncode ))
return TaskFailed( e )
return self.checkTargets( 'Druc.doTask' )
def create_doit_tasks ( self ):
return { 'basename' : self.basename
, 'actions' : [ self.doTask ]
, 'doc' : 'Run {}.'.format( self )
, 'file_dep' : self.file_dep
}