encoderfile 0.3.0

Distribute and run transformer encoders with a single file.
Documentation
use std::path::PathBuf;

fn main() {
    let encoderfile_core_dep_str = match option_env!("ENCODERFILE_DEV") {
        // include local path if in dev mode
        Some("true") => get_local_encoderfile_dep(),
        // otherwise use coupled version. encoderfile and encoderfile-core
        // should ALWAYS have the same version.
        Some("false") | None => get_versioned_encoderfile_dep(),
        _ => panic!("ENCODERFILE_DEV must either be \"true\" or \"false\""),
    };

    println!(
        "cargo:rustc-env=ENCODERFILE_CORE_DEP_STR={}",
        encoderfile_core_dep_str
    );
}

fn get_local_encoderfile_dep() -> String {
    let encoderfile_dir: PathBuf = PathBuf::from("../encoderfile-core")
        .canonicalize()
        .expect("Failed to find encoderfile-core directory. This should not happen.");

    format!("path = {:?}", encoderfile_dir.to_str().unwrap())
}

fn get_versioned_encoderfile_dep() -> String {
    format!("version = \"{}\"", env!("CARGO_PKG_VERSION"))
}