Use build script
This commit is contained in:
parent
a8e5d09ff0
commit
e78315025d
2 changed files with 15 additions and 10 deletions
15
build.rs
15
build.rs
|
@ -1,10 +1,25 @@
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
use vergen::{vergen, Config, ShaKind};
|
use vergen::{vergen, Config, ShaKind};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
// Initialize vergen stuff
|
||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
*config.git_mut().sha_kind_mut() = ShaKind::Short;
|
*config.git_mut().sha_kind_mut() = ShaKind::Short;
|
||||||
vergen(config)?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in a new issue