PKGBUILDs/extra/protobuf/PKGBUILD

155 lines
4.4 KiB
Bash
Raw Normal View History

2024-06-28 22:42:53 +00:00
# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: David Runge <dvzrv@archlinux.org>
# Contributor: Aleksey Filippov <sarum9in@gmail.com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Thomas S Hatch <thatch45@gmail.com>
# Contributor: Geoffroy Carrier <geoffroy@archlinux.org>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# - remove makedpends on bazel
# - remove python package
# ALARM: BrainDamage <braindamage@archlinux.org>
# - re-enable python package
# - split off python-protobuf to its own PKGBUILD file
2024-06-28 22:42:53 +00:00
pkgbase='protobuf'
2024-08-21 00:28:14 +00:00
pkgname=('protobuf' 'ruby-google-protobuf')
2024-11-10 13:25:42 +00:00
pkgver=28.3
pkgrel=1
# Note: python-protobuf needs to be updated alongside this package to the same version
2024-06-28 22:42:53 +00:00
pkgdesc="Protocol Buffers - Google's data interchange format"
arch=('x86_64')
url='https://developers.google.com/protocol-buffers/'
2024-09-12 18:09:11 +00:00
license=('BSD-3-Clause')
2024-06-28 22:42:53 +00:00
depends=(
'gcc-libs'
'glibc'
'zlib'
'abseil-cpp'
)
makedepends=(
'cmake'
'gtest'
'python-build'
'python-installer'
'python-setuptools'
'python-wheel'
2024-08-21 00:28:14 +00:00
'ruby'
'ruby-rake'
'ruby-rake-compiler'
2024-06-28 22:42:53 +00:00
)
checkdepends=(
python-pytest
python-numpy
)
source=(https://github.com/protocolbuffers/protobuf/archive/v$pkgver/$pkgname-$pkgver.tar.gz
2024-09-12 18:09:11 +00:00
protobuf-fix-build-type-none.patch
2024-08-21 00:28:14 +00:00
$pkgbase-25.3-ruby-disable-LTO.patch) # https://github.com/protocolbuffers/protobuf/issues/11935
2024-11-10 13:25:42 +00:00
sha512sums=('a91e175fed7eb01c4240842a5af73a7d3cefccbb10885434bceeb7bc89ab6c56a74912cee290bf46e81d4026f3c9c2b10faad5545816064e215c4bae7908263d'
2024-09-12 18:09:11 +00:00
'18bc71031bbcbc3810a9985fa670465040f06a6c104ab8079b56bdfc499bb6cec40805a0cefd455031142490a576dc60aa8000523877ac0353b93558e9beabbd'
2024-08-21 00:28:14 +00:00
'1ebdea4e533ee0f71baf1b3fe2623ca723b36a08c6b97475ea5996b10aeb6873cf94d9120596ddd1216bd2f6feb991f8c33078e8104008a5078ace5be5431efd')
2024-09-12 18:09:11 +00:00
options=(!lto)
2024-08-21 00:28:14 +00:00
_gemname=google-protobuf
2024-06-28 22:42:53 +00:00
prepare() {
2024-09-12 18:09:11 +00:00
patch -d $pkgname-$pkgver -p1 < protobuf-fix-build-type-none.patch # Fix cmake config compatibility mode
2024-08-21 00:28:14 +00:00
patch -d $pkgbase-$pkgver -p1 < $pkgbase-25.3-ruby-disable-LTO.patch
2024-06-28 22:42:53 +00:00
}
build() {
local cmake_options=(
-B build
-D CMAKE_BUILD_TYPE=None
-D CMAKE_INSTALL_PREFIX=/usr
-D CMAKE_C_FLAGS="$CFLAGS -ffat-lto-objects"
-D CMAKE_CXX_FLAGS="$CXXFLAGS -ffat-lto-objects"
-D protobuf_BUILD_SHARED_LIBS=ON
-D protobuf_USE_EXTERNAL_GTEST=ON
-D protobuf_ABSL_PROVIDER=package
-S "$pkgbase-$pkgver"
-W no-dev
)
cmake "${cmake_options[@]}"
cmake --build build --verbose
2024-08-21 00:28:14 +00:00
cd $pkgbase-$pkgver/ruby
local _gemdir="$(gem env gemdir)"
local _gemver=4.$pkgver
PROTOC="$srcdir"/build/protoc \
rake genproto
rake copy_third_party
gem build --verbose "${_gemname}.gemspec"
gem install \
--local \
--verbose \
--ignore-dependencies \
--no-user-install \
--install-dir "tmp_install${_gemdir}" \
--bindir "tmp_install/usr/bin" \
"${_gemname}-${_gemver}.gem"
# remove unrepreducible files
rm --force --recursive --verbose \
"tmp_install${_gemdir}/cache/" \
"tmp_install${_gemdir}/gems/${_gemname}-${_gemver}/vendor/" \
"tmp_install${_gemdir}/doc/${_gemname}-${_gemver}/ri/ext/"
find "tmp_install${_gemdir}/gems/" \
-type f \
\( \
-iname "*.o" -o \
-iname "*.c" -o \
-iname "*.so" -o \
-iname "*.time" -o \
-iname "gem.build_complete" -o \
-iname "Makefile" \
\) \
-delete
find "tmp_install${_gemdir}/extensions/" \
-type f \
\( \
-iname "mkmf.log" -o \
-iname "gem_make.out" \
\) \
-delete
2024-06-28 22:42:53 +00:00
}
check() {
ctest --test-dir build
}
package_protobuf() {
replaces=('protobuf-cpp')
provides=('libprotoc.so' 'libprotobuf.so' 'libprotobuf-lite.so')
DESTDIR="$pkgdir" cmake --install build
cd $pkgbase-$pkgver
install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
install -vDm 644 editors/protobuf-mode.el \
-t "$pkgdir/usr/share/emacs/site-lisp/"
install -vDm 644 editors/proto.vim \
-t "${pkgdir}/usr/share/vim/vimfiles/syntax"
}
2024-08-21 00:28:14 +00:00
package_ruby-google-protobuf() {
pkgdesc='Ruby bindings for Google Protocol Buffers'
depends=(
'ruby'
)
cp -a $pkgbase-$pkgver/ruby/tmp_install/* "$pkgdir"
install -vDm 644 $pkgbase-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
install -Dm 0644 $pkgbase-$pkgver/ruby/*.md -t "$pkgdir/usr/share/doc/${pkgname}"
}