Skip to content

Commit

Permalink
read versions from built.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
pront committed Aug 29, 2023
1 parent b125221 commit 5057447
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 1,328 deletions.
22 changes: 0 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/vector-vrl/web-playground/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ gloo-utils = { version = "0.2", features = ["serde"] }
getrandom = { version = "0.2", features = ["js"] }
vector-vrl-functions = { path = "../functions" }
enrichment = { path = "../../enrichment" }
built = { version = "0.6.1" }

[build-dependencies]
cargo_toml = "0.15.3"
19 changes: 9 additions & 10 deletions lib/vector-vrl/web-playground/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ fn write_build_constants(manifest: &Manifest, dest_path: &Path) -> io::Result<()
"// AUTOGENERATED CONSTANTS. SEE BUILD.RS AT REPOSITORY ROOT. DO NOT MODIFY.\n".as_ref(),
)?;

let vector_version_const = format!(
"pub const {}: &str = \"{}\"",
"VECTOR_VERSION",
manifest.package().version()
);
let create_const_statement =
|name, value| format!("pub const {}: &str = \"{}\";\n", name, value);
// TODO: For releases, we should use the manifest.package().version().
let vector_version_const = create_const_statement("VECTOR_VERSION", "master");
output_file
.write_all(vector_version_const.as_bytes())
.expect("Failed to write Vector version constant");
Expand All @@ -40,18 +39,18 @@ fn write_build_constants(manifest: &Manifest, dest_path: &Path) -> io::Result<()
.detail()
.unwrap()
.version
.clone()
.unwrap();
let vrl_version_const = format!("pub const {}: &str = \"{}\"", "VRL_VERSION", vrl_version);
let vrl_version_const = create_const_statement("VRL_VERSION", vrl_version);
output_file
.write_all(vector_version_const.as_bytes())
.write_all(vrl_version_const.as_bytes())
.expect("Failed to write Vector version constant");
Ok(())
}

fn main() {
//println!("cargo:rerun-if-changed(../../../Cargo.toml");
let manifest =
Manifest::from_path(&get_vector_toml_path()).expect("Failed to load Vector Cargo.toml");
let dst = std::path::Path::new(&env::var("OUT_DIR").unwrap()).join("built.rs");
Manifest::from_path(get_vector_toml_path()).expect("Failed to load Vector Cargo.toml");
let dst = Path::new(&env::var("OUT_DIR").unwrap()).join("built.rs");
write_build_constants(&manifest, &dst).expect("Failed to write constants");
}
Loading

0 comments on commit 5057447

Please sign in to comment.