From e78315025da355d512d6cef6ce93337b734b79fa Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Fri, 9 Jul 2021 17:32:00 -0400 Subject: [PATCH] Use build script --- build.rs | 15 +++++++++++++++ init_cache.sh | 10 ---------- 2 files changed, 15 insertions(+), 10 deletions(-) delete mode 100755 init_cache.sh diff --git a/build.rs b/build.rs index b6d7130..f7069f7 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,25 @@ use std::error::Error; +use std::process::Command; use vergen::{vergen, Config, ShaKind}; fn main() -> Result<(), Box> { + // Initialize vergen stuff let mut config = Config::default(); *config.git_mut().sha_kind_mut() = ShaKind::Short; vergen(config)?; + + // Initialize SQL stuff + let project_root = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + Command::new("mkdir") + .args(["cache", "--parents"]) + .current_dir(&project_root) + .output()?; + + Command::new("sqlite3") + .args(["cache/metadata.sqlite", include_str!("db_queries/init.sql")]) + .current_dir(&project_root) + .output()?; + Ok(()) } diff --git a/init_cache.sh b/init_cache.sh deleted file mode 100755 index 17ec19b..0000000 --- a/init_cache.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# This script needs to be run once in order for compile time macros to not -# complain about a missing DB - -# We can trust that our program will initialize the db at runtime the same way -# as it pulls from the same file for initialization - -mkdir cache -sqlite3 cache/metadata.sqlite < db_queries/init.sql \ No newline at end of file