Switch from version strings to schema versions

Should help reduce some churn a bit!
This commit is contained in:
Alex Crichton 2018-03-05 20:05:44 -08:00
parent 1db5b3fb50
commit 98030e0e4a
3 changed files with 5 additions and 1 deletions

View File

@ -163,7 +163,7 @@ fn extract_programs(module: &mut Module) -> Vec<shared::Program> {
panic!("failed to decode what looked like wasm-bindgen data: {}", e) panic!("failed to decode what looked like wasm-bindgen data: {}", e)
} }
}; };
if p.version != version { if p.schema_version != shared::SCHEMA_VERSION {
panic!(" panic!("
it looks like the Rust project used to create this wasm file was linked against it looks like the Rust project used to create this wasm file was linked against

View File

@ -351,6 +351,7 @@ impl Program {
}) })
}), }),
("version", &|a| a.str(&shared::version())), ("version", &|a| a.str(&shared::version())),
("schema_version", &|a| a.str(&shared::SCHEMA_VERSION)),
]); ]);
a.cnt a.cnt
}; };

View File

@ -5,6 +5,8 @@ extern crate fnv;
use std::char; use std::char;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
pub const SCHEMA_VERSION: &str = "0";
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct Program { pub struct Program {
pub exports: Vec<Export>, pub exports: Vec<Export>,
@ -12,6 +14,7 @@ pub struct Program {
pub imports: Vec<Import>, pub imports: Vec<Import>,
pub custom_type_names: Vec<CustomTypeName>, pub custom_type_names: Vec<CustomTypeName>,
pub version: String, pub version: String,
pub schema_version: String,
} }
#[derive(Deserialize)] #[derive(Deserialize)]