How to use the fusesoc.provider.provider.Provider 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 / provider / coregen.py View on Github external
import logging
import os
import shutil
from fusesoc.provider.provider import Provider
from fusesoc.utils import Launcher

logger = logging.getLogger(__name__)

class Coregen(Provider):

    def _checkout(self, local_dir):
        script_file  = self.config.get('script_file')
        project_file = self.config.get('project_file')
        extra_files  = self.config.get('extra_files')
        logger.info("Using Coregen to generate project " + project_file)
        if not os.path.isdir(local_dir):
            os.makedirs(local_dir)
        src_files = [script_file, project_file]
        if extra_files:
            src_files += extra_files.split()

        for f in src_files:
            f_src = os.path.join(self.core_root, f)
            f_dst = os.path.join(local_dir, f)
            if os.path.exists(f_src):
github olofk / fusesoc / fusesoc / provider / logicore.py View on Github external
import logging
import os
import shutil
from fusesoc.provider.provider import Provider
from fusesoc.utils import Launcher

logger = logging.getLogger(__name__)

class Logicore(Provider):

    def _checkout(self, local_dir):
        script_file  = self.config.get('script_file')
        project_file = self.config.get('project_file')
        extra_files  = self.config.get('extra_files')
        logger.info("Using Xilinx Vivado to generate LogiCORE(tm) project " + project_file)
        if not os.path.isdir(local_dir):
            os.mkdir(local_dir)
        src_files = [script_file, project_file]
        if extra_files:
            src_files += extra_files.split()

        for f in src_files:
            f_src = os.path.join(self.core_root, f)
            f_dst = os.path.join(local_dir, f)
            if os.path.exists(f_src):
github olofk / fusesoc / fusesoc / provider / local.py View on Github external
import logging
import os.path
from fusesoc.provider.provider import Provider

logger = logging.getLogger(__name__)

class Local(Provider):
    @staticmethod
    def init_library(library):
        if not os.path.isdir(library.location):
            logger.error("Local library at location '{}' not found.".format(library.location))
            exit(1)

    def _checkout(self, local_dir):
        pass

    @staticmethod
    def update_library(library):
        pass
github olofk / fusesoc / fusesoc / provider / git.py View on Github external
import logging
import shutil
import os.path
import subprocess
from fusesoc.provider.provider import Provider
from fusesoc.utils import Launcher

logger = logging.getLogger(__name__)

class Git(Provider):
    @staticmethod
    def init_library(library):
        logger.info("Cloning library into {}".format(library.location))
        git_args = ['clone', library.sync_uri, library.location]
        try:
            Launcher('git', git_args).run()
        except subprocess.CalledProcessError as e:
            raise RuntimeError(str(e))

    @staticmethod
    def update_library(library):
        git_args = ['-C', library.location, 'pull']
        try:
            Launcher('git', git_args).run()
        except subprocess.CalledProcessError as e:
            raise RuntimeError(str(e))
github olofk / fusesoc / fusesoc / provider / url.py View on Github external
import shutil

logger = logging.getLogger(__name__)

if sys.version_info[0] >= 3:
    import urllib.request as urllib
    from urllib.error import URLError
    from urllib.error import HTTPError
else:
    import urllib
    from urllib2 import URLError
    from urllib2 import HTTPError

from fusesoc.provider.provider import Provider

class Url(Provider):

    def _checkout(self, local_dir):
        url = self.config.get('url')
        logger.info("Downloading...")
        user_agent = self.config.get('user-agent')
        if not self.config.get('verify_cert', True):
            import ssl
            ssl._create_default_https_context = ssl._create_unverified_context

        if user_agent and sys.version_info[0] >= 3:
            opener = urllib.build_opener()
            opener.addheaders = [('User-agent', user_agent)]
            urllib.install_opener(opener)
        try:
            (filename, headers) = urllib.urlretrieve(url)
        except (URLError, HTTPError) as e:
github olofk / fusesoc / fusesoc / provider / opencores.py View on Github external
import logging
import sys

from fusesoc.provider.provider import Provider
from fusesoc.utils import Launcher, cygpath, is_mingw

logger = logging.getLogger(__name__)

REPO_PATH = 'http://opencores.org/ocsvn/{}/{}/{}'

class Opencores(Provider):

    def _checkout(self, local_dir):
        repo_name = self.config.get('repo_name')
        repo_path = REPO_PATH.format(repo_name,
                                     repo_name,
                                     self.config.get('repo_root'))
        revision_number  = self.config.get('revision')
        logger.info("Downloading " + repo_name + " from OpenCores")

        if is_mingw():
            logger.debug("Using cygpath translation")
            local_dir = cygpath(local_dir)

        Launcher('svn', ['co', '-q', '--no-auth-cache',
                         '-r', revision_number,
                         '--username', 'orpsoc',
github olofk / fusesoc / fusesoc / provider / github.py View on Github external
import sys
import tarfile
from fusesoc.provider.provider import Provider

logger = logging.getLogger(__name__)

if sys.version_info[0] >= 3:
    import urllib.request as urllib
    from urllib.error import URLError
else:
    import urllib
    from urllib2 import URLError

URL = 'https://github.com/{user}/{repo}/archive/{version}.tar.gz'

class Github(Provider):

    def _checkout(self, local_dir):
        user   = self.config.get('user')
        repo   = self.config.get('repo')

        version = self.config.get('version', 'master')

        #TODO : Sanitize URL
        url = URL.format(user=user,
                         repo=repo,
                         version=version)
        logger.info("Downloading {}/{} from github".format(user,
                                                       repo))
        try:
            (filename, headers) = urllib.urlretrieve(url)
        except URLError as e: