summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/client/gtkbind
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /toolkit/crashreporter/client/gtkbind
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/crashreporter/client/gtkbind')
-rw-r--r--toolkit/crashreporter/client/gtkbind/Cargo.toml8
-rw-r--r--toolkit/crashreporter/client/gtkbind/build.rs43
-rw-r--r--toolkit/crashreporter/client/gtkbind/src/lib.rs9
3 files changed, 60 insertions, 0 deletions
diff --git a/toolkit/crashreporter/client/gtkbind/Cargo.toml b/toolkit/crashreporter/client/gtkbind/Cargo.toml
new file mode 100644
index 0000000000..813d43dbe3
--- /dev/null
+++ b/toolkit/crashreporter/client/gtkbind/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "gtkbind"
+version = "0.1.0"
+edition = "2021"
+
+[build-dependencies]
+bindgen = { version = "0.69.0", default-features = false, features = ["runtime"] }
+mozbuild = "0.1.0"
diff --git a/toolkit/crashreporter/client/gtkbind/build.rs b/toolkit/crashreporter/client/gtkbind/build.rs
new file mode 100644
index 0000000000..fa3402fdf2
--- /dev/null
+++ b/toolkit/crashreporter/client/gtkbind/build.rs
@@ -0,0 +1,43 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use mozbuild::config::{
+ CC_BASE_FLAGS as CFLAGS, MOZ_GTK3_CFLAGS as GTK_CFLAGS, MOZ_GTK3_LIBS as GTK_LIBS,
+};
+
+const HEADER: &str = r#"
+#include "gtk/gtk.h"
+#include "pango/pango.h"
+#include "gdk-pixbuf/gdk-pixbuf.h"
+"#;
+
+fn main() {
+ let bindings = bindgen::Builder::default()
+ .header_contents("gtk_bindings.h", HEADER)
+ .clang_args(CFLAGS)
+ .clang_args(GTK_CFLAGS)
+ .allowlist_function("gtk_.*")
+ .allowlist_function(
+ "g_(application|main_context|memory_input_stream|object|signal|timeout)_.*",
+ )
+ .allowlist_function("gdk_pixbuf_new_from_stream")
+ .allowlist_function("pango_attr_.*")
+ // The gtk/glib valist functions generate FFI-unsafe signatures on aarch64 which cause
+ // compile errors. We don't use them anyway.
+ .blocklist_function(".*_valist")
+ .derive_default(true)
+ .generate()
+ .expect("unable to generate gtk bindings");
+ for flag in GTK_LIBS {
+ if let Some(lib) = flag.strip_prefix("-l") {
+ println!("cargo:rustc-link-lib={lib}");
+ } else if let Some(path) = flag.strip_prefix("-L") {
+ println!("cargo:rustc-link-search={path}");
+ }
+ }
+ let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
+ bindings
+ .write_to_file(out_path.join("gtk_bindings.rs"))
+ .expect("failed to write gtk bindings");
+}
diff --git a/toolkit/crashreporter/client/gtkbind/src/lib.rs b/toolkit/crashreporter/client/gtkbind/src/lib.rs
new file mode 100644
index 0000000000..714f3ed047
--- /dev/null
+++ b/toolkit/crashreporter/client/gtkbind/src/lib.rs
@@ -0,0 +1,9 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+#![allow(non_upper_case_globals)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+
+include!(concat!(env!("OUT_DIR"), "/gtk_bindings.rs"));