# 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.5.1.tar.gz
            sha256: a7a3f2a7420cb6a6a94d80c24163e183cf1d2f1bed2df3bbc397c81808a57237
            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.86.0/leptonica-1.86.0.tar.gz
                sha256: 1fa08e40bb37fd45802d5e6e7b43927449a5c47d4608ef99d3bd3f0fa76baedc
                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
