Skip to content

Commit

Permalink
Clean up build scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaranov34 committed Nov 22, 2024
1 parent 8c306ae commit 4001aad
Showing 1 changed file with 41 additions and 26 deletions.
67 changes: 41 additions & 26 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ fn build_tonlibjson(cmake_build_type: &str) {
let mut dst = cfg
.configure_arg("-DTON_ONLY_TONLIB=true")
.configure_arg("-DBUILD_SHARED_LIBS=false")
.define("TON_ONLY_TONLIB", "ON")
.define("TON_ONLY_TONLIB", "OFF")
.define("BUILD_SHARED_LIBS", "OFF")
.define("PORTABLE", "1")
.define("CMAKE_BUILD_TYPE", cmake_build_type)
// .define("_GLIBCXX_USE_CXX11_ABI", "1")
.define("CMAKE_C_FLAGS", "-w")
.define("CMAKE_CXX_FLAGS", "-w")
// multi-thread build used to fail compilation. Please try comment out next 2 lines if you have build errors
.build_arg("-j")
.build_arg(available_parallelism().unwrap().get().to_string())
Expand Down Expand Up @@ -179,30 +180,35 @@ fn build_tonlibjson(cmake_build_type: &str) {
dst.display()
);
println!("cargo:rustc-link-lib=static=keys");
println!("cargo:rerun-if-changed={}/build/keys", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/lite-client",
dst.display()
);
println!("cargo:rustc-link-lib=static=lite-client-common");
println!("cargo:rerun-if-changed={}/build/lite-client", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/adnl",
dst.display()
);
println!("cargo:rustc-link-lib=static=adnllite");
println!("cargo:rerun-if-changed={}/build/adnl", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/tdactor",
dst.display()
);
println!("cargo:rustc-link-lib=static=tdactor");
println!("cargo:rerun-if-changed={}/build/tdactor", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/tdutils",
dst.display()
);
println!("cargo:rustc-link-lib=static=tdutils");
println!("cargo:rerun-if-changed={}/build/tdutils", dst.display());

println!("cargo:rustc-link-lib=dylib=sodium");
println!("cargo:rustc-link-lib=dylib=secp256k1");
Expand All @@ -212,24 +218,7 @@ fn build_tonlibjson(cmake_build_type: &str) {
println!("cargo:rustc-link-lib=static=tl_api");
println!("cargo:rustc-link-lib=static=tl_tonlib_api_json");
println!("cargo:rustc-link-lib=static=tl_tonlib_api");

println!(
"cargo:rustc-link-search=native={}/build/keys",
dst.display()
);
println!("cargo:rustc-link-lib=static=keys");

println!(
"cargo:rustc-link-search=native={}/build/lite-client",
dst.display()
);
println!("cargo:rustc-link-lib=static=lite-client-common");

println!(
"cargo:rustc-link-search=native={}/build/adnl",
dst.display()
);
println!("cargo:rustc-link-lib=static=adnllite");
println!("cargo:rerun-if-changed={}/build/tl", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/tdnet",
Expand All @@ -242,6 +231,7 @@ fn build_tonlibjson(cmake_build_type: &str) {
dst.display()
);
println!("cargo:rustc-link-lib=static=tl-utils");
println!("cargo:rerun-if-changed={}/build/tl-utils", dst.display());
println!("cargo:rustc-link-lib=static=tl-lite-utils");

println!(
Expand All @@ -253,6 +243,8 @@ fn build_tonlibjson(cmake_build_type: &str) {
println!("cargo:rustc-link-lib=static=ton_crypto");
println!("cargo:rustc-link-lib=static=ton_crypto_core");

println!("cargo:rerun-if-changed={}/build/crypto", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/tddb",
dst.display()
Expand All @@ -264,12 +256,20 @@ fn build_tonlibjson(cmake_build_type: &str) {
dst.display()
);
println!("cargo:rustc-link-lib=static=crc32c");
println!(
"cargo:rerun-if-changed={}/build/third-party/crc32c",
dst.display()
);

println!(
"cargo:rustc-link-search=native={}/build/third-party/blst",
dst.display()
);
println!("cargo:rustc-link-lib=static=blst");
println!(
"cargo:rerun-if-changed={}/build/third-party/blst",
dst.display()
);

println!("cargo:rustc-link-lib=static=z");
println!("cargo:rustc-link-lib=static=crypto");
Expand All @@ -280,6 +280,7 @@ fn build_tonlibjson(cmake_build_type: &str) {
dst.display()
);
println!("cargo:rustc-link-lib=static=emulator_static");
println!("cargo:rerun-if-changed={}/build/emulator", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/tonlib",
Expand All @@ -299,7 +300,8 @@ fn build_emulator(cmake_build_type: &str) {
.define("BUILD_SHARED_LIBS", "OFF")
.define("PORTABLE", "1")
.define("CMAKE_BUILD_TYPE", cmake_build_type)
// .define("_GLIBCXX_USE_CXX11_ABI", "1")
.define("CMAKE_C_FLAGS", "-w")
.define("CMAKE_CXX_FLAGS", "-w")
// multi-thread build used to fail compilation. Please try comment out next 2 lines if you have build errors
.build_arg("-j")
.build_arg(available_parallelism().unwrap().get().to_string())
Expand All @@ -320,18 +322,26 @@ fn build_emulator(cmake_build_type: &str) {
println!("cargo:rustc-link-lib=dylib=stdc++");
println!("cargo:rustc-link-arg=-lstdc++");
}
println!(
"cargo:rustc-link-search=native={}/build/tdutils",
dst.display()
);
println!("cargo:rustc-link-lib=static=tdutils");
println!("cargo:rerun-if-changed={}/build/tdutils", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/keys",
dst.display()
);
println!("cargo:rustc-link-lib=static=keys");
println!("cargo:rerun-if-changed={}/build/keys", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/lite-client",
dst.display()
);
println!("cargo:rustc-link-lib=static=lite-client-common");
println!("cargo:rerun-if-changed={}/build/lite-client", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/adnl",
Expand Down Expand Up @@ -368,6 +378,7 @@ fn build_emulator(cmake_build_type: &str) {
println!("cargo:rustc-link-lib=static=tl_api");
println!("cargo:rustc-link-lib=static=tl_tonlib_api_json");
println!("cargo:rustc-link-lib=static=tl_tonlib_api");
println!("cargo:rerun-if-changed={}/build/tl", dst.display());

println!(
"cargo:rustc-link-search=native={}/build/keys",
Expand Down Expand Up @@ -403,20 +414,24 @@ fn build_emulator(cmake_build_type: &str) {
dst.display()
);
println!("cargo:rustc-link-lib=static=crc32c");
println!(
"cargo:rerun-if-changed={}/build/third-party/crc32c",
dst.display()
);

println!(
"cargo:rustc-link-search=native={}/build/third-party/blst",
dst.display()
);
println!("cargo:rustc-link-lib=static=blst");
println!(
"cargo:rerun-if-changed={}/build/third-party/blst",
dst.display()
);

println!("cargo:rustc-link-lib=static=z");
println!("cargo:rustc-link-lib=static=crypto");
println!("cargo:rustc-link-lib=static=dl");

println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
println!("cargo:rustc-link-search=native=/usr/include");
println!("cargo:rustc-link-search=native=/lib/x86_64-linux-gnu");

println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
println!("cargo:rustc-link-search=native=/usr/include");
println!("cargo:rustc-link-search=native=/lib/x86_64-linux-gnu");
Expand Down

0 comments on commit 4001aad

Please sign in to comment.