-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.rs
51 lines (43 loc) · 1.5 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
/*
Building by default will compile a program which stores/looks for data in:
- /home/root/.local/share/webinterface-wifi
And stores/looks for the config in:
- /home/root/.config/webinterface-wifi
Building with the enviroment variable WIW_DATADIR="/opt/etc" will compile
a program which stores/looks for data in:
- /opt/etc/webinterface-wifi
Building with the enviroment variable WIW_CONFDIR="/etc" will compile
a program which stores/looks for data in:
- /etc/webinterface-wifi
*/
use std::env::var;
use std::str;
const CARGOENV: &str = "cargo:rustc-env=";
const PACKAGE_NAME: &str = "webinterface-wifi";
const LOCALDATADIR: &str = "/home/root/.local/share";
const LOCALCONFDIR: &str = "/home/root/.config";
macro_rules! to_build_env {
($($destdir:ident: $envname:tt: $fpath:tt$(,)?)*) => {
$(println!("{}",
format!(
"{}{}=/{}/{}/{}",
CARGOENV,
$envname,
$destdir,
PACKAGE_NAME,
$fpath
).replace("//", "/")
);)*
};
}
fn main() {
let data_dir = var("WIW_DATADIR").unwrap_or(LOCALDATADIR.to_string());
let conf_dir = var("WIW_CONFDIR").unwrap_or(LOCALCONFDIR.to_string());
to_build_env!(
data_dir: "DEF_PASS_PATH": "auth/login.pass",
data_dir: "DEF_SSL_CERT_PATH": "ssl/ssl_cert.pem",
data_dir: "DEF_SSL_PRIV_PATH": "ssl/ssl_priv.rsa",
data_dir: "FAVICON_PATH": "assets/favicon.ico",
conf_dir: "DEF_CNFG_PATH": "config.toml",
);
}