Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Created July 19, 2024 12:17
Show Gist options
  • Save RandyMcMillan/8029449c76db694cf01264f314f524fe to your computer and use it in GitHub Desktop.
Save RandyMcMillan/8029449c76db694cf01264f314f524fe to your computer and use it in GitHub Desktop.
generic build.rs
// build.rs
use std::env;
use std::fs;
use std::path::Path;
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("hello.rs");
fs::write(
&dest_path,
"pub fn message() -> &'static str {
\"Hello, World!\"
}
"
).unwrap();
println!("cargo:rerun-if-changed=build.rs");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment