Skip to content

Commit

Permalink
add static linking support for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Nov 20, 2021
1 parent 58b5a29 commit 3f99219
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ extension = []
# Otherwise, links statically to `libsciter-gtk.so` or `libsciter.dylib`.
dynamic = []

# Only for windows static linking
skia = []

# Build this crate specifically for Sciter.Lite versions
# which are incompatible with the regular ones.
windowless = []
Expand Down
21 changes: 21 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#[cfg(all(windows, not(feature = "dynamic")))]
fn main() {
use std::{env, path::PathBuf};
if let Ok(path) = env::var("SCITER_STATIC_LIBRARY") {
let lib_dir = PathBuf::from(path);
println!("cargo:rustc-link-search=native={}", lib_dir.display());
println!("cargo:rustc-link-lib=static:-bundle={}", "sciter.static");
if cfg!(feature = "skia") {
println!("cargo:rustc-link-lib=static:-bundle={}", "atls");
}
println!("cargo:rustc-link-lib={}", "Comdlg32");
println!("cargo:rustc-link-lib={}", "windowscodecs");
println!("cargo:rustc-link-lib={}", "Wininet");
} else {
println!("cargo:warning=Set SCITER_STATIC_LIBRARY to link static library");
}

}

#[cfg(not(all(windows, not(feature = "dynamic"))))]
fn main() {}
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub use capi::scapi::{ISciterAPI};
use capi::scgraphics::SciterGraphicsAPI;
use capi::screquest::SciterRequestAPI;

#[cfg(windows)]
#[cfg(all(windows, feature = "dynamic"))]
mod ext {
// Note:
// Sciter 4.x shipped with universal "sciter.dll" library for different builds:
Expand Down Expand Up @@ -217,6 +217,13 @@ mod ext {
}
}

#[cfg(all(windows, not(feature = "dynamic")))]
mod ext {
use capi::scapi::{ISciterAPI};

extern "C" { pub fn SciterAPI() -> *const ISciterAPI; }
}

#[cfg(all(feature = "dynamic", unix))]
mod ext {
#![allow(non_snake_case, non_camel_case_types)]
Expand Down

0 comments on commit 3f99219

Please sign in to comment.