Skip to content

Commit 80d741a

Browse files
committed
Build hyperlight-guest-bin before wasm_runtime
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 6881166 commit 80d741a

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/hyperlight_wasm/build.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,36 @@ 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+
.arg("--target-dir")
126+
.arg(&target_dir)
127+
.current_dir(&in_repo_dir)
128+
.env_clear()
129+
.envs(env_vars.clone());
130+
let status = cmd
131+
.status()
132+
.unwrap_or_else(|e| panic!("could not run cargo build hyperlight-guest-bin: {}", e));
133+
if !status.success() {
134+
panic!("could not compile wasm_runtime");
135+
}
136+
137+
let mut cargo_cmd = std::process::Command::new(&cargo_bin);
138+
let cmd = cargo_cmd
118139
.arg("build")
119140
.arg("--profile")
120141
.arg(cargo_profile)
@@ -127,7 +148,7 @@ fn build_wasm_runtime() -> PathBuf {
127148

128149
let status = cmd
129150
.status()
130-
.unwrap_or_else(|e| panic!("could not run cargo build: {}", e));
151+
.unwrap_or_else(|e| panic!("could not run cargo build wasm_runtime: {}", e));
131152
if !status.success() {
132153
panic!("could not compile wasm_runtime");
133154
}

0 commit comments

Comments
 (0)