# Beware: git branch names need the 'refs/heads/' prefix, while tags need 'refs/tags/'
- project:
    name: tcwg_bmk-#{PROFILE_NAME}-#{BMK}-#{TOOLCHAIN}
#if TOOLCHAIN_gnu || TOOLCHAIN_gnu_eabi
    binutils_url: git://sourceware.org/git/binutils-gdb.git
    gcc_url: git+ssh://linaroci@gcc.gnu.org/git/gcc.git
# if TOOLCHAIN_gnu
    linux_url: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable.git
    linux_branch: linux-rolling-stable
    glibc_url: git://sourceware.org/git/glibc.git
# elif TOOLCHAIN_gnu_eabi
    newlib_url: git://sourceware.org/git/newlib-cygwin.git
# endif
#elif TOOLCHAIN_llvm
    llvm_url: https://github.com/llvm/llvm-project.git
#endif

    toolchain_name: #{TOOLCHAIN}

    # BMK defined in def files
    bmk:
#if BMK_coremark
      - coremark
#endif
#if BMK_spec2k6
      - spec2k6
#endif
#if BMK_cpu2017fast
      - cpu2017fast
#endif
#if BMK_cpu2017speed
      - cpu2017speed
#endif
#if BMK_cpu2017rate
      - cpu2017rate
#endif

    target:
#if TARGET_arm
#if SET_DOCKER_ARCH_yes
      - arm:
          docker_arch: armhf
#else
      - arm
#endif
#endif
#if TARGET_arm_eabi
      - arm_eabi
#endif
#if TARGET_aarch64
#if SET_DOCKER_ARCH_yes
      - aarch64:
          docker_arch: arm64
#else
      - aarch64
#endif
#endif


    # PROFILE_NAME defined in def files
    cflags:
#if (PROFILE_NAME_code_size && ! TOOLCHAIN_llvm)
      - O2
#endif
#if (PROFILE_NAME_code_size && ! TOOLCHAIN_llvm)
      - O2_LTO
#endif
#if ! PROFILE_NAME_code_size
      - O3
#endif
#if ! PROFILE_NAME_code_size
      - O3_LTO
#endif
#if PROFILE_NAME_code_size
      - Os
      - Os_LTO
# if TOOLCHAIN_llvm
      - Oz
      - Oz_LTO
# endif
#endif

    jobs:
#if BRANCH_master
      - 'tcwg_bmk-#{TOOLCHAIN}-master'
#endif


#if BRANCH_master
- job-group:
    name: tcwg_bmk-#{TOOLCHAIN}-master
    toolchain_ver: master
#if TOOLCHAIN_gnu || TOOLCHAIN_gnu_eabi
    binutils_branch: master
    gcc_branch: master
# if TOOLCHAIN_gnu
    glibc_branch: master
# elif TOOLCHAIN_gnu_eabi
    newlib_branch: master
# endif
#elif TOOLCHAIN_llvm
    llvm_branch: main
#endif
#if DISTRO_jammy
    distro: jammy
#else
    distro: default
#endif
#if (PROFILE_NAME_fujitsu_speed || PROFILE_NAME_qc_speed) && TOOLCHAIN_llvm
    # Schedule for Fujitsu and Qualcomm configurations are increased for llvm toolchain only
    cron_schedule: 'H H * * *'
#else
    cron_schedule: 'H H H/3 * *'
#endif
    jobs:
      - 'tcwg_bmk-#{PROFILE_NAME}-#{BMK}--#{TOOLCHAIN}-{target}-{toolchain_ver}-{cflags}-build'
      - 'tcwg_bmk-#{PROFILE_NAME}-#{BMK}--#{TOOLCHAIN}-{target}-{toolchain_ver}-{cflags}-bisect'
    ci_project: 'tcwg_bmk-#{PROFILE_NAME}-#{BMK}'
    ci_config: '#{TOOLCHAIN}-{target}-{toolchain_ver}-{cflags}'
#endif

#include tcwg/round-robin.yaml.inc

- job-template:
    name: tcwg_bmk-#{PROFILE_NAME}-#{BMK}--#{TOOLCHAIN}-{target}-{toolchain_ver}-{cflags}-build
    project-type: freestyle
    defaults: global
    properties:
      - build-properties:
          ci_project: '{ci_project}'
          ci_config: '{ci_config}'
    parameters:
      - build-parameters:
          default_git: 'default'
          distro: '{distro}'
    disabled: false
#if TOOLCHAIN_gnu_eabi
    node: tcwg-x86_64-build
#elif TOOLCHAIN_llvm || TOOLCHAIN_gnu
    node: tcwg-build_bmk && tcwg-armv8_64
#endif
    concurrent: false
    display-name: 'TCWG Build {ci_project}--{ci_config}'
    workspace: workspace/tcwg_bmk_$EXECUTOR_NUMBER
    scm:
      - build-scms:
#if TOOLCHAIN_gnu || TOOLCHAIN_gnu_eabi
          binutils_url: '{binutils_url}'
          binutils_branch: '{binutils_branch}'
          gcc_url: '{gcc_url}'
          gcc_branch: '{gcc_branch}'
# if TOOLCHAIN_gnu
          linux_url: '{linux_url}'
          linux_branch: '{linux_branch}'
          glibc_url: '{glibc_url}'
          glibc_branch: '{glibc_branch}'
# elif TOOLCHAIN_gnu_eabi
          newlib_url: '{newlib_url}'
          newlib_branch: '{newlib_branch}'
# endif
#elif TOOLCHAIN_llvm
          llvm_url: '{llvm_url}'
          llvm_branch: '{llvm_branch}'
#endif
    triggers:
      - pollscm:
          cron: '{cron_schedule}'
    wrappers:
      - build-wrappers:
#if PROFILE_NAME_fujitsu_speed
          timeout: 1200
#else
          timeout: 600
#endif
    builders:
      - run-build:
          ci_project: '{ci_project}'
          ci_config: '{ci_config}'
          build_script: 'tcwg_bmk-build.sh'
#if SET_DOCKER_ARCH_yes
          docker_arch: '{docker_arch}'
#endif
    publishers:
      - build-publishers:
          email_on_failure: false
          email_on_success: true

- job-template:
    name: tcwg_bmk-#{PROFILE_NAME}-#{BMK}--#{TOOLCHAIN}-{target}-{toolchain_ver}-{cflags}-bisect
    project-type: freestyle
    defaults: global
    properties:
      - bisect-properties:
          ci_project: '{ci_project}'
          ci_config: '{ci_config}'
    parameters:
      - bisect-parameters:
          distro: '{distro}'
    disabled: false
#if TOOLCHAIN_gnu_eabi
    node: tcwg-x86_64-build
#elif TOOLCHAIN_llvm || TOOLCHAIN_gnu
    node: tcwg-build_bmk && tcwg-armv8_64
#endif
    concurrent: false
    display-name: 'TCWG Bisect {ci_project}--{ci_config}'
    workspace: workspace/tcwg_bmk_$EXECUTOR_NUMBER
    scm:
      - jenkins-scripts
    wrappers:
      - bisect-wrappers:
          timeout: 2880
    builders:
      - run-bisect:
          ci_project: '{ci_project}'
          ci_config: '{ci_config}'
          build_script: 'tcwg_bmk-build.sh'
#if SET_DOCKER_ARCH_yes
          docker_arch: '{docker_arch}'
#endif
    publishers:
        - bisect-publishers

