예제 #1
0
def fetch_dependencies(dependency_names=None,
                       platform=None,
                       env=None,
                       fetch=True,
                       nuget=True,
                       clean=True,
                       source=False,
                       logfile=None,
                       list_details=False,
                       local_overrides=True,
                       verbose=False):
    '''
    Fetch all the dependencies defined in projectdata/dependencies.json and in
    projectdata/packages.config.
    platform:
        Name of target platform. E.g. 'Windows-x86', 'Linux-x64', 'Mac-x64'...
    env:
        Extra variables referenced by the dependencies file.
    fetch:
        True to fetch the listed dependencies, False to skip.
    nuget:
        True to fetch nuget packages listed in packages.config, False to skip.
    clean:
        True to clean out directories before fetching, False to skip.
    source:
        True to fetch source for the listed dependencies, False to skip.
    logfile:
        File-like object for log messages.
    '''
    if env is None:
        env = {}
    if platform is not None:
        env['platform'] = platform
    if 'platform' not in env:
        platform = env['platform'] = default_platform()
    if '-' in platform:
        env['system'], env['architecture'] = platform.split('-', 2)

    if platform is None:
        raise Exception('Platform not specified and unable to guess.')
    if clean and not list_details:
        clean_dirs = []
        if fetch:
            clean_dirs += [
                'dependencies/AnyPlatform', 'dependencies/' + platform
            ]
        if nuget:
            clean_dirs += ['dependencies/nuget']
        clean_directories(clean_dirs)

    overrides_filename = '../dependency_overrides.json' if local_overrides else None
    dependencies = read_json_dependencies_from_filename(
        'projectdata/dependencies.json',
        overrides_filename,
        env=env,
        logfile=logfile)
    if list_details:
        for name, dependency in dependencies.items():
            print "Dependency '{0}':".format(name)
            print "    fetches from:     {0!r}".format(
                dependency['archive-path'])
            print "    unpacks to:       {0!r}".format(dependency['dest'])
            print "    local override:   {0}".format(
                "YES (see '../dependency_overrides.json')" if dependency.
                has_overrides else 'no')
            if verbose:
                print "    all keys:"
                for key, value in sorted(dependency.items()):
                    print "        {0} = {1!r}".format(key, value)
            print ""
    else:
        if fetch:
            dependencies.fetch(dependency_names)
        if nuget:
            if not os.path.exists('projectdata/packages.config'):
                print "Skipping NuGet invocation because projectdata/packages.config not found."
            else:
                nuget_exes = [
                    os.path.normpath(p) for p in glob(
                        'dependencies/AnyPlatform/NuGet.[0-9]*/NuGet.exe')
                ]
                if len(nuget_exes) == 0:
                    raise Exception(
                        "'NuGet.exe' not found, cannot fetch NuGet dependencies."
                    )
                nuget_exe = nuget_exes[0]
                if len(nuget_exes) > 1:
                    print "Warning: multiple copies of 'NuGet.exe' found. Using:"
                    print "    " + nuget_exe
                cli([
                    nuget_exe, 'install', 'projectdata/packages.config',
                    '-OutputDirectory', 'dependencies/nuget'
                ])
        if source:
            dependencies.checkout(dependency_names)
    return dependencies
