# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2018-2023 Collabora, Ltd. and the Monado contributors

# Please run the following from the repo root after modifying this file:
#   make -f .gitlab-ci/ci-scripts.mk

fdo_ci_templates_sha: 7811ba9814a3bad379377241c6c6b62d78b20eac

# These are a mapping, instead of a list/array, so we can merge.
.default_debian_packages:
  &default_debian_packages # Packages required for build and some other basic jobs
  build-essential:
  git:
  wget:
  unzip:
  cmake:
  ninja-build:
  libeigen3-dev:
  curl:
  patch:
  python3:
  pkg-config:
  libx11-dev:
  libx11-xcb-dev:
  libxxf86vm-dev:
  libxrandr-dev:
  libxcb-randr0-dev:
  libvulkan-dev:
  glslang-tools:
  libglvnd-dev:
  libgl1-mesa-dev:
  ca-certificates:
  libusb-1.0-0-dev:
  libudev-dev:
  # These are optional packages, that we're building against to ensure we build as much code as possible
  libhidapi-dev:
  libwayland-dev:
  libuvc-dev:
  libavcodec-dev:
  libopencv-dev:
  libv4l-dev:
  libcjson-dev:
  libsdl2-dev:
  libegl1-mesa-dev:
  libdbus-1-dev:
  libgstreamer1.0-dev:
  libgstreamer-plugins-base1.0-dev:
  libsystemd-dev:
  libbsd-dev:
  libbluetooth-dev:
  # Only used for building packages
  devscripts:
  debhelper:
  dput-ng:
  gettext-base:
  pandoc:

# These config defines are used for all NDK builds
.android_cmake_defines: &android_cmake_defines
  ANDROID_PLATFORM: 26
  CMAKE_TOOLCHAIN_FILE: /opt/android-ndk/build/cmake/android.toolchain.cmake
  Eigen3_DIR: /usr/lib/cmake/eigen3/
  EIGEN3_INCLUDE_DIR: /usr/include/eigen3

# Which build job do we use to build the documentation.
documentation_build: "debian:cmake"

# The distributions we'll make an image for
distributions:
  - name: debian
    images:
      # This image does some extra work.
      - codename: bullseye
        script: i386_and_proclamation_container_prep.sh
        tag: "2023-04-07"
        deb_version_suffix: bpo11
        packages:
          <<: *default_debian_packages
          codespell:
          doxygen:
          graphviz:
          python3-pip:
          python3-click:
          clang-format:
        build_jobs:
          - name: "debian:cmake"
            # Generate "changes since last release" and add to changelog,
            # since this is the build that makes our docs.
            before_script:
              - pushd doc/changes
              - proclamation build --overwrite vNEXT
              - popd
            artifact_path: build/doc/html/

          - name: "debian:cmake-no-opencv"
            cmake_defines:
              XRT_HAVE_OPENCV: "OFF"

          - name: "debian:cmake-no-sdl2"
            cmake_defines:
              XRT_HAVE_SDL2: "OFF"

          - name: "debian:cmake-no-service"
            cmake_defines:
              XRT_FEATURE_SERVICE: "OFF"

          - name: "debian:cmake:32bit"
            cmake_defines:
              CMAKE_TOOLCHAIN_FILE: .gitlab-ci/i386.cmake
              # OpenCV doesn't play nicely with us in multi-arch.
              XRT_HAVE_OPENCV: "OFF"

      # This one is pretty minimal, compared to the others.
      # Though, we now install the android SDK in it...
      - codename: bullseye-ndk
        distro_version: bullseye
        repo_suffix: ndk
        script: android_container_prep.sh
        tag: "2023-04-10.1"
        # This must match ext.sharedCompileSdk in build.gradle
        android_compile_sdk: 32
        # This must match buildscript.ext.buildToolsVersion in build.gradle
        android_build_tools: 32.0.0
        # look up on https://developer.android.com/studio/index.html#downloads when updating other versions
        android_cli_tools: 9477386

        packages:
          git:
          wget:
          unzip:
          cmake:
          meson:
          ninja-build:
          libeigen3-dev:
          python3:
          pkg-config:
          ca-certificates:
          glslang-tools:
          default-jdk-headless:
        build_jobs:
          - name: "ndk:armeabi-v7a"
            cmake_defines:
              <<: *android_cmake_defines
              ANDROID_ABI: armeabi-v7a

          - name: "ndk:arm64-v8a"
            cmake_defines:
              <<: *android_cmake_defines
              ANDROID_ABI: arm64-v8a

          - name: android:spotlessCheck
            target: spotlessCheck

          - name: android:outOfProcessDebug
            target: assembleOutOfProcessDebug
            artifact_path: src/xrt/targets/openxr_android/build/outputs/apk/outOfProcess

          - name: android:inProcessDebug
            target: assembleInProcessDebug
            artifact_path: src/xrt/targets/openxr_android/build/outputs/apk/inProcess

          - name: android:outOfProcessRelease
            target: assembleOutOfProcessRelease
            artifact_path: src/xrt/targets/openxr_android/build/outputs/apk/outOfProcess

          - name: android:inProcessRelease
            target: assembleInProcessRelease
            artifact_path: src/xrt/targets/openxr_android/build/outputs/apk/inProcess

  - name: ubuntu
    images:
      # LTS
      - codename: focal
        distro_version: "20.04"
        tag: "2022-09-20.0"
        deb_version_suffix: ubuntu2004
        packages:
          <<: *default_debian_packages
        build_jobs:
          - name: "ubuntu:focal:cmake"
            cmake_defines:

      - codename: jammy
        distro_version: "22.04"
        tag: "2022-09-20.0"
        deb_version_suffix: ubuntu2204
        packages:
          <<: *default_debian_packages
          reprepro:
        build_jobs:
          - name: "ubuntu:jammy:cmake"
            cmake_defines:

  - name: arch
    images:
      - codename: rolling
        tag: "2023-05-22.0"
        script: install-arch-additional-deps.sh
        # pipewire-jack wireplumber: Explicitly choose dependencies to avoid pacman asking interactively
        # python-setuptools glu: librealsense
        # glew boost gtest fmt bc: basalt-monado-git
        # python-attrs: xr-hardware-git
        packages:
          base-devel:
          pipewire-jack:
          wireplumber:
          bluez-libs:
          check:
          clang:
          cmake:
          diffutils:
          doxygen:
          eigen:
          ffmpeg:
          gcc:
          git:
          glfw-x11:
          glslang:
          graphviz:
          gtk3:
          hidapi:
          libusb:
          libxrandr:
          mesa:
          ninja:
          opencv:
          patch:
          pkgconfig:
          python3:
          qt6-base:
          v4l-utils:
          vulkan-headers:
          vulkan-icd-loader:
          wget:
          meson:
          python-setuptools:
          glu:
          glew:
          boost:
          gtest:
          fmt:
          bc:
          wayland:
          libbsd:
          python-attrs:
        build_jobs:
          - name: "arch:cmake"

          - name: "arch:cmake:clang"
            cmake_defines:
              CMAKE_C_COMPILER: /usr/bin/clang
              CMAKE_CXX_COMPILER: /usr/bin/clang++

android:
  platform: 26

packaging:
  # Name and email associated with the package
  name: "Monado CI"
  email: "ryan.pavlik@collabora.com"