Skip to content

Commit 3f99219

Browse files
committed
add static linking support for windows
1 parent 58b5a29 commit 3f99219

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ extension = []
4343
# Otherwise, links statically to `libsciter-gtk.so` or `libsciter.dylib`.
4444
dynamic = []
4545

46+
# Only for windows static linking
47+
skia = []
48+
4649
# Build this crate specifically for Sciter.Lite versions
4750
# which are incompatible with the regular ones.
4851
windowless = []

build.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#[cfg(all(windows, not(feature = "dynamic")))]
2+
fn main() {
3+
use std::{env, path::PathBuf};
4+
if let Ok(path) = env::var("SCITER_STATIC_LIBRARY") {
5+
let lib_dir = PathBuf::from(path);
6+
println!("cargo:rustc-link-search=native={}", lib_dir.display());
7+
println!("cargo:rustc-link-lib=static:-bundle={}", "sciter.static");
8+
if cfg!(feature = "skia") {
9+
println!("cargo:rustc-link-lib=static:-bundle={}", "atls");
10+
}
11+
println!("cargo:rustc-link-lib={}", "Comdlg32");
12+
println!("cargo:rustc-link-lib={}", "windowscodecs");
13+
println!("cargo:rustc-link-lib={}", "Wininet");
14+
} else {
15+
println!("cargo:warning=Set SCITER_STATIC_LIBRARY to link static library");
16+
}
17+
18+
}
19+
20+
#[cfg(not(all(windows, not(feature = "dynamic"))))]
21+
fn main() {}

src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub use capi::scapi::{ISciterAPI};
129129
use capi::scgraphics::SciterGraphicsAPI;
130130
use capi::screquest::SciterRequestAPI;
131131

132-
#[cfg(windows)]
132+
#[cfg(all(windows, feature = "dynamic"))]
133133
mod ext {
134134
// Note:
135135
// Sciter 4.x shipped with universal "sciter.dll" library for different builds:
@@ -217,6 +217,13 @@ mod ext {
217217
}
218218
}
219219

220+
#[cfg(all(windows, not(feature = "dynamic")))]
221+
mod ext {
222+
use capi::scapi::{ISciterAPI};
223+
224+
extern "C" { pub fn SciterAPI() -> *const ISciterAPI; }
225+
}
226+
220227
#[cfg(all(feature = "dynamic", unix))]
221228
mod ext {
222229
#![allow(non_snake_case, non_camel_case_types)]

0 commit comments

Comments
 (0)