1414# limitations under the License.
1515"""Configuring the C++ toolchain on macOS."""
1616
17- load ("@bazel_tools//tools/osx:xcode_configure.bzl" , "run_xcode_locator" )
17+ load (
18+ "@bazel_tools//tools/osx:xcode_configure.bzl" ,
19+ "OSX_EXECUTE_TIMEOUT" ,
20+ "run_xcode_locator" ,
21+ )
1822load (
1923 "@bazel_tools//tools/cpp:lib_cc_configure.bzl" ,
2024 "escape_string" ,
@@ -54,7 +58,7 @@ def _get_escaped_xcode_cxx_inc_directories(repository_ctx, cc, xcode_toolchains)
5458 return include_dirs
5559
5660# TODO: Remove once Xcode 12 is the minimum supported version
57- def _compile_cc_file_single_arch (repository_ctx , src_name , out_name ):
61+ def _compile_cc_file_single_arch (repository_ctx , src_name , out_name , timeout ):
5862 env = repository_ctx .os .environ
5963 xcrun_result = repository_ctx .execute ([
6064 "env" ,
@@ -71,7 +75,7 @@ def _compile_cc_file_single_arch(repository_ctx, src_name, out_name):
7175 "-o" ,
7276 out_name ,
7377 src_name ,
74- ], 60 )
78+ ], timeout )
7579 if (xcrun_result .return_code != 0 ):
7680 error_msg = (
7781 "return code {code}, stderr: {err}, stdout: {out}"
@@ -84,7 +88,7 @@ def _compile_cc_file_single_arch(repository_ctx, src_name, out_name):
8488 "https://github.com/bazelbuild/bazel/issues with the following:\n " +
8589 error_msg )
8690
87- def _compile_cc_file (repository_ctx , src_name , out_name ):
91+ def _compile_cc_file (repository_ctx , src_name , out_name , timeout ):
8892 env = repository_ctx .os .environ
8993 xcrun_result = repository_ctx .execute ([
9094 "env" ,
@@ -107,7 +111,7 @@ def _compile_cc_file(repository_ctx, src_name, out_name):
107111 "-o" ,
108112 out_name ,
109113 src_name ,
110- ], 60 )
114+ ], timeout )
111115
112116 if xcrun_result .return_code == 0 :
113117 xcrun_result = repository_ctx .execute ([
@@ -120,7 +124,7 @@ def _compile_cc_file(repository_ctx, src_name, out_name):
120124 "--sign" ,
121125 "-" ,
122126 out_name ,
123- ], 60 )
127+ ], timeout )
124128 if xcrun_result .return_code != 0 :
125129 error_msg = (
126130 "codesign return code {code}, stderr: {err}, stdout: {out}"
@@ -133,7 +137,7 @@ def _compile_cc_file(repository_ctx, src_name, out_name):
133137 "https://github.com/bazelbuild/bazel/issues with the following:\n " +
134138 error_msg )
135139 else :
136- _compile_cc_file_single_arch (repository_ctx , src_name , out_name )
140+ _compile_cc_file_single_arch (repository_ctx , src_name , out_name , timeout )
137141
138142def configure_osx_toolchain (repository_ctx , cpu_value , overriden_tools ):
139143 """Configure C++ toolchain on macOS.
@@ -157,6 +161,10 @@ def configure_osx_toolchain(repository_ctx, cpu_value, overriden_tools):
157161
158162 env = repository_ctx .os .environ
159163 should_use_xcode = "BAZEL_USE_XCODE_TOOLCHAIN" in env and env ["BAZEL_USE_XCODE_TOOLCHAIN" ] == "1"
164+ if "BAZEL_OSX_EXECUTE_TIMEOUT" in env :
165+ timeout = int (env ["BAZEL_OSX_EXECUTE_TIMEOUT" ])
166+ else :
167+ timeout = OSX_EXECUTE_TIMEOUT
160168 xcode_toolchains = []
161169
162170 # Make the following logic in sync with //tools/cpp:cc_configure.bzl#cc_autoconf_toolchains_impl
@@ -208,11 +216,16 @@ def configure_osx_toolchain(repository_ctx, cpu_value, overriden_tools):
208216 libtool_check_unique_src_path = str (repository_ctx .path (
209217 paths ["@bazel_tools//tools/objc:libtool_check_unique.cc" ],
210218 ))
211- _compile_cc_file (repository_ctx , libtool_check_unique_src_path , "libtool_check_unique" )
219+ _compile_cc_file (
220+ repository_ctx ,
221+ libtool_check_unique_src_path ,
222+ "libtool_check_unique" ,
223+ timeout ,
224+ )
212225 wrapped_clang_src_path = str (repository_ctx .path (
213226 paths ["@bazel_tools//tools/osx/crosstool:wrapped_clang.cc" ],
214227 ))
215- _compile_cc_file (repository_ctx , wrapped_clang_src_path , "wrapped_clang" )
228+ _compile_cc_file (repository_ctx , wrapped_clang_src_path , "wrapped_clang" , timeout )
216229 repository_ctx .symlink ("wrapped_clang" , "wrapped_clang_pp" )
217230
218231 tool_paths = {}
0 commit comments