MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / update_capi_version

Function update_capi_version

scripts/publish.rs:384–410  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

382}
383
384fn update_capi_version() {
385 let version = read_crate(None, "./Cargo.toml".as_ref()).version;
386
387 let mut iter = version.split('.').map(|s| s.parse::<u32>().unwrap());
388 let major = iter.next().expect("major version");
389 let minor = iter.next().expect("minor version");
390 let patch = iter.next().expect("patch version");
391
392 let mut new_header = String::new();
393 let contents = fs::read_to_string(C_HEADER_PATH).unwrap();
394 for line in contents.lines() {
395 if line.starts_with("#define WASMTIME_VERSION \"") {
396 new_header.push_str(&format!("#define WASMTIME_VERSION \"{version}\""));
397 } else if line.starts_with("#define WASMTIME_VERSION_MAJOR") {
398 new_header.push_str(&format!("#define WASMTIME_VERSION_MAJOR {major}"));
399 } else if line.starts_with("#define WASMTIME_VERSION_MINOR") {
400 new_header.push_str(&format!("#define WASMTIME_VERSION_MINOR {minor}"));
401 } else if line.starts_with("#define WASMTIME_VERSION_PATCH") {
402 new_header.push_str(&format!("#define WASMTIME_VERSION_PATCH {patch}"));
403 } else {
404 new_header.push_str(line);
405 }
406 new_header.push_str("\n");
407 }
408
409 fs::write(&C_HEADER_PATH, new_header).unwrap();
410}
411
412/// Performs a major version bump increment on the semver version `version`.
413///

Callers 1

mainFunction · 0.85

Calls 11

read_crateFunction · 0.85
read_to_stringFunction · 0.85
splitMethod · 0.80
newFunction · 0.50
writeFunction · 0.50
as_refMethod · 0.45
mapMethod · 0.45
unwrapMethod · 0.45
expectMethod · 0.45
nextMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected