@@ -204,7 +204,8 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
204204 let src_path = get_boringssl_source_path ( config) ;
205205 let mut boringssl_cmake = cmake:: Config :: new ( src_path) ;
206206
207- if config. env . cmake_toolchain_file . is_some ( ) {
207+ if config. env . cmake_toolchain_file_is_set {
208+ println ! ( "cargo::warning=CMAKE_TOOLCHAIN_FILE var set; won't customize cmake vars" ) ;
208209 return boringssl_cmake;
209210 }
210211
@@ -213,14 +214,18 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
213214 // This is required now because newest BoringSSL requires CMake 3.22 which
214215 // uses the new logic with CMAKE_MSVC_RUNTIME_LIBRARY introduced in CMake 3.15.
215216 // https://github.com/rust-lang/cmake-rs/pull/30#issuecomment-2969758499
216- if config. target_features . iter ( ) . any ( |f| f == "crt-static" ) {
217- boringssl_cmake . define ( "CMAKE_MSVC_RUNTIME_LIBRARY" , " MultiThreaded") ;
217+ let rt = if config. target_features . iter ( ) . any ( |f| f == "crt-static" ) {
218+ " MultiThreaded"
218219 } else {
219- boringssl_cmake. define ( "CMAKE_MSVC_RUNTIME_LIBRARY" , "MultiThreadedDLL" ) ;
220- }
220+ "MultiThreadedDLL"
221+ } ;
222+ boringssl_cmake. define ( "CMAKE_MSVC_RUNTIME_LIBRARY" , rt) ;
221223 }
222224
223225 if config. host == config. target {
226+ if config. env . compiler_external_toolchain . is_some ( ) {
227+ println ! ( "cargo::warning=COMPILER_EXTERNAL_TOOLCHAIN won't be used" ) ;
228+ }
224229 return boringssl_cmake;
225230 }
226231
@@ -253,7 +258,7 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
253258 }
254259
255260 // Add platform-specific parameters for cross-compilation.
256- match & * config. target_os {
261+ let toolchain_file = match & * config. target_os {
257262 "android" => {
258263 // We need ANDROID_NDK_HOME to be set properly.
259264 let android_ndk_home = config
@@ -266,68 +271,44 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
266271 boringssl_cmake. define ( name, value) ;
267272 }
268273 let toolchain_file = android_ndk_home. join ( "build/cmake/android.toolchain.cmake" ) ;
269- let toolchain_file = toolchain_file. to_str ( ) . unwrap ( ) ;
270- eprintln ! ( "android toolchain={toolchain_file}" ) ;
271- boringssl_cmake. define ( "CMAKE_TOOLCHAIN_FILE" , toolchain_file) ;
272274
273275 // 21 is the minimum level tested. You can give higher value.
274276 boringssl_cmake. define ( "CMAKE_SYSTEM_VERSION" , "21" ) ;
275277 boringssl_cmake. define ( "CMAKE_ANDROID_STL_TYPE" , "c++_shared" ) ;
278+ Some ( toolchain_file)
276279 }
277-
278280 os @ ( "macos" | "ios" ) => {
279281 for ( name, value) in cmake_params_apple ( config) {
280282 eprintln ! ( "{os} arch={} add {}={}" , config. target_arch, name, value) ;
281283 boringssl_cmake. define ( name, value) ;
282284 }
285+ None
283286 }
284-
285287 "windows" if config. host . contains ( "windows" ) => {
286288 // BoringSSL's CMakeLists.txt isn't set up for cross-compiling using Visual Studio.
287289 // Disable assembly support so that it at least builds.
288290 boringssl_cmake. define ( "OPENSSL_NO_ASM" , "YES" ) ;
291+ None
289292 }
290-
291293 "linux" => match & * config. target_arch {
292- "x86" => {
293- boringssl_cmake. define (
294- "CMAKE_TOOLCHAIN_FILE" ,
295- // `src_path` can be a path relative to the manifest dir, but
296- // cmake hates that.
297- config
298- . manifest_dir
299- . join ( src_path)
300- . join ( "util/32-bit-toolchain.cmake" )
301- . as_os_str ( ) ,
302- ) ;
303- }
304- "aarch64" => {
305- boringssl_cmake. define (
306- "CMAKE_TOOLCHAIN_FILE" ,
307- config
308- . manifest_dir
309- . join ( "cmake/aarch64-linux.cmake" )
310- . as_os_str ( ) ,
311- ) ;
312- }
313- "arm" => {
314- boringssl_cmake. define (
315- "CMAKE_TOOLCHAIN_FILE" ,
316- config
317- . manifest_dir
318- . join ( "cmake/armv7-linux.cmake" )
319- . as_os_str ( ) ,
320- ) ;
321- }
322- _ => {
323- println ! (
324- "cargo:warning=no toolchain file configured by boring-sys for {}" ,
325- config. target
326- ) ;
327- }
294+ "x86" => Some (
295+ config
296+ . manifest_dir
297+ . join ( src_path)
298+ . join ( "util/32-bit-toolchain.cmake" ) ,
299+ ) ,
300+ "aarch64" => Some ( config. manifest_dir . join ( "cmake/aarch64-linux.cmake" ) ) ,
301+ "arm" => Some ( config. manifest_dir . join ( "cmake/armv7-linux.cmake" ) ) ,
302+ _ => None ,
328303 } ,
304+ _ => None ,
305+ } ;
329306
330- _ => { }
307+ if let Some ( tf) = toolchain_file {
308+ eprintln ! ( "{} toolchain={}" , config. target_os, tf. display( ) ) ;
309+ boringssl_cmake. define ( "CMAKE_TOOLCHAIN_FILE" , tf) ;
310+ } else {
311+ println ! ( "cargo:warning=no toolchain file set for {}" , config. target) ;
331312 }
332313
333314 boringssl_cmake
0 commit comments