diff --git a/Cargo.lock b/Cargo.lock index 098ed53..31731d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,7 +60,7 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitnet-cpp" -version = "0.0.3" +version = "0.0.4" dependencies = [ "bitnet-cpp-sys", "encoding_rs", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "bitnet-cpp-sys" -version = "0.0.3" +version = "0.0.4" dependencies = [ "bindgen", "cc", diff --git a/bitnet-cpp-sys/Cargo.toml b/bitnet-cpp-sys/Cargo.toml index 851b156..1937143 100644 --- a/bitnet-cpp-sys/Cargo.toml +++ b/bitnet-cpp-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bitnet-cpp-sys" description = "Low Level Bindings to bitnet.cpp" -version = "0.0.3" +version = "0.0.4" edition = "2021" license = "MIT" repository = "https://github.com/eugenehp/bitnet-cpp-rs" @@ -24,6 +24,7 @@ include = [ "wrapper.h", "build.rs", "/src", + "/patches", "/bitnet/src", "/bitnet/include/*", diff --git a/bitnet-cpp-sys/build.rs b/bitnet-cpp-sys/build.rs index 2fb4fdb..56f16d1 100644 --- a/bitnet-cpp-sys/build.rs +++ b/bitnet-cpp-sys/build.rs @@ -15,10 +15,12 @@ macro_rules! debug_log { }; } -const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME"); +// const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME"); +const CARGO_PKG_NAME: &str = "bitnet-cpp-sys"; // this has to be hardcoded to enable `bitnet-cpp` build const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); const BITNET_DIR: &str = "bitnet"; const LLAMA_CPP_DIR: &str = "bitnet/3rdparty/llama.cpp"; +const PATCHES_DIR: &str = "patches"; #[cfg(target_os = "windows")] const OS_EXTRA_ARGS: [(&str, &str); 1] = [("-T", "ClangCL")]; // these are cflags, so should be defined as .cflag("-foo") @@ -210,12 +212,16 @@ fn macos_link_search_path() -> Option { fn build() { let target = env::var("TARGET").unwrap(); let out_dir = get_out_dir(); + let src_dir = get_src_dir(); let target_dir = get_cargo_target_dir().unwrap(); let bitnet_dst = out_dir.join(BITNET_DIR); let bitnet_src = Path::new(&CARGO_MANIFEST_DIR).join(BITNET_DIR); + let patches_dst = out_dir.join(PATCHES_DIR); + let patches_src = Path::new(&src_dir).join(PATCHES_DIR); + let build_shared_libs = cfg!(feature = "cuda") || cfg!(feature = "dynamic-link"); let build_shared_libs = std::env::var("LLAMA_BUILD_SHARED_LIBS") @@ -232,6 +238,15 @@ fn build() { debug_log!("OUT_DIR: {}", out_dir.display()); debug_log!("BUILD_SHARED: {}", build_shared_libs); + if !patches_dst.exists() { + debug_log!( + "Copy {} to {}", + patches_src.display(), + patches_dst.display() + ); + copy_folder(&patches_src, &patches_dst); + } + if !bitnet_dst.exists() { debug_log!("Copy {} to {}", bitnet_src.display(), bitnet_dst.display()); copy_folder(&bitnet_src, &bitnet_dst); @@ -451,10 +466,11 @@ fn build() { } fn apply_patch(patch_name: &str, output_dir: &str) { - let src_dir = get_src_dir(); + // let src_dir = get_src_dir(); let out_dir = get_out_dir(); - let patches_dir = src_dir.join("patches"); + // let patches_dir = src_dir.join("patches"); + let patches_dir = out_dir.join(PATCHES_DIR); let content = fs::read_to_string(patches_dir.join(patch_name)).unwrap(); // uncomment this if you want to see atomic commits in the main git repo diff --git a/bitnet-cpp/Cargo.toml b/bitnet-cpp/Cargo.toml index 14ba659..0ce2308 100644 --- a/bitnet-cpp/Cargo.toml +++ b/bitnet-cpp/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bitnet-cpp" description = "bitnet.cpp bindings for Rust" -version = "0.0.3" +version = "0.0.4" edition = "2021" license = "MIT" repository = "https://github.com/eugenehp/bitnet-cpp-rs" @@ -23,7 +23,7 @@ keywords = [ [dependencies] enumflags2 = "0.7.10" -bitnet-cpp-sys = { path = "../bitnet-cpp-sys", version = "*" } +bitnet-cpp-sys = { path = "../bitnet-cpp-sys", version = "0.0.4" } thiserror = { workspace = true } tracing = { workspace = true }