Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add static link support #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
29 changes: 29 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#[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());
if cfg!(feature = "nightly") {
// -bundle allow msvc linker link the library with ltcg
// this is a nightly feature now: https://github.com/rust-lang/rust/issues/81490
println!("cargo:rustc-link-lib=static:-bundle={}", "sciter.static");
if cfg!(feature = "skia") {
println!("cargo:rustc-link-lib=static:-bundle={}", "atls");
}
} else {
println!("cargo:rustc-link-lib=static={}", "sciter.static");
if cfg!(feature = "skia") {
println!("cargo:rustc-link-lib=static={}", "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