stages:
- wrs_sw_compile

job_wrs_compile:
  stage: wrs_sw_compile
  script:
    - apt update && apt upgrade -y && apt install -y git make build-essential m4 gettext bison flex texinfo libncurses-dev libncursesw5-dev bc python unzip wget cpio locales
    - locale-gen en_US.UTF-8
    # use the user who triggered a job to appear in binaries
    - echo "[user]" >  ~/.gitconfig
    - echo "    name = CI ${GITLAB_USER_NAME}" >>  ~/.gitconfig
    - cd ..
    - echo "Remove leftovers from the previous build"
    - rm -rf *.tar
    - rm -rf *.log
    - rm -rf build
    - rm -rf images
    - cd wr-switch-sw ; cd userspace/ppsi ; git fetch -p; cd ../..; git submodule update; cd ..
    - echo "Using `grep -c ^processor /proc/cpuinfo` parallel jobs" 
    - MAKEFLAGS="-j `grep -c ^processor /proc/cpuinfo`" wr-switch-sw/build/wrs_build-all > ${CI_PROJECT_DIR}/log_${CI_JOB_ID}.txt
    - cp *.tar ${CI_PROJECT_DIR}
  artifacts:
    name: "wrs_sw_ci_${CI_JOB_ID}"
    when: always
    paths:
    - log_${CI_JOB_ID}.txt
    - ./*.tar
  tags:
    - wrs_sw
