Skip to content

Commit 271e1b6

Browse files
authored
add bindgen version to file header (#490)
* add wit-bindgen pkg version to file headers Signed-off-by: Jiaxiao Zhou <jiazho@microsoft.com> * fmt Signed-off-by: Jiaxiao Zhou <jiazho@microsoft.com> --------- Signed-off-by: Jiaxiao Zhou <jiazho@microsoft.com>
1 parent 8557bf0 commit 271e1b6

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

crates/gen-guest-c/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,12 @@ impl WorldGenerator for C {
259259
",
260260
);
261261
}
262-
262+
let version = env!("CARGO_PKG_VERSION");
263263
let mut h_str = wit_bindgen_core::Source::default();
264+
uwriteln!(
265+
h_str,
266+
"// Generated by `wit-bindgen` {version}. DO NOT EDIT!"
267+
);
264268

265269
uwrite!(
266270
h_str,
@@ -283,6 +287,10 @@ impl WorldGenerator for C {
283287
}
284288

285289
let mut c_str = wit_bindgen_core::Source::default();
290+
uwriteln!(
291+
c_str,
292+
"// Generated by `wit-bindgen` {version}. DO NOT EDIT!"
293+
);
286294
uwriteln!(c_str, "#include \"{snake}.h\"");
287295
if c_str.len() > 0 {
288296
c_str.push_str("\n");

crates/gen-guest-rust/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ impl RustWasm {
113113

114114
impl WorldGenerator for RustWasm {
115115
fn preprocess(&mut self, resolve: &Resolve, _world: WorldId) {
116+
let version = env!("CARGO_PKG_VERSION");
117+
uwriteln!(
118+
self.src,
119+
"// Generated by `wit-bindgen` {version}. DO NOT EDIT!"
120+
);
116121
self.types.analyze(resolve);
117122
}
118123

crates/gen-guest-teavm-java/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ impl WorldGenerator for TeaVmJava {
179179
let package = format!("wit_{}", world.name.to_snake_case());
180180
let name = world.name.to_upper_camel_case();
181181

182+
let version = env!("CARGO_PKG_VERSION");
182183
let mut src = String::new();
184+
uwriteln!(src, "// Generated by `wit-bindgen` {version}. DO NOT EDIT!");
183185

184186
uwrite!(
185187
src,
@@ -361,7 +363,8 @@ impl WorldGenerator for TeaVmJava {
361363
.join("\n");
362364

363365
let body = format!(
364-
"package {package};
366+
"// Generated by `wit-bindgen` {version}. DO NOT EDIT!
367+
package {package};
365368
366369
{IMPORTS}
367370
@@ -386,7 +389,8 @@ impl WorldGenerator for TeaVmJava {
386389
.join("\n");
387390

388391
let body = format!(
389-
"package {package};
392+
"// Generated by `wit-bindgen` {version}. DO NOT EDIT!
393+
package {package};
390394
391395
{IMPORTS}
392396

0 commit comments

Comments
 (0)