-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate link attribute only for msvc
- Loading branch information
Showing
19 changed files
with
55 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[build-dependencies] | ||
system-deps = "7" | ||
pkg-config = "0.3" | ||
|
||
[dependencies] | ||
libc = "0.2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::{env, fs::File, io::Write, path::Path}; | ||
|
||
pub fn main() { | ||
let deps = system_deps::Config::new() | ||
.probe() | ||
.expect("if this module is called, this is valid"); | ||
|
||
let out_dir = env::var("OUT_DIR").unwrap(); | ||
let out_path = Path::new(&out_dir).join("param_spec.rs"); | ||
|
||
// Generating a link attribute is necessary in windows | ||
// (see https://rust-lang.github.io/rfcs/1717-dllimport.html#drawbacks) | ||
// even if we are already linking with system_deps. | ||
// We allow configuration of the library name from upstream dependents | ||
// using the alias variable in the pkgconfig file. | ||
let lib_name = deps | ||
.iter() | ||
.into_iter() | ||
.filter_map(|(_, l)| pkg_config::get_variable(&l.name, "alias").ok()) | ||
.find(|s| !s.is_empty()) | ||
.unwrap_or("gobject-2.0".into()); | ||
let link = if cfg!(target_os = "windows") { | ||
format!("#[link(name = \"{}\")]", lib_name) | ||
} else { | ||
"".into() | ||
}; | ||
|
||
let code = format!("{link} extern \"C\" {{ pub static g_param_spec_types: *const GType; }}"); | ||
let mut f = File::create(&out_path).unwrap(); | ||
f.write_all(code.as_bytes()).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
// Take a look at the license at the top of the repository in the LICENSE file. | ||
|
||
use glib_sys::GType; | ||
|
||
extern "C" { | ||
#[cfg_attr(target_os = "windows", link_name = "__imp_g_param_spec_types")] | ||
pub static g_param_spec_types: *const GType; | ||
} | ||
// `g_param_spec_types` extern binding generated by build.rs | ||
include!(concat!(env!("OUT_DIR"), "/param_spec.rs")); | ||
|
||
// SAFETY: This should be safe as long as the offset added to g_param_spec_types is in bounds. | ||
/// # Safety | ||
/// This should be safe as long as the offset added to g_param_spec_types is in bounds. | ||
pub unsafe fn g_param_spec_types_get_type(offset: usize) -> GType { | ||
*g_param_spec_types.add(offset) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Generated by gir (https://github.com/gtk-rs/gir @ 37c4bce0892f) | ||
Generated by gir (https://github.com/gtk-rs/gir @ d2ee14efdb8b) | ||
from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) |