Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Created July 19, 2024 12:16
Show Gist options
  • Save RandyMcMillan/33a46d3d3d17a575bf75b3f41196cb14 to your computer and use it in GitHub Desktop.
Save RandyMcMillan/33a46d3d3d17a575bf75b3f41196cb14 to your computer and use it in GitHub Desktop.
// 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