Skip to content

Commit

Permalink
(#20091) grpc-proto: use host_version for protobuf in build requireme…
Browse files Browse the repository at this point in the history
…nts and bump protobuf

* use host_version for protobuf in build requirements and bump protobuf

* fix min conan v2 version
  • Loading branch information
SpaceIm authored Nov 2, 2023
1 parent 305e2b2 commit 23db355
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions recipes/grpc-proto/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import can_run, check_min_cppstd
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import get, collect_libs, copy
from conan.tools.scm import Version

from helpers import parse_proto_libraries

required_conan_version = ">=1.53.0"
required_conan_version = ">=1.60.0 <2.0 || >=2.0.5"


class GRPCProto(ConanFile):
Expand All @@ -33,6 +33,10 @@ class GRPCProto(ConanFile):
}
exports = "helpers.py"

@property
def _is_legacy_one_profile(self):
return not hasattr(self, "settings_build")

def export_sources(self):
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)

Expand All @@ -56,7 +60,7 @@ def layout(self):
def requirements(self):
# protobuf symbols are exposed from generated structures
# https://github.com/conan-io/conan-center-index/pull/16185#issuecomment-1501174215
self.requires("protobuf/3.21.9", transitive_headers=True, transitive_libs=True, run=can_run(self))
self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True)
self.requires("googleapis/cci.20230501")

def validate(self):
Expand All @@ -71,16 +75,16 @@ def validate(self):
)

def build_requirements(self):
if not can_run(self):
self.tool_requires("protobuf/3.21.9")
if not self._is_legacy_one_profile:
self.tool_requires("protobuf/<host_version>")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
if can_run(self):
if self._is_legacy_one_profile:
env = VirtualRunEnv(self)
env.generate(scope="build")
tc = CMakeToolchain(self)
Expand Down

0 comments on commit 23db355

Please sign in to comment.