summaryrefslogtreecommitdiff
path: root/user/protobuf
diff options
context:
space:
mode:
authorDan Theisen <djt@hxx.in>2018-10-05 03:15:07 -0700
committerDan Theisen <djt@hxx.in>2018-10-05 03:15:07 -0700
commit2ba6865311296c8ed0aa7ffde55c12737ef0abf4 (patch)
tree4295cd53dc9d6267ecaed694ae2ca877cfd8e76f /user/protobuf
parent1b0bf7092df10ea56033ce9f04a2eb6d6983ad75 (diff)
downloadpackages-2ba6865311296c8ed0aa7ffde55c12737ef0abf4.tar.gz
packages-2ba6865311296c8ed0aa7ffde55c12737ef0abf4.tar.bz2
packages-2ba6865311296c8ed0aa7ffde55c12737ef0abf4.tar.xz
packages-2ba6865311296c8ed0aa7ffde55c12737ef0abf4.zip
user/protobuf: new package from alpine, ugh
Diffstat (limited to 'user/protobuf')
-rw-r--r--user/protobuf/APKBUILD108
-rw-r--r--user/protobuf/musl-fix.patch22
-rw-r--r--user/protobuf/trim-rakefile.patch72
3 files changed, 202 insertions, 0 deletions
diff --git a/user/protobuf/APKBUILD b/user/protobuf/APKBUILD
new file mode 100644
index 000000000..5f00430bf
--- /dev/null
+++ b/user/protobuf/APKBUILD
@@ -0,0 +1,108 @@
+# Contributor: Kiyoshi Aman <kiyoshi.aman@gmail.com>
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Dan Theisen <djt@hxx.in>
+# TODO: Build Python module, and clean up Ruby build process
+pkgname=protobuf
+_gemname=google-protobuf
+pkgver=3.6.1
+_tstver=1.8.0
+pkgrel=0
+pkgdesc="Library for extensible, efficient structure packing"
+url="https://github.com/google/protobuf"
+arch="all"
+license="BSD-3-Clause"
+depends_dev="zlib-dev"
+makedepends="$depends_dev autoconf automake libtool ruby ruby-dev ruby-rake"
+subpackages="ruby-$_gemname:_ruby $pkgname-dev $pkgname-vim::noarch"
+source="$pkgname-$pkgver.tar.gz::https://github.com/google/$pkgname/archive/v$pkgver.tar.gz
+ googletest-$_tstver.tar.gz::https://github.com/google/googletest/archive/release-$_tstver.tar.gz
+ musl-fix.patch
+ trim-rakefile.patch"
+builddir="$srcdir/$pkgname-$pkgver"
+
+prepare() {
+ default_prepare
+
+ cd "$builddir"
+ ./autogen.sh
+
+ # symlink tests to the test directory
+ rm -rf third_party/*
+ ln -sf "$srcdir"/googletest-release-$_tstver \
+ "$builddir"/third_party/googletest
+}
+
+build() {
+ cd "$builddir"
+
+ CXXFLAGS="$CXXFLAGS -fno-delete-null-pointer-checks" \
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var
+ make
+
+ cd "$builddir"/ruby
+
+ # Generate proto files for built-in protocols.
+ rake genproto
+
+ gem build $_gemname.gemspec
+ gem install --local \
+ --install-dir dist \
+ --ignore-dependencies \
+ --no-document \
+ --verbose \
+ $_gemname
+
+ # build test-suite
+ local test; for test in googletest googlemock; do
+ cd "$builddir/third_party/googletest/$test"
+ autoreconf -vfi
+ ./configure
+ make
+ done
+}
+
+# TODO: Run tests for ruby gem.
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+_ruby() {
+ pkgdesc="Ruby bindings to Google's data interchange format"
+
+ local gemdir="$subpkgdir/$(ruby -e 'puts Gem.default_dir')"
+ cd "$builddir"/ruby/dist
+
+ mkdir -p "$gemdir"
+ cp -r extensions gems specifications "$gemdir"/
+
+ # Remove duplicated .so libs (should be only in extensions directory).
+ find "$gemdir"/gems/ -name "*.so" -delete
+
+ # Remove unnecessary files.
+ cd "$gemdir"/gems/$_gemname-$pkgver
+ rm -r ext/ tests/
+}
+
+vim() {
+ pkgdesc="Vim syntax for $pkgname"
+ depends=""
+ install_if="$pkgname=$pkgver-r$pkgrel vim"
+
+ install -Dm644 "$builddir"/editors/proto.vim \
+ "$subpkgdir"/usr/share/vim/vimfiles/syntax/proto.vim
+}
+
+sha512sums="1bc175d24b49de1b1e41eaf39598194e583afffb924c86c8d2e569d935af21874be76b2cbd4d9655a1d38bac3d4cd811de88bc2c72d81bad79115e69e5b0d839 protobuf-3.6.1.tar.gz
+1dbece324473e53a83a60601b02c92c089f5d314761351974e097b2cf4d24af4296f9eb8653b6b03b1e363d9c5f793897acae1f0c7ac40149216035c4d395d9d googletest-1.8.0.tar.gz
+875592bc5dc5efe9087ea1b340673f54c984ecd5aa3b110a2da136bdc28009af7ce1a9c57f4747ff809fc02eb6c39a0209c277177172af467a54172d9700188a musl-fix.patch
+d1d11fe76d2a1ae92f47f9eb1e0d94c67b7192a9dc4a382b6c0835f4fe4dbc2f98ca1b3c5095ad5b4e368581072330f943209c0decea02ebb47938588543fdb1 trim-rakefile.patch"
diff --git a/user/protobuf/musl-fix.patch b/user/protobuf/musl-fix.patch
new file mode 100644
index 000000000..442ca20ed
--- /dev/null
+++ b/user/protobuf/musl-fix.patch
@@ -0,0 +1,22 @@
+seems like both musl libc and android has byteswap.h
+
+--- a/src/google/protobuf/stubs/port.h
++++ b/src/google/protobuf/stubs/port.h
+@@ -94,7 +94,7 @@
+ #include <intrin.h>
+ #elif defined(__APPLE__)
+ #include <libkern/OSByteOrder.h>
+-#elif defined(__GLIBC__) || defined(__BIONIC__) || defined(__CYGWIN__)
++#elif defined(__linux__) || defined(__BIONIC__) || defined(__CYGWIN__)
+ #include <byteswap.h> // IWYU pragma: export
+ #endif
+
+@@ -380,7 +380,7 @@ inline void GOOGLE_UNALIGNED_STORE64(voi
+ #define bswap_32(x) OSSwapInt32(x)
+ #define bswap_64(x) OSSwapInt64(x)
+
+-#elif !defined(__GLIBC__) && !defined(__BIONIC__) && !defined(__CYGWIN__)
++#elif !defined(__linux__) && !defined(__BIONIC__) && !defined(__CYGWIN__)
+
+ static inline uint16 bswap_16(uint16 x) {
+ return static_cast<uint16>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8));
diff --git a/user/protobuf/trim-rakefile.patch b/user/protobuf/trim-rakefile.patch
new file mode 100644
index 000000000..7f53d7099
--- /dev/null
+++ b/user/protobuf/trim-rakefile.patch
@@ -0,0 +1,72 @@
+Remove code that we don't use to avoid installing additional dependencies.
+--- a/ruby/Rakefile
++++ b/ruby/Rakefile
+@@ -1,6 +1,4 @@
+ require "rubygems"
+-require "rubygems/package_task"
+-require "rake/extensiontask" unless RUBY_PLATFORM == "java"
+ require "rake/testtask"
+
+ spec = Gem::Specification.load("google-protobuf.gemspec")
+@@ -39,51 +37,6 @@
+ end
+ end
+
+-if RUBY_PLATFORM == "java"
+- if `which mvn` == ''
+- raise ArgumentError, "maven needs to be installed"
+- end
+- task :clean do
+- system("mvn --batch-mode clean")
+- end
+-
+- task :compile do
+- system("mvn --batch-mode package")
+- end
+-else
+- Rake::ExtensionTask.new("protobuf_c", spec) do |ext|
+- unless RUBY_PLATFORM =~ /darwin/
+- # TODO: also set "no_native to true" for mac if possible. As is,
+- # "no_native" can only be set if the RUBY_PLATFORM doing
+- # cross-compilation is contained in the "ext.cross_platform" array.
+- ext.no_native = true
+- end
+- ext.ext_dir = "ext/google/protobuf_c"
+- ext.lib_dir = "lib/google"
+- ext.cross_compile = true
+- ext.cross_platform = [
+- 'x86-mingw32', 'x64-mingw32',
+- 'x86_64-linux', 'x86-linux',
+- 'universal-darwin'
+- ]
+- end
+-
+- task 'gem:windows' do
+- require 'rake_compiler_dock'
+- RakeCompilerDock.sh "bundle && IN_DOCKER=true rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0"
+- end
+-
+- if RUBY_PLATFORM =~ /darwin/
+- task 'gem:native' do
+- system "rake genproto"
+- system "rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0"
+- end
+- else
+- task 'gem:native' => [:genproto, 'gem:windows']
+- end
+-end
+-
+-
+ # Proto for tests.
+ genproto_output << "tests/generated_code.rb"
+ genproto_output << "tests/test_import.rb"
+@@ -104,9 +57,6 @@
+
+ task :clean do
+ sh "rm -f #{genproto_output.join(' ')}"
+-end
+-
+-Gem::PackageTask.new(spec) do |pkg|
+ end
+
+ Rake::TestTask.new(:test => :build) do |t|