hk32-partial-hal 0.3.1

HK32 partial HAL
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
    let memory_x = {
        if cfg!(feature = "hk32c030xx-mem-x") {
            include_bytes!("memory_c030xx.x").as_ref()
        } else if cfg!(feature = "hk32f0301mxxc-mem-x") {
            include_bytes!("memory_f0301mxxc.x").as_ref()
        } else if cfg!(feature = "hk32f005-mem-x") {
            include_bytes!("memory_f005.x").as_ref()
        } else {
            return;
        }
    };

    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
    println!("cargo:rustc-link-search={}", out.display());
    File::create(out.join("memory.x"))
        .unwrap()
        .write_all(memory_x)
        .unwrap();
}