def print_version(data): ver_str = "" i = 0 for k in version_vars: ver_str += str(try_get_key(data, k, '0')) if i != 4: ver_str += '.' i += 1 return ver_str
def jenkins_gen_config(build_info, src_dir): def mk_groovy_list(l): glist = '' for e in l: glist = "'%s', %s" % (e, glist) return glist makers_dir = '%s/toolchain/makers' % src_dir template_dir = '%s/toolchain/cmake/Templates' % src_dir deps = get_dep_list(build_info) linux_targets = create_target_matrix(makers_dir, 'linux', build_info) osx_targets = create_target_matrix(makers_dir, 'osx', build_info) windows_targets = create_target_matrix(makers_dir, 'windows', build_info) repo_url = sshgit_to_https(git_get_origin(src_dir)) script_locations_unix = get_script_locations(build_info, 'unix') script_locations_windows = get_script_locations(build_info, 'windows') variables = { 'PROJECT_NAME': try_get_key(build_info, 'name', 'coffee'), 'LINUX_TARGETS': mk_groovy_list(linux_targets), 'OSX_TARGETS': mk_groovy_list(osx_targets), 'WINDOWS_TARGETS': mk_groovy_list(windows_targets), 'DEPENDENCIES': deps.replace(";", "%"), 'DEPENDENCIES_NIX': deps.replace(";", "%"), 'REPO_URL': repo_url, 'MAKEFILE_DIR': try_get_key(build_info, 'makefile_location', 'ci'), 'WINDOWS_BUILD_SCRIPT': '${srcDir}\\' + script_locations_windows.build[0], 'UNIX_BUILD_SCRIPT': '${srcDir}/' + script_locations_unix.build[0] } with open('%s/JenkinsTemplate.groovy' % template_dir, mode='r') as f: data = f.read() return configure_string(data, variables)
def jenkins_gen_config(build_info, src_dir): def mk_groovy_list(l): glist = '' for e in l: glist = "'%s', %s" % (e, glist) return glist makers_dir = '%s/toolchain/makers' % src_dir template_dir = '%s/toolchain/cmake/Templates' % src_dir linux_targets = create_target_matrix(makers_dir, 'linux', build_info) osx_targets = create_target_matrix(makers_dir, 'osx', build_info) windows_targets = create_target_matrix(makers_dir, 'windows', build_info) repo_url = sshgit_to_https(git_get_origin(src_dir)) script_locations_unix = get_script_locations(build_info, 'unix') script_locations_windows = get_script_locations(build_info, 'windows') variables = { 'PROJECT_NAME': try_get_key(build_info, 'name', 'coffee'), 'LINUX_TARGETS': mk_groovy_list(linux_targets), 'OSX_TARGETS': mk_groovy_list(osx_targets), 'WINDOWS_TARGETS': mk_groovy_list(windows_targets), 'REPO_URL': repo_url, 'MAKEFILE_DIR': try_get_key(build_info, 'makefile_location', 'ci'), 'WINDOWS_BUILD_SCRIPT': '${srcDir}\\' + script_locations_windows.build[0], 'UNIX_BUILD_SCRIPT': '${srcDir}/' + script_locations_unix.build[0] } with open('%s/JenkinsTemplate.groovy' % template_dir, mode='r') as f: data = f.read() return configure_string(data, variables)
def generate_config_files(services, build_info, source_dir): service_configs = {} for service in services: for plat in flatten_map(try_get_key(build_info, 'platforms', [])): if service.compatible_with(plat): try: service_configs[service.get_filename()] = (service(build_info, source_dir), service) except FileNotFoundError as e: print('%s: %s: %s: %s' % (service, e.__class__.__name__, e.filename, e.strerror)) except RuntimeError as e: print('%s: %s: %s' % (service, e.__class__.__name__, e.args)) break return service_configs
def generate_config_files(services, build_info, source_dir): service_configs = {} for service in services: for plat in flatten_map(try_get_key(build_info, 'platforms', [])): if service.compatible_with(plat): try: service_configs[service.get_filename()] = (service( build_info, source_dir), service) except FileNotFoundError as e: print('%s: %s: %s: %s' % (service, e.__class__.__name__, e.filename, e.strerror)) except RuntimeError as e: print('%s: %s: %s' % (service, e.__class__.__name__, e.args)) break return service_configs
def get_script_locations(build_info, platform): locs = ScriptLocations([], [], []) script_loc = try_get_key(build_info, 'script_location', 'toolchain/ci') if platform == 'windows': locs.deps.append(script_loc + '/appveyor-deps.ps1') locs.build.append(script_loc + '/appveyor-build.ps1') locs.deploy.append(script_loc + '/appveyor-deploy.ps1') locs.deps[0] = locs.deps[0].replace('/', '\\') locs.build[0] = locs.build[0].replace('/', '\\') locs.deploy[0] = locs.deploy[0].replace('/', '\\') elif platform == 'unix': locs.deps.append(script_loc + '/travis-deps.sh') locs.build.append(script_loc + '/travis-build.sh') locs.deploy.append(script_loc + '/travis-deploy.sh') return locs
def get_deploy_info(build_info): deploy_data = DeployInfo([], []) for e in try_get_key(build_info, 'branches', []): name = 'master' if 'name' in e: name = e['name'] if 'build' in e: if e['build']: deploy_data.build_branches.append(name) if 'deploy' in e: if e['deploy']: deploy_data.deploy_branches.append(name) else: pass if len(deploy_data.deploy_branches) == 0: deploy_data.deploy_branches.append('master') return deploy_data
def appveyor_gen_config(build_info, repo_dir): deploy_info = get_deploy_info(build_info) dependencies_list = get_dep_list(build_info) script_loc = build_info['script_location'].replace('/', '\\') make_loc = build_info['makefile_location'].replace('/', '\\') make_loc_native = build_info['makefile_location'] allow_fails = [] for f in try_get_key(build_info, 'allow_fail', []): e = f['env'].split('=') allow_fails += [{e[0]: e[1]}] deploy_patterns = '' secret = try_get_key(try_get_key(build_info, 'secrets', {}), 'appveyor', '') matrix = [] for p in create_target_matrix(repo_dir + '/' + make_loc_native, 'windows', build_info): matrix += [{'BUILDVARIANT': p}] script_locations = get_script_locations(build_info, 'windows') return { 'version': '{build}', 'skip_tags': True, 'branches': { 'only': deploy_info.build_branches }, 'configuration': ['Debug'], 'platform': 'x64', 'clone_script': [ { 'cmd': 'git clone -q --recursive --branch=%APPVEYOR_REPO_BRANCH% https://github.com/%APPVEYOR_REPO_NAME%.git %SOURCE_DIR%', }, { 'cmd': 'cd %SOURCE_DIR% && git checkout -qf %APPVEYOR_REPO_COMMIT%' } ], 'image': ['Visual Studio 2015', 'Visual Studio 2017'], 'matrix': { 'allow_failures': allow_fails, 'exclude': [ { 'BUILDVARIANT': 'uwp.amd64', 'image': 'Visual Studio 2015' } ] }, 'environment': { 'matrix': matrix, 'BUILD_DIR': 'C:\\projects\\%APPVEYOR_PROJECT_SLUG%', 'SOURCE_DIR': 'C:\\projects\\%APPVEYOR_PROJECT_SLUG%\\src', 'NOBUILD': 1, 'SAME_BUILD_DIR': 1, 'CMAKE_BIN': 'cmake.exe', 'MAKEFILE_DIR': make_loc, 'DEPENDENCIES': dependencies_list, 'DEPLOY_PATTERNS': deploy_patterns, 'GITHUB_TOKEN': { 'secure': secret } }, 'install': [ {'ps': script} for script in script_locations.deps ], 'build': { 'parallel': True, 'verbosity': 'minimal', 'project': '%s.sln' % (try_get_key(build_info, 'name', 'coffee'),) }, 'before_build': [ {'ps': script} for script in script_locations.build ], 'before_deploy': [ {'cmd': 'cmake.exe --build %BUILD_DIR% --target install --config %CONFIGURATION%'} ], 'deploy_script': [ {'ps': script} for script in script_locations.deploy ] }
def github_gen_config(build_info, repo_dir): script_loc = try_get_key(build_info, 'script_location', 'ci') make_loc = try_get_key(build_info, 'makefile_location', 'ci') linux_targets = create_target_matrix(repo_dir + '/' + make_loc, 'linux', build_info) macos_targets = create_target_matrix(repo_dir + '/' + make_loc, 'osx', build_info) windows_targets = create_target_matrix(repo_dir + '/' + make_loc, 'windows', build_info) linux_targets = {x: {'variant': x} for x in linux_targets} macos_targets = {x: {'variant': x} for x in macos_targets} windows_targets = {x: {'variant': x} for x in windows_targets} include_branches = [ x['name'] for x in try_get_key(build_info, 'branches', []) ] unix_env = { 'CONFIGURATION': 'Release', 'GENERATE_PROGRAMS': 'ON', 'BUILDVARIANT': '${{ matrix.variant }}', 'ACTIONS': '1', 'MAKEFILE_DIR': 'toolchain/makers', 'SOURCE_DIR': '${{ github.workspace }}/source', 'BUILD_DIR': '${{ github.workspace }}/build', 'BUILD_REPO_URI': '${{ github.repository }}', 'BUILD_REPO_BRANCH': '${{ github.ref }}', 'BUILD_REPO_EVENT': 'push', 'BUILD_REPO_ID': '', 'BUILD_REPO_URL': 'https://github.com/${{ github.repository }}', 'TRAVIS_COMMIT': '${{ github.sha }}', 'TRAVIS_REPO_SLUG': '${{ github.repository }}', 'GITHUB_TOKEN': '${{ secrets.GITHUB_TOKEN }}' } linux_env = unix_env.copy() osx_env = unix_env.copy() linux_env['TRAVIS_OS_NAME'] = 'linux' osx_env['TRAVIS_OS_NAME'] = 'osx' windows_env = { 'AZURE_IMAGE': 'vs2019-win2019', 'VSVERSION': '2019', 'OPENSSL_ROOT_DIR': '$(Build.SourcesDirectory)/openssl-libs/', 'ACTIONS': '1', 'BUILD_REPO_URI': '${{ github.repository }}', 'BUILD_REPO_BRANCH': '${{ github.ref }}', 'BUILD_REPO_EVENT': 'push', 'BUILD_REPO_ID': '${{ matrix.variant }}', 'BUILD_REPO_URL': 'https://github.com/${{ github.repository }}', 'GITHUB_TOKEN': '${{ secrets.GITHUB_TOKEN }}', 'CMAKE_BIN': 'cmake.exe', 'MAKEFILE_DIR': 'toolchain/makers', 'SAME_BUILD_DIR': '1', 'NOBUILD': '1', 'SOURCE_DIR': '${{ github.workspace }}/source', 'BUILD_DIR': '${{ github.workspace }}/build', 'APPVEYOR_BUILD_FOLDER': '${{ github.workspace }}/build', 'APPVEYOR_REPO_NAME': '${{ github.repository }}', 'APPVEYOR_REPO_COMMIT': '${{ github.sha }}', 'BUILDVARIANT': '${{ matrix.variant }}', 'GENERATE_PROGRAMS': 'ON', 'CONFIGURATION': 'Debug' } linux_strategy = defaultdict(list) macos_strategy = defaultdict(list) windows_strategy = defaultdict(list) android_strategy = defaultdict(list) for val in linux_targets.values(): for key in val: if val[key].startswith('android.'): android_strategy[key].append(val[key]) else: linux_strategy[key].append(val[key]) for val in macos_targets.values(): for key in val: macos_strategy[key].append(val[key]) for val in windows_targets.values(): for key in val: windows_strategy[key].append(val[key]) linux_strategy = dict(linux_strategy) macos_strategy = dict(macos_strategy) windows_strategy = dict(windows_strategy) android_strategy = dict(android_strategy) checkout_step = { 'uses': 'actions/checkout@v2', 'with': { 'submodules': True, 'path': 'source' } } package_step = [{ 'name': 'Compress executables', 'run': 'source/cb compress-usr-dir bin' }, { 'name': 'Compress libraries', 'run': 'source/cb compress-usr-dir libraries' }, { 'name': 'Uploading artifacts', 'uses': 'actions/upload-artifact@v2', 'with': { 'name': '{{matrix.variant}}', 'path': '*.tar.bz2' } }] return { 'name': 'CMake Build', 'on': { 'push': { 'branches': ['master', 'testing', 'feature**'] } }, 'jobs': { 'Linux': { 'runs-on': 'ubuntu-18.04', 'strategy': { 'fail-fast': False, 'matrix': linux_strategy }, 'env': linux_env.copy(), 'steps': [ deepcopy(checkout_step), { 'name': 'Select Docker container', 'run': 'sh ${{ github.workspace }}/source/.github/cmake/select/${{ matrix.variant }}.sh' }, { 'name': 'Building project', 'run': 'source/cb docker-build -GNinja' } ] + deepcopy(package_step) }, 'Coverage': { 'runs-on': 'ubuntu-18.04', 'strategy': { 'fail-fast': False, 'matrix': { 'variant': ['coverage'] } }, 'env': linux_env.copy(), 'steps': [ deepcopy(checkout_step), { 'name': 'Select Docker container', 'run': 'sh ${{ github.workspace }}/source/.github/cmake/select/${{ matrix.variant }}.sh' }, { 'name': 'Building project', 'run': 'source/cb docker-build -GNinja' }, { 'name': 'Running tests', 'env': { 'BUILD_TARGET': 'CoverageTest' }, 'run': 'source/cb docker-build -GNinja' }, { 'name': 'Gathering coverage info', 'uses': 'codecov/codecov-action@v1' } ] }, 'Android': { 'runs-on': 'ubuntu-18.04', 'strategy': { 'fail-fast': False, 'matrix': android_strategy }, 'env': linux_env.copy(), 'steps': [ deepcopy(checkout_step), { 'name': 'Select Docker container', 'run': 'echo "::set-env name=CONTAINER::hbirch/android:r21"' }, { 'name': 'Building project', 'run': 'source/cb docker-build -GNinja' } ] + deepcopy(package_step) }, 'macOS': { 'runs-on': 'macos-latest', 'strategy': { 'fail-fast': False, 'matrix': macos_strategy }, 'env': osx_env.copy(), 'steps': [ deepcopy(checkout_step), { 'name': 'Installing system dependencies', 'run': 'source/toolchain/ci/travis-deps.sh' }, { 'name': 'Building project', 'run': 'source/cb ci-build -GXcode', 'env': { 'BUILD_TARGET': 'ALL_BUILD' } } ] + deepcopy(package_step) }, 'Windows': { 'runs-on': 'windows-2019', 'strategy': { 'fail-fast': False, 'matrix': windows_strategy }, 'env': windows_env, 'steps': [ deepcopy(checkout_step), { 'run': 'source/toolchain/ci/appveyor-deps.ps1', 'shell': 'powershell', 'name': 'Downloading dependencies' }, { 'run': 'echo "::add-path::C:/Program Files/Nasm"', 'name': 'Add Nasm to PATH' }, { 'run': 'source/toolchain/ci/appveyor-build.ps1', 'shell': 'powershell', 'name': 'Configuring project' }, { 'run': '& cmake.exe --build $env:BUILD_DIR --target install --config $env:CONFIGURATION', 'shell': 'powershell', 'name': 'Building project' }, { 'run': 'source/toolchain/ci/appveyor-deploy.ps1', 'shell': 'powershell', 'name': 'Deploying artifacts', 'continue-on-error': True }, { 'name': 'Uploading artifacts', 'uses': 'actions/upload-artifact@v2', 'with': { 'name': '{{matrix.variant}}', 'path': 'build/*.7z' } } ] } } }
def create_target_matrix(makers_dir, target_base, build_info): targets = load_targets(makers_dir, target_base) platforms = list(flatten_map(try_get_key(build_info, 'platforms', {}))) return intersect_targets(targets.real_targets, targets.supports, platforms)
def get_dep_list(build_info): dependencies = '' deps = try_get_key(build_info, 'dependencies', []) for dep in deps: dependencies = '%s;%s' % (dep, dependencies) return dependencies
def appveyor_gen_config(build_info, repo_dir): deploy_info = get_deploy_info(build_info) script_loc = build_info['script_location'].replace('/', '\\') make_loc = build_info['makefile_location'].replace('/', '\\') make_loc_native = build_info['makefile_location'] allow_fails = [] for f in try_get_key(build_info, 'allow_fail', []): e = f['env'].split('=') allow_fails += [{e[0]: e[1]}] deploy_patterns = '' secret = try_get_key(try_get_key(build_info, 'secrets', {}), 'appveyor', '') matrix = [] for p in create_target_matrix(repo_dir + '/' + make_loc_native, 'windows', build_info): matrix += [{'BUILDVARIANT': p}] script_locations = get_script_locations(build_info, 'windows') return { 'version': '{build}', 'skip_tags': True, 'branches': { 'only': deploy_info.build_branches }, 'configuration': ['Debug'], 'platform': 'x64', 'clone_script': [{ 'cmd': 'git clone -q --recursive --branch=%APPVEYOR_REPO_BRANCH% https://github.com/%APPVEYOR_REPO_NAME%.git %SOURCE_DIR%', }, { 'cmd': 'cd %SOURCE_DIR% && git checkout -qf %APPVEYOR_REPO_COMMIT%' }], 'image': ['Visual Studio 2015', 'Visual Studio 2017'], 'matrix': { 'allow_failures': allow_fails, 'exclude': [{ 'BUILDVARIANT': 'uwp.amd64', 'image': 'Visual Studio 2015' }] }, 'environment': { 'matrix': matrix, 'BUILD_DIR': 'C:\\projects\\%APPVEYOR_PROJECT_SLUG%', 'SOURCE_DIR': 'C:\\projects\\%APPVEYOR_PROJECT_SLUG%\\src', 'NOBUILD': 1, 'SAME_BUILD_DIR': 1, 'CMAKE_BIN': 'cmake.exe', 'MAKEFILE_DIR': make_loc, 'DEPLOY_PATTERNS': deploy_patterns, 'GITHUB_TOKEN': { 'secure': secret } }, 'install': [{ 'ps': script } for script in script_locations.deps], 'build': { 'parallel': True, 'verbosity': 'minimal', 'project': '%s.sln' % (try_get_key(build_info, 'name', 'coffee'), ) }, 'before_build': [{ 'ps': script } for script in script_locations.build], 'before_deploy': [{ 'cmd': 'cmake.exe --build %BUILD_DIR% --target install --config %CONFIGURATION%' }], 'deploy_script': [{ 'ps': script } for script in script_locations.deploy] }
if not isfile(build_config): raise RuntimeError('Failed to locate build configuration file, exiting') def print_version(data): ver_str = "" i = 0 for k in version_vars: ver_str += str(try_get_key(data, k, '0')) if i != 4: ver_str += '.' i += 1 return ver_str config = read_yaml_file(build_config) version_cfg = try_get_key(config, 'version', {}) version_prefix = try_get_key(config, 'versionprefix', 'automated-release-') if len(version_cfg.keys()) == 0: for k in version_vars: version_cfg[k] = 0 version_cfg['major'] = 1 if args.increment_type != 'none': version_cfg[args.increment_type] = 1 + try_get_key(version_cfg, args.increment_type, 0) found_type = False for i in range(len(version_vars)):
def pipelines_gen_config(build_info, repo_dir): script_loc = try_get_key(build_info, 'script_location', 'ci') make_loc = try_get_key(build_info, 'makefile_location', 'ci') linux_targets = create_target_matrix(repo_dir + '/' + make_loc, 'linux', build_info) macos_targets = create_target_matrix(repo_dir + '/' + make_loc, 'osx', build_info) windows_targets = create_target_matrix(repo_dir + '/' + make_loc, 'windows', build_info) linux_targets = {x: {'variant': x} for x in linux_targets} macos_targets = {x: {'variant': x} for x in macos_targets} windows_targets = {x: {'variant': x} for x in windows_targets} include_branches = [ x['name'] for x in try_get_key(build_info, 'branches', []) ] unix_env = { 'CONFIGURATION': 'Release', 'BUILDVARIANT': '$(variant)', 'PIPELINES': '1', 'MAKEFILE_DIR': 'toolchain/makers', 'BUILD_REPO_URI': '$(Build.Repository.Uri)', 'BUILD_REPO_BRANCH': '$(Build.SourceBranch)', 'BUILD_REPO_EVENT': '$(Build.Reason)', 'BUILD_REPO_ID': '$(variant)', 'BUILD_REPO_URL': '', 'TRAVIS_COMMIT': '$(Build.SourceVersion)', 'TRAVIS_REPO_SLUG': '$(Build.Repository.Name)', 'GITHUB_TOKEN': '$(Github.Token)' } linux_env = unix_env.copy() osx_env = unix_env.copy() linux_env['TRAVIS_OS_NAME'] = 'linux' osx_env['TRAVIS_OS_NAME'] = 'osx' windows_env = { 'AZURE_IMAGE': 'vs2019-win2019', 'VSVERSION': '2019', 'OPENSSL_ROOT_DIR': '$(Build.SourcesDirectory)/openssl-libs/', 'PIPELINES': '1', 'BUILD_REPO_URI': '$(Build.Repository.Uri)', 'BUILD_REPO_BRANCH': '$(Build.SourceBranch)', 'BUILD_REPO_EVENT': '$(Build.Reason)', 'BUILD_REPO_ID': '$(variant)', 'BUILD_REPO_URL': '', 'GITHUB_TOKEN': '$(Github.Token)', 'CMAKE_BIN': 'cmake.exe', 'MAKEFILE_DIR': 'toolchain/makers', 'SAME_BUILD_DIR': '1', 'NOBUILD': '1', 'SOURCE_DIR': '$(Build.SourcesDirectory)', 'BUILD_DIR': '$(Build.SourcesDirectory)/build', 'APPVEYOR_BUILD_FOLDER': '$(Build.SourcesDirectory)/build', 'APPVEYOR_REPO_NAME': '$(Build.Repository.Name)', 'APPVEYOR_REPO_COMMIT': '$(Build.SourceVersion)', 'BUILDVARIANT': '$(variant)', 'CONFIGURATION': 'Debug', 'PATH': '$(Path);C:/Program Files/NASM' } return { 'trigger': { 'paths': { 'include': ['examples/*', 'src/*', 'tests/*', 'toolchain/*'] }, 'branches': { 'include': include_branches } }, 'jobs': [{ 'job': 'Linux', 'pool': { 'vmImage': 'ubuntu-18.04' }, 'strategy': { 'matrix': linux_targets }, 'steps': [{ 'checkout': 'self', 'submodules': True }, { 'script': './toolchain/ci/travis-deps.sh', 'displayName': 'Downloading dependencies', 'env': { 'TRAVIS_OS_NAME': 'linux', 'PIPELINES': '1' } }, { 'script': './toolchain/ci/travis-build.sh', 'displayName': 'Building project', 'env': linux_env.copy() }, { 'script': './toolchain/ci/travis-deploy.sh', 'displayName': 'Deploying artifacts', 'continueOnError': True, 'env': linux_env.copy() }] }, { 'job': 'macOS_and_iOS', 'pool': { 'vmImage': 'macos-10.14' }, 'strategy': { 'matrix': macos_targets }, 'steps': [{ 'checkout': 'self', 'submodules': True }, { 'script': './toolchain/ci/travis-deps.sh', 'displayName': 'Downloading dependencies', 'env': { 'TRAVIS_OS_NAME': 'osx', 'PIPELINES': '1' } }, { 'script': './toolchain/ci/travis-build.sh', 'displayName': 'Building project', 'env': osx_env.copy() }, { 'script': './toolchain/ci/travis-deploy.sh', 'displayName': 'Deploying artifacts', 'continueOnError': True, 'env': osx_env.copy() }] }, { 'job': 'Windows', 'pool': { 'vmImage': 'windows-2019' }, 'strategy': { 'matrix': windows_targets }, 'steps': [{ 'checkout': 'self', 'submodules': True }, { 'powershell': './toolchain/ci/appveyor-deps.ps1', 'displayName': 'Downloading dependencies', 'env': { 'AZURE_IMAGE': 'vs2019-win2019', 'OPENSSL_ROOT_DIR': '$(Build.SourcesDirectory)/openssl-libs/', 'PIPELINES': '1' } }, { 'powershell': './toolchain/ci/appveyor-build.ps1', 'displayName': 'Configuring project', 'env': windows_env.copy() }, { 'powershell': '& cmake.exe --build $env:BUILD_DIR --target install --config $env:CONFIGURATION', 'displayName': 'Building project', 'env': windows_env.copy() }, { 'powershell': './toolchain/ci/appveyor-deploy.ps1', 'displayName': 'Deploying artifacts', 'continueOnError': True, 'env': windows_env.copy() }] }] } pass
def travis_gen_config(build_info, repo_dir): script_loc = try_get_key(build_info, 'script_location', 'ci') make_loc = try_get_key(build_info, 'makefile_location', 'ci') def create_travis_matrix(current, build_info): env = create_env_matrix(current, build_info) for i, var in enumerate(env): env[i] = 'BUILDVARIANT=%s' % var return env def create_build_matrix(targets, build_info): excludes = [] matrices = [] for target in targets: matrix = create_target_matrix(repo_dir + '/' + make_loc, target, build_info) for i, e in enumerate(matrix): matrix[i] = "BUILDVARIANT=%s" % e matrices += matrix for target2 in targets: if target2 != target: for dist in matrix: excludes.append({'os': target2, 'env': dist}) return matrices, excludes build_matrix, excludes = create_build_matrix(['linux', 'osx'], build_info) if try_get_key(build_info, 'coverage', False): build_matrix.append('BUILDVARIANT=coverage') excludes.append({'os': 'osx', 'env': 'BUILDVARIANT=coverage'}) deploy_data = get_deploy_info(build_info) script_locs = get_script_locations(build_info, 'unix') return { 'language': 'cpp', 'dist': 'bionic', 'sudo': 'required', 'services': ['docker'], 'notifications': { 'email': True }, 'os': ['linux', 'osx'], 'compiles': ['clang'], 'env': { 'global': ['MAKEFILE_DIR=%s' % make_loc, 'CONFIGURATION=Release'], 'matrix': build_matrix }, 'matrix': { 'exclude': excludes, 'allow_failures': try_get_key(build_info, 'allow_fail', []) }, 'branches': { 'only': deploy_data.build_branches }, 'apt': { 'update': True }, 'addons': { 'homebrew': { 'update': True, 'packages': ['sdl2', 'cmake', 'python3', 'python', 'jq'] } }, 'before_script': script_locs.deps, 'script': script_locs.build, 'after_success': script_locs.deploy }
def travis_gen_config(build_info, repo_dir): script_loc = try_get_key(build_info, 'script_location', 'ci') make_loc = try_get_key(build_info, 'makefile_location', 'ci') def create_travis_matrix(current, build_info): env = create_env_matrix(current, build_info) for i, var in enumerate(env): env[i] = 'BUILDVARIANT=%s' % var return env def create_build_matrix(targets, build_info): excludes = [] matrices = [] for target in targets: matrix = create_target_matrix(repo_dir + '/' + make_loc, target, build_info) for i, e in enumerate(matrix): matrix[i] = "BUILDVARIANT=%s" % e matrices += matrix for target2 in targets: if target2 != target: for dist in matrix: excludes.append({'os': target2, 'env': dist}) return matrices, excludes build_matrix, excludes = create_build_matrix(['linux', 'osx'], build_info) if try_get_key(build_info, 'coverage', False): build_matrix.append('BUILDVARIANT=coverage') excludes.append({'os': 'osx', 'env': 'BUILDVARIANT=coverage'}) deploy_data = get_deploy_info(build_info) dependencies = get_dep_list(build_info).replace(";", "%") script_locs = get_script_locations(build_info, 'unix') return { 'language': 'cpp', 'dist': 'trusty', 'sudo': 'required', 'services': ['docker'], 'notifications': { 'email': True }, 'os': ['linux', 'osx'], 'compiles': ['clang'], 'env': { 'global': ['MAKEFILE_DIR=%s' % make_loc, 'DEPENDENCIES=%s' % dependencies, 'CONFIGURATION=Release'], 'matrix': build_matrix }, 'matrix': { 'exclude': excludes, 'allow_failures': try_get_key(build_info, 'allow_fail', []) }, 'branches': { 'only': deploy_data.build_branches }, 'apt': {'update': True}, 'before_script': script_locs.deps, 'script': script_locs.build, 'after_success': script_locs.deploy }