-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
62 lines (50 loc) · 1.89 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use camino::Utf8PathBuf;
use cargo_leptos::ext::PathBufExt;
use cargo_leptos::{
compile::{self, ChangeSet},
config::{Cli, Config},
};
use clap_builder::Parser;
const BUILD_LOCK_ENV: &str = "__BUILD_LOCK__";
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=Cargo.lock");
if std::env::var("SHUTTLE").is_err() || std::env::var(BUILD_LOCK_ENV).is_ok() {
return;
}
std::env::set_var(BUILD_LOCK_ENV, "true");
// technically should check if release/debug but since we are only running on shuttle we just force release
let args = vec!["leptos", "build", "--release"].into_iter().map(str::to_string);
let args = Cli::parse_from(args);
let manifest_path = Utf8PathBuf::from("Cargo.toml").resolve_home_dir().unwrap();
let mut cwd = Utf8PathBuf::from_path_buf(std::env::current_dir().unwrap()).unwrap();
cwd.clean_windows_path();
let opts = args.opts().unwrap();
let config = Config::load(opts, &cwd, &manifest_path, false).unwrap();
let proj = config.current_project().unwrap();
let changes = ChangeSet::all_changes();
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(async move {
let front_outcome = compile::front(&proj, &changes)
.await
.await
.unwrap()
.unwrap();
assert!(front_outcome.is_success());
let asset_outcome = compile::assets(&proj, &changes, true)
.await
.await
.unwrap()
.unwrap();
assert!(asset_outcome.is_success());
let style_outcome = compile::style(&proj, &changes)
.await
.await
.unwrap()
.unwrap();
assert!(style_outcome.is_success());
})
}