diff options
author | Mingli Yu <Mingli.Yu@windriver.com> | 2017-12-22 10:54:51 +0800 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2017-12-27 07:25:03 -0800 |
commit | 5f6fcfd36272768a3ff9078c07c572cf5dc01ccd (patch) | |
tree | 25022af3a188e2f53cb4ee65fee02bf543946c9d /meta-oe/recipes-devtools | |
parent | 13c84c645b6126f0cb3d768e8934992f594a82ab (diff) | |
download | meta-openembedded-5f6fcfd36272768a3ff9078c07c572cf5dc01ccd.tar.gz |
protobuf: add ptest support
* Add DEPENDS_class-target = "protobuf-native"
to fix below error:
| DEBUG: SITE files ['endian-little', 'common-linux', 'common-glibc', 'bit-64', 'x86_64-linux', 'common']
| DEBUG: Executing shell function do_compile_ptest_base
| NOTE: make -C $Prj/build/tmp-glibc/work/core2-64-wrs-linux/protobuf/3.4.1+gitAUTOINC+b04e5cba35-r0/git/examples cpp
| make: Entering directory '$Prj/build/tmp-glibc/work/core2-64-wrs-linux/protobuf/3.4.1+gitAUTOINC+b04e5cba35-r0/git/examples'
| protoc --cpp_out=. --java_out=. --python_out=. addressbook.proto
| make: protoc: Command not found
| make: *** [Makefile:25: protoc_middleman] Error 127
* Add run-ptest
* Add rdepends on bash and python-protobuf for ptest
Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-oe/recipes-devtools')
-rw-r--r-- | meta-oe/recipes-devtools/protobuf/protobuf/run-ptest | 38 | ||||
-rw-r--r-- | meta-oe/recipes-devtools/protobuf/protobuf_3.4.1.bb | 54 |
2 files changed, 90 insertions, 2 deletions
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/run-ptest b/meta-oe/recipes-devtools/protobuf/protobuf/run-ptest new file mode 100644 index 000000000..7c3a8d1b3 --- /dev/null +++ b/meta-oe/recipes-devtools/protobuf/protobuf/run-ptest | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/bash | ||
2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
3 | TEST_FILE="/tmp/test.data" | ||
4 | |||
5 | RETVAL=0 | ||
6 | # Test every writing test application | ||
7 | for write_exe_full_path in ${DIR}/add_person_*; do | ||
8 | if [ -x "${write_exe_full_path}" ]; then | ||
9 | write_exe=`basename ${write_exe_full_path}` | ||
10 | echo "Generating new test file using ${write_exe}..." | ||
11 | ${write_exe_full_path} "${TEST_FILE}" | ||
12 | RETVAL=$? | ||
13 | [ $RETVAL -eq 0 ] || exit $RETVAL | ||
14 | |||
15 | # Test every reading test application | ||
16 | for read_exe_full_path in ${DIR}/list_people_*; do | ||
17 | read_exe=`basename ${read_exe_full_path}` | ||
18 | echo "Test: Write with ${write_exe}; Read with ${read_exe}..." | ||
19 | if [ -x "${read_exe_full_path}" ]; then | ||
20 | ${read_exe_full_path} "${TEST_FILE}" | ||
21 | RETVAL=$? | ||
22 | [ $RETVAL -eq 0 ] || exit $RETVAL | ||
23 | fi | ||
24 | done | ||
25 | |||
26 | # Cleanup... | ||
27 | if [ -e "${TEST_FILE}" ]; then | ||
28 | rm "${TEST_FILE}" | ||
29 | fi | ||
30 | fi | ||
31 | done | ||
32 | |||
33 | if [ $RETVAL -eq 0 ] ; then | ||
34 | echo "PASS: protobuf" | ||
35 | else | ||
36 | echo "FAIL: protobuf" | ||
37 | fi | ||
38 | |||
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf_3.4.1.bb b/meta-oe/recipes-devtools/protobuf/protobuf_3.4.1.bb index fae7c18a1..1407d08bb 100644 --- a/meta-oe/recipes-devtools/protobuf/protobuf_3.4.1.bb +++ b/meta-oe/recipes-devtools/protobuf/protobuf_3.4.1.bb | |||
@@ -9,8 +9,10 @@ LICENSE = "BSD-3-Clause" | |||
9 | PACKAGE_BEFORE_PN = "${PN}-compiler ${PN}-lite" | 9 | PACKAGE_BEFORE_PN = "${PN}-compiler ${PN}-lite" |
10 | 10 | ||
11 | DEPENDS = "zlib" | 11 | DEPENDS = "zlib" |
12 | DEPENDS_append_class-target = " protobuf-native" | ||
12 | RDEPENDS_${PN}-compiler = "${PN}" | 13 | RDEPENDS_${PN}-compiler = "${PN}" |
13 | RDEPENDS_${PN}-dev += "${PN}-compiler" | 14 | RDEPENDS_${PN}-dev += "${PN}-compiler" |
15 | RDEPENDS_${PN}-ptest = "bash python-protobuf" | ||
14 | 16 | ||
15 | LIC_FILES_CHKSUM = "file://LICENSE;md5=35953c752efc9299b184f91bef540095" | 17 | LIC_FILES_CHKSUM = "file://LICENSE;md5=35953c752efc9299b184f91bef540095" |
16 | 18 | ||
@@ -18,13 +20,61 @@ SRCREV = "b04e5cba356212e4e8c66c61bbe0c3a20537c5b9" | |||
18 | 20 | ||
19 | PV = "3.4.1+git${SRCPV}" | 21 | PV = "3.4.1+git${SRCPV}" |
20 | 22 | ||
21 | SRC_URI = "git://github.com/google/protobuf.git;branch=3.4.x" | 23 | SRC_URI = "git://github.com/google/protobuf.git;branch=3.4.x \ |
24 | file://run-ptest \ | ||
25 | " | ||
22 | 26 | ||
23 | EXTRA_OECONF += " --with-protoc=echo" | 27 | EXTRA_OECONF += " --with-protoc=echo" |
24 | 28 | ||
25 | inherit autotools-brokensep | 29 | inherit autotools-brokensep pkgconfig ptest |
26 | 30 | ||
27 | S = "${WORKDIR}/git" | 31 | S = "${WORKDIR}/git" |
32 | TEST_SRC_DIR="examples" | ||
33 | LANG_SUPPORT="cpp python" | ||
34 | |||
35 | do_compile_ptest() { | ||
36 | # Modify makefile to use the cross-compiler | ||
37 | sed -e "s|c++|${CXX} \$(LDFLAGS)|g" -i "${S}/${TEST_SRC_DIR}/Makefile" | ||
38 | |||
39 | mkdir -p "${B}/${TEST_SRC_DIR}" | ||
40 | |||
41 | # Add the location of the cross-compiled header and library files | ||
42 | # which haven't been installed yet. | ||
43 | cp "${B}/protobuf.pc" "${B}/${TEST_SRC_DIR}/protobuf.pc" | ||
44 | sed -e 's|libdir=|libdir=${PKG_CONFIG_SYSROOT_DIR}|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" | ||
45 | sed -e 's|Cflags:|Cflags: -I${S}/src|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" | ||
46 | sed -e 's|Libs:|Libs: -L${B}/src/.libs|' -i "${B}/${TEST_SRC_DIR}/protobuf.pc" | ||
47 | export PKG_CONFIG_PATH="${B}/${TEST_SRC_DIR}" | ||
48 | |||
49 | # Save the pkgcfg sysroot variable, and update it to nothing so | ||
50 | # that it doesn't append the sysroot to the beginning of paths. | ||
51 | # The header and library files aren't installed to the target | ||
52 | # system yet. So the absolute paths were specified above. | ||
53 | save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR | ||
54 | export PKG_CONFIG_SYSROOT_DIR= | ||
55 | |||
56 | # Compile the tests | ||
57 | for lang in ${LANG_SUPPORT}; do | ||
58 | oe_runmake -C "${S}/${TEST_SRC_DIR}" ${lang} | ||
59 | done | ||
60 | |||
61 | # Restore the pkgconfig sysroot variable | ||
62 | export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir | ||
63 | } | ||
64 | |||
65 | do_install_ptest() { | ||
66 | local olddir=`pwd` | ||
67 | |||
68 | cd "${S}/${TEST_SRC_DIR}" | ||
69 | install -d "${D}/${PTEST_PATH}" | ||
70 | for i in add_person* list_people*; do | ||
71 | if [ -x "$i" ]; then | ||
72 | install "$i" "${D}/${PTEST_PATH}" | ||
73 | fi | ||
74 | done | ||
75 | cp "${S}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}" | ||
76 | cd "$olddir" | ||
77 | } | ||
28 | 78 | ||
29 | FILES_${PN}-compiler = "${bindir} ${libdir}/libprotoc${SOLIBS}" | 79 | FILES_${PN}-compiler = "${bindir} ${libdir}/libprotoc${SOLIBS}" |
30 | FILES_${PN}-lite = "${bindir} ${libdir}/libprotobuf-lite${SOLIBS}" | 80 | FILES_${PN}-lite = "${bindir} ${libdir}/libprotobuf-lite${SOLIBS}" |