From 738f3da8948d816f6cd1612b5b75c03011e01920 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 21 Dec 2024 21:06:02 -0600 Subject: [PATCH] demo app, long string print --- demo/Cargo.toml | 7 +++++++ demo/build.rs | 18 ++++++++++++++++++ demo/src/main.rs | 5 +++++ 3 files changed, 30 insertions(+) create mode 100644 demo/Cargo.toml create mode 100644 demo/build.rs create mode 100644 demo/src/main.rs diff --git a/demo/Cargo.toml b/demo/Cargo.toml new file mode 100644 index 0000000..5eb3be1 --- /dev/null +++ b/demo/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "demo" +version = "0.1.0" +edition = "2021" +build = "build.rs" + +[dependencies] diff --git a/demo/build.rs b/demo/build.rs new file mode 100644 index 0000000..87ee1ab --- /dev/null +++ b/demo/build.rs @@ -0,0 +1,18 @@ +use std::{ + env, + error::Error, + fs::File, + io::{BufWriter, Write}, + path::Path, +}; + +fn main() -> Result<(), Box> { + let out_dir = env::var("OUT_DIR")?; + let dest_path = Path::new(&out_dir).join("long_string.txt"); + let mut f = BufWriter::new(File::create(&dest_path)?); + + let long_string = "abc".repeat(100); + write!(f, "{}", long_string)?; + + Ok(()) +} diff --git a/demo/src/main.rs b/demo/src/main.rs new file mode 100644 index 0000000..728158b --- /dev/null +++ b/demo/src/main.rs @@ -0,0 +1,5 @@ +static LONG_STRING: &'static str = include_str!(concat!(env!("OUT_DIR"), "/long_string.txt")); + +fn main() { + println!("This package was compiled at {}", LONG_STRING); +}