Skip to content
Snippets Groups Projects
Commit 61568830 authored by calrama's avatar calrama
Browse files

Update ci/cd

parent 5b27ffc7
No related branches found
No related tags found
No related merge requests found
Pipeline #18641 passed
Pipeline: utility

#18642

    #! /usr/bin/env python3
    from os import environ as env
    from platform import system
    from subprocess import check_call, check_output
    from argparse import ArgumentParser
    def define(key: str, value: str):
    return ['-D', f'{key}={value}']
    def define_env(name: str):
    return define(name, env[name]) if name in env else []
    if system() == 'Windows':
    def setup_msvc():
    msvc_path = 'C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools'
    lines = check_output(
    [
    'cmd',
    '/c',
    'VsDevCmd.bat',
    '-arch=amd64',
    f'-vcvars_ver={env["VCVARS_VER"]}',
    '&',
    'set'
    ],
    cwd=msvc_path
    ).decode('utf-8').splitlines()
    for line in lines:
    split = line.split('=')
    if len(split) != 2:
    continue
    key, value = split
    if key in env and env[key] == value:
    continue
    env[key] = value
    def build(args):
    if system() == 'Windows':
    setup_msvc()
    command = ['cmake']
    command += ['-S', '.']
    command += ['-B', 'build']
    command += ['-G', 'Ninja']
    command += define_env('CMAKE_BUILD_TYPE')
    command += define('CMAKE_SUPPRESS_REGENERATION', 'ON')
    command += define('CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY', 'ON')
    if system() == 'Windows':
    command += define(
    'CMAKE_TOOLCHAIN_FILE',
    env['VCPKG_DIR'] + '/scripts/buildsystems/vcpkg.cmake'
    )
    command += define('VCPKG_TARGET_TRIPLET', env['VCPKG_TRIPLET'])
    check_call(command)
    command = ['ninja', '-C', 'build']
    check_call(command)
    def package(args):
    command = ['ninja', '-C', 'build', 'package']
    check_call(command)
    if __name__ == '__main__':
    parser = ArgumentParser()
    subparsers = parser.add_subparsers()
    build_parser = subparsers.add_parser('build')
    build_parser.set_defaults(task=build)
    package_parser = subparsers.add_parser('package')
    package_parser.set_defaults(task=package)
    args = parser.parse_args()
    args.task(args)
    ......@@ -8,9 +8,9 @@ stages:
    tags: [ linux, docker ]
    image: git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:devel-ubuntu18.04
    .windows:
    tags: [ windows, docker ]
    image: git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:devel-windows
    .windows-1809:
    tags: [ windows-1809, docker ]
    image: git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:devel-windows1809
    .gcc8: &gcc8
    ......@@ -18,54 +18,40 @@ stages:
    CXX: g++-8
    .msvc15.9: &msvc15_9
    VSDevEnv -arch=amd64 -vcvars_ver="14.16"
    .debug: &debug
    CMAKE_BUILD_TYPE: Debug
    VCVARS_VER: '14.16'
    .release: &release
    CMAKE_BUILD_TYPE: Release
    .debug: &debug
    CMAKE_BUILD_TYPE: Debug
    .build ubuntu-18.04:
    extends: .ubuntu-18.04
    stage: build
    artifacts:
    paths:
    - build
    expire_in: 1 day
    script:
    - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -G Ninja -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_SKIP_PACKAGE_ALL_DEPENDENCY=ON
    - ninja -C build
    .build windows:
    extends: .windows
    .build: &build
    stage: build
    artifacts:
    paths:
    - build
    expire_in: 1 day
    before_script:
    - . $Profile
    - *msvc15_9
    script:
    - cmake -Bbuild "-H." -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -G Ninja -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="$env:VCPKG_TRIPLET" -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_SKIP_PACKAGE_ALL_DEPENDENCY=ON
    - ninja -C build
    script: ./.gitlab-ci.py build
    build ubuntu-18.04:
    extends: .build ubuntu-18.04
    extends: .ubuntu-18.04
    <<: *build
    variables:
    <<: [ *gcc8, *release ]
    build windows:
    extends: .build windows
    build windows-1809:
    extends: .windows-1809
    <<: *build
    variables:
    <<: [ *release ]
    <<: [ *msvc15_9, *release ]
    build windows[debug]:
    extends: .build windows
    build windows-1809[debug]:
    extends: .windows-1809
    <<: *build
    variables:
    <<: [ *debug ]
    <<: [ *msvc15_9, *debug ]
    .package: &package
    ......@@ -74,8 +60,7 @@ build windows[debug]:
    paths:
    - build/*.tar.xz
    expire_in: 1 week
    script:
    - ninja -C build package
    script: ./.gitlab-ci.py package
    package ubuntu-18.04:
    extends: .ubuntu-18.04
    ......@@ -83,22 +68,20 @@ package ubuntu-18.04:
    - build ubuntu-18.04
    <<: *package
    package windows:
    extends: .windows
    package windows-1809:
    extends: .windows-1809
    dependencies:
    - build windows
    - build windows-1809
    <<: *package
    package windows[debug]:
    extends: .windows
    package windows-1809[debug]:
    extends: .windows-1809
    dependencies:
    - build windows[debug]
    - build windows-1809[debug]
    <<: *package
    trigger dependents:
    extends: .ubuntu-18.04
    trigger robofish/utility:
    stage: deploy
    script:
    - . /etc/profile.d/robofish.sh
    - gitlab-trigger-pipeline bioroboticslab%2Fbiotracker%2Futility $CI_JOB_TOKEN master
    trigger:
    project: bioroboticslab/biotracker/utility
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment