blob: fd81fe765f354da3f658fb8f7a8d87b05ea141ba [file] [log] [blame]
Patrick Williamsd849ec72016-08-17 14:59:38 -05001SUMMARY = "protobuf"
2DESCRIPTION = "Protocol Buffers are a way of encoding structured data in \
3an efficient yet extensible format. Google uses Protocol Buffers for \
4almost all of its internal RPC protocols and file formats."
5HOMEPAGE = "http://code.google.com/p/protobuf/"
6SECTION = "console/tools"
7LICENSE = "BSD-3-Clause"
8
Patrick Williamse69d2352017-02-23 20:56:04 -06009LIC_FILES_CHKSUM = "file://LICENSE;md5=35953c752efc9299b184f91bef540095"
Patrick Williamsd849ec72016-08-17 14:59:38 -050010
11PR = "r0"
12EXCLUDE_FROM_WORLD = "1"
13
Patrick Williamse69d2352017-02-23 20:56:04 -060014SRC_URI[md5sum] = "d4f6ca65aadc6310b3872ee421e79fa6"
15SRC_URI[sha256sum] = "f5b3563f118f1d3d6e001705fa7082e8fc3bda50038ac3dff787650795734146"
16SRC_URI = "https://github.com/google/protobuf/archive/v3.0.0.tar.gz;downloadfilename=protobuf-3.0.0.tar.gz\
17 file://protobuf-allow-running-python-scripts-from-anywhere.patch \
18 file://run-ptest \
19 "
Patrick Williamsd849ec72016-08-17 14:59:38 -050020
21COMPATIBLE_HOST = "(x86_64|arm|aarch64).*-linux"
22
23EXTRA_OECONF += " --with-protoc=${STAGING_BINDIR_NATIVE}/protoc"
24inherit autotools setuptools ptest
25
26DEPENDS += "protobuf-native"
Patrick Williamse69d2352017-02-23 20:56:04 -060027RDEPENDS_${PN}-ptest = "bash"
Patrick Williamsd849ec72016-08-17 14:59:38 -050028
29PYTHON_SRC_DIR="python"
30TEST_SRC_DIR="examples"
31LANG_SUPPORT="cpp python"
32
33do_compile() {
34 # Compile protoc compiler
35 base_do_compile
36}
37
38do_compile_ptest() {
39 # Modify makefile to use the cross-compiler
Patrick Williamse69d2352017-02-23 20:56:04 -060040 sed -e "s|c++|${CXX} \$(LDFLAGS)|g" -i "${S}/${TEST_SRC_DIR}/Makefile"
Patrick Williamsd849ec72016-08-17 14:59:38 -050041
42 mkdir -p "${B}/${TEST_SRC_DIR}"
43
44 # Add the location of the cross-compiled header and library files
45 # which haven't been installed yet.
46 cp "${B}/protobuf.pc" "${B}/${TEST_SRC_DIR}/protobuf.pc"
47 sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
48 sed -e 's|Cflags:|Cflags: -I${S}/src|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
49 sed -e 's|Libs:|Libs: -L${B}/src/.libs|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc"
50 export PKG_CONFIG_PATH="${B}/${TEST_SRC_DIR}"
51
52 # Save the pkgcfg sysroot variable, and update it to nothing so
53 # that it doesn't append the sysroot to the beginning of paths.
54 # The header and library files aren't installed to the target
55 # system yet. So the absolute paths were specified above.
56 save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR
57 export PKG_CONFIG_SYSROOT_DIR=
58
59 # Compile the tests
60 for lang in ${LANG_SUPPORT}; do
61 oe_runmake -C "${S}/${TEST_SRC_DIR}" ${lang}
62 done
63
64 # Restore the pkgconfig sysroot variable
65 export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir
66}
67
68do_install() {
69 local olddir=`pwd`
70
71 # Install protoc compiler
72 autotools_do_install
73
74 # Install header files
75 export PROTOC="${STAGING_BINDIR_NATIVE}/protoc"
76 cd "${S}/${PYTHON_SRC_DIR}"
77 distutils_do_install
78
79 cd "$olddir"
80}
81
82do_install_ptest() {
83 local olddir=`pwd`
84
85 cd "${S}/${TEST_SRC_DIR}"
86 install -d "${D}/${PTEST_PATH}"
87 for i in add_person* list_people*; do
88 if [ -x "$i" ]; then
89 install "$i" "${D}/${PTEST_PATH}"
90 fi
91 done
92 cp "${S}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}"
93
94 cd "$olddir"
95}
96
97BBCLASSEXTEND = "nativesdk"
98