diff --git a/.gitignore b/.gitignore index 62de6f1bf9fbf..19a67cebd19eb 100644 --- a/.gitignore +++ b/.gitignore @@ -215,3 +215,12 @@ BenchmarkDotNet.Artifacts/ # Clangd uses these common ephemeral files .cache compile_commands.json + +src/*.a +src/*.so* +src/CMakeCache.txt +src/CMakeFiles/ +src/cmake_install.cmake +src/install_manifest.txt +src/lib/ +src/protoc-* diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 83e970312c40a..05e13c1fe9569 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -112,7 +112,6 @@ if(protobuf_BUILD_SHARED_LIBS) endif() set_target_properties(libprotobuf-lite PROPERTIES VERSION ${protobuf_VERSION} - SOVERSION 32 OUTPUT_NAME ${LIB_PREFIX}protobuf-lite DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite) diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake index 07e4bcf57fac1..d37c1ccad747e 100644 --- a/cmake/libprotobuf.cmake +++ b/cmake/libprotobuf.cmake @@ -128,7 +128,6 @@ if(protobuf_BUILD_SHARED_LIBS) endif() set_target_properties(libprotobuf PROPERTIES VERSION ${protobuf_VERSION} - SOVERSION 32 OUTPUT_NAME ${LIB_PREFIX}protobuf DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") add_library(protobuf::libprotobuf ALIAS libprotobuf) diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index 15a47e53fa188..d43b5dffab49c 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -130,7 +130,6 @@ endif() set_target_properties(libprotoc PROPERTIES COMPILE_DEFINITIONS LIBPROTOC_EXPORTS VERSION ${protobuf_VERSION} - SOVERSION 32 OUTPUT_NAME ${LIB_PREFIX}protoc DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") add_library(protobuf::libprotoc ALIAS libprotoc) diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000000000..cefb2ec10cae6 --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,13 @@ +*.substvars +*debhelper* +.debhelper +autoreconf.* +files +libprotobuf-dev +libprotobuf-lite32 +libprotobuf32 +libprotoc-dev +libprotoc32 +protobuf-compiler +python3-protobuf +tmp diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000000..ca892867d42e0 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +protobuf (100:3.21.6-1) UNRELEASED; urgency=medium + + * https://github.com/protocolbuffers/protobuf/releases/tag/v3.21.6 + + -- Wong Hoi Sing Edison Wed, 14 Sep 2022 13:19:04 +0800 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000000..08a57a52007e5 --- /dev/null +++ b/debian/control @@ -0,0 +1,107 @@ +Source: protobuf +Section: devel +Priority: optional +Standards-Version: 4.5.0 +Maintainer: Wong Hoi Sing Edison +Homepage: https://github.com/protocolbuffers/protobuf/tags +Vcs-Browser: https://github.com/alvistack/protocolbuffers-protobuf +Vcs-Git: https://github.com/alvistack/protocolbuffers-protobuf.git +Build-Depends: + debhelper, + debhelper-compat (= 10), + dh-python, + fdupes, + cmake, + python3-dev, + python3-setuptools, + zlib1g-dev, + +Package: libprotobuf32 +Architecture: any +Section: libs +Description: protocol buffers C++ library + This package contains the runtime library needed for C++ applications. +Depends: + ${misc:Depends}, + ${shlibs:Depends}, +Breaks: + cura-engine (<< 1:3.3.0-2.1+b1), + libarcus3 (<< 3.3.0-2), + +Package: libprotobuf-lite32 +Architecture: any +Section: libs +Description: protocol buffers C++ library (lite version) + This package contains the runtime library needed for C++ applications whose + message definitions have the "lite runtime" optimization setting. +Depends: + ${misc:Depends}, + ${shlibs:Depends}, + +Package: libprotobuf-dev +Architecture: any +Section: libdevel +Description: protocol buffers C++ library (development files) and proto files + This package contains the development headers and static libraries needed for + writing C++ applications. Includes well known proto type files. +Depends: + ${misc:Depends}, + zlib1g-dev, + libprotobuf32 (= ${source:Version}), + libprotobuf-lite32 (= ${source:Version}), +Breaks: + protobuf-compiler (<< ${source:Version}), + protobuf-compiler (>> ${source:Version}), +Provides: + protobuf-api-32-0, + +Package: libprotoc32 +Architecture: any +Multi-Arch: same +Section: libs +Description: protocol buffers compiler library + This package contains the runtime library needed for the protocol buffer + compiler. +Depends: + ${shlibs:Depends}, + ${misc:Depends}, + +Package: libprotoc-dev +Architecture: any +Section: libdevel +Description: protocol buffers compiler library (development files) + This package contains the development headers and static library needed for + writing protobuf compilers. +Depends: + ${misc:Depends}, + libprotobuf-dev (= ${source:Version}), + libprotoc32 (= ${source:Version}), +Replaces: + libprotobuf-dev (<< 2.1.0), +Breaks: + libprotobuf-dev (<< 2.1.0), + +Package: protobuf-compiler +Architecture: any +Description: compiler for protocol buffer definition files + This package contains the protocol buffer compiler that is used for + translating from .proto files (containing the definitions) to the language + binding for the supported languages. +Depends: + ${shlibs:Depends}, + ${misc:Depends}, + libprotoc32 (= ${binary:Version}), + +Package: python3-protobuf +Architecture: any +Section: python +Description: Python 3 bindings for protocol buffers + This package contains the Python 3 bindings for the protocol buffers. You will + need the protoc tool (in the protobuf-compiler package) to compile your + definition to Python classes, and then the modules in this package will allow + you to use those classes in your programs. +Depends: + ${misc:Depends}, + ${python3:Depends}, + ${shlibs:Depends}, + python3, diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/debian/libprotobuf-dev.install b/debian/libprotobuf-dev.install new file mode 100644 index 0000000000000..5b5f43fb60b30 --- /dev/null +++ b/debian/libprotobuf-dev.install @@ -0,0 +1,5 @@ +usr/include +usr/lib/*/cmake +usr/lib/*/libprotobuf-lite.so +usr/lib/*/libprotobuf.so +usr/lib/*/pkgconfig/* diff --git a/debian/libprotobuf-dev.lintian-overrides b/debian/libprotobuf-dev.lintian-overrides new file mode 100644 index 0000000000000..30fd66a144cf2 --- /dev/null +++ b/debian/libprotobuf-dev.lintian-overrides @@ -0,0 +1,3 @@ +libprotobuf-dev: copyright-without-copyright-notice +libprotobuf-dev: initial-upload-closes-no-bugs +libprotobuf-dev: zero-byte-file-in-doc-directory diff --git a/debian/libprotobuf-lite32.install b/debian/libprotobuf-lite32.install new file mode 100644 index 0000000000000..45e00546a30a2 --- /dev/null +++ b/debian/libprotobuf-lite32.install @@ -0,0 +1 @@ +usr/lib/*/libprotobuf-lite.so.* diff --git a/debian/libprotobuf-lite32.lintian-overrides b/debian/libprotobuf-lite32.lintian-overrides new file mode 100644 index 0000000000000..499fad0733923 --- /dev/null +++ b/debian/libprotobuf-lite32.lintian-overrides @@ -0,0 +1,4 @@ +libprotobuf-lite32: copyright-without-copyright-notice +libprotobuf-lite32: initial-upload-closes-no-bugs +libprotobuf-lite32: package-name-doesnt-match-sonames +libprotobuf-lite32: zero-byte-file-in-doc-directory diff --git a/debian/libprotobuf32.install b/debian/libprotobuf32.install new file mode 100644 index 0000000000000..9ac8d247dccb8 --- /dev/null +++ b/debian/libprotobuf32.install @@ -0,0 +1 @@ +usr/lib/*/libprotobuf.so.* diff --git a/debian/libprotobuf32.lintian-overrides b/debian/libprotobuf32.lintian-overrides new file mode 100644 index 0000000000000..eb338d3a4c480 --- /dev/null +++ b/debian/libprotobuf32.lintian-overrides @@ -0,0 +1,4 @@ +libprotobuf32: copyright-without-copyright-notice +libprotobuf32: initial-upload-closes-no-bugs +libprotobuf32: package-name-doesnt-match-sonames +libprotobuf32: zero-byte-file-in-doc-directory diff --git a/debian/libprotoc-dev.install b/debian/libprotoc-dev.install new file mode 100644 index 0000000000000..899bb85fe3b0f --- /dev/null +++ b/debian/libprotoc-dev.install @@ -0,0 +1,2 @@ +usr/include/google/protobuf/compiler +usr/lib/*/libprotoc.so diff --git a/debian/libprotoc-dev.lintian-overrides b/debian/libprotoc-dev.lintian-overrides new file mode 100644 index 0000000000000..f90c4d60db90b --- /dev/null +++ b/debian/libprotoc-dev.lintian-overrides @@ -0,0 +1,3 @@ +libprotoc-dev: copyright-without-copyright-notice +libprotoc-dev: initial-upload-closes-no-bugs +libprotoc-dev: zero-byte-file-in-doc-directory diff --git a/debian/libprotoc32.install b/debian/libprotoc32.install new file mode 100644 index 0000000000000..a28013348f3fe --- /dev/null +++ b/debian/libprotoc32.install @@ -0,0 +1 @@ +usr/lib/*/libprotoc*.so.* diff --git a/debian/libprotoc32.lintian-overrides b/debian/libprotoc32.lintian-overrides new file mode 100644 index 0000000000000..19933fd80ca89 --- /dev/null +++ b/debian/libprotoc32.lintian-overrides @@ -0,0 +1,4 @@ +libprotoc32: copyright-without-copyright-notice +libprotoc32: initial-upload-closes-no-bugs +libprotoc32: package-name-doesnt-match-sonames +libprotoc32: zero-byte-file-in-doc-directory diff --git a/debian/protobuf-compiler.install b/debian/protobuf-compiler.install new file mode 100644 index 0000000000000..1df36c612fb7c --- /dev/null +++ b/debian/protobuf-compiler.install @@ -0,0 +1 @@ +usr/bin/* diff --git a/debian/protobuf-compiler.lintian-overrides b/debian/protobuf-compiler.lintian-overrides new file mode 100644 index 0000000000000..6f8cc44579013 --- /dev/null +++ b/debian/protobuf-compiler.lintian-overrides @@ -0,0 +1,4 @@ +protobuf-compiler: copyright-without-copyright-notice +protobuf-compiler: initial-upload-closes-no-bugs +protobuf-compiler: no-manual-page +protobuf-compiler: zero-byte-file-in-doc-directory diff --git a/debian/python3-protobuf.install b/debian/python3-protobuf.install new file mode 100644 index 0000000000000..e3da3e75536a9 --- /dev/null +++ b/debian/python3-protobuf.install @@ -0,0 +1 @@ +usr/lib/python*/*-packages/* diff --git a/debian/python3-protobuf.lintian-overrides b/debian/python3-protobuf.lintian-overrides new file mode 100644 index 0000000000000..83767c0cd5bcc --- /dev/null +++ b/debian/python3-protobuf.lintian-overrides @@ -0,0 +1,4 @@ +python3-protobuf: copyright-without-copyright-notice +python3-protobuf: initial-upload-closes-no-bugs +python3-protobuf: shared-library-lacks-prerequisites +python3-protobuf: zero-byte-file-in-doc-directory diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000000..0f8f2f8f85adc --- /dev/null +++ b/debian/rules @@ -0,0 +1,66 @@ +#!/usr/bin/make -f + +SHELL := /bin/bash + +PYTHON3_PROTOBUF_VERSION = 100:4.21.6-1 + +override_dh_autoreconf: + +override_dh_auto_configure: + pushd src && \ + cmake \ + ../cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -Dprotobuf_BUILD_LIBPROTOC=ON \ + -Dprotobuf_BUILD_PROTOC_BINARIES=ON \ + -Dprotobuf_BUILD_SHARED_LIBS=ON \ + -Dprotobuf_BUILD_TESTS=OFF && \ + popd + +override_dh_auto_build: + pushd src && \ + cmake \ + --build . \ + --parallel 10 \ + --config Release && \ + popd + mkdir -p src/.libs + pushd src/.libs && \ + ln -fs ../*.so* . && \ + popd + pushd python && \ + python3 setup.py build \ + --cpp_implementation && \ + popd + +override_dh_auto_install: + pushd src && \ + export DESTDIR=../debian/tmp && \ + cmake \ + --install . && \ + popd + pushd python && \ + python3 setup.py install \ + --cpp_implementation \ + --no-compile \ + --install-layout=deb \ + --root=../debian/tmp && \ + popd + find debian/tmp/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \; + fdupes -qnrps debian/tmp/usr/lib/python*/*-packages + +override_dh_install: + dh_install + rm -rf debian/libprotobuf-dev/usr/include/google/protobuf/compiler + +override_dh_gencontrol: + dh_gencontrol + dh_gencontrol -ppython3-protobuf -- -v$(PYTHON3_PROTOBUF_VERSION) + +override_dh_auto_test: + +override_dh_auto_clean: + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000000000..163aaf8d82b6c --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 0000000000000..e3178ff6c4d8b --- /dev/null +++ b/debian/source/lintian-overrides @@ -0,0 +1,6 @@ +protobuf source: configure-generated-file-in-source +protobuf source: dependency-is-not-multi-archified +protobuf source: no-debian-changes +protobuf source: not-binnmuable-any-depends-any +protobuf source: python3-depends-but-no-python3-helper +protobuf source: weak-library-dev-dependency diff --git a/protobuf.spec b/protobuf.spec new file mode 100644 index 0000000000000..99bb7e7e4645c --- /dev/null +++ b/protobuf.spec @@ -0,0 +1,277 @@ +%global debug_package %{nil} + +Name: protobuf +Epoch: 100 +Version: 3.21.6 +Release: 1%{?dist} +Summary: Protocol Buffers - Google's data interchange format +License: BSD-3-Clause +URL: https://github.com/protocolbuffers/protobuf/tags +Source0: %{name}_%{version}.orig.tar.gz +BuildRequires: cmake +BuildRequires: fdupes +BuildRequires: gcc-c++ +BuildRequires: make +BuildRequires: python-rpm-macros +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: zlib-devel + +%description +Protocol Buffers are a way of encoding structured data in an efficient yet +extensible format. Google uses Protocol Buffers for almost all of its internal +RPC protocols and file formats. + +%prep +%autosetup -T -c -n %{name}_%{version}-%{release} +tar -zx -f %{S:0} --strip-components=1 -C . + +%build +pushd src && \ + cmake \ + ../cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -Dprotobuf_BUILD_LIBPROTOC=ON \ + -Dprotobuf_BUILD_PROTOC_BINARIES=ON \ + -Dprotobuf_BUILD_SHARED_LIBS=ON \ + -Dprotobuf_BUILD_TESTS=OFF && \ +popd +pushd src && \ + cmake \ + --build . \ + --parallel 10 \ + --config Release && \ +popd +mkdir -p src/.libs +pushd src/.libs && \ + ln -fs ../*.so* . && \ +popd +pushd python && \ + python3 setup.py build \ + --cpp_implementation && \ +popd + +%install +pushd src && \ + export DESTDIR=%{buildroot} && \ + cmake \ + --install . && \ +popd +pushd python && \ + python3 setup.py install \ + --cpp_implementation \ + --no-compile \ + --root=%{buildroot} && \ +popd +find %{buildroot}%{python3_sitearch} -type f -name '*.pyc' -exec rm -rf {} \; +fdupes -qnrps %{buildroot}%{python3_sitearch} + +%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150000 +%package -n libprotobuf3_21_6_0 +Summary: Protocol Buffers - Google's data interchange format + +%description -n libprotobuf3_21_6_0 +Protocol Buffers are a way of encoding structured data in an efficient +yet extensible format. Google uses Protocol Buffers for almost all of +its internal RPC protocols and file formats. + +%package -n libprotoc3_21_6_0 +Summary: Protocol Buffers - Google's data interchange format + +%description -n libprotoc3_21_6_0 +Protocol Buffers are a way of encoding structured data in an efficient +yet extensible format. Google uses Protocol Buffers for almost all of +its internal RPC protocols and file formats. + +%package -n libprotobuf-lite3_21_6_0 +Summary: Protocol Buffers - Google's data interchange format + +%description -n libprotobuf-lite3_21_6_0 +Protocol Buffers are a way of encoding structured data in an efficient +yet extensible format. Google uses Protocol Buffers for almost all of +its internal RPC protocols and file formats. + +%package -n protobuf-devel +Summary: Header files, libraries and development documentation for %{name} +Requires: gcc-c++ +Requires: libprotobuf-lite3_21_6_0 = %{epoch}:%{version}-%{release} +Requires: libprotobuf3_21_6_0 = %{epoch}:%{version}-%{release} +Requires: pkgconfig(zlib) +Provides: libprotobuf-devel = %{epoch}:%{version}-%{release} +Conflicts: protobuf2-devel + +%description -n protobuf-devel +Protocol Buffers are a way of encoding structured data in an efficient yet +extensible format. Google uses Protocol Buffers for almost all of its internal +RPC protocols and file formats. + +%if 0%{?suse_version} > 1500 +%package -n python%{python3_version_nodots}-protobuf +Epoch: 100 +Version: 4.21.6 +Release: 1%{?dist} +Summary: Python3 Bindings for Google Protocol Buffers +Requires: python3 +Requires: python3-six >= 1.9 +Provides: python3-protobuf = %{epoch}:%{version}-%{release} +Provides: python3dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(protobuf) = %{epoch}:%{version}-%{release} + +%description -n python%{python3_version_nodots}-protobuf +This package contains the Python bindings for Google Protocol Buffers. +%endif + +%if 0%{?sle_version} > 150000 +%package -n python3-protobuf +Epoch: 100 +Version: 4.21.6 +Release: 1%{?dist} +Summary: Python3 Bindings for Google Protocol Buffers +Requires: python3 +Requires: python3-six >= 1.9 +Provides: python3-protobuf = %{epoch}:%{version}-%{release} +Provides: python3dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(protobuf) = %{epoch}:%{version}-%{release} + +%description -n python3-protobuf +This package contains the Python bindings for Google Protocol Buffers. +%endif + +%post -n libprotobuf3_21_6_0 -p /sbin/ldconfig +%postun -n libprotobuf3_21_6_0 -p /sbin/ldconfig +%post -n libprotoc3_21_6_0 -p /sbin/ldconfig +%postun -n libprotoc3_21_6_0 -p /sbin/ldconfig +%post -n libprotobuf-lite3_21_6_0 -p /sbin/ldconfig +%postun -n libprotobuf-lite3_21_6_0 -p /sbin/ldconfig + +%files -n libprotobuf3_21_6_0 +%license LICENSE +%{_libdir}/libprotobuf.so.* + +%files -n libprotoc3_21_6_0 +%{_libdir}/libprotoc.so.* + +%files -n libprotobuf-lite3_21_6_0 +%{_libdir}/libprotobuf-lite.so.* + +%files -n protobuf-devel +%dir %{_includedir}/google +%dir %{_libdir}/cmake +%dir %{_libdir}/cmake/protobuf +%{_bindir}/* +%{_includedir}/google/protobuf/ +%{_libdir}/cmake/protobuf/*.cmake +%{_libdir}/libprotobuf-lite.so +%{_libdir}/libprotobuf.so +%{_libdir}/libprotoc.so +%{_libdir}/pkgconfig/protobuf-lite.pc +%{_libdir}/pkgconfig/protobuf.pc + +%if 0%{?suse_version} > 1500 +%files -n python%{python3_version_nodots}-protobuf +%license LICENSE +%{python3_sitearch}/* +%endif + +%if 0%{?sle_version} > 150000 +%files -n python3-protobuf +%license LICENSE +%{python3_sitearch}/* +%endif +%endif + +%if !(0%{?suse_version} > 1500) && !(0%{?sle_version} > 150000) +%package -n protobuf-compiler +Summary: Protocol Buffers compiler +Requires: protobuf = %{epoch}:%{version}-%{release} + +%description -n protobuf-compiler +This package contains Protocol Buffers compiler for all programming +languages + +%package -n protobuf-devel +Summary: Protocol Buffers C++ headers and libraries +Requires: protobuf = %{epoch}:%{version}-%{release} +Requires: protobuf-compiler = %{epoch}:%{version}-%{release} +Requires: zlib-devel +Requires: pkgconfig + +%description -n protobuf-devel +This package contains Protocol Buffers compiler for all languages and +C++ headers and libraries + +%package -n protobuf-lite +Summary: Protocol Buffers LITE_RUNTIME libraries + +%description -n protobuf-lite +Protocol Buffers built with optimize_for = LITE_RUNTIME. + +%package -n protobuf-lite-devel +Summary: Protocol Buffers LITE_RUNTIME development libraries +Requires: protobuf-devel = %{epoch}:%{version}-%{release} +Requires: protobuf-lite = %{epoch}:%{version}-%{release} + +%description -n protobuf-lite-devel +This package contains development libraries built with optimize_for = +LITE_RUNTIME. + +%package -n python3-protobuf +Epoch: 100 +Version: 4.21.6 +Release: 1%{?dist} +Summary: Python 3 bindings for Google Protocol Buffers +Requires: python3-six >= 1.9 +Provides: python3-protobuf = %{epoch}:%{version}-%{release} +Provides: python3dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(protobuf) = %{epoch}:%{version}-%{release} + +%description -n python3-protobuf +This package contains Python 3 libraries for Google Protocol Buffers + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig +%post -n protobuf-compiler -p /sbin/ldconfig +%postun -n protobuf-compiler -p /sbin/ldconfig +%post -n protobuf-lite -p /sbin/ldconfig +%postun -n protobuf-lite -p /sbin/ldconfig + +%files +%license LICENSE +%{_libdir}/libprotobuf.so.* + +%files -n protobuf-compiler +%{_bindir}/* +%{_libdir}/libprotoc.so.* + +%files -n protobuf-devel +%dir %{_includedir}/google +%dir %{_libdir}/cmake +%dir %{_libdir}/cmake/protobuf +%{_includedir}/google/protobuf/ +%{_libdir}/cmake/protobuf/*.cmake +%{_libdir}/libprotobuf.so +%{_libdir}/libprotoc.so +%{_libdir}/pkgconfig/protobuf.pc + +%files -n protobuf-lite +%{_libdir}/libprotobuf-lite.so.* + +%files -n protobuf-lite-devel +%{_libdir}/libprotobuf-lite.so +%{_libdir}/pkgconfig/protobuf-lite.pc + +%files -n python3-protobuf +%{python3_sitearch}/* +%endif + +%changelog diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc index 162531226e5f8..57a7007478585 100644 --- a/python/google/protobuf/pyext/descriptor.cc +++ b/python/google/protobuf/pyext/descriptor.cc @@ -58,6 +58,43 @@ : 0) \ : PyBytes_AsStringAndSize(ob, (charpp), (sizep))) +#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION) +static inline PyCodeObject* PyFrame_GetCode(PyFrameObject *frame) +{ + Py_INCREF(frame->f_code); + return frame->f_code; +} + +static inline PyFrameObject* PyFrame_GetBack(PyFrameObject *frame) +{ + Py_XINCREF(frame->f_back); + return frame->f_back; +} +#endif + +#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION) +static inline PyObject* PyFrame_GetLocals(PyFrameObject *frame) +{ +#if PY_VERSION_HEX >= 0x030400B1 + if (PyFrame_FastToLocalsWithError(frame) < 0) { + return NULL; + } +#else + PyFrame_FastToLocals(frame); +#endif + Py_INCREF(frame->f_locals); + return frame->f_locals; +} +#endif + +#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION) +static inline PyObject* PyFrame_GetGlobals(PyFrameObject *frame) +{ + Py_INCREF(frame->f_globals); + return frame->f_globals; +} +#endif + namespace google { namespace protobuf { namespace python { @@ -99,43 +136,63 @@ bool _CalledFromGeneratedFile(int stacklevel) { if (frame == nullptr) { return false; } + Py_INCREF(frame); while (stacklevel-- > 0) { - frame = frame->f_back; + PyFrameObject* next_frame = PyFrame_GetBack(frame); + Py_DECREF(frame); + frame = next_frame; if (frame == nullptr) { return false; } } - if (frame->f_code->co_filename == nullptr) { + PyCodeObject* frame_code = PyFrame_GetCode(frame); + if (frame_code->co_filename == nullptr) { + Py_DECREF(frame_code); + Py_DECREF(frame); return false; } char* filename; Py_ssize_t filename_size; - if (PyString_AsStringAndSize(frame->f_code->co_filename, + if (PyString_AsStringAndSize(frame_code->co_filename, &filename, &filename_size) < 0) { // filename is not a string. + Py_DECREF(frame_code); + Py_DECREF(frame); PyErr_Clear(); return false; } + Py_DECREF(frame_code); if ((filename_size < 3) || (strcmp(&filename[filename_size - 3], ".py") != 0)) { // Cython's stack does not have .py file name and is not at global module // scope. + Py_DECREF(frame); return true; } if (filename_size < 7) { // filename is too short. + Py_DECREF(frame); return false; } if (strcmp(&filename[filename_size - 7], "_pb2.py") != 0) { // Filename is not ending with _pb2. + Py_DECREF(frame); return false; } - if (frame->f_globals != frame->f_locals) { + PyObject* frame_globals = PyFrame_GetGlobals(frame); + PyObject* frame_locals = PyFrame_GetLocals(frame); + if (frame_globals != frame_locals) { // Not at global module scope + Py_DECREF(frame_globals); + Py_XDECREF(frame_locals); + Py_DECREF(frame); return false; } + Py_DECREF(frame_globals); + Py_XDECREF(frame_locals); + Py_DECREF(frame); #endif return true; } diff --git a/src/Makefile.am b/src/Makefile.am index 3a6ecdc42ede9..f1f6f340db63d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 32:6:0 +PROTOBUF_VERSION = 3.21.6 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison @@ -188,7 +188,7 @@ nobase_include_HEADERS = \ lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS) $(LIBATOMIC_LIBS) -libprotobuf_lite_la_LDFLAGS = -version-info $(PROTOBUF_VERSION) -export-dynamic -no-undefined +libprotobuf_lite_la_LDFLAGS = -release $(PROTOBUF_VERSION) -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotobuf_lite_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf-lite.map EXTRA_libprotobuf_lite_la_DEPENDENCIES = libprotobuf-lite.map @@ -235,7 +235,7 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/wire_format_lite.cc libprotobuf_la_LIBADD = $(PTHREAD_LIBS) $(LIBATOMIC_LIBS) -libprotobuf_la_LDFLAGS = -version-info $(PROTOBUF_VERSION) -export-dynamic -no-undefined +libprotobuf_la_LDFLAGS = -release $(PROTOBUF_VERSION) -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotobuf_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf.map EXTRA_libprotobuf_la_DEPENDENCIES = libprotobuf.map @@ -320,7 +320,7 @@ libprotobuf_la_SOURCES = \ nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES) libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la -libprotoc_la_LDFLAGS = -version-info $(PROTOBUF_VERSION) -export-dynamic -no-undefined +libprotoc_la_LDFLAGS = -release $(PROTOBUF_VERSION) -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotoc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotoc.map EXTRA_libprotoc_la_DEPENDENCIES = libprotoc.map diff --git a/src/libprotobuf-lite.map b/src/libprotobuf-lite.map index 391554669481a..a1853ca6cbf23 100644 --- a/src/libprotobuf-lite.map +++ b/src/libprotobuf-lite.map @@ -3,6 +3,8 @@ extern "C++" { *google*; }; + scc_info_*; + descriptor_table_*; local: *; diff --git a/src/libprotobuf.map b/src/libprotobuf.map index 391554669481a..a1853ca6cbf23 100644 --- a/src/libprotobuf.map +++ b/src/libprotobuf.map @@ -3,6 +3,8 @@ extern "C++" { *google*; }; + scc_info_*; + descriptor_table_*; local: *; diff --git a/src/libprotoc.map b/src/libprotoc.map index 391554669481a..a1853ca6cbf23 100644 --- a/src/libprotoc.map +++ b/src/libprotoc.map @@ -3,6 +3,8 @@ extern "C++" { *google*; }; + scc_info_*; + descriptor_table_*; local: *;