File tree Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,21 @@ use crate::exec::cmd;
3
3
use crate :: utils:: io:: copy_directory;
4
4
use camino:: { Utf8Path , Utf8PathBuf } ;
5
5
6
- pub ( super ) struct LinuxEnvironment ;
6
+ pub ( super ) struct LinuxEnvironment {
7
+ target_triple : String ,
8
+ }
9
+
10
+ impl LinuxEnvironment {
11
+ pub fn new ( target_triple : String ) -> Self {
12
+ Self { target_triple }
13
+ }
14
+ }
7
15
8
16
impl Environment for LinuxEnvironment {
17
+ fn host_triple ( & self ) -> & str {
18
+ & self . target_triple
19
+ }
20
+
9
21
fn python_binary ( & self ) -> & ' static str {
10
22
"python3"
11
23
}
Original file line number Diff line number Diff line change @@ -6,9 +6,7 @@ mod linux;
6
6
mod windows;
7
7
8
8
pub trait Environment {
9
- fn host_triple ( & self ) -> String {
10
- std:: env:: var ( "PGO_HOST" ) . expect ( "PGO_HOST environment variable missing" )
11
- }
9
+ fn host_triple ( & self ) -> & str ;
12
10
13
11
fn python_binary ( & self ) -> & ' static str ;
14
12
@@ -69,9 +67,9 @@ pub trait Environment {
69
67
fn skipped_tests ( & self ) -> & ' static [ & ' static str ] ;
70
68
}
71
69
72
- pub fn create_environment ( ) -> Box < dyn Environment > {
70
+ pub fn create_environment ( target_triple : String ) -> Box < dyn Environment > {
73
71
#[ cfg( target_family = "unix" ) ]
74
- return Box :: new ( linux:: LinuxEnvironment ) ;
72
+ return Box :: new ( linux:: LinuxEnvironment :: new ( target_triple ) ) ;
75
73
#[ cfg( target_family = "windows" ) ]
76
- return Box :: new ( windows:: WindowsEnvironment :: new ( ) ) ;
74
+ return Box :: new ( windows:: WindowsEnvironment :: new ( target_triple ) ) ;
77
75
}
Original file line number Diff line number Diff line change @@ -9,15 +9,20 @@ use zip::ZipArchive;
9
9
10
10
pub ( super ) struct WindowsEnvironment {
11
11
checkout_dir : Utf8PathBuf ,
12
+ target_triple : String ,
12
13
}
13
14
14
15
impl WindowsEnvironment {
15
- pub fn new ( ) -> Self {
16
- Self { checkout_dir : std:: env:: current_dir ( ) . unwrap ( ) . try_into ( ) . unwrap ( ) }
16
+ pub fn new ( target_triple : String ) -> Self {
17
+ Self { checkout_dir : std:: env:: current_dir ( ) . unwrap ( ) . try_into ( ) . unwrap ( ) , target_triple }
17
18
}
18
19
}
19
20
20
21
impl Environment for WindowsEnvironment {
22
+ fn host_triple ( & self ) -> & str {
23
+ & self . target_triple
24
+ }
25
+
21
26
fn python_binary ( & self ) -> & ' static str {
22
27
"python"
23
28
}
Original file line number Diff line number Diff line change @@ -171,6 +171,8 @@ fn main() -> anyhow::Result<()> {
171
171
. parse_default_env ( )
172
172
. init ( ) ;
173
173
174
+ let target_triple = std:: env:: var ( "PGO_HOST" ) . expect ( "PGO_HOST environment variable missing" ) ;
175
+
174
176
let mut build_args: Vec < String > = std:: env:: args ( ) . skip ( 1 ) . collect ( ) ;
175
177
println ! ( "Running optimized build pipeline with args `{}`" , build_args. join( " " ) ) ;
176
178
@@ -202,7 +204,7 @@ fn main() -> anyhow::Result<()> {
202
204
}
203
205
204
206
let mut timer = Timer :: new ( ) ;
205
- let env = create_environment ( ) ;
207
+ let env = create_environment ( target_triple ) ;
206
208
207
209
let result = execute_pipeline ( env. as_ref ( ) , & mut timer, build_args) ;
208
210
log:: info!( "Timer results\n {}" , timer. format_stats( ) ) ;
You can’t perform that action at this time.
0 commit comments