Skip to content

Commit df58d90

Browse files
committed
detect static library and regenerate gir
1 parent 18becdb commit df58d90

File tree

19 files changed

+54
-33
lines changed

19 files changed

+54
-33
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gdk-pixbuf/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

gdk-pixbuf/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

gio/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

gio/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

glib/gobject-sys/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[build-dependencies]
22
system-deps = "7"
3-
pkg-config = "0.3"
43

54
[dependencies]
65
libc = "0.2"
@@ -29,7 +28,7 @@ v2_82 = ["v2_80"]
2928
name = "gobject_sys"
3029

3130
[package]
32-
build = "build.rs"
31+
build = "build_manual.rs"
3332
description = "FFI bindings to libgobject-2.0"
3433
keywords = ["gobject", "ffi", "gtk-rs", "gnome"]
3534
name = "gobject-sys"
@@ -99,3 +98,7 @@ version = "2.81"
9998
rustc-args = ["--cfg", "docsrs"]
10099
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
101100
all-features = true
101+
102+
[lints.rust.unexpected_cfgs]
103+
level = "warn"
104+
check-cfg = ["cfg(msvc_dll)"]

glib/gobject-sys/build_manual.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#[cfg(docsrs)]
2+
fn main() {} // prevent linking libraries to avoid documentation failure
3+
4+
#[cfg(not(docsrs))]
5+
fn main() {
6+
match system_deps::Config::new().probe() {
7+
Ok(deps) => {
8+
let msvc = std::env::var("CARGO_CFG_TARGET_ENV")
9+
.expect("Cargo should set this variable")
10+
== "msvc";
11+
let lib = deps
12+
.get_by_name("gobject_2_0")
13+
.expect("The dependency key for gobject in its Cargo.toml should not change");
14+
if msvc && !lib.statik {
15+
println!("cargo:rustc-cfg=msvc_dll");
16+
}
17+
}
18+
Err(s) => {
19+
println!("cargo:warning={s}");
20+
std::process::exit(1);
21+
}
22+
}
23+
}

glib/gobject-sys/src/manual.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
use glib_sys::GType;
22

3-
#[cfg(not(target_os = "windows"))]
3+
#[cfg(not(msvc_dll))]
44
type GParamSpecType = *const GType;
55

6-
#[cfg(target_os = "windows")]
6+
#[cfg(msvc_dll)]
77
type GParamSpecType = *const *const GType;
88

9+
// When using MSVC, variables marked with dllexport only have the load time linking version
10+
// (prefixed by `__imp_`) publicly exported in the library. This means that it is necessary to either
11+
// call dllimport those symbols (in Rust, this only happens when using the `#[link]` attribute), or
12+
// to manually link to the `__imp_` version when using dynamic libraries. Since we need more customization
13+
// of the library name than the link attribute currently allows, we choose the second option.
914
extern "C" {
10-
#[cfg_attr(target_os = "windows", link_name = "__imp_g_param_spec_types")]
15+
#[cfg_attr(msvc_dll, link_name = "__imp_g_param_spec_types")]
1116
static g_param_spec_types: GParamSpecType;
1217
}
1318

1419
/// # Safety
1520
/// This should be safe as long as the offset added to g_param_spec_types is in bounds.
1621
pub unsafe fn g_param_spec_types_get_type(offset: usize) -> GType {
17-
#[cfg(not(target_os = "windows"))]
22+
#[cfg(not(msvc_dll))]
1823
let ptr = g_param_spec_types;
1924

20-
// One more step of indirection on windows because of the __imp_ prefix
21-
#[cfg(target_os = "windows")]
25+
// One more step of indirection on windows because `__imp_` signifies a pointer to the
26+
// underlying symbol https://learn.microsoft.com/en-us/windows/win32/dlls/load-time-dynamic-linking.
27+
#[cfg(msvc_dll)]
2228
let ptr = *g_param_spec_types;
2329

2430
*ptr.add(offset)

glib/gobject-sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

glib/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

glib/sys/Cargo.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ version = "2.80"
9999
[package.metadata.system-deps.glib_2_0.v2_82]
100100
version = "2.81"
101101

102-
[package.metadata.system-deps.gobject_2_0]
103-
name = "gobject-2.0"
104-
version = "2.56"
105-
106-
[package.metadata.system-deps.gobject_2_0.v2_58]
107-
version = "2.58"
108-
109-
[package.metadata.system-deps.gobject_2_0.v2_62]
110-
version = "2.62"
111-
112102
[package.metadata.docs.rs]
113103
rustc-args = ["--cfg", "docsrs"]
114104
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]

glib/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

graphene/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

graphene/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

pango/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

pango/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

pangocairo/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

pangocairo/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ f0a4546b0a06)
1+
Generated by gir (https://github.com/gtk-rs/gir @ ea1ee40bf933)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)

0 commit comments

Comments
 (0)