Skip to content

Commit

Permalink
Merge pull request #3 from eugenehp/0.0.4
Browse files Browse the repository at this point in the history
0.0.4
  • Loading branch information
eugenehp authored Nov 17, 2024
2 parents 73c84f3 + 23269be commit d77d74d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion bitnet-cpp-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -24,6 +24,7 @@ include = [
"wrapper.h",
"build.rs",
"/src",
"/patches",

"/bitnet/src",
"/bitnet/include/*",
Expand Down
22 changes: 19 additions & 3 deletions bitnet-cpp-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -210,12 +212,16 @@ fn macos_link_search_path() -> Option<String> {
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")
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bitnet-cpp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 }

Expand Down

0 comments on commit d77d74d

Please sign in to comment.