Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add protobuf 3.12.3 #2037

Merged
merged 41 commits into from
Nov 16, 2020
Merged

Conversation

uilianries
Copy link
Member

@uilianries uilianries commented Jun 24, 2020

Specify library name and version: protobuf/3.12.3

closes #2031

Protobuf it's a special case:

All targets are lower-case:
protobuf::libprotobuf, protobuf::libprotobuf-lite, protobuf::libprotoc, protobuf::protoc

However, variables and the cmake find file are CamelCase:

FindProtobuf.cmake
Protobuf_LIBRARY
Protobuf_PROTOC_LIBRARY
...

@danimtb What's the magic for using Protobuf for the file name, but protobuf as target namespace?

/cc @madebr

  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the
    conan-center hook activated.

@uilianries uilianries requested review from SSE4 and danimtb June 24, 2020 22:38
@madebr
Copy link
Contributor

madebr commented Jun 24, 2020

The problem with enabling protobuflite is that protoc is not built.
I think the following is required:

  • build both protobuf and protobuflite, + protoc
  • change the patches to only patch the installed cmake scripts
  • in package_id, remove the lite option
  • in package_info, only add the lite or full library to cpp_info.libs (or the corresponding component)

@conan-center-bot
Copy link
Collaborator

Some configurations of 'protobuf/3.9.1' failed in build 1 (1ebf261f9b1ae5e9e1a0520c6b1618b28fd6d4be):

  • Linux x86_64, Release, gcc 5, libstdc++ . Options: protobuf:shared-True
    • Hooks errors detected:
      • [HOOK - conan-center.py] pre_export(): ERROR: [RECIPE FOLDER SIZE (KB-H009)] The size of your recipe folder (267.583984375 KB) is larger than the maximum allowed size (256KB). (https://github.com/conan-io/conan-center-index/wiki/Error-Knowledge-Base#KB-H009)
    • Log download
    • Log error Download
    • Profile
  • Access to all the logs

@uilianries
Copy link
Member Author

@madebr

* build both protobuf and protobuflite, + protoc

Why? if options.lite is enable, it means the user only wants it.

* change the patches to only patch the installed cmake scripts

Do you mean changing only cmake/install.cmake ? Why?

* in `package_id`, remove the `lite` option

I didn't get, lite generates a different binary package.

@uilianries
Copy link
Member Author

[HOOK - conan-center.py] pre_export(): ERROR: [RECIPE FOLDER SIZE (KB-H009)] The size of your recipe folder (267.583984375 KB) is larger than the maximum allowed size (256KB)

Seems like we need to stop patching and finding a definitive alternative.

@madebr
Copy link
Contributor

madebr commented Jun 24, 2020

@madebr

* build both protobuf and protobuflite, + protoc

Why? if options.lite is enable, it means the user only wants it.

Because protoc won't be available. Which might be required.
If we only add lite in package_info to the libs, then the full protobuf library won't be added to the generated cmake/pkg_config/... scripts.

Do you mean changing only cmake/install.cmake ? Why?

I meant we won't have to patch the files to disable building protobuf/protoc when protobuflite is enabled.
Smaller patches makes easier maintenance.

* in `package_id`, remove the `lite` option

I didn't get, lite generates a different binary package.

The built package will contain both libprobotuf.so and libprotobuflite.so, but the cpp_info.libs will only contain one (or both) of them.

This is just a proposal.
Because I think an issue will be opened soon by someone about protoc not being available when lite is enabled.

@madebr
Copy link
Contributor

madebr commented Jun 24, 2020

[HOOK - conan-center.py] pre_export(): ERROR: [RECIPE FOLDER SIZE (KB-H009)] The size of your recipe folder (267.583984375 KB) is larger than the maximum allowed size (256KB)

Seems like we need to stop patching and finding a definitive alternative.

By applying my proposal, then protoc will be available always.
Then we can get away with the generated .pb.cc files in test_package, which are relatively huge.

@uilianries
Copy link
Member Author

@madebr thanks for the details. Indeed your idea sounds correct, as we are using all together and build context can help for other cases, the patches are no longer required. I'll update following your idea, thanks again

@conan-center-bot
Copy link
Collaborator

Some configurations of 'protobuf/3.9.1' failed in build 2 (1ebf261f9b1ae5e9e1a0520c6b1618b28fd6d4be):

  • Linux x86_64, Release, gcc 5, libstdc++ . Options: protobuf:shared-True
    • Hooks errors detected:
      • [HOOK - conan-center.py] pre_export(): ERROR: [RECIPE FOLDER SIZE (KB-H009)] The size of your recipe folder (267.583984375 KB) is larger than the maximum allowed size (256KB). (https://github.com/conan-io/conan-center-index/wiki/Error-Knowledge-Base#KB-H009)
    • Log download
    • Log error Download
    • Profile
  • Access to all the logs

@SSE4 SSE4 removed their request for review July 7, 2020 18:18
@SSE4
Copy link
Contributor

SSE4 commented Jul 7, 2020

@uilianries please fix conflicts, fix the build, and then re-request the review(s)

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@Croydon
Copy link
Contributor

Croydon commented Jul 29, 2020

Do we agree that it is completely acceptable to have libprotobuf, libprotobuf-lite and protoc all in one package?

I don't see why not as long as you don't link against the entire package (which is always bad I guess) there should be no danger of linking against libprotobuf and libprotobuf-lite at the same time

We could also change this behaviour only for protobuf > 3.12 to not break anyone

@Croydon
Copy link
Contributor

Croydon commented Jul 29, 2020

I think I got pretty far, but run into protocolbuffers/protobuf#7759

@madebr
Copy link
Contributor

madebr commented Jul 29, 2020

@Croydon Makes sense to me.
Does protobuf currently build protoc when using protobuf-lite?
I gues you will build all variants, but will only add specific libraries in package_info and will handle this in package_id?

@uilianries
Copy link
Member Author

@uilianries please fix conflicts, fix the build, and then re-request the review(s)

@madebr it requires the new components feature first, custom cmake filename.

@sourcedelica
Copy link
Contributor

sourcedelica commented Jul 29, 2020

I ran into a problem with the 3.11.4 recipe that I could not use protobuf_generate_cpp after find_package(Protobuf). The test_package recipe adds protoc to the path explicitly. protobuf_generate_cpp should be getting protoc from CMake targets instead.

@Croydon
Copy link
Contributor

Croydon commented Jul 29, 2020

@sourcedelica I noticed this too. We currently explicitly patching this, as we did not had the protobuf::protoc target before. I'm seeing what I can do

@Croydon
Copy link
Contributor

Croydon commented Jul 29, 2020

lib/cmake/protobuf-module.cmake is using serveral calls like the following

get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
  IMPORTED_LOCATION_RELEASE)

which each time causes an error like

 INTERFACE_LIBRARY targets may only have whitelisted properties.  The
  property "IMPORTED_LOCATION_RELEASE" is not allowed.

I'm not sure if we can provide these properties somehow or If I need to patch this file heavily to get the values otherwise?

@Croydon
Copy link
Contributor

Croydon commented Jul 29, 2020

Does protobuf currently build protoc when using protobuf-lite?
I gues you will build all variants, but will only add specific libraries in package_info and will handle this in package_id?

Without patching it seems to build everything by default in one go.

My current idea is to provide a protobuf::protobuf target which requires the components libprotobuf, libproto and protoc and otherwise you have all the individual components including protobuf::libprotobuf-lite available

@Croydon
Copy link
Contributor

Croydon commented Jul 30, 2020

I spend quite some time with protobuf/protoc yesterday and basically went through hell and back.

I still encounter some problems that CMake can't find the targets despite Conan generating exactly those targets...

@Croydon
Copy link
Contributor

Croydon commented Jul 30, 2020

I think we should split this.

Add the new version in a new PR and leave adding components and refactoring here

@madebr
Copy link
Contributor

madebr commented Jul 30, 2020

@Croydon
You can always post your intermediate recipe + (failed) tests so we can take a look.

@danimtb
Copy link
Member

danimtb commented Jul 31, 2020

I agree with @Croydon. The case of this library is quite singular and getting components right might take some more tries. I'd suggest adding the new version with the minimal require changes to the recipe and patches and then resume the work here with components and cross-building

@conan-center-bot
Copy link
Collaborator

Git error in build 3:

Command "git merge b85bb1348b4f6efad93a45ffa8a3e1eec5b4d14f" returned status code 1:
stdout: Removing recipes/spdlog/all/patches/0003-header-only.patch
Removing recipes/spdlog/all/patches/0002-header-only.patch
Removing recipes/spdlog/all/patches/0001-header-only.patch
Auto-merging recipes/protobuf/all/conanfile.py
CONFLICT (content): Merge conflict in recipes/protobuf/all/conanfile.py
Removing recipes/msys2/all/LICENSE.md
Removing recipes/libxml2/all/patches/0002-fix-install-mingw.patch
Removing recipes/libxml2/all/patches/0001-fix-install-mingw.patch
Removing recipes/cmake/3.x.x/CMakeLists.txt
Removing recipes/b2/all/conanfile.py
Automatic merge failed; fix conflicts and then commit the result.

stderr: 

* fix CMake file names to be lowercase
* replace huge version dependent patches which a few replace_in_file which are much easier to maintain
* protoc is now always available; removing all non-protoc ways in the test_package
@conan-center-bot
Copy link
Collaborator

Recipe syntax error in build 39:

WARN: Remotes registry file missing, creating default one in /home/conan/w/cci_PR-2037/39/dc52ec45-2d24-4779-a9c7-92d7a35e6f66/.conan/remotes.json
ERROR: Error loading conanfile at '/home/conan/w/cci_PR-2037/recipes/protobuf/all/conanfile.py': Unable to load conanfile in /home/conan/w/cci_PR-2037/recipes/protobuf/all/conanfile.py
  File "/opt/pyenv/versions/3.7.5/lib/python3.7/site-packages/conans/model/ref.py", line 197, in loads
    name, version, user, channel, revision = get_reference_fields(text)
  File "/opt/pyenv/versions/3.7.5/lib/python3.7/site-packages/conans/model/ref.py", line 66, in get_reference_fields
    el1, el2 = _split_pair(arg_reference, "/") or (arg_reference, None)
  File "/opt/pyenv/versions/3.7.5/lib/python3.7/site-packages/conans/model/ref.py", line 18, in _split_pair
    raise ConanException("The reference has too many '{}'".format(split_char))
conans.errors.ConanException: The reference has too many '/'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/pyenv/versions/3.7.5/lib/python3.7/site-packages/conans/client/loader.py", line 382, in _parse_conanfile
    loaded = imp.load_source(module_id, conan_file_path)
  File "/opt/pyenv/versions/3.7.5/lib/python3.7/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 860, in get_code
  File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/conan/w/cci_PR-2037/recipes/protobuf/all/conanfile.py", line 140
    os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path", "protobuf-targets.cmake"))
                                                                                ^
SyntaxError: invalid syntax


@conan-center-bot
Copy link
Collaborator

All green in build 40 (7624dc6485fb687fd421aace861212e9ab00a870)! 😊

@Croydon
Copy link
Contributor

Croydon commented Nov 12, 2020

@madebr @prince-chrismc @SpaceIm @SSE4 (& co): Please review (again)😄

@prince-chrismc
Copy link
Contributor

No more changes, let's merge and save them for the next PR 🚀 I know a lot of us are dying to get this in CCI

@Croydon
Copy link
Contributor

Croydon commented Nov 12, 2020

Critical things should always be fixed, but I agree, no more nit-picking in this one please. I will also very soon open a PR for version 3.13.0 anyway (if not someone else will be faster) 😄

Copy link
Contributor

@prince-chrismc prince-chrismc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only think is we test one of the module package names, since they are different that would be a future add (if thats even possible)

recipes/protobuf/all/conanfile.py Show resolved Hide resolved
tools.replace_in_file(
os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in"),
"""COMMAND protobuf::protoc
ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_protobuf_include_path} ${_abs_file}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Croydon
Has this problem been resolved?

os.path.join(self._source_subfolder, "cmake", "protobuf-module.cmake.in"),
'# Version info variable',
'endif()',
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Croydon
Has this problem been resolved?

Comment on lines +209 to +214
self.cpp_info.components["libprotobuf-lite"].builddirs = [self._cmake_install_base_path]
self.cpp_info.components["libprotobuf-lite"].build_modules.extend([
os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"),
os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"),
os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"),
])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct to only include these files when lite=True?
Doesn't the hooks complain when lite=False, because it will find .cmake files, not added as a build module?

Copy link
Contributor

@Croydon Croydon Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also included for the libprotobuf component

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks, I see.
Now I'm curious whether these modulse will be included once or twice.

@Croydon
Copy link
Contributor

Croydon commented Nov 12, 2020

GitHub behaves sometimes strange for me in the last few days.

@madebr I can't directly response to your two Has this problem been resolved? questions. I'm not sure what you mean exactly by them.

In some cases the location of Protoc might still fail, but there is another PR open for it, we shouldn't block this one further since it works in many, maybe most, cases

The other line replacement is just to effectively disable a larger part of the CMake file without having version specific patches which are much harder to maintain

@madebr
Copy link
Contributor

madebr commented Nov 12, 2020

@madebr I can't directly response to your two Has this problem been resolved? questions. I'm not sure what you mean exactly by them.

They are responses on remarks by another user.
See https://github.com/conan-io/conan-center-index/pull/2037/files
(and search for Has this problem been resolved)

@prince-chrismc
Copy link
Contributor

I can't directly response to your two Has this problem been resolved? questions. I'm not sure what you mean exactly by them.

I believe the issues are hidden by then fold mechanics, if you use the "files changes" tab they still appear (and you can reply)

I am pretty sure they are.. but the diff a few lines down did not mark them as outdated

"# CONAN PATCH include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")"
)
if tools.Version(self.version) < "3.12.0":
tools.replace_in_file(
Copy link
Contributor

@madebr madebr Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Croydon
I won't object here, but why did you use tools.replace_in_file here, instead of a patch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They would be more version specific and are much harder to maintain then those few replacements

@dheater
Copy link
Contributor

dheater commented Nov 13, 2020

I'm testing this in my project by following test_package as an example but getting a failure in the cmake .. step. It's reproducible from the test_package. I do mkdir build; cd build; conan install ..; cmake .. and I get:

CMake Error at CMakeLists.txt:7 (find_package):
  Could not find a package configuration file provided by "protobuf" with any
  of the following names:

    protobufConfig.cmake
    protobuf-config.cmake

  Add the installation prefix of "protobuf" to CMAKE_PREFIX_PATH or set
  "protobuf_DIR" to a directory containing one of the above files.  If
  "protobuf" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!

This is on Ubuntu 20.04 with cmake --version 3.16.3
BTW, uppercase Protobuf is no better.

@Croydon
Copy link
Contributor

Croydon commented Nov 13, 2020

@dheater We need much more information to understand what you are doing. Conan version, what Conan generators you used, the CMake code...

@dheater
Copy link
Contributor

dheater commented Nov 13, 2020

@dheater We need much more information to understand what you are doing. Conan version, what Conan generators you used, the CMake code...

Conan version is 1.31.2.
I'm just using the code from the test_package folder in this recipe/branch.

@Croydon
Copy link
Contributor

Croydon commented Nov 13, 2020

If you are just installing the protobuf recipe and then just execute a cmake build with the CMakeLists.txt from the test_package then you didn't run any Conan generators which produce the find and config CMake files.

@dheater
Copy link
Contributor

dheater commented Nov 13, 2020

If you are just installing the protobuf recipe and then just execute a cmake build with the CMakeLists.txt from the test_package then you didn't run any Conan generators which produce the find and config CMake files.

Ah. I see. The conanfile.py file in test_package does not have requires = protobuf/<version> entry. Adding that gets cmake to work (still fails to build). So the test_package is not really a suitable example of how to use the package.

Thanks!

@madebr
Copy link
Contributor

madebr commented Nov 13, 2020

@dheater
Test packages can be run with the following command:

conan test test_package protobuf/3.12.3@

@Croydon
Copy link
Contributor

Croydon commented Nov 13, 2020

@jgsogo @danimtb Please review 😄

Copy link
Member

@danimtb danimtb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot to everyone for the hard work in this PR. Let's move it forward!

@conan-center-bot conan-center-bot merged commit c5c1cc0 into conan-io:master Nov 16, 2020
del self.options.fPIC

compiler_version = Version(self.settings.compiler.version.value)
if compiler_version < "14":
raise ConanInvalidConfiguration("On Windows Protobuf can only be built with "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this piece of code be executed on Linux?

Because I saw this on Linux right now :-(

$ conan create . protobuf/3.12.4@ -o protobuf:shared=True
Exporting package recipe
protobuf/3.12.4 exports: File 'conandata.yml' found. Exporting it...
protobuf/3.12.4 exports: Copied 1 '.yml' file: conandata.yml
protobuf/3.12.4 exports_sources: Copied 1 '.txt' file: CMakeLists.txt
protobuf/3.12.4 exports_sources: Copied 2 '.patch' files: upstream-issue-7567-no-export-template-define.patch, upstream-pr-7761-cmake-regex-fix.patch
protobuf/3.12.4: A new conanfile.py version was exported
protobuf/3.12.4: Folder: /home/pfarre/.conan/data/protobuf/3.12.4/_/_/export
protobuf/3.12.4: Exported revision: fcab376e471eb6443f1f3fd012065226
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=9
os=Linux
os_build=Linux
[options]
protobuf:shared=True
[build_requires]
[env]

ERROR: protobuf/3.12.4: Invalid configuration: On Windows Protobuf can only be built with Visual Studio 2015 or higher.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that's a bug.
You can't build a shared protobuf using a current compiler.
(or it's a feature and you'll have to wait until 2024 when gcc 14 gets released 😄 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[request] protobuf/3.12.3