{% set name = "pcre2" %}
{% set version = "10.46" %}

package:
  name: {{ name }}
  version: {{ version }}

source:
  - url: https://github.com/PCRE2Project/{{ name }}/archive/refs/tags/{{ name }}-{{ version }}.tar.gz
    sha256: ffde0c6ead457c4f8edcd8f9ce490bbabd30adabdfd179ecaddd320946cf3872
  # Unvendoring not possible due to lack of version tracking in SLJIT project.
  # This dependency provides a feature of significant performance improvements for PCRE2
  # by compiling the regular expression to a block of equivalent native machine code.
  - url: https://github.com/zherczeg/sljit/archive/e51eabbfb8eabc6526f56e4e88b29fb10d1ee048.tar.gz
    sha256: 5caf31959f4c2dfa9fdbaf290b0e16538527d929d5c1c5bd1a3e6df01436c1cf
    folder: deps/sljit

build:
  number: 0
  run_exports:
    # https://abi-laboratory.pro/index.php?view=timeline&l=pcre2
    - {{ pin_subpackage(name, max_pin="x.x") }}

requirements:
  build:
    - {{ stdlib('c') }}
    - {{ compiler('c') }}
    - cmake
    - ninja-base
    - msys2-posix  # [win]
    - msys2-sed    # [win]
  host:
    - bzip2
    - zlib

test:
  commands:
    - pcre2test --version
    - pcre2grep --version

    - pcre2-config --version                                           # [not win]
    - test -f ${PREFIX}/include/pcre2.h                                # [not win]
    - test -f ${PREFIX}/include/pcre2posix.h                           # [not win]
    - test -f ${PREFIX}/lib/libpcre2-posix${SHLIB_EXT}                 # [not win]
    - test -f ${PREFIX}/lib/libpcre2-posix.3${SHLIB_EXT}               # [osx]
    - test -f ${PREFIX}/lib/libpcre2-posix${SHLIB_EXT}.3               # [linux]
    - test -f ${PREFIX}/lib/libpcre2-posix${SHLIB_EXT}.3.0.6           # [linux]
    - test -f ${PREFIX}/lib/libpcre2-8${SHLIB_EXT}                     # [not win]
    - test -f ${PREFIX}/lib/libpcre2-8.0${SHLIB_EXT}                   # [osx]
    - test -f ${PREFIX}/lib/libpcre2-8${SHLIB_EXT}.0                   # [linux]
    - test -f ${PREFIX}/lib/libpcre2-8${SHLIB_EXT}.0.14.0              # [linux]
    - test -f ${PREFIX}/lib/libpcre2-16${SHLIB_EXT}                    # [not win]
    - test -f ${PREFIX}/lib/libpcre2-16.0${SHLIB_EXT}                  # [osx]
    - test -f ${PREFIX}/lib/libpcre2-16${SHLIB_EXT}.0                  # [linux]
    - test -f ${PREFIX}/lib/libpcre2-16${SHLIB_EXT}.0.14.0             # [linux]
    - test -f ${PREFIX}/lib/libpcre2-32${SHLIB_EXT}                    # [not win]
    - test -f ${PREFIX}/lib/libpcre2-32.0${SHLIB_EXT}                  # [osx]
    - test -f ${PREFIX}/lib/libpcre2-32${SHLIB_EXT}.0                  # [linux]
    - test -f ${PREFIX}/lib/libpcre2-32${SHLIB_EXT}.0.14.0             # [linux]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-8.pc                    # [not win]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-16.pc                   # [not win]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-32.pc                   # [not win]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-posix.pc                # [not win]
    - test -f ${PREFIX}/lib/cmake/pcre2/pcre2-config.cmake             # [not win]
    - test -f ${PREFIX}/lib/cmake/pcre2/pcre2-config-version.cmake     # [not win]

    - if not exist %LIBRARY_INC%\\pcre2.h exit 1                       # [win]
    - if not exist %LIBRARY_INC%\\pcre2posix.h exit 1                  # [win]
    - if not exist %LIBRARY_BIN%\\pcre2-8.dll exit 1                   # [win]
    - if not exist %LIBRARY_BIN%\\pcre2-16.dll exit 1                  # [win]
    - if not exist %LIBRARY_BIN%\\pcre2-32.dll exit 1                  # [win]
    - if not exist %LIBRARY_BIN%\\pcre2-posix.dll exit 1               # [win]
    - if not exist %LIBRARY_LIB%\\pcre2-8.lib exit 1                   # [win]
    - if not exist %LIBRARY_LIB%\\pcre2-16.lib exit 1                  # [win]
    - if not exist %LIBRARY_LIB%\\pcre2-32.lib exit 1                  # [win]
    - if not exist %LIBRARY_LIB%\\pcre2-posix.lib exit 1               # [win]
    - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-posix.pc exit 1  # [win]
    - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-8.pc exit 1      # [win]
    - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-16.pc exit 1     # [win]
    - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-32.pc exit 1     # [win]

about:
  home: https://www.pcre.org
  license: BSD-3-Clause WITH PCRE2-exception
  license_family: BSD
  license_file: LICENCE.md
  summary: Regular expression pattern matching using Perl 5 syntax and semantics.
  description: |
    The PCRE library is a set of functions that implement regular expression pattern matching
    using the same syntax and semantics as Perl 5. PCRE has its own native API, as well as a set of
    wrapper functions that correspond to the POSIX regular expression API. The PCRE library is
    free, even for building proprietary software.
  dev_url: https://github.com/PCRE2Project/pcre2
  doc_url: https://www.pcre.org/current/doc/html/

extra:
  recipe-maintainers:
    - dfornika
    - mariusvniekerk
    - xhochy
