Ejemplo n.º 1
0
    def __init__(self, core_file=None, name=None, core_root=None):
        if core_file:
            basename = os.path.basename(core_file)
        self.depend = []
        self.simulators = []

        self.plusargs = None
        self.provider = None
        self.system   = None

        for s in section.SECTION_MAP:
            assert(not hasattr(self, s))
            setattr(self, s, None)

        self.core_root = os.path.dirname(core_file)
        self.files_root = self.core_root

        if core_file:

            self.name = basename.split('.core')[0]
            config = FusesocConfigParser(core_file)

            #FIXME : Make simulators part of the core object
            self.simulator        = config.get_section('simulator')

            for s in section.load_all(config, name=self.name):
                setattr(self, s.TAG, s)
            self.depend     = self.main.depend
            self.simulators = self.main.simulators

            self.pre_run_scripts  = config.get_list('scripts','pre_run_scripts')
            self.post_run_scripts = config.get_list('scripts','post_run_scripts')

            cache_root = os.path.join(Config().cache_root, self.name)
            if config.has_section('plusargs'):
                self.plusargs = Plusargs(dict(config.items('plusargs')))
            if config.has_section('provider'):
                items    = dict(config.items('provider'))

                provider_name = items.get('name')
                if provider_name is None:
                    raise RuntimeError('Missing "name" in section [provider]')
                try:
                    provider_module = importlib.import_module(
                            'fusesoc.provider.%s' % provider_name)
                    self.provider = provider_module.PROVIDER_CLASS(self.name,
                        items, self.core_root, cache_root)
                except ImportError:
                    raise RuntimeError(
                            'Unknown provider "%s" in section [provider]' %
                            provider_name)
            if self.provider:
                self.files_root = self.provider.files_root

            system_file = os.path.join(self.core_root, self.name+'.system')
            if os.path.exists(system_file):
                self.system = System(system_file)
        else:
            self.name = name
            self.provider = None
Ejemplo n.º 2
0
    def __init__(self, core_file=None, name=None, core_root=None):
        if core_file:
            basename = os.path.basename(core_file)
        self.depend = []
        self.simulators = []

        self.plusargs = None
        self.provider = None
        self.system   = None

        for s in section.SECTION_MAP:
            assert(not hasattr(self, s))
            if(section.SECTION_MAP[s].named):
                setattr(self, s, OrderedDict())
            else:
                setattr(self, s, None)

        self.core_root = os.path.dirname(core_file)
        self.files_root = self.core_root

        self.export_files = []
        if core_file:

            config = FusesocConfigParser(core_file)

            #FIXME : Make simulators part of the core object
            self.simulator        = config.get_section('simulator')

            for s in section.load_all(config, core_file):
                if type(s) == tuple:
                    _l = getattr(self, s[0].TAG)
                    _l[s[1]] = s[0]
                    setattr(self, s[0].TAG, _l)
                else:
                    setattr(self, s.TAG, s)

            if self.main.name:
                self.name = self.main.name
            else:
                self.name = basename.split('.core')[0]

            self.sanitized_name = self.name

            self.depend     = self.main.depend
            self.simulators = self.main.simulators

            self._collect_filesets()

            cache_root = os.path.join(Config().cache_root, self.sanitized_name)
            if config.has_section('plusargs'):
                utils.pr_warn("plusargs section is deprecated and will not be parsed by FuseSoC. Please migrate to parameters in " + str(self.name))
                self.plusargs = Plusargs(dict(config.items('plusargs')))
            if config.has_section('provider'):
                items    = dict(config.items('provider'))

                provider_name = items.get('name')
                if provider_name is None:
                    raise RuntimeError('Missing "name" in section [provider]')
                try:
                    provider_module = importlib.import_module(
                            'fusesoc.provider.%s' % provider_name)
                    self.provider = provider_module.PROVIDER_CLASS(self.name,
                        items, self.core_root, cache_root)
                except ImportError:
                    raise
            if self.provider:
                self.files_root = self.provider.files_root

            # We need the component file here, but it might not be
            # available until the core is fetched. Try to fetch first if any
            # of the component files are missing
            if False in [os.path.exists(f) for f in self.main.component]:
                self.setup()

            for f in self.main.component:
                self._parse_component(os.path.join(self.files_root, f))

            system_file = os.path.join(self.core_root, basename.split('.core')[0]+'.system')
            if os.path.exists(system_file):
                self.system = System(system_file)
        else:
            self.name = name
            self.provider = None
