/
build.rs
72 lines (61 loc) · 1.67 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
63
64
65
66
67
68
69
70
71
72
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
const INDEX_HTML_TEMPLATE: &'static str =
r##"<html>
<head>
<meta charset="utf-8"/>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no' />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="theme-color" content="#74ae76"/>
<meta name="msapplication-navbutton-color" content="#74ae76"/>
<meta name="apple-mobile-web-app-status-bar-style" content="#74ae76"/>
<style>
* {
margin: 0;
padding: 0;
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
}
html, body {
width: 100vw;
height: 100vh;
position: fixed;
overflow: hidden;
background: #69cc82;
}
canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
display: block;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script src="[[pkg_name]]/[[build_type]].js"></script>
</body>
</html>"##;
fn main() {
let profile = env::var("PROFILE").unwrap();
let index_html = INDEX_HTML_TEMPLATE.to_string()
.replace("[[build_type]]", &profile)
.replace("[[pkg_name]]", env!("CARGO_PKG_NAME"));
let dest = env::var("CARGO_MANIFEST_DIR").unwrap();
let path = Path::new(&dest).join("index.html");
let mut file = File::create(&path).unwrap();
file.write_all(index_html.as_bytes()).unwrap();
if profile == "debug" {
println!("cargo:rustc-cfg=debug");
// println!("cargo:rustc-cfg=dom_console");
}
}