@@ -27,7 +27,7 @@ fn main() -> anyhow::Result<()> {
2727fn test ( params : test:: Params ) -> anyhow:: Result < ( ) > {
2828 let project_path = obtain_project_path ( ) ?;
2929
30- init_env ( & project_path, params. ci ) ?;
30+ init_env ( & project_path, params. no_infer_bin_path ) ?;
3131
3232 build:: build ( & project_path, params. build ) ?;
3333
@@ -78,27 +78,47 @@ fn wait_interrupt() {
7878
7979// Set up environment variables needed by the compilation and testing process.
8080//
81- // If ci flag is specified, all binaries are added to PATH env variable
82- // and the sovereign constant manifest position is specified through the
83- // CONSTANTS_MANIFEST new env variable
84- fn init_env ( project_path : & Path , ci : bool ) -> anyhow:: Result < ( ) > {
85- if ci {
86- let path = std:: env:: var ( "PATH" ) . unwrap_or_else ( |_| "" . to_string ( ) ) ;
87-
88- // `cargo_target` is the target used in ci by cargo as destination
89- // for all intermediate and final artifacts
90- let new_path = format ! ( "/cargo_target/release/:{}" , path) ;
91- std:: env:: set_var ( "PATH" , new_path) ;
92-
93- let path = project_path. join ( "demo/sovereign/constants.json" ) ;
94- if !path. exists ( ) {
95- anyhow:: bail!(
96- "The `constants.json` file for Sovereign does not exist,\n \
81+ // Add the sovereign constant manifest position through the
82+ // CONSTANTS_MANIFEST new env variable and if no_infer_bin_path is not specified
83+ // add to the path all required binaries.
84+ fn init_env ( project_path : & PathBuf , no_infer_bin_path : bool ) -> anyhow:: Result < ( ) > {
85+ let path = project_path. join ( "demo/sovereign/constants.json" ) ;
86+ if !path. exists ( ) {
87+ anyhow:: bail!(
88+ "The `constants.json` file for Sovereign does not exist,\n \
9789 or it is not in the expected position, `demo/sovereign/constants.json`"
98- )
99- }
100- std:: env:: set_var ( "CONSTANTS_MANIFEST" , path) ;
90+ )
10191 }
92+ std:: env:: set_var ( "CONSTANTS_MANIFEST" , path) ;
93+
94+ if no_infer_bin_path {
95+ return Ok ( ( ) ) ;
96+ }
97+
98+ let path = std:: env:: var ( "PATH" ) . unwrap_or_else ( |_| "" . to_string ( ) ) ;
99+
100+ #[ rustfmt:: skip]
101+ let chain_target_path = duct:: cmd!(
102+ "sh" , "-c" ,
103+ "cargo metadata --format-version 1 | jq -r '.target_directory'"
104+ )
105+ . stdout_capture ( )
106+ . run ( ) ?;
107+ let chain_target_path = str:: from_utf8 ( & chain_target_path. stdout ) ?. trim ( ) ;
108+
109+ #[ rustfmt:: skip]
110+ let sovereign_target_path = duct:: cmd!(
111+ "sh" , "-c" ,
112+ "cd demo/sovereign && cargo metadata --format-version 1 | jq -r '.target_directory'"
113+ )
114+ . stdout_capture ( )
115+ . run ( ) ?;
116+ let sovereign_target_path = str:: from_utf8 ( & sovereign_target_path. stdout ) ?. trim ( ) ;
117+
118+ std:: env:: set_var (
119+ "PATH" ,
120+ format ! ( "{chain_target_path}/release/:{sovereign_target_path}/release/:{path}" ) ,
121+ ) ;
102122
103123 Ok ( ( ) )
104124}
0 commit comments