# Maintainer: Anatol Pomozov

pkgname=aws-c-http
pkgver=0.7.11
pkgrel=1
pkgdesc='C99 implementation of the HTTP/1.1 and HTTP/2 specifications'
arch=(x86_64 aarch64)
url='https://github.com/awslabs/aws-c-http'
license=(Apache)
depends=(aws-c-common aws-c-compression aws-c-io)
makedepends=(cmake)
source=(aws-c-http-$pkgver.zip::https://github.com/awslabs/aws-c-http/archive/v$pkgver.zip)
sha256sums=('114c7aad8d9de0103cf0a63eb828ee90b8e4c29bc23b043563a5fdc227d624b0')

prepare() {
  cd $pkgname-$pkgver

  # avoid tests failed in aarch64 CI
  sed -i \
    -e '/connection_setup_shutdown_tls/d' \
    -e '/connection_customized_alpn/d' \
    -e '/connection_customized_alpn_error_with_unknown_return_string/d' \
    tests/CMakeLists.txt
}

build() {
  cd aws-c-http-$pkgver

  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON -S . -B build
  cmake --build build
}

check() {
  cd aws-c-http-$pkgver
  cmake --build build --target test
}

package() {
  cd aws-c-http-$pkgver

  cmake --build build --target install -- DESTDIR="$pkgdir/"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
