-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
37 lines (31 loc) · 1.11 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
use std::env;
use std::fs;
use std::io::Write;
use std::path::PathBuf;
fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let config_dir = out_dir.join("config");
fs::create_dir_all(&config_dir).unwrap();
let default_cfg = r#"
number_feature = false
dollar_sign_feature = false
tabs_feature = false
compress_empty_line_feature = false
"#;
let config_file = config_dir.join("ricat_cfg.toml");
fs::write(&config_file, default_cfg).unwrap();
let home_dir = dirs::home_dir().expect("Failed to find home directory");
let target_config_dir = home_dir.join(".config/ricat");
fs::create_dir_all(&target_config_dir).expect("Failed to create target config directory");
let target_config_file = target_config_dir.join("ricat_cfg.toml");
fs::copy(&config_file, &target_config_file).expect("Failed to copy config file");
println!(
"cargo:rustc-env=RICAT_CONFIG_DIR={}",
target_config_dir.display()
);
println!(
"ricat configuration file created at: {}",
target_config_file.display()
);
std::io::stdout().flush().unwrap();
}