summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2019-02-15 01:04:45 -0500
committerKhem Raj <raj.khem@gmail.com>2019-02-17 12:21:26 -0800
commitce02a140a0214c6cace3de3e1f1e3ed943b0655a (patch)
treea1bcf1f5721aa2e0bef3fd9bba6aa75939d3297d
parentcb1b5130441b79473fde4083c07ac5d18dd28561 (diff)
downloadmeta-openembedded-ce02a140a0214c6cace3de3e1f1e3ed943b0655a.tar.gz
python3-protobuf: add cpp implementation support
- Compiling with option `--cpp_implementation', add cpp implementation support which requires to build with protobuf. - Workaround native compile failure while host gcc <= 4.8 Setting environment KOKORO_BUILD_NUMBER, the build will explicitly compile with option `-std=c++11', it could workaround native compile failure while host gcc <= 4.8 ... /usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options ... - Add Python 3.7 compatibility Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-python/recipes-devtools/python/python-protobuf.inc1
-rw-r--r--meta-python/recipes-devtools/python/python3-protobuf/0001-Add-Python-3.7-compatibility-4862.patch98
-rw-r--r--meta-python/recipes-devtools/python/python3-protobuf_3.6.1.bb9
3 files changed, 108 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python-protobuf.inc b/meta-python/recipes-devtools/python/python-protobuf.inc
index 51037915d..54eacc0b7 100644
--- a/meta-python/recipes-devtools/python/python-protobuf.inc
+++ b/meta-python/recipes-devtools/python/python-protobuf.inc
@@ -29,3 +29,4 @@ RDEPENDS_${PN} += " \
29 29
30# For usage in other recipies when compiling protobuf files (e.g. by grpcio-tools) 30# For usage in other recipies when compiling protobuf files (e.g. by grpcio-tools)
31BBCLASSEXTEND = "native nativesdk" 31BBCLASSEXTEND = "native nativesdk"
32
diff --git a/meta-python/recipes-devtools/python/python3-protobuf/0001-Add-Python-3.7-compatibility-4862.patch b/meta-python/recipes-devtools/python/python3-protobuf/0001-Add-Python-3.7-compatibility-4862.patch
new file mode 100644
index 000000000..da5e73b15
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-protobuf/0001-Add-Python-3.7-compatibility-4862.patch
@@ -0,0 +1,98 @@
1From 539bc017a62f91bdf7c547b58948cb5a2f59d918 Mon Sep 17 00:00:00 2001
2From: Ben Webb <ben@salilab.org>
3Date: Thu, 12 Jul 2018 10:58:10 -0700
4Subject: [PATCH] Add Python 3.7 compatibility (#4862)
5
6Compilation of Python wrappers fails with Python 3.7 because
7the Python folks changed their C API such that
8PyUnicode_AsUTF8AndSize() now returns a const char* rather
9than a char*. Add a patch to work around. Relates #4086.
10
11Upstream-Status: Backport [https://github.com/protocolbuffers/protobuf.git]
12Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
13
14---
15 google/protobuf/pyext/descriptor.cc | 2 +-
16 google/protobuf/pyext/descriptor_containers.cc | 2 +-
17 google/protobuf/pyext/descriptor_pool.cc | 2 +-
18 google/protobuf/pyext/extension_dict.cc | 2 +-
19 google/protobuf/pyext/message.cc | 4 ++--
20 5 files changed, 6 insertions(+), 6 deletions(-)
21
22diff --git a/google/protobuf/pyext/descriptor.cc b/google/protobuf/pyext/descriptor.cc
23index 8af0cb1..19a1c38 100644
24--- a/google/protobuf/pyext/descriptor.cc
25+++ b/google/protobuf/pyext/descriptor.cc
26@@ -56,7 +56,7 @@
27 #endif
28 #define PyString_AsStringAndSize(ob, charpp, sizep) \
29 (PyUnicode_Check(ob)? \
30- ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
31+ ((*(charpp) = const_cast<char*>(PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL? -1: 0): \
32 PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
33 #endif
34
35diff --git a/google/protobuf/pyext/descriptor_containers.cc b/google/protobuf/pyext/descriptor_containers.cc
36index bc007f7..0153664 100644
37--- a/google/protobuf/pyext/descriptor_containers.cc
38+++ b/google/protobuf/pyext/descriptor_containers.cc
39@@ -66,7 +66,7 @@
40 #endif
41 #define PyString_AsStringAndSize(ob, charpp, sizep) \
42 (PyUnicode_Check(ob)? \
43- ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
44+ ((*(charpp) = const_cast<char*>(PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL? -1: 0): \
45 PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
46 #endif
47
48diff --git a/google/protobuf/pyext/descriptor_pool.cc b/google/protobuf/pyext/descriptor_pool.cc
49index 95882ae..962accc 100644
50--- a/google/protobuf/pyext/descriptor_pool.cc
51+++ b/google/protobuf/pyext/descriptor_pool.cc
52@@ -48,7 +48,7 @@
53 #endif
54 #define PyString_AsStringAndSize(ob, charpp, sizep) \
55 (PyUnicode_Check(ob)? \
56- ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
57+ ((*(charpp) = const_cast<char*>(PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL? -1: 0): \
58 PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
59 #endif
60
61diff --git a/google/protobuf/pyext/extension_dict.cc b/google/protobuf/pyext/extension_dict.cc
62index 018b5c2..174c547 100644
63--- a/google/protobuf/pyext/extension_dict.cc
64+++ b/google/protobuf/pyext/extension_dict.cc
65@@ -53,7 +53,7 @@
66 #endif
67 #define PyString_AsStringAndSize(ob, charpp, sizep) \
68 (PyUnicode_Check(ob)? \
69- ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
70+ ((*(charpp) = const_cast<char*>(PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL? -1: 0): \
71 PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
72 #endif
73
74diff --git a/google/protobuf/pyext/message.cc b/google/protobuf/pyext/message.cc
75index 5893533..31094b7 100644
76--- a/google/protobuf/pyext/message.cc
77+++ b/google/protobuf/pyext/message.cc
78@@ -79,7 +79,7 @@
79 (PyUnicode_Check(ob)? PyUnicode_AsUTF8(ob): PyBytes_AsString(ob))
80 #define PyString_AsStringAndSize(ob, charpp, sizep) \
81 (PyUnicode_Check(ob)? \
82- ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
83+ ((*(charpp) = const_cast<char*>(PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL? -1: 0): \
84 PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
85 #endif
86 #endif
87@@ -1529,7 +1529,7 @@ PyObject* HasField(CMessage* self, PyObject* arg) {
88 return NULL;
89 }
90 #else
91- field_name = PyUnicode_AsUTF8AndSize(arg, &size);
92+ field_name = const_cast<char*>(PyUnicode_AsUTF8AndSize(arg, &size));
93 if (!field_name) {
94 return NULL;
95 }
96--
972.7.4
98
diff --git a/meta-python/recipes-devtools/python/python3-protobuf_3.6.1.bb b/meta-python/recipes-devtools/python/python3-protobuf_3.6.1.bb
index 781d1dc4d..9b0668a02 100644
--- a/meta-python/recipes-devtools/python/python3-protobuf_3.6.1.bb
+++ b/meta-python/recipes-devtools/python/python3-protobuf_3.6.1.bb
@@ -1,2 +1,11 @@
1inherit setuptools3 1inherit setuptools3
2require python-protobuf.inc 2require python-protobuf.inc
3
4SRC_URI += "file://0001-Add-Python-3.7-compatibility-4862.patch"
5DEPENDS += "protobuf"
6DISTUTILS_BUILD_ARGS += "--cpp_implementation"
7DISTUTILS_INSTALL_ARGS += "--cpp_implementation"
8
9do_compile_prepend_class-native () {
10 export KOKORO_BUILD_NUMBER="1"
11}