mirror of
https://github.com/enso-org/enso.git
synced 2024-12-29 04:42:46 +03:00
build scripts should store their output in the proper place (https://github.com/enso-org/ide/pull/1837)
Original commit: 883146efdb
This commit is contained in:
parent
7a00e309d3
commit
dab63b0b0e
@ -10,6 +10,7 @@ fn main() {
|
||||
|
||||
let f = std::fs::File::open(CONFIG_PATH).unwrap();
|
||||
let value: Value = serde_yaml::from_reader(f).unwrap();
|
||||
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("missing environment variable CARGO_MANIFEST_DIR:");
|
||||
|
||||
let indent = " ".repeat(4);
|
||||
let mut def = "".to_string();
|
||||
@ -22,24 +23,27 @@ fn main() {
|
||||
let value = value.as_str().unwrap();
|
||||
def.push_str(&format!("{}pub {} : &'static str,\n",indent,key));
|
||||
inst.push_str(&format!("{}{} : \"{}\",\n",indent,key,value));
|
||||
vars.push_str(&format!("pub const {} : &str = \"{}\";\n",key,value));
|
||||
vars.push_str(&format!("#[allow(non_upper_case_globals)]\npub const {} : &str = \"{}\";\n",key,value));
|
||||
}
|
||||
}
|
||||
_ => panic!("Unexpected config format.")
|
||||
}
|
||||
|
||||
let file = format!(r#"// THIS IS AN AUTOGENERATED FILE BASED ON THE '{config_path}' CONFIG FILE. DO NOT MODIFY IT.
|
||||
// Generated by the build script in {my_path}.
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
pub struct Config {{
|
||||
mod autogenerated {{
|
||||
pub struct Config {{
|
||||
{def}
|
||||
}}
|
||||
|
||||
pub const CONFIG : Config = Config {{
|
||||
{inst}
|
||||
}};
|
||||
}}
|
||||
|
||||
pub const CONFIG : Config = Config {{
|
||||
{inst}
|
||||
}};
|
||||
|
||||
{vars}"#,
|
||||
config_path=CONFIG_PATH, def=def, inst=inst, vars=vars);
|
||||
fs::write("src/autogenerated.rs",file).ok();
|
||||
my_path=manifest_dir, config_path=CONFIG_PATH, def=def, inst=inst, vars=vars);
|
||||
let out_dir = std::env::var("OUT_DIR").expect("missing environment variable OUT_DIR:");
|
||||
fs::write(out_dir + "/config.rs",file).ok();
|
||||
}
|
||||
|
@ -1,2 +1,4 @@
|
||||
mod autogenerated;
|
||||
// Defines module `autogenerated`.
|
||||
include!(concat!(env!("OUT_DIR"), "/config.rs"));
|
||||
|
||||
pub use autogenerated::*;
|
||||
|
Loading…
Reference in New Issue
Block a user