use std::error::Error;
const MODELS: [(bool, &str, &str, &str, &str); 4] = [
(
cfg!(feature = "embed-model-ipadic"),
"lindera-dependency-ipadic",
"prebuilt-ipadic.json",
"LINDERA_BUILD_DEPENDENCY_MODEL_IPADIC_FILE",
"dependency-ipadic.model",
),
(
cfg!(feature = "embed-model-unidic"),
"lindera-dependency-unidic",
"prebuilt-unidic.json",
"LINDERA_BUILD_DEPENDENCY_MODEL_UNIDIC_FILE",
"dependency-unidic.model",
),
(
cfg!(feature = "embed-model-unidic-cwj"),
"lindera-dependency-unidic-cwj",
"prebuilt-unidic-cwj.json",
"LINDERA_BUILD_DEPENDENCY_MODEL_UNIDIC_CWJ_FILE",
"dependency-unidic-cwj.model",
),
(
cfg!(feature = "embed-model-unidic-csj"),
"lindera-dependency-unidic-csj",
"prebuilt-unidic-csj.json",
"LINDERA_BUILD_DEPENDENCY_MODEL_UNIDIC_CSJ_FILE",
"dependency-unidic-csj.model",
),
];
fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rerun-if-changed=build.rs");
#[cfg(any(
feature = "embed-model-ipadic",
feature = "embed-model-unidic",
feature = "embed-model-unidic-cwj",
feature = "embed-model-unidic-csj"
))]
for (enabled, key, pin, file_env, output) in MODELS {
if !enabled {
continue;
}
lindera_dictionary::assets::build_embedded_file(
true,
lindera_dictionary::assets::PublishedFile {
key,
pin,
file: "dependency.model",
format_version: 4,
file_env,
output,
how_to_make: "build the model with scripts/dependency/build_model.sh of the \
Lindera repository",
},
)?;
}
let _ = MODELS;
Ok(())
}