@@ -13,11 +13,9 @@ use std::path::{Path, PathBuf};
13
13
use std:: sync:: OnceLock ;
14
14
15
15
use build_helper:: ci:: CiEnv ;
16
- use build_helper:: git:: get_closest_merge_commit;
17
16
18
- use crate :: Config ;
19
17
use crate :: core:: builder:: { Builder , Cargo , Kind , RunConfig , ShouldRun , Step } ;
20
- use crate :: core:: config:: { GccCiMode , TargetSelection } ;
18
+ use crate :: core:: config:: TargetSelection ;
21
19
use crate :: utils:: build_stamp:: { BuildStamp , generate_smart_stamp_hash} ;
22
20
use crate :: utils:: exec:: command;
23
21
use crate :: utils:: helpers:: { self , t} ;
@@ -93,9 +91,10 @@ pub enum GccBuildStatus {
93
91
/// Tries to download GCC from CI if it is enabled and GCC artifacts
94
92
/// are available for the given target.
95
93
/// Returns a path to the libgccjit.so file.
94
+ #[ cfg( not( test) ) ]
96
95
fn try_download_gcc ( builder : & Builder < ' _ > , target : TargetSelection ) -> Option < PathBuf > {
97
96
// Try to download GCC from CI if configured and available
98
- if !matches ! ( builder. config. gcc_ci_mode, GccCiMode :: DownloadFromCi ) {
97
+ if !matches ! ( builder. config. gcc_ci_mode, crate :: core :: config :: GccCiMode :: DownloadFromCi ) {
99
98
return None ;
100
99
}
101
100
if target != "x86_64-unknown-linux-gnu" {
@@ -114,6 +113,11 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
114
113
Some ( root. join ( "libgccjit.so" ) )
115
114
}
116
115
116
+ #[ cfg( test) ]
117
+ fn try_download_gcc ( _builder : & Builder < ' _ > , _target : TargetSelection ) -> Option < PathBuf > {
118
+ None
119
+ }
120
+
117
121
/// This returns information about whether GCC should be built or if it's already built.
118
122
/// It transparently handles downloading GCC from CI if needed.
119
123
///
@@ -247,12 +251,16 @@ pub fn add_cg_gcc_cargo_flags(cargo: &mut Cargo, gcc: &GccOutput) {
247
251
}
248
252
249
253
/// The absolute path to the downloaded GCC artifacts.
250
- fn ci_gcc_root ( config : & Config ) -> PathBuf {
254
+ #[ cfg( not( test) ) ]
255
+ fn ci_gcc_root ( config : & crate :: Config ) -> PathBuf {
251
256
config. out . join ( config. build ) . join ( "ci-gcc" )
252
257
}
253
258
254
259
/// This retrieves the GCC sha we *want* to use, according to git history.
255
- fn detect_gcc_sha ( config : & Config , is_git : bool ) -> String {
260
+ #[ cfg( not( test) ) ]
261
+ fn detect_gcc_sha ( config : & crate :: Config , is_git : bool ) -> String {
262
+ use build_helper:: git:: get_closest_merge_commit;
263
+
256
264
let gcc_sha = if is_git {
257
265
get_closest_merge_commit (
258
266
Some ( & config. src ) ,
0 commit comments