# SPDX-FileCopyrightText: none
# SPDX-License-Identifier: CC0-1.0

id: org.kde.CrowTranslate
branch: master
sdk: org.kde.Sdk
runtime: org.kde.Platform
runtime-version: "6.9"
tags: ["nightly"]
desktop-file-name-suffix: " (Nightly)"
add-extensions:
  org.kde.CrowTranslate.tessdata:
    directory: share/tessdata
    version: stable
    versions: stable;beta;test
    no-autodownload: true
    autodelete: true
finish-args:
  - --device=dri
  - --env=TESSDATA_PREFIX=/app/share
  - --share=ipc
  - --share=network
  - --socket=fallback-x11
  - --socket=pulseaudio
  - --socket=wayland
  - --talk-name=org.freedesktop.Notifications
  - --talk-name=org.kde.StatusNotifierWatcher
copy-icon: true
command: crow
separate-locales: false
cleanup:
  - '*.a'
  - '*.la'
  - /include
  - /lib/cmake
  - /lib/pkgconfig
modules:
  - name: crow-translate
    buildsystem: cmake-ninja
    sources:
      - type: dir
        path: .
    modules:
      - name: onnxruntime
        buildsystem: simple
        build-commands:
          - mkdir -p ${FLATPAK_DEST}/lib
          - mkdir -p ${FLATPAK_DEST}/include
          - cp -av lib/* ${FLATPAK_DEST}/lib/
          - cp -av include/* ${FLATPAK_DEST}/include/
        sources:
          - type: archive
            url: https://github.com/microsoft/onnxruntime/releases/download/v1.22.0/onnxruntime-linux-x64-1.22.0.tgz
            sha256: 8344d55f93d5bc5021ce342db50f62079daf39aaafb5d311a451846228be49b3
            x-checker-data:
              type: github-releases
              owner: microsoft
              repo: onnxruntime
              stable-only: true
              asset-name: onnxruntime-linux-x64-$version.tgz
              url-template: https://github.com/microsoft/onnxruntime/releases/download/v$version/onnxruntime-linux-x64-$version.tgz
      - name: tesseract
        buildsystem: cmake-ninja
        builddir: true
        config-opts:
          - -DBUILD_SHARED_LIBS:BOOL=ON
        cleanup:
          - /bin
        sources:
          - type: archive
            url: https://github.com/tesseract-ocr/tesseract/archive/refs/tags/5.4.1.tar.gz
            sha256: c4bc2a81c12a472f445b7c2fb4705a08bd643ef467f51ec84f0e148bd368051b
            x-checker-data:
              type: anitya
              project-id: 4954
              url-template: https://github.com/tesseract-ocr/tesseract/archive/refs/tags/$version.tar.gz
        modules:
          - name: leptonica
            buildsystem: cmake-ninja
            builddir: true
            config-opts:
              - -DBUILD_SHARED_LIBS:BOOL=ON
            sources:
              - type: archive
                url: https://github.com/DanBloomberg/leptonica/releases/download/1.84.1/leptonica-1.84.1.tar.gz
                sha256: 2b3e1254b1cca381e77c819b59ca99774ff43530209b9aeb511e1d46588a64f6
                x-checker-data:
                  type: anitya
                  project-id: 1549
                  url-template: https://github.com/DanBloomberg/leptonica/releases/download/$version/leptonica-$version.tar.gz

      # The `tessdata_fast` variant is recommended for end users: https://tesseract-ocr.github.io/tessdoc/Data-Files
      - name: tessdata_fast
        buildsystem: simple
        build-commands:
          - rm -rf ${FLATPAK_DEST}/share/tessdata
          - mkdir -p ${FLATPAK_DEST}/share/tessdata
          - cp -av * ${FLATPAK_DEST}/share/tessdata/
        sources:
          - type: git
            url: https://github.com/tesseract-ocr/tessdata_fast
            tag: 4.1.0
            commit: 65727574dfcd264acbb0c3e07860e4e9e9b22185
            x-checker-data:
              type: anitya
              project-id: 326567
              tag-template: $version
