Skip to content

Commit

Permalink
Location of dynamic libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
td202 committed Jan 18, 2024
1 parent ce83a27 commit e55feca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions concordium-consensus/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ library:
when:
- condition: "!(os(windows)) && !(flag(dynamic))"
ghc-options: -fPIC -static
src-dirs: src-lib
source-dirs: src-lib

# Other options might be needed, such has -dynamic -lHSrts or -lHSrts-ghc8.4.3
# Possibly this depends on the platform

verbatim: |
foreign-library concordium-consensus-lib
foreign-library concordium-consensus
type: native-shared
if os(Windows)
options: standalone
Expand Down
20 changes: 18 additions & 2 deletions concordium-node/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@ fn main() -> std::io::Result<()> {
println!("cargo:rustc-link-search=native={}", extra_library_dir);
}

println!("cargo:rustc-link-search=native=../concordium-consensus");
println!("cargo:rustc-link-lib=dylib=HSdll");
// We assume that the consensus library was built using the stack.yaml file in
// the root of the repository. (This is what the Windows build script does.)
let stack_install_root_command = command_output(Command::new("stack").args([
"--stack-yaml",
"../stack.yaml",
"path",
"--local-install-root",
]));
let stack_install_root = Path::new(&stack_install_root_command);
let dll_location = stack_install_root.join("lib");

println!("cargo:rustc-link-search=native={}", dll_location.to_string_lossy());
println!("cargo:rustc-link-lib=dylib=concordium-consensus");
}
#[cfg(not(windows))]
{
Expand All @@ -58,6 +69,7 @@ fn main() -> std::io::Result<()> {
return Err(e);
}
println!("cargo:rustc-link-search=native={}", root);
println!("cargo:rustc-link-lib=dylib=concordium-consensus");
println!("cargo:rustc-link-lib=dylib=HSconcordium-consensus-0.1.0.0");
println!("cargo:rustc-link-lib=dylib=HSconcordium-base-0.1.0.0");
println!("cargo:rustc-link-lib=dylib=HSlmdb-0.2.5");
Expand All @@ -70,6 +82,10 @@ fn main() -> std::io::Result<()> {
"--local-install-root",
]));
let stack_install_root = Path::new(&stack_install_root_command);
let stack_install_lib = stack_install_root.join("lib");

println!("cargo:rustc-link-search={}", stack_install_lib.to_string_lossy());
println!("cargo:rustc-link-lib=dylib=concordium-consensus");

let local_package = stack_install_root.join("lib").join(GHC_VARIANT);
let dir = std::fs::read_dir(&local_package)?;
Expand Down

0 comments on commit e55feca

Please sign in to comment.