{% set version = "3.16.0" %}

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

source:
  - url: https://github.com/protocolbuffers/protobuf/archive/v{{ version }}/libprotobuf-v{{ version }}.tar.gz
    sha256: 7892a35d979304a404400a101c46ce90e85ec9e2a766a86041bb361f626247f5
    patches:
      - 0001-remove-Werror-from-test-flags.patch  # [ppc64le or aarch64]
      # This issue gets fixed and then reintroduced often
      # https://github.com/protocolbuffers/protobuf/issues/7567
      #- issue-7567.patch
  # these are git submodules from the 3.10.1 release
  # https://github.com/protocolbuffers/protobuf/tree/v3.10.1/third_party
  - url: https://github.com/google/benchmark/archive/5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8.tar.gz
    sha256: 5dc92703f811f94e2aa63bdab07ab749f28a094befa6cdfd5fe177f947590a48
    folder: third_party/benchmark
  - url: https://github.com/google/googletest/archive/5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081.tar.gz
    sha256: 0e2f36e8e403c125fd0ab02171bdb786d3b6b3875b6ccf3b2eb7969be8faecd0
    folder: third_party/googletest

build:
  number: 0

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake  # [win]
    - ninja  # [win]
    - autoconf  # [not win]
    - automake  # [not win]
    - libtool  # [not win]
    - pkg-config  # [not win]
    - unzip  # [not win]
    - make  # [not win]
  host:
    - zlib
  run:
    - zlib

outputs:
  - name: libprotobuf
    build:
      run_exports:
        # breaks backwards compatibility and new SONAME each minor release
        # https://abi-laboratory.pro/tracker/timeline/protobuf/
        # One exception was that 3.6.1 was incompatible with 3.6.0
        - {{ pin_subpackage('libprotobuf', max_pin='x.x') }}
    test:
      commands:
        - protoc --help
        - test -f ${PREFIX}/lib/libprotobuf${SHLIB_EXT}  # [not win]
        - test ! -f ${PREFIX}/lib/libprotobuf.a  # [not win]
        - if not exist %PREFIX%\\Library\\lib\\libprotoc.lib exit 1  # [win]
        - if not exist %PREFIX%\\Library\\lib\\libprotobuf.lib exit 1  # [win]
        - if not exist %PREFIX%\\Library\\lib\\libprotobuf-lite.lib exit 1  # [win]
  - name: libprotobuf-static
    script: build_static.sh  # [unix]
    build:
      skip: true  # [win]
    test:
      commands:
        - test -f ${PREFIX}/lib/libprotobuf.a  # [unix]
        - test -f ${PREFIX}/lib/libprotobuf-lite.a  # [unix]
        - test -f ${PREFIX}/lib/libprotoc.a  # [unix]

about:
  home: https://developers.google.com/protocol-buffers/
  license: BSD-3-Clause
  license_family: BSD
  license_file: LICENSE
  summary: Protocol Buffers - Google's data interchange format. C++ Libraries and protoc, the protobuf compiler.
  description: |
    Protocol buffers are Google's language-neutral,
    platform-neutral, extensible mechanism for serializing structured data-
    think XML, but smaller, faster, and simpler.
  doc_url: https://developers.google.com/protocol-buffers/
  doc_source_url: https://github.com/protocolbuffers/protobuf/releases

extra:
  recipe-maintainers:
    - dopplershift
    - jakirkham
    - ocefpaf
    - wesm
    - hajapy
    - xhochy
