An extremely minimal subset of Monero is now all that's built, and I'm 
sufficiently happy with it.
This commit is contained in:
Luke Parker
2022-07-09 21:51:39 -04:00
parent 53267a46c8
commit 854fca3806
5 changed files with 121 additions and 98 deletions

View File

@@ -14,7 +14,6 @@ fn main() {
// Use a file to signal if Monero was already built, as that should never be rebuilt
// If the signaling file was deleted, run this script again to rebuild Monero though
// TODO: Move this signaling file into OUT_DIR once Monero is built statically successfully
println!("cargo:rerun-if-changed=c/.build/monero");
if !Path::new("c/.build/monero").exists() {
if !Command::new("make").arg(format!("-j{}", &env::var("THREADS").unwrap_or("2".to_string())))
@@ -28,81 +27,46 @@ fn main() {
}
}
println!("cargo:rerun-if-env-changed=OUT_DIR");
if !Path::new(
&format!(
"{}/{}cncrypto.{}",
out_dir,
&env::consts::DLL_PREFIX,
&env::consts::DLL_EXTENSION
)
).exists() {
let mut paths = vec![
"c/monero/build/release/contrib/epee/src/libepee.a".to_string(),
"c/monero/build/release/external/easylogging++/libeasylogging.a".to_string(),
"c/monero/build/release/external/randomx/librandomx.a".to_string()
];
for (folder, lib) in [
("common", "common"),
("crypto", "cncrypto"),
("crypto/wallet", "wallet-crypto"),
("cryptonote_basic", "cryptonote_basic"),
("cryptonote_basic", "cryptonote_format_utils_basic"),
("", "version"),
("device", "device"),
("ringct", "ringct_basic"),
("ringct", "ringct")
] {
paths.push(
format!(
"c/monero/build/release/src/{}/{}{}.a",
folder,
&env::consts::DLL_PREFIX,
lib
)
);
}
for path in paths {
if !Command::new("cp").args(&[&path, out_dir]).status().unwrap().success() {
panic!("Failed to cp {}", path);
}
}
}
println!("cargo:rerun-if-changed=c/wrapper.cpp");
if !Path::new(&format!("{}/{}wrapper.a", out_dir, &env::consts::DLL_PREFIX)).exists() {
cc::Build::new()
.file("c/wrapper.cpp")
.cpp(true)
.warnings(false)
.include("c/monero/contrib/epee/include")
.include("c/monero/src")
.compile("wrapper");
}
cc::Build::new()
.static_flag(true)
.warnings(false)
.extra_warnings(false)
.flag("-Wno-deprecated-declarations")
.include("c/monero/external/supercop/include")
.include("c/monero/contrib/epee/include")
.include("c/monero/src")
.include("c/monero/build/release/generated_include")
.define("AUTO_INITIALIZE_EASYLOGGINGPP", None)
.include("c/monero/external/easylogging++")
.file("c/monero/external/easylogging++/easylogging++.cc")
.file("c/monero/src/common/aligned.c")
.file("c/monero/src/common/perf_timer.cpp")
.include("c/monero/src/crypto")
.file("c/monero/src/crypto/crypto-ops-data.c")
.file("c/monero/src/crypto/crypto-ops.c")
.file("c/monero/src/crypto/keccak.c")
.file("c/monero/src/crypto/hash.c")
.include("c/monero/src/device")
.file("c/monero/src/device/device_default.cpp")
.include("c/monero/src/ringct")
.file("c/monero/src/ringct/rctCryptoOps.c")
.file("c/monero/src/ringct/rctTypes.cpp")
.file("c/monero/src/ringct/rctOps.cpp")
.file("c/monero/src/ringct/multiexp.cc")
.file("c/monero/src/ringct/bulletproofs.cc")
.file("c/monero/src/ringct/rctSigs.cpp")
.file("c/wrapper.cpp")
.compile("wrapper");
println!("cargo:rustc-link-search={}", out_dir);
println!("cargo:rustc-link-lib=wrapper");
println!("cargo:rustc-link-lib=ringct");
println!("cargo:rustc-link-lib=ringct_basic");
println!("cargo:rustc-link-lib=device");
println!("cargo:rustc-link-lib=cryptonote_basic");
println!("cargo:rustc-link-lib=cncrypto");
println!("cargo:rustc-link-lib=cryptonote_format_utils_basic");
println!("cargo:rustc-link-lib=version");
println!("cargo:rustc-link-lib=wallet-crypto");
println!("cargo:rustc-link-lib=easylogging");
println!("cargo:rustc-link-lib=epee");
println!("cargo:rustc-link-lib=common");
println!("cargo:rustc-link-lib=randomx");
println!("cargo:rustc-link-lib=unbound");
println!("cargo:rustc-link-lib=sodium");
println!("cargo:rustc-link-lib=boost_system");
println!("cargo:rustc-link-lib=boost_thread");
println!("cargo:rustc-link-lib=boost_filesystem");
println!("cargo:rustc-link-lib=hidapi-hidraw");
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-arg=-zmuldefs");
}