diff --git a/Cargo.lock b/Cargo.lock index 4e0d6b2cd6..f463aa77c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1068,6 +1068,7 @@ dependencies = [ "camino", "clap", "glob", + "mozilla-central-workspace-hack", "serde", "toml 0.5.9", "uniffi_bindgen", @@ -2587,6 +2588,7 @@ dependencies = [ "lazy_static", "logins", "merino", + "mozilla-central-workspace-hack", "nimbus-sdk", "places", "push", @@ -2787,6 +2789,14 @@ dependencies = [ "similar", ] +[[package]] +name = "mozbuild" +version = "0.1.0" + +[[package]] +name = "mozilla-central-workspace-hack" +version = "0.1.0" + [[package]] name = "native-tls" version = "0.2.10" @@ -2884,6 +2894,7 @@ dependencies = [ "icu_segmenter", "itertools 0.14.0", "lazy_static", + "mozilla-central-workspace-hack", "regex", "serde", "serde_json", @@ -3053,13 +3064,13 @@ dependencies = [ [[package]] name = "ohttp" version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41a03aaaf57495c75ce66aee6a7c3b21abf046c9d4cca3d45b22cdbf0de1bfba" +source = "git+https://github.com/martinthomson/ohttp#324f876e79394c9b815dcacda3fd4f48f105fdf2" dependencies = [ "bindgen", "byteorder", "hex", "log", + "mozbuild", "serde", "serde_derive", "thiserror 2.0.3", diff --git a/Cargo.toml b/Cargo.toml index ad07d4126f..c152e88664 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,9 @@ members = [ "examples/*/", "testing/separated/*/", "testing/sync-test", + + "monorepo-hacks/workspace-hack", + "monorepo-hacks/mozbuild", ] exclude = [ @@ -159,3 +162,8 @@ lto = "thin" uniffi = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "59b035078322fbc0a605cc3c784cc38214113450" } uniffi_bindgen = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "59b035078322fbc0a605cc3c784cc38214113450" } uniffi_pipeline = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "59b035078322fbc0a605cc3c784cc38214113450" } +# dummy crates for m-c integration hacks. +mozilla-central-workspace-hack = { path = "monorepo-hacks/workspace-hack" } +mozbuild = { path = "monorepo-hacks/mozbuild" } +# temporary ohttp override enabling the above hacks while we wait for a new version. +ohttp = { git = "https://github.com/martinthomson/ohttp", revision = "324f876e79394c9b815dcacda3fd4f48f105fdf2" } diff --git a/components/support/nimbus-fml/Cargo.toml b/components/support/nimbus-fml/Cargo.toml index 39991f9ee3..7a2c8c4c6c 100644 --- a/components/support/nimbus-fml/Cargo.toml +++ b/components/support/nimbus-fml/Cargo.toml @@ -52,3 +52,4 @@ itertools = "0" regex = "1.9" viaduct = { path = "../../viaduct/" } termcolor = "1.4.1" +mozilla-central-workspace-hack = { version = "0.1", features = ["nimbus-fml"], optional = true } diff --git a/megazords/full/Cargo.toml b/megazords/full/Cargo.toml index 8f779f4460..f947c83383 100644 --- a/megazords/full/Cargo.toml +++ b/megazords/full/Cargo.toml @@ -33,3 +33,4 @@ init_rust_components = { path = "../../components/init_rust_components" } merino = { path = "../../components/merino" } relay = { path = "../../components/relay" } ads-client = { path = "../../components/ads-client" } +mozilla-central-workspace-hack = { version = "0.1", features = ["megazord"], optional = true } diff --git a/monorepo-hacks/README.md b/monorepo-hacks/README.md new file mode 100644 index 0000000000..c62bef2646 --- /dev/null +++ b/monorepo-hacks/README.md @@ -0,0 +1,15 @@ +This directory holds a couple of crates which are hacks to help us on the +path to moving this repo into mozilla-central. + +They exist only to keep Cargo and/or the Rust compiler happy, so the +same code/config can be used in both repos. They serve no actual purpose +and are never actually called in this repo. + +They are: + +* workspace-hack/* contains a dummy `mozilla-central-workspace-hack` crate, which + is referenced from a few "top-level" crates built in m-c. + +* mozbuild/* contains a dummy `mozbuild` crate, which is referenced by the ohttp + crate when the "app-svc" feature is enabled. That feature auto-detects whether + it is in this repo or in mozilla-central. diff --git a/monorepo-hacks/mozbuild/Cargo.toml b/monorepo-hacks/mozbuild/Cargo.toml new file mode 100644 index 0000000000..33a2f0e591 --- /dev/null +++ b/monorepo-hacks/mozbuild/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "mozbuild" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/monorepo-hacks/mozbuild/src/lib.rs b/monorepo-hacks/mozbuild/src/lib.rs new file mode 100644 index 0000000000..6a087b1156 --- /dev/null +++ b/monorepo-hacks/mozbuild/src/lib.rs @@ -0,0 +1,27 @@ +/* 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/. */ + +// A dummy mozbuild which exists purely so ohttp can be built in this repo. +// This implementation is never actually called, it just needs to exist +// to keep the compiler happy. + +use std::path::Path; + +// from https://searchfox.org/firefox-main/source/build/rust/mozbuild/lib.rs + +// Path::new is not const at the moment. This is a non-generic version +// of Path::new, similar to libstd's implementation of Path::new. +#[inline(always)] +const fn const_path(s: &'static str) -> &'static std::path::Path { + unsafe { &*(s as *const str as *const std::path::Path) } +} + +pub const TOPOBJDIR: &Path = const_path(""); + +pub mod config { + pub const MOZ_FOLD_LIBS: bool = true; + pub const BINDGEN_SYSTEM_FLAGS: [&str; 0] = []; + pub const NSS_CFLAGS: [&str; 0] = []; + pub const NSPR_CFLAGS: [&str; 0] = []; +} diff --git a/monorepo-hacks/workspace-hack/Cargo.toml b/monorepo-hacks/workspace-hack/Cargo.toml new file mode 100644 index 0000000000..545807f007 --- /dev/null +++ b/monorepo-hacks/workspace-hack/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "mozilla-central-workspace-hack" +version = "0.1.0" +license = "MPL-2.0" +description = "Workspace hack for mozilla-central" +edition = "2024" + +# This is a copy of the workspace hack in mozilla-central - https://searchfox.org/firefox-main/source/build/workspace-hack +# It exists only so that the crates in this repo which need the "workspace hack" once in mozilla-central +# automagically get it. +# It serves no purpose in application-services other than to allow our +# crates to be build in mozilla-central without modification. + +[features] +megazord = [] +embedded-uniffi-bindgen = [] +nimbus-fml = [] diff --git a/monorepo-hacks/workspace-hack/src/lib.rs b/monorepo-hacks/workspace-hack/src/lib.rs new file mode 100644 index 0000000000..b15e83eb00 --- /dev/null +++ b/monorepo-hacks/workspace-hack/src/lib.rs @@ -0,0 +1,11 @@ +/* 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/. */ + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/tools/embedded-uniffi-bindgen/Cargo.toml b/tools/embedded-uniffi-bindgen/Cargo.toml index 367a2c9300..b814282add 100644 --- a/tools/embedded-uniffi-bindgen/Cargo.toml +++ b/tools/embedded-uniffi-bindgen/Cargo.toml @@ -17,3 +17,4 @@ clap = {version = "4.2", default-features = false, features = ["std", "derive"]} serde = { version = "1", features = ["derive"] } uniffi_bindgen = { version = "0.31" } uniffi_pipeline = { version = "0.31" } +mozilla-central-workspace-hack = { version = "0.1", features = ["embedded-uniffi-bindgen"], optional = true }