anki/rslib/build.rs
Damien Elmes 0f77de896d Fix building outside workspace
rslib/build.rs needs descriptors, even if env var not set
2023-07-02 18:22:44 +10:00

23 lines
742 B
Rust

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
mod rust_interface;
use std::fs;
use anki_proto_gen::descriptors_path;
use anyhow::Result;
use prost_reflect::DescriptorPool;
fn main() -> Result<()> {
println!("cargo:rerun-if-changed=../out/buildhash");
let buildhash = fs::read_to_string("../out/buildhash").unwrap_or_default();
println!("cargo:rustc-env=BUILDHASH={buildhash}");
let descriptors_path = descriptors_path();
println!("cargo:rerun-if-changed={}", descriptors_path.display());
let pool = DescriptorPool::decode(std::fs::read(descriptors_path)?.as_ref())?;
rust_interface::write_rust_interface(&pool)?;
Ok(())
}