---
app-id: me.gapixels.Megapixels
runtime: org.gnome.Platform
runtime-version: "47"
sdk: org.gnome.Sdk
command: megapixels
finish-args:
  # access /dev/media* and /dev/video*
  - --device=all
  # access /sys/firmware/devicetree/base/compatible
  - --filesystem=/sys

  # X11 + XShm access
  - --socket=fallback-x11
  - --share=ipc

  # wayland access
  - --socket=wayland

  # sound recording
  - --socket=pulseaudio

  # Needs to save file locally
  - --filesystem=xdg-pictures
  - --filesystem=xdg-videos

  # camera shutter feedback
  - --talk-name=org.sigxcpu.Feedback

  # accelerometer sensor for orientation
  - --system-talk-name=net.hadess.SensorProxy

modules:
  - name: megapixels
    buildsystem: meson
    run-tests: false
    sources:
      - type: dir
        path: ../
    post-install:
      # meson should probably be doing this
      - glib-compile-schemas --strict /app/share/glib-2.0/schemas

    modules:
      - name: libmegapixels
        buildsystem: meson
        sources:
          - type: git
            url: https://gitlab.com/megapixels-org/libmegapixels
            tag: 0.2.1
        modules:
          - name: libconfig
            sources:
              - type: archive
                url: https://hyperrealm.github.io/libconfig/dist/libconfig-1.8.tar.gz
                sha256: 051e15dd0e907c44905f317933f5487314f2a56e8c6726c8304ce990884850aa
            cleanup:
              - "/include"
              - "*.la"
              - "*.a"
              - "/lib/pkgconfig"
      - name: libfeedback
        buildsystem: meson
        config-opts:
          - -Dtests=false
          - -Ddaemon=false
        sources:
          - type: git
            url: https://source.puri.sm/Librem5/feedbackd.git
            tag: v0.8.1
      - name: zbar
        config-opts:
          - --disable-doc
          - --disable-video
          - --enable-codes=qrcode
          - --without-dbus
          - --without-directshow
          - --without-gir
          - --without-graphicsmagick
          - --without-gtk
          - --without-imagemagick
          - --without-jpeg
          - --without-java
          - --without-npapi
          - --without-python
          - --without-qt
          - --without-qt5
          - --without-xshm
          - --without-xv
        sources:
          - type: git
            url: https://github.com/mchehab/zbar
            tag: 0.23.93
          - type: script
            dest-filename: autogen.sh
            commands:
              - autoreconf -vfi -W none
      - name: libdng
        buildsystem: meson
        sources:
          - type: git
            url: https://gitlab.com/megapixels-org/libdng
            tag: 0.2.1
  - name: postprocessd
    buildsystem: meson
    sources:
      - type: git
        url: https://gitlab.com/megapixels-org/postprocessd
        commit: 6264c9bfa71c961fd0868a2c4976845699760ed7
    modules:
      - name: libraw
        builddir: true
        sources:
          - type: git
            url: https://github.com/LibRaw/LibRaw
            tag: 0.21.4
          - type: shell
            commands:
              - autoreconf -vfi
      - name: opencv
        buildsystem: cmake-ninja
        builddir: true
        config-opts:
          - -DCMAKE_BUILD_TYPE=Release
          - -DOPENCV_GENERATE_PKGCONFIG=ON
          - -DBUILD_LIST=core,imgproc,tracking,imgcodecs,videostab
        sources:
          - type: archive
            url: https://github.com/opencv/opencv/archive/4.11.0.tar.gz
            sha256: 9a7c11f924eff5f8d8070e297b322ee68b9227e003fd600d4b8122198091665f
          - type: archive
            url: https://github.com/opencv/opencv_contrib/archive/4.11.0.tar.gz
            sha256: 2dfc5957201de2aa785064711125af6abb2e80a64e2dc246aca4119b19687041
      - name: lensfun
        buildsystem: cmake-ninja
        config-opts:
          - -DCMAKE_BUILD_TYPE=RelWithDebInfo
        cleanup:
          - /bin
          - '/lib/python3.*'
        sources:
          - type: git
            url: https://github.com/lensfun/lensfun.git
            tag: v0.3.4
  - name: ImageMagick
    config-opts:
      - --disable-static
      - --disable-docs
      - --with-hdri
      - --with-pic
    sources:
      - type: git
        url: https://github.com/ImageMagick/ImageMagick
        tag: 7.1.1-47
  - name: exiftool
    buildsystem: simple
    build-commands:
      - perl Makefile.PL
      - make install
    cleanup:
      - '*.pod'
    sources:
      - type: git
        url: https://github.com/exiftool/exiftool.git
        tag: "13.29"
    modules:
      - name: perl
        buildsystem: simple
        build-commands:
          - ./Configure -des -Dprefix=$FLATPAK_DEST -Dman1dir=none -Dman3dir=none
          - make
          - make install
        sources:
          - type: git
            url: https://github.com/Perl/perl5.git
            tag: v5.40.2
            disable-fsckobjects: true
        post-install:
          # Fix permissions
          - chmod -R u+w $FLATPAK_DEST/lib/perl5