예제 #2
0
def fetch_dependencies(dependency_names=None, platform=None, env=None, fetch=True, nuget_packages=None, nuget_sln=None, nuget_config='nuget.config', clean=True, source=False, logfile=None, list_details=False, local_overrides=True, verbose=False):
    '''
    Fetch all the dependencies defined in projectdata/dependencies.json and in
    projectdata/packages.config.
    platform:
        Name of target platform. E.g. 'Windows-x86', 'Linux-x64', 'Mac-x64'...
    env:
        Extra variables referenced by the dependencies file.
    fetch:
        True to fetch the listed dependencies, False to skip.
    nuget:
        True to fetch nuget packages listed in packages.config, False to skip.
    clean:
        True to clean out directories before fetching, False to skip.
    source:
        True to fetch source for the listed dependencies, False to skip.
    logfile:
        File-like object for log messages.
    '''
    nuget = nuget_packages is not None or nuget_sln is not None
    if env is None:
        env = {}
    if platform is not None:
        env['platform'] = platform
    if 'platform' not in env:
        platform = env['platform'] = default_platform()
    if '-' in platform:
        env['system'], env['architecture'] = platform.split('-',2)

    if platform is None:
        raise Exception('Platform not specified and unable to guess.')
    if clean and not list_details:
        try:
            os.unlink('dependencies/loadedDeps.json')
        except:
            pass
        clean_dirs = ['dependencies']
        clean_directories(clean_dirs)

    overrides_filename = '../dependency_overrides.json' if local_overrides else None
    dependencies = read_json_dependencies_from_filename('projectdata/dependencies.json', overrides_filename, env=env, logfile=logfile)
    if list_details:
        for name, dependency in dependencies.items():
            print "Dependency '{0}':".format(name)
            print "    fetches from:     {0!r}".format(dependency['archive-path'])
            print "    unpacks to:       {0!r}".format(dependency['dest'])
            print "    local override:   {0}".format("YES (see '../dependency_overrides.json')" if dependency.has_overrides else 'no')
            if verbose:
                print "    all keys:"
                for key, value in sorted(dependency.items()):
                    print "        {0} = {1!r}".format(key, value)
            print ""
    else:
        if fetch:
            if not dependencies.fetch(dependency_names):
                raise Exception("Failed to load requested dependencies")

        if source:
            dependencies.checkout(dependency_names)

        if nuget_packages:
            # follow the legacy behaviour if a valid nuget packages.config file has been specified
            if not os.path.exists(nuget_packages):
                print "Skipping NuGet invocation because projectdata/packages.config not found."
            else:
                print "Fetching dependencies based on {0}".format(nuget_packages)
                nuget_exes = [os.path.normpath(p) for p in glob('dependencies/AnyPlatform/NuGet.[0-9]*/NuGet.exe')]
                if len(nuget_exes) == 0:
                    raise Exception("'NuGet.exe' not found, cannot fetch NuGet dependencies.")
                nuget_exe = nuget_exes[0]
                if len(nuget_exes) > 1:
                    print "Warning: multiple copies of 'NuGet.exe' found. Using:"
                    print "    " + nuget_exe
                cli([nuget_exe, 'install', nuget_packages, '-OutputDirectory', 'dependencies/nuget'])
        elif nuget_sln:
            if not os.path.exists(nuget_sln):
                print "Skipping NuGet invocation because {0} not found.".format(nuget_sln)
            else:
                print "Fetching dependencies based on {0}".format(nuget_sln)
                # recursive lookup of the nuget.config file does not work on linux... So,
                # the location of the file needs to be specified explicitly
                args = ['../ohdevtools/nuget/nuget.exe', 'restore', nuget_sln]
                if nuget_config is not None and os.path.isfile(nuget_config):
                    args += ['-ConfigFile', nuget_config]
                cli(args)

    # Finally perform cross-check of (major.minor) dependency versions to ensure that these are in sync
    # across this (current) repo and all its pulled-in dependencies. Done as totally seperate operation
    # to isolate from the main fetcher code to assist with any future maintenance
    if not clean:
        xcheck = deps_cross_checker.DepsCrossChecker( platform )
        result = xcheck.execute()
        if result != 0:
            raise Exception( 'Failed: dependency cross-checker detected problem(s)' )

    return dependencies
