Skip to content

Commit 04351d1

Browse files
committed
build script
1 parent 27899dd commit 04351d1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

rs/pocket_ic_server/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,22 @@ struct Dashboard<'a> {{
7171
);
7272
}
7373
}
74+
75+
// The environment variable `MAINNET_ROUTING_TABLE` pointing to a file (storing the mainnet routing table) is needed
76+
// for the PocketIC server to compile. There are two flows to support:
77+
// - code validation using `cargo`: we create a dummy file and point `MAINNET_ROUTING_TABLE` to that file for code validation to succeed;
78+
// - building the PocketIC server using `bazel`: `bazel` always sets `MAINNET_ROUTING_TABLE` to an actual file storing the mainnet routing table
79+
// (built separately) and thus we don't override `MAINNET_ROUTING_TABLE` if already set.
80+
let mainnet_routing_table_var_name = "MAINNET_ROUTING_TABLE".to_string();
81+
if std::env::var(&mainnet_routing_table_var_name).is_err() {
82+
let mainnet_routing_table_file_name = "mainnet_routing_table.json";
83+
let mainnet_routing_table_file_path =
84+
PathBuf::from(std::env::var("OUT_DIR").unwrap()).join(mainnet_routing_table_file_name);
85+
File::create(&mainnet_routing_table_file_path).unwrap();
86+
println!(
87+
"cargo:rustc-env={}={}",
88+
mainnet_routing_table_var_name,
89+
mainnet_routing_table_file_path.display()
90+
);
91+
}
7492
}

0 commit comments

Comments
 (0)