# vim: sts=2 sw=2 ai

################################################################################
# snes9x
################################################################################

snes9x_linux-gtk-amd64_task:
  container:
    image: gcc:latest

  setup_script:
    - git submodule update --init --recursive
    - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install meson gettext libsdl2-dev libgtkmm-3.0-dev libgtk-3-dev libminizip-dev portaudio19-dev glslang-dev cmake

  compile_script:
    - cmake -G Ninja -B build -S gtk -DCMAKE_BUILD_TYPE=Release
    - ninja -j2 -C build

  package_script:
    - mkdir snes9x
    - cp -ar build/snes9x-gtk README.md LICENSE docs data gtk/AUTHORS snes9x/
    - tar -caf "snes9x-gtk-${CIRRUS_CHANGE_IN_REPO}.txz" snes9x

  build_artifacts:
    path: "snes9x-gtk-${CIRRUS_CHANGE_IN_REPO}.txz"


snes9x_linux-x11-amd64_task:
  container:
    image: gcc:latest

  setup_script:
    - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install libxv-dev libxinerama-dev

  compile_script:
    - cd unix
    - touch configure
    - ./configure
    - make -j2

  package_script:
    - mkdir snes9x
    - cp -ar unix/snes9x unix/docs unix/snes9x.conf.default README.md LICENSE data snes9x/
    - tar -caf "snes9x-x11-${CIRRUS_CHANGE_IN_REPO}.txz" snes9x

  build_artifacts:
    path: "snes9x-x11-${CIRRUS_CHANGE_IN_REPO}.txz"


snes9x_freebsd-x11-amd64_task:
  freebsd_instance:
    image: freebsd-13-2-release-amd64

  setup_script:
    - pkg install -y gmake pkgconf minizip libX11 libXext

  compile_script:
    - cd unix
    - touch configure
    - ./configure
    - gmake -j2

  package_script:
    - mkdir snes9x
    - cp -a unix/snes9x unix/docs unix/snes9x.conf.default README.md LICENSE data snes9x/
    - tar -caf "snes9x-x11-${CIRRUS_CHANGE_IN_REPO}.txz" snes9x

  build_artifacts:
    path: "snes9x-x11-${CIRRUS_CHANGE_IN_REPO}.txz"


snes9x_macOS-amd64_task:
  macos_instance:
    image: ghcr.io/cirruslabs/macos-ventura-xcode:latest

  compile_script:
    - xcodebuild -project macosx/snes9x.xcodeproj -target Snes9x -configuration Release build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

  package_script:
    - mkdir snes9x
    - cp -R macosx/build/Release/Snes9x.app macosx/docs README.md LICENSE snes9x/
    - zip -r "snes9x-${CIRRUS_CHANGE_IN_REPO}.zip" snes9x

  build_artifacts:
    path: "snes9x-${CIRRUS_CHANGE_IN_REPO}.zip"

################################################################################
# libretro
################################################################################

libretro_linux-amd64_task:
  container:
    image: gcc:latest
  compile_script:
    - make -j2 -C libretro
  build_artifacts:
    path: "libretro/snes9x_libretro.so"


libretro_linux-i386_task:
  container:
    image: dockcross/linux-x86
  compile_script:
    - make -j2 -C libretro
  build_artifacts:
    path: "libretro/snes9x_libretro.so"


libretro_linux-armhf_task:
  container:
    image: dockcross/linux-armv7
  compile_script:
    - make -j2 -C libretro
  build_artifacts:
    path: "libretro/snes9x_libretro.so"


libretro_linux-armv7-neon-hf_task:
  container:
    image: dockcross/linux-armv7
  compile_script:
    - make -j2 -C libretro platform=unix-armv7-neon-hardfloat
  build_artifacts:
    path: "libretro/snes9x_libretro.so"


libretro_linux-arm64_task:
  container:
    image: dockcross/linux-arm64
  compile_script:
    - make -j2 -C libretro
  build_artifacts:
    path: "libretro/snes9x_libretro.so"


libretro_android-arm_task:
  container:
    image: dockcross/android-arm
  compile_script:
    - make -j2 -C libretro platform=unix
  build_artifacts:
    path: "libretro/snes9x_libretro.so"


libretro_android-arm64_task:
  container:
    image: dockcross/android-arm64
  compile_script:
    - make -j2 -C libretro platform=unix-arm64
  build_artifacts:
    path: "libretro/snes9x_libretro.so"


libretro_emscripten_task:
  container:
    image: gcc:latest
  compile_script:
    - make -j2 -C libretro platform=emscripten
  build_artifacts:
    path: "libretro/snes9x_libretro_emscripten.bc"


libretro_macOS-amd64_task:
  macos_instance:
    image: ghcr.io/cirruslabs/macos-ventura-xcode:latest
  compile_script:
    - make -j2 -C libretro
  build_artifacts:
    path: "libretro/snes9x_libretro.dylib"


libretro_nintendo-wii_task:
  container:
    image: devkitpro/devkitppc
  compile_script:
    - make -j2 -C libretro platform=wii
  build_artifacts:
    path: "libretro/snes9x_libretro_wii.a"


libretro_nintendo-switch-libnx_task:
  container:
    image: devkitpro/devkita64
  compile_script:
    - make -j2 -C libretro platform=libnx
  build_artifacts:
    path: "libretro/snes9x_libretro_libnx.a"


libretro_nintendo-ngc_task:
  container:
    image: devkitpro/devkitppc
  compile_script:
    - make -j2 -C libretro platform=ngc
  build_artifacts:
    path: "libretro/snes9x_libretro_ngc.a"