예제 #3
0
def fetch_dependencies(dependency_names=None,
                       platform=None,
                       env=None,
                       fetch=True,
                       clean=True,
                       source=False,
                       list_details=False,
                       local_overrides=True,
                       verbose=False):
    '''
    Fetch all the dependencies defined in projectdata/dependencies.json and in
    projectdata/packages.config.
    platform:
        Name of target platform. E.g. 'Windows-x86', 'Linux-x64', 'Mac-x64'...
    env:
        Extra variables referenced by the dependencies file.
    fetch:
        True to fetch the listed dependencies, False to skip.
    clean:
        True to clean out directories before fetching, False to skip.
    source:
        True to fetch source for the listed dependencies, False to skip.
    '''
    if env is None:
        env = {}

    if platform is not None:
        env['platform'] = None
        fName = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                             'platforms.txt')
        f = open(fName, 'rt')
        supported = f.readlines()
        f.close()
        for entry in supported:
            if platform in entry:
                env['platform'] = platform
        if not env['platform']:
            raise Exception(
                'Platform not supported (%s) - see %s for list of supported platforms'
                % (platform, fName))
    if 'platform' not in env:
        platform = env['platform'] = default_platform()
    if '-' in platform:
        env['system'], env['architecture'] = platform.split('-', 2)
    if platform is None:
        raise Exception('Platform not specified and unable to guess.')

    if clean and not list_details:
        try:
            os.unlink('dependencies/loadedDeps.json')
        except:
            pass
        clean_dirs('dependencies')

    overrides_filename = '../dependency_overrides.json' if local_overrides else None
    dependencies = read_json_dependencies_from_filename(
        'projectdata/dependencies.json', overrides_filename, env=env)
    if list_details:
        for name, dependency in dependencies.items():
            print("Dependency '{0}':".format(name))
            print("    fetches from:     {0!r}".format(
                dependency['archive-path']))
            print("    unpacks to:       {0!r}".format(dependency['dest']))
            print("    local override:   {0}".format(
                "YES (see '../dependency_overrides.json')" if dependency.
                has_overrides else 'no'))
            if verbose:
                print("    all keys:")
                for key, value in sorted(dependency.items()):
                    print("        {0} = {1!r}".format(key, value))
            print("")
    else:
        if fetch:
            if not dependencies.fetch(dependency_names):
                raise Exception("Failed to load requested dependencies")

        if source:
            dependencies.checkout(dependency_names)

    # Finally perform cross-check of (major.minor) dependency versions to ensure that these are in sync
    # across this (current) repo and all its pulled-in dependencies. Done as totally seperate operation
    # to isolate from the main fetcher code to assist with any future maintenance
    if not clean:
        xcheck = deps_cross_checker.DepsCrossChecker(platform)
        result = xcheck.execute()
        if result != 0:
            raise Exception(
                'Failed: dependency cross-checker detected problem(s)')

    return dependencies
예제 #4
0
        'archive-suffix': '',
        'binary-repo': 'http://builds.openhome.org/releases/artifacts',
        'mirror-repo': 'http://PC868.linn.co.uk/mirror.openhome.org/releases/artifacts',
        'archive-directory': '${binary-repo}/${name}/',
        'archive-filename': '${archive-prefix}${name}-${version}-${archive-platform}${archive-suffix}${archive-extension}',
        'remote-archive-path': '${archive-directory}${archive-filename}',
        'use-local-archive': False,
        'archive-path': '${use-local-archive?local-archive-path:remote-archive-path}',
        'mirror-path': '${mirror-repo}/${name}/${archive-filename}',
        'source-path': '${linn-git-user}@core.linn.co.uk:/home/git',
        'repo-name': '${name}',
        'source-git': '${source-path}/${repo-name}.git',
        'tag': '${repo-name}_${version}',
        'any-platform': 'AnyPlatform',
        'platform-specific': True,
        'host-platform': default_platform(),
        'archive-platform': '${platform-specific?platform:any-platform}',
        'dest': 'dependencies/${archive-platform}/',
        'configure-args': [],
        'strip-archive-dirs': 0
        },

    # Internal dependencies are named and structured in a similar manner
    # to those of type 'openhome', but are considered private, and held
    # on core.linn.co.uk
    #
    # Must define, at minimum:
    #       name
    #       version
    #
    # Commonly overridden:
예제 #5
0
        'archive-suffix': '',
        'binary-repo': 'http://builds.openhome.org/releases/artifacts',
        'archive-directory': '${binary-repo}/${name}/',
        'archive-filename':
        '${archive-prefix}${name}-${version}-${archive-platform}${archive-suffix}${archive-extension}',
        'remote-archive-path': '${archive-directory}${archive-filename}',
        'use-local-archive': False,
        'archive-path':
        '${use-local-archive?local-archive-path:remote-archive-path}',
        'source-path': '${linn-git-user}@core.linn.co.uk:/home/git',
        'repo-name': '${name}',
        'source-git': '${source-path}/${repo-name}.git',
        'tag': '${repo-name}_${version}',
        'any-platform': 'AnyPlatform',
        'platform-specific': True,
        'host-platform': default_platform(),
        'archive-platform': '${platform-specific?platform:any-platform}',
        'dest': 'dependencies/${archive-platform}/',
        'configure-args': []
    },

    # Internal dependencies are named and structured in a similar manner
    # to those of type 'openhome', but are considered private, and held
    # in a non-public location
    #
    # Must define, at minimum:
    #       name
    #       version
    #
    # Commonly overridden:
    #       archive-suffix