Skip to content

Commit

Permalink
Retry gRPC CMake configuration if it fails
Browse files Browse the repository at this point in the history
The gRPC CMake configuration step can fail to due to a failure when downloading third party archives.  These failures are expected, and the user is instructed to retry.  So, if configuration fails, retry it

Also set the `gRPC_DOWNLOAD_ARCHIVES` CMake flag to `False`, to avoid downloading these unnecessary archives in the first place, in versions of gRPC that understand the flag
  • Loading branch information
js-nano committed Jun 12, 2024
1 parent 91626c4 commit 0ac619c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions recipes/grpc/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.errors import ConanInvalidConfiguration, ConanException
from conan.tools.apple import is_apple_os
from conan.tools.build import cross_building, valid_min_cppstd, check_min_cppstd
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain, CMakeDeps
Expand Down Expand Up @@ -174,6 +174,11 @@ def generate(self):
tc.cache_variables["gRPC_BUILD_GRPC_PYTHON_PLUGIN"] = self.options.python_plugin
tc.cache_variables["gRPC_BUILD_GRPC_RUBY_PLUGIN"] = self.options.ruby_plugin

# Never download unnecessary archives
# (supported in gRPC >= 1.62.0)
tc.cache_variables["gRPC_DOWNLOAD_ARCHIVES"] = False


# Consumed targets (abseil) via interface target_compiler_feature can propagate newer standards
if not valid_min_cppstd(self, self._cxxstd_required):
tc.cache_variables["CMAKE_CXX_STANDARD"] = self._cxxstd_required
Expand Down Expand Up @@ -207,7 +212,13 @@ def _patch_sources(self):
def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()

# The CMake configure step can fail spuriously, but succeed on a retry
try:
cmake.configure()
except ConanException:
cmake.configure()

cmake.build()

def package(self):
Expand Down

0 comments on commit 0ac619c

Please sign in to comment.