Skip to content

Commit d77d74d

Browse files
authored
Merge pull request #3 from eugenehp/0.0.4
0.0.4
2 parents 73c84f3 + 23269be commit d77d74d

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bitnet-cpp-sys/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bitnet-cpp-sys"
33
description = "Low Level Bindings to bitnet.cpp"
4-
version = "0.0.3"
4+
version = "0.0.4"
55
edition = "2021"
66
license = "MIT"
77
repository = "https://github.com/eugenehp/bitnet-cpp-rs"
@@ -24,6 +24,7 @@ include = [
2424
"wrapper.h",
2525
"build.rs",
2626
"/src",
27+
"/patches",
2728

2829
"/bitnet/src",
2930
"/bitnet/include/*",

bitnet-cpp-sys/build.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ macro_rules! debug_log {
1515
};
1616
}
1717

18-
const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME");
18+
// const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME");
19+
const CARGO_PKG_NAME: &str = "bitnet-cpp-sys"; // this has to be hardcoded to enable `bitnet-cpp` build
1920
const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
2021
const BITNET_DIR: &str = "bitnet";
2122
const LLAMA_CPP_DIR: &str = "bitnet/3rdparty/llama.cpp";
23+
const PATCHES_DIR: &str = "patches";
2224

2325
#[cfg(target_os = "windows")]
2426
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<String> {
210212
fn build() {
211213
let target = env::var("TARGET").unwrap();
212214
let out_dir = get_out_dir();
215+
let src_dir = get_src_dir();
213216

214217
let target_dir = get_cargo_target_dir().unwrap();
215218

216219
let bitnet_dst = out_dir.join(BITNET_DIR);
217220
let bitnet_src = Path::new(&CARGO_MANIFEST_DIR).join(BITNET_DIR);
218221

222+
let patches_dst = out_dir.join(PATCHES_DIR);
223+
let patches_src = Path::new(&src_dir).join(PATCHES_DIR);
224+
219225
let build_shared_libs = cfg!(feature = "cuda") || cfg!(feature = "dynamic-link");
220226

221227
let build_shared_libs = std::env::var("LLAMA_BUILD_SHARED_LIBS")
@@ -232,6 +238,15 @@ fn build() {
232238
debug_log!("OUT_DIR: {}", out_dir.display());
233239
debug_log!("BUILD_SHARED: {}", build_shared_libs);
234240

241+
if !patches_dst.exists() {
242+
debug_log!(
243+
"Copy {} to {}",
244+
patches_src.display(),
245+
patches_dst.display()
246+
);
247+
copy_folder(&patches_src, &patches_dst);
248+
}
249+
235250
if !bitnet_dst.exists() {
236251
debug_log!("Copy {} to {}", bitnet_src.display(), bitnet_dst.display());
237252
copy_folder(&bitnet_src, &bitnet_dst);
@@ -451,10 +466,11 @@ fn build() {
451466
}
452467

453468
fn apply_patch(patch_name: &str, output_dir: &str) {
454-
let src_dir = get_src_dir();
469+
// let src_dir = get_src_dir();
455470
let out_dir = get_out_dir();
456471

457-
let patches_dir = src_dir.join("patches");
472+
// let patches_dir = src_dir.join("patches");
473+
let patches_dir = out_dir.join(PATCHES_DIR);
458474

459475
let content = fs::read_to_string(patches_dir.join(patch_name)).unwrap();
460476
// uncomment this if you want to see atomic commits in the main git repo

bitnet-cpp/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bitnet-cpp"
33
description = "bitnet.cpp bindings for Rust"
4-
version = "0.0.3"
4+
version = "0.0.4"
55
edition = "2021"
66
license = "MIT"
77
repository = "https://github.com/eugenehp/bitnet-cpp-rs"
@@ -23,7 +23,7 @@ keywords = [
2323

2424
[dependencies]
2525
enumflags2 = "0.7.10"
26-
bitnet-cpp-sys = { path = "../bitnet-cpp-sys", version = "*" }
26+
bitnet-cpp-sys = { path = "../bitnet-cpp-sys", version = "0.0.4" }
2727
thiserror = { workspace = true }
2828
tracing = { workspace = true }
2929

0 commit comments

Comments
 (0)