variables:
    GIT_SUBMODULE_STRATEGY: recursive

stages:
    - build
    - deploy

.ci-polygon:
  tags:
     - ci-polygon
  
.tests:  
  extends: .ci-polygon
  stage: build
  timeout: 3 hours 30 minutes
  dependencies: []
  
  
tests:amd64.gcc:
    extends: .tests
    image: demlabs/debian/amd64:qt5
    before_script: /opt/buildtools/prepare_environment.sh amd64-linux
    script:
      - mkdir build
      - cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_CELLFRAME_SDK_TESTS=ON -DOFF_CORE_CELLFRAME_SDK_TESTS_OFF=network-monitor -DOFF_CRYPTO_CELLFRAME_SDK_TESTS_OFF="multisign" && make -j$(nproc) && ctest --verbose


tests:amd64.clang:
    extends: .tests
    image: demlabs/debian/amd64:qt5
    before_script: /opt/buildtools/prepare_environment.sh amd64-linux
    script:
      - mkdir build
      - cd build && cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DBUILD_CELLFRAME_SDK_TESTS=ON -DOFF_CORE_CELLFRAME_SDK_TESTS_OFF=network-monitor -DOFF_CRYPTO_CELLFRAME_SDK_TESTS_OFF="multisign" && make -j$(nproc) && ctest --verbose


tests:arm64.gcc:
    extends: .tests
    image: demlabs/debian/arm64:qt5
    before_script: /opt/buildtools/prepare_environment.sh arm64-linux
    script:
      - mkdir build
      - cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_CELLFRAME_SDK_TESTS=ON -DOFF_CORE_CELLFRAME_SDK_TESTS_OFF=network-monitor -DOFF_CRYPTO_CELLFRAME_SDK_TESTS_OFF="multisign" && make -j$(nproc) && ctest --verbose

tests:arm64.clang:
    extends: .tests
    image: demlabs/debian/arm64:qt5
    before_script: /opt/buildtools/prepare_environment.sh arm64-linux
    script:
      - mkdir build
      - cd build && cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DBUILD_CELLFRAME_SDK_TESTS=ON -DOFF_CORE_CELLFRAME_SDK_TESTS_OFF=network-monitor -DOFF_CRYPTO_CELLFRAME_SDK_TESTS_OFF="multisign" && make -j$(nproc) && ctest --verbose

tests:arm32.gcc:
    extends: .tests
    image: demlabs/debian/arm32:qt5
    before_script: /opt/buildtools/prepare_environment.sh arm32v7-linux
    script:
      - mkdir build
      - cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_CELLFRAME_SDK_TESTS=ON -DOFF_CORE_CELLFRAME_SDK_TESTS_OFF=network-monitor -DOFF_CRYPTO_CELLFRAME_SDK_TESTS_OFF="multisign" && make -j$(nproc) && ctest --verbose

tests:arm32.clang:
    extends: .tests
    image: demlabs/debian/arm32:qt5
    before_script: /opt/buildtools/prepare_environment.sh arm32v7-linux
    script:
      - mkdir build
      - cd build && cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DBUILD_CELLFRAME_SDK_TESTS=ON -DOFF_CORE_CELLFRAME_SDK_TESTS_OFF=network-monitor -DOFF_CRYPTO_CELLFRAME_SDK_TESTS_OFF="multisign" && make -j$(nproc) && ctest --verbose

build:windows:
    extends: .tests
    image: demlabs/windows/amd64:qt5
    before_script: /opt/buildtools/prepare_environment.sh amd64-windows
    script:
      - mkdir build
      - cd build && export PATH=${MXE_ROOT}/usr/bin:$PATH && x86_64-w64-mingw32.static-cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc)
    

build:macos:
    extends: .tests
    image: demlabs/macos/amd64:qt5
    before_script: /opt/buildtools/prepare_environment.sh amd64-windows
    script:
      - mkdir build
      - cd build && $(${OSXCROSS_ROOT}/bin/osxcross-conf) && export OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 && export OSXCROSS_HOST=x86_64-apple-darwin20.4 && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${OSXCROSS_ROOT}/toolchain.cmake -DBoost_INCLUDE_DIR=$BOOST_INCLUDE_DIR .. && make -j$(nproc)


build:android:
    extends: .tests
    image: demlabs/android/any:qt5
    before_script: /opt/buildtools/prepare_environment.sh amd64-windows
    script:
      - ./prod_build/build.sh --target android
