stages:
  - build-toolchain
  - embench
  - compliance-test 
  - dhrystone
  - coremark
  #- util_timing_rpt

build-toolchain:
    tags:
      - new-taiga-ci
    stage: build-toolchain
    script:
      - echo $CI_PROJECT_NAMESPACE
      - echo $CI_PROJECT_PATH
      - echo $CI_PROJECT_ROOT_NAMESPACE
      - echo $CI_PROJECT_TITLE
      - module load LANG/PYTHON/3.7.6
      - pip3 install meson
      # create the taiga project file hierachy 
      - cd ..
      - rm -rf taiga-project
      - cp -r $CI_PROJECT_TITLE taiga
      #- cp -r project-0 taiga # only used for local tests
      - git clone https://gitlab.com/sfu-rcl/taiga-project.git
      - mv -f taiga taiga-project/
      - cd taiga-project
      - source settings.sh
      - git clone https://github.com/gcc-mirror/gcc.git --branch releases/gcc-11 --single-branch tool-chain/gcc
      - git clone https://gitlab.com/sfu-rcl/taiga-picolibc.git --branch main --single-branch tool-chain/picolibc
      - git clone http://git.veripool.org/git/verilator --branch master --single-branch tool-chain/verilator
      - git clone https://github.com/bminor/binutils-gdb.git --branch binutils-2_36-branch --single-branch tool-chain/binutils-gdb
      - git clone https://github.com/mirror/newlib-cygwin.git --branch master --single-branch tool-chain/newlib-cygwin
      - git clone https://gitlab.com/sfu-rcl/taiga-embench.git --branch taiga-picolibc --single-branch benchmarks/embench
      - git clone https://gitlab.com/sfu-rcl/taiga-riscv-compliance.git --branch taiga-sim --single-branch benchmarks/riscv-compliance
      - git clone https://gitlab.com/sfu-rcl/taiga-dhrystone.git --branch master --single-branch benchmarks/taiga-dhrystone
      - git clone https://gitlab.com/sfu-rcl/taiga-coremark.git --branch master --single-branch benchmarks/taiga-coremark
      - cd tool-chain/gcc
      - ./contrib/download_prerequisites
      - cd $TAIGA_PROJECT_ROOT
      - ./build-tool-chain.sh
      - cp -rf $TAIGA_PROJECT_ROOT/tool-chain $CI_PROJECT_DIR #needed for caching

embench:
    tags:
    - new-taiga-ci
    stage: embench
    script:
      # create the taiga project file hierachy
      - pip3 install pandas
      - cd ..
      - cd taiga-project
      - source settings.sh
      - SCRIPT_DIR=$TAIGA_PROJECT_ROOT/tool-chain/scripts
      - bash -x $SCRIPT_DIR/embench.sh
      - python3 $SCRIPT_DIR/embench-check.py

compliance-test:
    tags:
      - new-taiga-ci
    stage: compliance-test
    script: 
      - cd ..
      - cd taiga-project
      - source settings.sh
      - SCRIPT_DIR=$TAIGA_PROJECT_ROOT/tool-chain/scripts
      - bash -x $SCRIPT_DIR/compliance.sh
      - make run-compliance-tests-verilator
    allow_failure: true

dhrystone:
    tags:
      - new-taiga-ci
    stage: dhrystone
    script: 
      - cd ..
      - cd taiga-project
      - source settings.sh
      - SCRIPT_DIR=$TAIGA_PROJECT_ROOT/tool-chain/scripts
      - bash -x $SCRIPT_DIR/dhrystone.sh

coremark:
    tags:
      - new-taiga-ci
    stage: coremark
    script:
      - cd ..
      - cd taiga-project
      - source settings.sh
      - SCRIPT_DIR=$TAIGA_PROJECT_ROOT/tool-chain/scripts
      - bash -x $SCRIPT_DIR/coremark.sh
    allow_failure: true

#util_timing_rpt-test:
    #tags:
    #- new-taiga-ci
    #stage: util_timing_rpt
    #script:
      #- source settings.sh
      #- cd ..
      #- cd taiga-project
      #- git clone https://gitlab.com/sfu-rcl/taiga-coremark.git --branch master --single-branch benchmarks/taiga-coremark
      #- source /exports/rcl-tools/Vivado/Vivado/2019.2/settings64.sh
      #- bash taiga/tools/PPA.sh
