diff options
author | Lzu Tao <taolzu@gmail.com> | 2020-04-24 21:16:36 +0700 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-04-24 17:39:25 +0200 |
commit | 56111aa20dc7473e36d1e5996dc0ffb804a8f123 (patch) | |
tree | a1a26cc14e6c2222caa503b11703abe93f9b3b3a /build.rs | |
parent | 5fe8a8342b8550eca8b8a923c81fb7af9754647b (diff) |
simplify build.rs
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -12,16 +12,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { use std::fs; use std::path::Path; - use lazy_static::lazy_static; - - static PROJECT_VERSION: &str = env!("CARGO_PKG_VERSION"); - // Read environment variables. - lazy_static! { - static ref PROJECT_NAME: &'static str = option_env!("PROJECT_NAME").unwrap_or("bat"); - static ref EXECUTABLE_NAME: &'static str = - option_env!("PROJECT_EXECUTABLE").unwrap_or(*PROJECT_NAME); - } + let project_name = option_env!("PROJECT_NAME").unwrap_or("bat"); + let executable_name = option_env!("PROJECT_EXECUTABLE").unwrap_or(project_name); + static PROJECT_VERSION: &str = env!("CARGO_PKG_VERSION"); /// Generates a file from a liquid template. fn template( @@ -38,9 +32,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { } let variables = liquid::object!({ - "PROJECT_NAME": PROJECT_NAME.to_owned(), - "PROJECT_EXECUTABLE": EXECUTABLE_NAME.to_owned(), - "PROJECT_VERSION": PROJECT_VERSION.to_owned(), + "PROJECT_NAME": project_name, + "PROJECT_EXECUTABLE": executable_name, + "PROJECT_VERSION": PROJECT_VERSION, }); let out_dir_env = std::env::var_os("OUT_DIR").expect("OUT_DIR to be set in build.rs"); |