How to use the fusesoc.librarymanager.Library function in fusesoc

To help you get started, we’ve selected a few fusesoc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github olofk / fusesoc / fusesoc / config.py View on Github external
sync_uri = None

            try:
                sync_type = config.get(section, 'sync-type')
            except configparser.NoOptionError:
                # sync-uri is absent for local libraries
                sync_type = None
            libraries.append(Library(name, location, sync_type, sync_uri, auto_sync))
        # Get the environment variable for further cores
        env_cores_root = []
        if os.getenv("FUSESOC_CORES"):
            env_cores_root = os.getenv("FUSESOC_CORES").split(":")
            env_cores_root.reverse()

        for root in cores_root + systems_root + env_cores_root:
            self.libraries.append(Library(root, root))

        self.libraries += libraries

        logger.debug('cache_root='+self.cache_root)
        logger.debug('library_root='+self.library_root)
github olofk / fusesoc / fusesoc / config.py View on Github external
_s = "Error parsing auto-sync '{}'. Ignoring library '{}'"
                logger.warning(_s.format(str(e), name))
                continue

            try:
                sync_uri = config.get(section, 'sync-uri')
            except configparser.NoOptionError:
                # sync-uri is absent for local libraries
                sync_uri = None

            try:
                sync_type = config.get(section, 'sync-type')
            except configparser.NoOptionError:
                # sync-uri is absent for local libraries
                sync_type = None
            libraries.append(Library(name, location, sync_type, sync_uri, auto_sync))
        # Get the environment variable for further cores
        env_cores_root = []
        if os.getenv("FUSESOC_CORES"):
            env_cores_root = os.getenv("FUSESOC_CORES").split(":")
            env_cores_root.reverse()

        for root in cores_root + systems_root + env_cores_root:
            self.libraries.append(Library(root, root))

        self.libraries += libraries

        logger.debug('cache_root='+self.cache_root)
        logger.debug('library_root='+self.library_root)
github olofk / fusesoc / fusesoc / main.py View on Github external
uri = repo[1]
        default_dir = os.path.join(cm._lm.library_root, name)
        prompt = 'Directory to use for {} ({}) [{}] : '
        if args.y:
            location = None
        else:
            location = input(prompt.format(repo[0], repo[2], default_dir))
        if not location:
            location = default_dir
        if os.path.exists(location):
            logger.warning("'{}' already exists. This library will not be added to fusesoc.conf".format(location))
            #TODO: Prompt for overwrite
        else:
            logger.info("Initializing {}".format(name))
            try:
                library = Library(name, location, 'git', uri, True)
                config.add_library(library)
            except RuntimeError as e:
                logger.error("Init failed: " + str(e))
                exit(1)
    logger.info("FuseSoC is ready to use!")
github olofk / fusesoc / fusesoc / main.py View on Github external
else:
        sync_type = None

    #Check if it's a dir. Otherwise fall back to git repo
    if not sync_type:
        if os.path.isdir(sync_uri):
            sync_type = 'local'
        else:
            sync_type = 'git'

    if sync_type == 'local':
        logger.info("Interpreting sync-uri '{}' as location for local provider.".format(sync_uri))
        location = os.path.abspath(sync_uri)

    auto_sync = not args.no_auto_sync
    library = Library(args.name, location, sync_type, sync_uri, auto_sync)

    if args.config:
        config = Config(file=args.config)
    elif vars(args)['global']:
        xdg_config_home = os.environ.get('XDG_CONFIG_HOME') or \
                          os.path.join(os.path.expanduser('~'), '.config')
        config_file = os.path.join(xdg_config_home, 'fusesoc', 'fusesoc.conf')
        config = Config(path=config_file)
    else:
        config = Config(path="fusesoc.conf")

    try:
        config.add_library(library)
    except RuntimeError as e:
        logger.error("`add library` failed: " + str(e))
        exit(1)
github olofk / fusesoc / fusesoc / main.py View on Github external
def init_coremanager(config, args_cores_root):
    logger.debug("Initializing core manager")
    cm = CoreManager(config)

    args_libs = [Library(acr, acr) for acr in args_cores_root]
    #Add libraries from config file, env var and command-line
    for library in config.libraries + args_libs:
        try:
            cm.add_library(library)
        except (RuntimeError, IOError) as e:
            _s = "Failed to register library '{}'"
            logger.warning(_s.format(str(e)))

    return cm