@@ -106,15 +106,34 @@ fn build_wasm_runtime() -> PathBuf {
106106 println ! ( "cargo::rerun-if-env-changed=WIT_WORLD" ) ;
107107 // the PROFILE env var unfortunately only gives us 1 bit of "dev or release"
108108 let cargo_profile = if profile == "debug" { "dev" } else { "release" } ;
109- let mut cmd = std:: process:: Command :: new ( cargo_bin) ;
109+ let mut cargo_cmd = std:: process:: Command :: new ( & cargo_bin) ;
110110
111111 // Clear the variables that control Cargo's behaviour (as listed
112112 // at https://doc.rust-lang.org/cargo/reference/environment-variables.html):
113113 // otherwise the nested build will build the wrong thing
114114 let mut env_vars = env:: vars ( ) . collect :: < Vec < _ > > ( ) ;
115115 env_vars. retain ( |( key, _) | !key. starts_with ( "CARGO_" ) ) ;
116116
117- let cmd = cmd
117+ // we need to build hyperlight-guest-bin dependency of wasm_runtime, before wasm_runtime
118+ let cmd = cargo_cmd
119+ . arg ( "build" )
120+ . arg ( "--profile" )
121+ . arg ( cargo_profile)
122+ . arg ( "--package" )
123+ . arg ( "hyperlight-guest-bin" )
124+ . arg ( "-v" )
125+ . current_dir ( & in_repo_dir)
126+ . env_clear ( )
127+ . envs ( env_vars. clone ( ) ) ;
128+ let status = cmd
129+ . status ( )
130+ . unwrap_or_else ( |e| panic ! ( "could not run cargo build hyperlight-guest-bin: {}" , e) ) ;
131+ if !status. success ( ) {
132+ panic ! ( "could not compile wasm_runtime" ) ;
133+ }
134+
135+ let mut cargo_cmd = std:: process:: Command :: new ( & cargo_bin) ;
136+ let cmd = cargo_cmd
118137 . arg ( "build" )
119138 . arg ( "--profile" )
120139 . arg ( cargo_profile)
@@ -127,7 +146,7 @@ fn build_wasm_runtime() -> PathBuf {
127146
128147 let status = cmd
129148 . status ( )
130- . unwrap_or_else ( |e| panic ! ( "could not run cargo build: {}" , e) ) ;
149+ . unwrap_or_else ( |e| panic ! ( "could not run cargo build wasm_runtime : {}" , e) ) ;
131150 if !status. success ( ) {
132151 panic ! ( "could not compile wasm_runtime" ) ;
133152 }
0 commit comments