summaryrefslogtreecommitdiffstats
path: root/toolkit/library/rust
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/library/rust
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/library/rust')
-rw-r--r--toolkit/library/rust/Cargo.toml31
-rw-r--r--toolkit/library/rust/gkrust-features.mozbuild84
-rw-r--r--toolkit/library/rust/lib.rs9
-rw-r--r--toolkit/library/rust/moz.build58
-rw-r--r--toolkit/library/rust/shared/Cargo.toml165
-rw-r--r--toolkit/library/rust/shared/lib.rs160
6 files changed, 507 insertions, 0 deletions
diff --git a/toolkit/library/rust/Cargo.toml b/toolkit/library/rust/Cargo.toml
new file mode 100644
index 0000000000..a7eee7999d
--- /dev/null
+++ b/toolkit/library/rust/Cargo.toml
@@ -0,0 +1,31 @@
+[package]
+name = "gkrust"
+version = "0.1.0"
+authors = ["The Mozilla Project Developers"]
+license = "MPL-2.0"
+description = "Rust code for libxul"
+
+[dependencies]
+gkrust-shared = { path = "shared" }
+mozilla-central-workspace-hack = { path = "../../../build/workspace-hack" }
+
+# Workarounds for https://github.com/rust-lang/rust/issues/58393
+mozglue-static = { path = "../../../mozglue/static/rust" }
+swgl = { path = "../../../gfx/wr/swgl" }
+lmdb-rkv-sys = "0.11"
+
+[dev-dependencies]
+stylo_tests = { path = "../../../servo/ports/geckolib/tests/" }
+
+[lib]
+path = "lib.rs"
+crate-type = ["staticlib"]
+test = false
+doctest = false
+bench = false
+doc = false
+plugin = false
+harness = false
+
+[package.metadata.cargo-udeps.ignore]
+normal = ["mozilla-central-workspace-hack"]
diff --git a/toolkit/library/rust/gkrust-features.mozbuild b/toolkit/library/rust/gkrust-features.mozbuild
new file mode 100644
index 0000000000..4e12307b38
--- /dev/null
+++ b/toolkit/library/rust/gkrust-features.mozbuild
@@ -0,0 +1,84 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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 http://mozilla.org/MPL/2.0/.
+
+gkrust_features = []
+
+if CONFIG['MOZ_DEBUG']:
+ gkrust_features += [
+ 'gecko_debug',
+ 'gecko_refcount_logging',
+ ]
+
+if CONFIG['MOZ_TSAN']:
+ gkrust_features += ['thread_sanitizer']
+
+if CONFIG['MOZ_WEBRENDER_DEBUGGER']:
+ gkrust_features += ['webrender_debugger']
+
+if CONFIG['MOZ_PULSEAUDIO']:
+ gkrust_features += ['cubeb_pulse_rust']
+
+if CONFIG['MOZ_AUDIOUNIT_RUST']:
+ gkrust_features += ['cubeb_coreaudio_rust']
+
+if CONFIG['MOZ_RUST_SIMD']:
+ gkrust_features += ['simd-accel']
+
+# This feature is not yet supported on all platforms, and this check needs to
+# match MOZ_CUBEB_REMOTING in CubebUtils.cpp.
+if (CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android') or CONFIG['OS_ARCH'] == 'Darwin' or (CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CPU_ARCH'] != 'aarch64'):
+ gkrust_features += ['cubeb-remoting']
+
+if CONFIG['MOZ_MEMORY']:
+ gkrust_features += ['moz_memory']
+
+if CONFIG['MOZ_PLACES']:
+ gkrust_features += ['moz_places']
+
+if CONFIG['JS_ENABLE_SMOOSH']:
+ gkrust_features += ['smoosh']
+
+if CONFIG['MOZ_GECKO_PROFILER']:
+ gkrust_features += ['gecko_profiler']
+
+if CONFIG['MOZ_GECKO_PROFILER_PARSE_ELF']:
+ gkrust_features += ['gecko_profiler_parse_elf']
+
+if CONFIG['MOZ_BITS_DOWNLOAD']:
+ gkrust_features += ['bitsdownload']
+
+if CONFIG['MOZ_NEW_XULSTORE']:
+ gkrust_features += ['new_xulstore']
+
+if CONFIG['LIBFUZZER']:
+ gkrust_features += ['libfuzzer']
+
+if CONFIG['MOZ_WEBRTC']:
+ gkrust_features += ['webrtc']
+
+# We need to tell Glean it is being built with Gecko.
+gkrust_features += ['glean_with_gecko']
+
+if not CONFIG['MOZILLA_OFFICIAL']:
+ gkrust_features += ['glean_disable_upload']
+
+if CONFIG['OS_TARGET'] != 'Android':
+ gkrust_features += ['glean_million_queue']
+
+if CONFIG['MOZ_ENABLE_DBUS']:
+ gkrust_features += ['with_dbus']
+
+if CONFIG["MOZ_CRASHREPORTER"] and CONFIG['MOZ_OXIDIZED_BREAKPAD']:
+ gkrust_features += ['oxidized_breakpad']
+
+if CONFIG["MOZ_WEBMIDI_MIDIR_IMPL"]:
+ gkrust_features += ['webmidi_midir_impl']
+
+if CONFIG["MOZ_UNIFFI_FIXTURES"]:
+ gkrust_features += ['uniffi_fixtures']
+
+# This must remain last.
+gkrust_features = ["gkrust-shared/%s" % f for f in gkrust_features]
diff --git a/toolkit/library/rust/lib.rs b/toolkit/library/rust/lib.rs
new file mode 100644
index 0000000000..815413a5da
--- /dev/null
+++ b/toolkit/library/rust/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 http://mozilla.org/MPL/2.0/.
+
+// You should not be adding code to this crate; you will almost certainly
+// get link errors when linking libxul-gtest. Add any |extern crate|
+// declarations or similar to the gkrust-shared crate in
+// toolkit/library/rust/shared/lib.rs.
+extern crate gkrust_shared;
diff --git a/toolkit/library/rust/moz.build b/toolkit/library/rust/moz.build
new file mode 100644
index 0000000000..ce34acec1f
--- /dev/null
+++ b/toolkit/library/rust/moz.build
@@ -0,0 +1,58 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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 http://mozilla.org/MPL/2.0/.
+
+include("gkrust-features.mozbuild")
+
+RustLibrary("gkrust", gkrust_features, is_gkrust=True)
+
+for feature in gkrust_features:
+ # We don't want to enable refcount logging during rusttests, since the
+ # relevant FFI symbols wouldn't be found.
+ # Nor do we want Glean to assume there are Gecko symbols.
+ if feature not in (
+ "gkrust-shared/gecko_refcount_logging",
+ "gkrust-shared/glean_with_gecko",
+ ):
+ RUST_TEST_FEATURES.append(feature)
+
+# Target directory doesn't matter a lot here, since we can't share panic=abort
+# compilation artifacts with gkrust.
+RUST_TESTS = [
+ "fog",
+ "l10nregistry",
+ "selectors",
+ "servo_arc",
+ "qcms",
+ # this does nothing, but is needed so that `gkrust_features` are recognized
+ # also see: https://github.com/rust-lang/cargo/issues/9856
+ "gkrust",
+]
+
+# Code coverage builds link a bunch of Gecko bindings code from the style
+# crate, which is not used by our tests but would cause link errors.
+#
+# Bug 1768874 tracks improving the setup to potentially remove these
+# altogether.
+if not CONFIG["MOZ_CODE_COVERAGE"]:
+ RUST_TESTS += ["stylo_tests"]
+ # Same happens for the style tests, except the windows linker is not great
+ # at eliminating dead code, so we end up with some missing symbols too.
+ if CONFIG["OS_TARGET"] != "WINNT":
+ RUST_TESTS += ["style"]
+
+if CONFIG["CPU_ARCH"] != "x86":
+ # malloc_size_of_derive is a build dependency, so if we are doing
+ # cross-compile for x86, this may not run correctly.
+ RUST_TESTS += ["malloc_size_of_derive"]
+
+if CONFIG["MOZ_BITS_DOWNLOAD"]:
+ RUST_TESTS += ["bits_client"]
+
+# Export the `rure` crate's included .h file. The symbols defined in that file
+# will be exported from the `gkrust-shared` crate.
+EXPORTS += [
+ "/third_party/rust/rure/include/rure.h",
+]
diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml
new file mode 100644
index 0000000000..dc46604068
--- /dev/null
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -0,0 +1,165 @@
+
+[package]
+name = "gkrust-shared"
+version = "0.1.0"
+authors = ["The Mozilla Project Developers"]
+license = "MPL-2.0"
+description = "Shared Rust code for libxul"
+
+[dependencies]
+moz_asserts = "0.1"
+mozglue-static = { path = "../../../../mozglue/static/rust" }
+geckoservo = { path = "../../../../servo/ports/geckolib" }
+kvstore = { path = "../../../components/kvstore" }
+lmdb-rkv-sys = { version = "0.11", features = ["mdb_idl_logn_9"] }
+mp4parse_capi = { git = "https://github.com/mozilla/mp4parse-rust", rev = "3bfc47d9a571d0842676043ba60716318e946c06", features = ["missing-pixi-permitted"] }
+nserror = { path = "../../../../xpcom/rust/nserror" }
+nsstring = { path = "../../../../xpcom/rust/nsstring" }
+netwerk_helper = { path = "../../../../netwerk/base/rust-helper" }
+xpcom = { path = "../../../../xpcom/rust/xpcom" }
+prefs_parser = { path = "../../../../modules/libpref/parser" }
+static_prefs = { path = "../../../../modules/libpref/init/static_prefs" }
+profiler_helper = { path = "../../../../tools/profiler/rust-helper", optional = true }
+mozurl = { path = "../../../../netwerk/base/mozurl" }
+webrender_bindings = { path = "../../../../gfx/webrender_bindings" }
+cubeb-coreaudio = { git = "https://github.com/mozilla/cubeb-coreaudio-rs", rev = "93b5c01a131f65c83c11aeb317f4583405c5eb79", optional = true }
+cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="cf48897be5cbe147d051ebbbe1eaf5fd8fb6bbc9", optional = true, features=["pulse-dlopen"] }
+cubeb-sys = { version = "0.10.3", optional = true, features=["gecko-in-tree"] }
+audioipc2-client = { git = "https://github.com/kinetiknz/audioipc-2", rev = "42eb59ab3b86cd43d3dbe37d159ce102a8eaf2a5", optional = true } # macos (v2) branch
+audioipc2-server = { git = "https://github.com/kinetiknz/audioipc-2", rev = "42eb59ab3b86cd43d3dbe37d159ce102a8eaf2a5", optional = true } # macos (v2) branch
+audioipc-client = { git = "https://github.com/mozilla/audioipc", rev = "fb7a2b12ced3b43e6a268621989c6191d1ed7e39", optional = true }
+audioipc-server = { git = "https://github.com/mozilla/audioipc", rev = "fb7a2b12ced3b43e6a268621989c6191d1ed7e39", optional = true }
+# Force tokio-reactor on an old version to avoid new dependencies of newer versions.
+# Remove when audioipc-client and audioipc-server above are replaced with
+# audioipc2-client and audioipc2-server.
+tokio-reactor = { version = "=0.1.3", optional = true }
+# Force tokio-threadpool on an old version that doesn't depend on crossbeam-queue 0.2
+# that has licensing issues.
+# Remove when audioipc-client and audioipc-server above are replaced with
+# audioipc2-client and audioipc2-server.
+tokio-threadpool = { version = "=0.1.17", optional = true }
+encoding_glue = { path = "../../../../intl/encoding_glue" }
+authenticator = { version = "0.4.0-alpha.6", features = ["gecko"] }
+gkrust_utils = { path = "../../../../xpcom/rust/gkrust_utils" }
+gecko_logger = { path = "../../../../xpcom/rust/gecko_logger" }
+rsdparsa_capi = { path = "../../../../dom/media/webrtc/sdp/rsdparsa_capi" }
+xulstore = { path = "../../../components/xulstore", optional = true }
+# We have these to enforce common feature sets for said crates.
+log = {version = "0.4", features = ["release_max_level_info"]}
+cose-c = { version = "0.1.5" }
+jsrust_shared = { path = "../../../../js/src/rust/shared" }
+cascade_bloom_filter = { path = "../../../components/cascade_bloom_filter" }
+cert_storage = { path = "../../../../security/manager/ssl/cert_storage" }
+bitsdownload = { path = "../../../components/bitsdownload", optional = true }
+storage = { path = "../../../../storage/rust" }
+bookmark_sync = { path = "../../../components/places/bookmark_sync", optional = true }
+chardetng_c = "0.1.1"
+audio_thread_priority = { version = "0.26.1", default_features = false, features = ["winapi"] }
+mdns_service = { path="../../../../dom/media/webrtc/transport/mdns_service", optional = true }
+neqo_glue = { path = "../../../../netwerk/socket/neqo_glue" }
+wgpu_bindings = { path = "../../../../gfx/wgpu_bindings" }
+mapped_hyph = { git = "https://github.com/jfkthame/mapped_hyph.git", rev = "c7651a0cffff41996ad13c44f689bd9cd2192c01" }
+fog_control = { path = "../../../components/glean" }
+app_services_logger = { path = "../../../../services/common/app_services_logger" }
+http_sfv = { path = "../../../../netwerk/base/http-sfv" }
+unic-langid = { version = "0.9", features = ["likelysubtags"] }
+unic-langid-ffi = { path = "../../../../intl/locale/rust/unic-langid-ffi" }
+fluent-langneg = { version = "0.13", features = ["cldr"] }
+fluent-langneg-ffi = { path = "../../../../intl/locale/rust/fluent-langneg-ffi" }
+rure = "0.2.2"
+rust_minidump_writer_linux = { path = "../../../crashreporter/rust_minidump_writer_linux", optional = true }
+gecko-profiler = { path = "../../../../tools/profiler/rust-api"}
+midir_impl = { path = "../../../../dom/midi/midir_impl", optional = true }
+dom = { path = "../../../../dom/base/rust" }
+origin-trials-ffi = { path = "../../../../dom/origin-trials/ffi" }
+jog = { path = "../../../components/glean/bindings/jog" }
+dap_ffi = { path = "../../../components/telemetry/dap/ffi" }
+data-encoding-ffi = { path = "../../../../dom/fs/parent/rust/data-encoding-ffi" }
+uniffi-example-arithmetic = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "846612a1d4fb5d11e246bf0682da4a499409424c", optional = true }
+uniffi-example-geometry = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "846612a1d4fb5d11e246bf0682da4a499409424c", optional = true }
+uniffi-example-rondpoint = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "846612a1d4fb5d11e246bf0682da4a499409424c", optional = true }
+uniffi-example-sprites = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "846612a1d4fb5d11e246bf0682da4a499409424c", optional = true }
+uniffi-example-todolist = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "846612a1d4fb5d11e246bf0682da4a499409424c", optional = true }
+uniffi-example-custom-types = { path = "../../../components/uniffi-example-custom-types/", optional = true }
+uniffi-fixture-callbacks = { path = "../../../components/uniffi-fixture-callbacks/", optional = true }
+uniffi-fixture-external-types = { path = "../../../components/uniffi-fixture-external-types/", optional = true }
+binary_http = { path = "../../../../netwerk/protocol/http/binary_http" }
+oblivious_http = { path = "../../../../netwerk/protocol/http/oblivious_http" }
+
+# Note: `modern_sqlite` means rusqlite's bindings file be for a sqlite with
+# version less than or equal to what we link to. This isn't a problem because we
+# tend to keep this up to date, but it needs to be taken into consideration when
+# changing this version.
+rusqlite = { version = "0.28.0", features = ["modern_sqlite", "in_gecko"] }
+
+fluent = { version = "0.16.0", features = ["fluent-pseudo"] }
+fluent-ffi = { path = "../../../../intl/l10n/rust/fluent-ffi" }
+l10nregistry-ffi = { path = "../../../../intl/l10n/rust/l10nregistry-ffi" }
+l10nregistry = { path = "../../../../intl/l10n/rust/l10nregistry-rs" }
+fluent-fallback = "0.7.0"
+localization-ffi = { path = "../../../../intl/l10n/rust/localization-ffi" }
+
+processtools = { path = "../../../components/processtools" }
+qcms = { path = "../../../../gfx/qcms", features = ["c_bindings", "neon"], default-features = false }
+
+wpf-gpu-raster = { git = "https://github.com/FirefoxGraphics/wpf-gpu-raster", rev = "a6514854d4518b02f2805719ff6cd74dae7dfde6" }
+aa-stroke = { git = "https://github.com/FirefoxGraphics/aa-stroke", rev = "07d3c25322518f294300e96246e09b95e118555d" }
+
+# Force url to stay at 2.1.0. See bug 1734538.
+url = "=2.1.0"
+
+# Force mio to stay at 0.8.0 to avoid windows-sys dependencies.
+mio = "=0.8.0"
+
+# Since we're building with at least rustc 1.63, enable rust 1.57 features (use of try_reserve methods).
+fallible_collections = { version = "0.4", features = ["rust_1_57"] }
+
+[target.'cfg(not(target_os = "android"))'.dependencies]
+viaduct = "0.1"
+webext_storage_bridge = { path = "../../../components/extensions/storage/webext_storage_bridge" }
+tabs = { version = "0.1" }
+
+[target.'cfg(target_os = "windows")'.dependencies]
+detect_win32k_conflicts = { path = "../../../xre/detect_win32k_conflicts" }
+
+[features]
+default = []
+moz_memory = ["mozglue-static/moz_memory"]
+cubeb-remoting = ["cubeb-sys", "audioipc-client", "audioipc-server", "audioipc2-client", "audioipc2-server"]
+cubeb_coreaudio_rust = ["cubeb-sys", "cubeb-coreaudio"]
+cubeb_pulse_rust = ["cubeb-sys", "cubeb-pulse"]
+gecko_debug = ["geckoservo/gecko_debug", "nsstring/gecko_debug"]
+gecko_refcount_logging = ["geckoservo/gecko_refcount_logging", "xpcom/gecko_refcount_logging"]
+simd-accel = ["encoding_glue/simd-accel", "jsrust_shared/simd-accel"]
+moz_places = ["bookmark_sync"]
+spidermonkey_rust = []
+smoosh = ["jsrust_shared/smoosh"]
+gecko_profiler = ["gecko-profiler/enabled", "profiler_helper"]
+gecko_profiler_parse_elf = ["profiler_helper/parse_elf"]
+new_xulstore = ["xulstore"]
+libfuzzer = ["neqo_glue/fuzzing"]
+webrtc = ["mdns_service"]
+glean_disable_upload = ["fog_control/disable_upload"]
+glean_million_queue = ["fog_control/million_queue"]
+glean_with_gecko = ["fog_control/with_gecko", "jog/with_gecko"]
+oxidized_breakpad = ["rust_minidump_writer_linux"]
+with_dbus = ["audio_thread_priority/with_dbus"]
+thread_sanitizer = ["xpcom/thread_sanitizer"]
+uniffi_fixtures = [
+ "uniffi-example-arithmetic", "uniffi-example-geometry", "uniffi-example-rondpoint", "uniffi-example-sprites",
+ "uniffi-example-todolist", "uniffi-example-custom-types", "uniffi-fixture-callbacks",
+ "uniffi-fixture-external-types",
+]
+webmidi_midir_impl = ["midir_impl"]
+
+[lib]
+path = "lib.rs"
+test = false
+doctest = false
+bench = false
+doc = false
+plugin = false
+harness = false
+
+[package.metadata.cargo-udeps.ignore]
+normal = ["moz_asserts"]
diff --git a/toolkit/library/rust/shared/lib.rs b/toolkit/library/rust/shared/lib.rs
new file mode 100644
index 0000000000..9b48c3ee76
--- /dev/null
+++ b/toolkit/library/rust/shared/lib.rs
@@ -0,0 +1,160 @@
+// 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 http://mozilla.org/MPL/2.0/.
+
+extern crate geckoservo;
+
+extern crate app_services_logger;
+#[cfg(feature = "cubeb-remoting")]
+extern crate audioipc2_client;
+#[cfg(feature = "cubeb-remoting")]
+extern crate audioipc2_server;
+#[cfg(feature = "cubeb-remoting")]
+extern crate audioipc_client;
+#[cfg(feature = "cubeb-remoting")]
+extern crate audioipc_server;
+extern crate authenticator;
+#[cfg(feature = "bitsdownload")]
+extern crate bitsdownload;
+#[cfg(feature = "moz_places")]
+extern crate bookmark_sync;
+extern crate cascade_bloom_filter;
+extern crate cert_storage;
+extern crate chardetng_c;
+extern crate cosec;
+#[cfg(feature = "cubeb_coreaudio_rust")]
+extern crate cubeb_coreaudio;
+#[cfg(feature = "cubeb_pulse_rust")]
+extern crate cubeb_pulse;
+extern crate encoding_glue;
+extern crate fog_control;
+extern crate gecko_profiler;
+extern crate gkrust_utils;
+extern crate http_sfv;
+extern crate jog;
+extern crate jsrust_shared;
+extern crate kvstore;
+extern crate mapped_hyph;
+extern crate mozurl;
+extern crate mp4parse_capi;
+extern crate netwerk_helper;
+extern crate nserror;
+extern crate nsstring;
+extern crate prefs_parser;
+extern crate processtools;
+#[cfg(feature = "gecko_profiler")]
+extern crate profiler_helper;
+extern crate rsdparsa_capi;
+extern crate static_prefs;
+extern crate storage;
+extern crate webrender_bindings;
+extern crate xpcom;
+#[cfg(feature = "new_xulstore")]
+extern crate xulstore;
+
+extern crate audio_thread_priority;
+
+#[cfg(not(target_os = "android"))]
+extern crate webext_storage_bridge;
+
+#[cfg(not(target_os = "android"))]
+extern crate tabs;
+
+#[cfg(not(target_os = "android"))]
+mod reexport_tabs {
+ tabs::uniffi_reexport_scaffolding!();
+}
+
+#[cfg(feature = "webrtc")]
+extern crate mdns_service;
+extern crate neqo_glue;
+extern crate wgpu_bindings;
+
+extern crate aa_stroke;
+extern crate qcms;
+extern crate wpf_gpu_raster;
+
+extern crate unic_langid;
+extern crate unic_langid_ffi;
+
+extern crate fluent_langneg;
+extern crate fluent_langneg_ffi;
+
+extern crate fluent;
+extern crate fluent_ffi;
+
+extern crate rure;
+
+extern crate fluent_fallback;
+extern crate l10nregistry_ffi;
+extern crate localization_ffi;
+
+#[cfg(not(target_os = "android"))]
+extern crate viaduct;
+
+extern crate gecko_logger;
+
+#[cfg(feature = "oxidized_breakpad")]
+extern crate rust_minidump_writer_linux;
+
+#[cfg(feature = "webmidi_midir_impl")]
+extern crate midir_impl;
+
+#[cfg(target_os = "windows")]
+extern crate detect_win32k_conflicts;
+
+extern crate origin_trials_ffi;
+
+extern crate dap_ffi;
+
+extern crate data_encoding_ffi;
+
+extern crate binary_http;
+extern crate oblivious_http;
+
+#[cfg(feature = "uniffi_fixtures")]
+mod uniffi_fixtures {
+ extern crate arithmetical;
+ extern crate uniffi_geometry;
+ extern crate uniffi_rondpoint;
+ extern crate uniffi_sprites;
+ extern crate uniffi_todolist;
+
+ arithmetical::uniffi_reexport_scaffolding!();
+ uniffi_fixture_callbacks::uniffi_reexport_scaffolding!();
+ uniffi_custom_types::uniffi_reexport_scaffolding!();
+ uniffi_fixture_external_types::uniffi_reexport_scaffolding!();
+ uniffi_geometry::uniffi_reexport_scaffolding!();
+ uniffi_rondpoint::uniffi_reexport_scaffolding!();
+ uniffi_sprites::uniffi_reexport_scaffolding!();
+ uniffi_todolist::uniffi_reexport_scaffolding!();
+}
+
+extern crate log;
+use log::info;
+
+use std::{ffi::CStr, os::raw::c_char};
+
+use gecko_logger::GeckoLogger;
+
+#[no_mangle]
+pub extern "C" fn GkRust_Init() {
+ // Initialize logging.
+ let _ = GeckoLogger::init();
+}
+
+#[no_mangle]
+pub extern "C" fn GkRust_Shutdown() {}
+
+/// Used to implement `nsIDebug2::RustPanic` for testing purposes.
+#[no_mangle]
+pub unsafe extern "C" fn intentional_panic(message: *const c_char) {
+ panic!("{}", CStr::from_ptr(message).to_string_lossy());
+}
+
+/// Used to implement `nsIDebug2::rustLog` for testing purposes.
+#[no_mangle]
+pub unsafe extern "C" fn debug_log(target: *const c_char, message: *const c_char) {
+ // NOTE: The `info!` log macro is used here because we have the `release_max_level_info` feature set.
+ info!(target: CStr::from_ptr(target).to_str().unwrap(), "{}", CStr::from_ptr(message).to_str().unwrap());
+}