app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

build.rs (992B)


      1 use std::env;
      2 use std::path::{Path, PathBuf};
      3 
      4 use mf2_i18n::build::{NativeModuleBuildOptions, build_native_module};
      5 
      6 fn main() {
      7     let manifest_dir =
      8         PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("cargo manifest dir should exist"));
      9     let app_root = manifest_dir
     10         .parent()
     11         .and_then(Path::parent)
     12         .expect("app root should be discoverable from i18n crate");
     13     let config_path = app_root.join("i18n").join("mf2_i18n.toml");
     14     let out_dir = PathBuf::from(env::var("OUT_DIR").expect("out dir should exist"));
     15 
     16     let build_output = build_native_module(&NativeModuleBuildOptions::new(
     17         &config_path,
     18         &out_dir,
     19         "app_i18n",
     20     ))
     21     .unwrap_or_else(|error| {
     22         panic!(
     23             "failed to build app i18n native module from {}: {error}",
     24             config_path.display()
     25         )
     26     });
     27 
     28     for path in build_output.rerun_if_changed_paths() {
     29         println!("cargo:rerun-if-changed={}", path.display());
     30     }
     31 }