archrelease: copy trunk to community-any
[ArchLinux/community.git] / flatbuffers / repos / community-x86_64 / PKGBUILD
blobc1d78b5fcaf1e1329704a87c2ece857910968ac2
1 # Maintainer: Antonio Rojas <arojas@archlinux.org>
2 # Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>
3 # Contributor: Daichi Shinozaki <dsdseg@gmail.com>
5 pkgbase=flatbuffers
6 pkgname=(flatbuffers python-flatbuffers)
7 # https://github.com/google/flatbuffers/blob/master/CHANGELOG.md
8 pkgver=23.3.3
9 pkgrel=2
10 pkgdesc='An efficient cross platform serialization library for C++, with support for Java, C# and Go'
11 arch=(x86_64)
12 url='https://google.github.io/flatbuffers/'
13 license=(Apache)
14 depends=(gcc-libs)
15 makedepends=(cmake python-setuptools python-numpy)
16 source=(https://github.com/google/$pkgbase/archive/v$pkgver/$pkgbase-$pkgver.tar.gz)
17 sha256sums=('8aff985da30aaab37edf8e5b02fda33ed4cbdd962699a8e2af98fdef306f4e4d')
19 prepare() {
20   sed -i 's/-Werror=/-W/g;s/-Werror//g' $pkgname-$pkgver/CMakeLists.txt
22   cd $pkgbase-$pkgver
23   # Work-around missing out-of-source build support in Python tests
24   sed -i 's#${test_dir}/../flatc#${test_dir}/../../build/flatc#' tests/PythonTest.sh
25   # This script no longer works for us after https://github.com/google/flatbuffers/pull/7529
26   # TODO: notify upstream about this and that the Python workflow [1] doesn't work [2]
27   # [1] https://github.com/google/flatbuffers/blob/v22.9.24/.github/workflows/build.yml#L413
28   # [2] https://github.com/google/flatbuffers/actions/runs/3103852116/jobs/5034196360
29   sed -i 's#${test_dir}/../../python#${test_dir}/../python#' tests/PythonTest.sh
32 build() {
33   cmake -B build -S $pkgbase-$pkgver \
34     -DCMAKE_INSTALL_PREFIX=/usr \
35     -DFLATBUFFERS_BUILD_FLATLIB=OFF \
36     -DFLATBUFFERS_BUILD_SHAREDLIB=ON
37   cmake --build build
39 # Python bindings
40   cd $pkgbase-$pkgver/python
41   VERSION=$pkgver python setup.py build
44 check() {
45   # tests are broken with out-of-source builds
46   # https://github.com/google/flatbuffers/issues/7282
47   cmake --build build --target test || true
49   ./$pkgbase-$pkgver/tests/PythonTest.sh
52 package_flatbuffers() {
53   DESTDIR="$pkgdir" cmake --install build
56 package_python-flatbuffers() {
57   pkgdesc='An efficient cross platform serialization library for Python'
58   depends=(python)
59   optdepends=(
60     'python-numpy: support for Numpy arrays'
61   )
63   cd $pkgbase-$pkgver/python
64   VERSION=$pkgver python setup.py install --root="$pkgdir" --optimize=1 --skip-build