# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2018-2024, 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: 185ede0e9b9b1924b92306ab8b882a6294e92613

# 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:
  curl:
  patch:
  python3:
  pkg-config:
  ca-certificates:
  glslang-tools:
  libeigen3-dev:
  libgl1-mesa-dev:
  libglvnd-dev:
  libudev-dev:
  libusb-1.0-0-dev:
  libvulkan-dev:
  libx11-dev:
  libx11-xcb-dev:
  libxcb-randr0-dev:
  libxrandr-dev:
  libxxf86vm-dev:
  wayland-protocols:
  # These are optional packages, that we're building against to ensure we build as much code as possible
  libbluetooth-dev:
  libbsd-dev:
  libcjson-dev:
  libdbus-1-dev:
  libegl1-mesa-dev:
  libgstreamer-plugins-base1.0-dev:
  libgstreamer1.0-dev:
  libhidapi-dev:
  libopencv-dev:
  libsdl2-dev:
  libsystemd-dev:
  libuvc-dev:
  libv4l-dev:
  libwayland-dev:
  # Only used for building packages
  debhelper:
  devscripts:
  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: bookworm
        script: i386_and_proclamation_container_prep.sh
        tag: "2024-04-16"
        deb_version_suffix: bpo12
        packages:
          <<: *default_debian_packages
          clang-format:
          codespell:
          doxygen:
          graphviz:
          pipx:
          python3-click:
          python3-pip:
          # reprepro must always run on the most recent debian-derived distribution so it is aware of all distros we package for.
          # Right now that is bookworm but it will be a new Ubuntu soon.
          reprepro:
        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 vNEXT
              - popd
            artifact_path: build/doc/html/
            cmake_defines:
              BUILD_DOC: "ON"

          - 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"

      - codename: bullseye
        tag: "2024-03-21"
        deb_version_suffix: bpo11
        packages:
          <<: *default_debian_packages
        build_jobs:
          - name: "debian:bullseye:cmake"


      # This one is pretty minimal, compared to the others.
      # Though, we now install the android SDK in it...
      - codename: bookworm-ndk
        distro_version: bookworm
        repo_suffix: ndk
        script: android_container_prep.sh
        tag: "2024-01-16"
        # 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: "2024-01-16"
        deb_version_suffix: ubuntu2004
        packages:
          <<: *default_debian_packages
        build_jobs:
          - name: "ubuntu:focal:cmake"
            cmake_defines:

      - codename: jammy
        distro_version: "22.04"
        tag: "2024-04-16"
        deb_version_suffix: ubuntu2204
        packages:
          <<: *default_debian_packages
        build_jobs:
          - name: "ubuntu:jammy:cmake"
            cmake_defines:

      - codename: noble
        distro_version: "24.04"
        tag: "2024-05-11"
        deb_version_suffix: ubuntu2404
        packages:
          <<: *default_debian_packages
        build_jobs:
          - name: "ubuntu:noble:cmake"
            cmake_defines:

  - name: arch
    images:
      - tag: "2024-01-16"
        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:
          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++

  - name: alpine
    images:
      - tag: "2024-01-16"
        packages:
          - "cmake"
          - "cmd:glslangValidator"
          - "cmd:wayland-scanner"
          - "build-base"
          - "doxygen"
          - "eigen-dev"
          - "eudev-dev"
          - "graphviz"
          - "libjpeg-turbo-dev"
          - "libsurvive-dev"
          - "libxrandr-dev"
          - "mesa-dev"
          - "opencv-dev"
          - "openhmd-dev"
          - "samurai"
          - "sdl2-dev"
          - "v4l-utils-dev"
          - "vulkan-loader-dev"
          - "wayland-dev"
          - "wayland-protocols"
          - "zlib-dev"
        build_jobs:
          - name: "alpine:cmake"

android:
  platform: 26

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