Commit f9294f35 authored by Sven Liefgen's avatar Sven Liefgen
Browse files

Improve error handling

parent ec57e918
......@@ -9,17 +9,17 @@ fn main() {
let dest_path = Path::new(&out_dir).join("xlap_generated.rs");
if let Ok(xlap) = env::var("XLAP") {
let yaml = fs::read_to_string(&xlap).unwrap();
let yaml = fs::read_to_string(&xlap).expect("Could not read file");
let yaml = YamlLoader::load_from_str(yaml.as_str())
.unwrap()
.expect("Could not load yml")
.pop()
.unwrap();
.expect("No documents in yml");
// Create XLAP array containing a table for each kind
let packet_types = &yaml["packet_types"];
let packet_types_count = packet_types.as_hash().unwrap().len();
let packet_types_count = packet_types.as_hash().expect("Expected `packet_types to be a `Hash`").len();
let mut static_xlap = format!(
"static XLAP: [AtomicPtr<TimestampTable>; {}] = [\n",
......@@ -47,7 +47,7 @@ fn main() {
let mut timestamp_id_enum = String::from("#[derive(EnumCount, EnumIter, AsRefStr)]\n");
timestamp_id_enum.push_str("pub enum TimestampId {\n");
for timestamp_id in timestamps.as_hash().unwrap().keys() {
for timestamp_id in timestamps.as_hash().expect("Expected `stamps` to be a `Hash`").keys() {
timestamp_id_enum.push_str(" ");
timestamp_id_enum.push_str(timestamp_id.as_str().unwrap());
timestamp_id_enum.push_str(",\n");
......@@ -58,7 +58,7 @@ fn main() {
let count = &yaml["rows"].as_i64().unwrap_or(4098);
let ts_rows = format!("const TS_ROWS: usize = {};\n", count);
let ts_rows = format!("const TS_ROWS: usize = {};\n", count + 1);
fs::write(
&dest_path,
......@@ -68,9 +68,9 @@ fn main() {
),
)
.unwrap();
println!("cargo::rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=src/lib.rs");
println!("cargo::rerun-if-changed={}", xlap);
println!("cargo::rerun-if-env-changed=XLAP");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed={}", xlap);
println!("cargo:rerun-if-env-changed=XLAP");
}
}
......@@ -18,8 +18,6 @@ pub unsafe fn current_cycle() -> u64 {
0
}
const TS_ROWS: usize = 128;
include!(concat!(env!("OUT_DIR"), "/xlap_generated.rs"));
// ---------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment