summaryrefslogtreecommitdiff
blob: 9b1cc5e0e550cf9f634722f1b393e6b4336b706a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6
JAVA_PKG_IUSE="doc source"

inherit java-pkg-2 java-pkg-simple

MY_PV=${PV/_beta/-beta-}
MY_PV=${MY_PV/_p/.}

DESCRIPTION="Google's Protocol Buffers - official Java Bindings"
HOMEPAGE="https://github.com/google/protobuf/ https://developers.google.com/protocol-buffers/"
SRC_URI="https://github.com/google/protobuf/archive/v${MY_PV}.tar.gz -> protobuf-${PV}.tar.gz"

LICENSE="Apache-2.0"
SLOT="0/11"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~sh ~x86 ~amd64-linux ~arm-linux ~x86-linux ~x64-macos ~x86-macos"
IUSE="nano"

# Protobuf is only a build-time dep, but depends on the exact same version
# (excluding revision), since we are using the same tarball.
# But probably same subslot is sufficient.
DEPEND=">=virtual/jdk-1.7
	>=dev-libs/protobuf-3"

RDEPEND=">=virtual/jre-1.7
	!<dev-libs/protobuf-3[java(-)]"

S="${WORKDIR}/protobuf-${MY_PV}"
src_prepare() {
	default
	java-pkg-2_src_prepare
}

src_compile() {
	pushd "${S}/java" >/dev/null || die
	einfo "Compiling Java library ..."
	"${EPREFIX}"/usr/bin/protoc --java_out=core/src/main/java -I../src ../src/google/protobuf/descriptor.proto || die
	JAVA_SRC_DIR="${S}/java/core/src/main/java"
	JAVA_JAR_FILENAME="protobuf.jar"
	java-pkg-simple_src_compile
	popd >/dev/null || die
	if use nano; then
		einfo "Compiling Java Nano library ..."
		pushd "${S}/javanano" >/dev/null || die
		"${EPREFIX}"/usr/bin/protoc --java_out=src/main/java -I../src ../src/google/protobuf/descriptor.proto || die
		JAVA_SRC_DIR="${S}/javanano/src/main/java"
		JAVA_GENTOO_CLASSPATH_EXTRA="${S}/java/core/src/main/java/"
		JAVA_JAR_FILENAME="protobuf-nano.jar"
		java-pkg-simple_src_compile
		popd >/dev/null || die
	fi
}

src_install() {
	JAVA_JAR_FILENAME="${S}/java/protobuf.jar"
	JAVA_SRC_DIR="${S}/java/core/src/main/java"
	if use nano; then
		JAVA_JAR_FILENAME="${JAVA_JAR_FILENAME} ${S}/javanano/protobuf-nano.jar"
		JAVA_SRC_DIR="${JAVA_SRC_DIR} ${S}/javanano/src/main/java"
	fi
	mv "${S}/java/target" . || die
	if use nano; then
		cp -Rvf "${S}/javanano/target" . || die
	fi
	java-pkg-simple_src_install
}