From 0ac619c39a7e119efdfa3a75546aefee41f4113c Mon Sep 17 00:00:00 2001 From: js-nano <62746467+js-nano@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:32:08 +0000 Subject: [PATCH] Retry gRPC CMake configuration if it fails 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 --- recipes/grpc/all/conanfile.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/recipes/grpc/all/conanfile.py b/recipes/grpc/all/conanfile.py index 1d39ab202a3b0..ee416f1a4550c 100644 --- a/recipes/grpc/all/conanfile.py +++ b/recipes/grpc/all/conanfile.py @@ -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 @@ -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 @@ -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):