diff --git a/CHANGELOG.md b/CHANGELOG.md index 33fd0e0..b507189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,3 +14,5 @@ - All builtin names (bool, int, true, false) are now defined in [stl/core.sus](stl/core.sus). This is so the templating system works for all of them. - Since link_info is now shared between Modules, Types and Constants, we now share all code for templating, typing, etc. - Instructions are now part of LinkInfo. +## 0.1.1 +- Change sus stl installation directory to $HOME/.sus/VERSION/stl diff --git a/Cargo.toml b/Cargo.toml index f1bc40e..57fea4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sus_compiler" description = "Compiler for the SUS Hardware Design Language" -version = "0.1.0" +version = "0.1.1" authors = ["Lennart Van Hirtum "] edition = "2021" license = "GPL-3.0-or-later" @@ -12,6 +12,8 @@ keywords = ["sus", "fpga", "vlsi", "hdl", "verilog"] categories = ["compilers", "text-processing"] rust-version = "1.78" +include = ["/src", "/stl/*", "/README.md", "/LICENSE", "/CHANGELOG.md", "/build.rs", "/rustfmt.toml"] + [workspace] members = [ "sus-proc-macro", @@ -49,6 +51,9 @@ serde_json = {version = "1.0.97", optional = true} serde = {version = "1.0.156", optional = true} +[build-dependencies] +dirs-next = "2.0.0" + [features] default = ["lsp"] diff --git a/build.rs b/build.rs index 77a1dad..2f442e1 100644 --- a/build.rs +++ b/build.rs @@ -1,14 +1,9 @@ -use std::env; -use std::fs; -use std::path::PathBuf; +use std::{fs, path::PathBuf}; fn main() { - let out_dir = env::var("OUT_DIR").unwrap(); - let install_dir = PathBuf::from(out_dir) - .join("../../..") - .join("share") - .join("sus_compiler") - .join("std"); + let mut install_dir = get_sus_dir(); + install_dir.push(env!("CARGO_PKG_VERSION")); + install_dir.push("stl"); fs::create_dir_all(&install_dir).expect("Failed to create std_lib directory"); @@ -18,6 +13,18 @@ fn main() { println!("cargo:rustc-env=SUS_COMPILER_STD_LIB_PATH={}", install_dir.display()); } +fn get_sus_dir() -> PathBuf { + let mut sus_dir = dirs_next::home_dir().expect("Could not determine home directory"); + sus_dir.push(".sus"); + + // Create the .sus directory if it doesn't exist + if !sus_dir.exists() { + fs::create_dir(&sus_dir).expect("Failed to create .sus directory"); + } + + sus_dir +} + // Helper function to copy a directory and its contents recursively fn copy_dir(src: &str, dst: &PathBuf) -> std::io::Result<()> { for entry in fs::read_dir(src)? {