Ejemplo n.º 3
0
    def __init__(self, core_file):
        basename = os.path.basename(core_file)
        self.depend = []
        self.simulators = []

        self.plusargs = None
        self.provider = None
        self.backend = None

        for s in section.SECTION_MAP:
            assert (not hasattr(self, s))
            if (section.SECTION_MAP[s].named):
                setattr(self, s, OrderedDict())
            else:
                setattr(self, s, None)

        self.core_root = os.path.dirname(core_file)
        self.files_root = self.core_root

        self.export_files = []

        config = FusesocConfigParser(core_file)

        #Add .system options to .core file
        system_file = os.path.join(self.core_root,
                                   basename.split('.core')[0] + '.system')
        if os.path.exists(system_file):
            self._merge_system_file(system_file, config)

        #FIXME : Make simulators part of the core object
        self.simulator = config.get_section('simulator')
        if not 'toplevel' in self.simulator:
            self.simulator['toplevel'] = 'orpsoc_tb'

        for s in section.load_all(config, core_file):
            if type(s) == tuple:
                _l = getattr(self, s[0].TAG)
                _l[s[1]] = s[0]
                setattr(self, s[0].TAG, _l)
            else:
                setattr(self, s.TAG, s)

        if self.main.name:
            self.name = Vlnv(self.main.name)
        else:
            self.name = Vlnv(basename.split('.core')[0])

        self.sanitized_name = self.name.sanitized_name

        self.depend = self.main.depend
        self.simulators = self.main.simulators

        if self.main.backend:
            self.backend = getattr(self, self.main.backend)

        self._collect_filesets()

        cache_root = os.path.join(Config().cache_root, self.sanitized_name)
        if config.has_section('plusargs'):
            logger.warning(
                "plusargs section is deprecated and will not be parsed by FuseSoC. Please migrate to parameters in "
                + str(self.name))
            self.plusargs = Plusargs(dict(config.items('plusargs')))
        if config.has_section('provider'):
            items = dict(config.items('provider'))
            patch_root = os.path.join(self.core_root, 'patches')
            patches = self.main.patches
            if os.path.exists(patch_root):
                for p in sorted(os.listdir(patch_root)):
                    patches.append(os.path.join('patches', p))
            items['patches'] = patches
            provider_name = items.get('name')
            if provider_name is None:
                raise RuntimeError('Missing "name" in section [provider]')
            provider_module = importlib.import_module('fusesoc.provider.%s' %
                                                      provider_name)
            self.provider = provider_module.PROVIDER_CLASS(
                items, self.core_root, cache_root)
        if self.provider:
            self.files_root = self.provider.files_root

        # We need the component file here, but it might not be
        # available until the core is fetched. Try to fetch first if any
        # of the component files are missing
        if False in [os.path.exists(f) for f in self.main.component]:
            self.setup()

        for f in self.main.component:
            self._parse_component(f)
Ejemplo n.º 4
0
    def __init__(self, core_file=None, name=None, core_root=None):
        if core_file:
            basename = os.path.basename(core_file)
        self.depend = []
        self.simulators = []

        self.plusargs = None
        self.provider = None
        self.system = None

        for s in section.SECTION_MAP:
            assert (not hasattr(self, s))
            setattr(self, s, None)

        self.core_root = os.path.dirname(core_file)
        self.files_root = self.core_root

        if core_file:

            self.name = basename.split('.core')[0]
            config = FusesocConfigParser(core_file)

            #FIXME : Make simulators part of the core object
            self.simulator = config.get_section('simulator')

            for s in section.load_all(config, name=self.name):
                setattr(self, s.TAG, s)
            self.depend = self.main.depend
            self.simulators = self.main.simulators

            self.pre_build_scripts = config.get_list('scripts',
                                                     'pre_build_scripts')
            self.pre_run_scripts = config.get_list('scripts',
                                                   'pre_run_scripts')
            self.post_run_scripts = config.get_list('scripts',
                                                    'post_run_scripts')

            cache_root = os.path.join(Config().cache_root, self.name)
            if config.has_section('plusargs'):
                self.plusargs = Plusargs(dict(config.items('plusargs')))
            if config.has_section('provider'):
                items = dict(config.items('provider'))

                provider_name = items.get('name')
                if provider_name is None:
                    raise RuntimeError('Missing "name" in section [provider]')
                try:
                    provider_module = importlib.import_module(
                        'fusesoc.provider.%s' % provider_name)
                    self.provider = provider_module.PROVIDER_CLASS(
                        self.name, items, self.core_root, cache_root)
                except ImportError:
                    raise
            if self.provider:
                self.files_root = self.provider.files_root

            system_file = os.path.join(self.core_root, self.name + '.system')
            if os.path.exists(system_file):
                self.system = System(system_file)
        else:
            self.name = name
            self.provider = None