Skip to content

Commit acfd9b7

Browse files
committed
Add build tooling so we can work in mozilla-central.
Most of the files here are ignored when in application-services, but when copied into mozilla-central they enable "mach build" to build our megazord and other tooling.
1 parent 432aa60 commit acfd9b7

File tree

8 files changed

+181
-0
lines changed

8 files changed

+181
-0
lines changed

megazords/fenix-dylib/megazord_stub.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5+
6+
#include "mozilla/Types.h"
7+
8+
// This seems sad?
9+
// If we could get a stub .rs we could use `tabs::uniffi_reexport_scaffolding!();` etc,
10+
// but here we are.
11+
// To get the symbols from our static lib we need to refer to a symbol from each crate within it.
12+
// This is an arbitrary choice - any symbol will do, but we chose these because every uniffi crate has it.
13+
extern int MOZ_EXPORT ffi_autofill_uniffi_contract_version();
14+
extern int MOZ_EXPORT ffi_crashtest_uniffi_contract_version();
15+
extern int MOZ_EXPORT ffi_fxa_client_uniffi_contract_version();
16+
extern int MOZ_EXPORT ffi_init_rust_components_uniffi_contract_version();
17+
extern int MOZ_EXPORT ffi_logins_uniffi_contract_version();
18+
extern int MOZ_EXPORT ffi_merino_uniffi_contract_version();
19+
extern int MOZ_EXPORT ffi_nimbus_uniffi_contract_version();
20+
extern int MOZ_EXPORT ffi_places_uniffi_contract_version();
21+
extern int MOZ_EXPORT ffi_push_uniffi_contract_version();
22+
extern int MOZ_EXPORT ffi_remote_settings_uniffi_contract_version();
23+
extern int MOZ_EXPORT ffi_rust_log_forwarder_uniffi_contract_version();
24+
extern int MOZ_EXPORT ffi_search_uniffi_contract_version();
25+
extern int MOZ_EXPORT ffi_suggest_uniffi_contract_version();
26+
extern int MOZ_EXPORT ffi_sync15_uniffi_contract_version();
27+
extern int MOZ_EXPORT ffi_sync_manager_uniffi_contract_version();
28+
extern int MOZ_EXPORT ffi_tabs_uniffi_contract_version();
29+
30+
// far out, this is crazy - without this, only the search _NAMESPACE meta comes in,
31+
// meaning uniffi ends up generating a completely empty kotlin module for search.
32+
// Looking at `nm obj-dir/.../libsearch-*.rlib` you can see many symbols
33+
// are in a different .o - this symbol is one taken randomly from the .o with
34+
// the missing symbols, and they all happily come in.
35+
// W T A F.
36+
extern int MOZ_EXPORT uniffi_search_checksum_constructor_searchengineselector_new();
37+
38+
void _local_megazord_dummy_symbol() {
39+
ffi_autofill_uniffi_contract_version();
40+
ffi_crashtest_uniffi_contract_version();
41+
ffi_fxa_client_uniffi_contract_version();
42+
ffi_init_rust_components_uniffi_contract_version();
43+
ffi_logins_uniffi_contract_version();
44+
ffi_merino_uniffi_contract_version();
45+
ffi_nimbus_uniffi_contract_version();
46+
ffi_places_uniffi_contract_version();
47+
ffi_push_uniffi_contract_version();
48+
ffi_remote_settings_uniffi_contract_version();
49+
ffi_rust_log_forwarder_uniffi_contract_version();
50+
ffi_search_uniffi_contract_version();
51+
ffi_suggest_uniffi_contract_version();
52+
ffi_sync15_uniffi_contract_version();
53+
ffi_sync_manager_uniffi_contract_version();
54+
ffi_tabs_uniffi_contract_version();
55+
uniffi_search_checksum_constructor_searchengineselector_new();
56+
}

megazords/fenix-dylib/moz.build

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
# There are 2 parts to our megazord - a staticlib in megazords/full, then this
6+
# build file to create the final dyib .so
7+
# See the comments in megazords/full/moz.build.
8+
9+
UNIFIED_SOURCES += [
10+
"megazord_stub.c",
11+
]
12+
13+
# This name confusion is a reflection of the 2 megazord parts. It should be
14+
# fixed after we land in m-c.
15+
SharedLibrary("megazord-so")
16+
SHARED_LIBRARY_NAME = "megazord"
17+
18+
USE_LIBS += ["megazord", "mozpkix", "nspr"]
19+
20+
# copy-pasta from other moz.build files.
21+
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
22+
OS_LIBS += ["-framework CoreFoundation"]
23+
elif CONFIG["OS_TARGET"] == "WINNT":
24+
OS_LIBS += [
25+
"advapi32",
26+
"bcrypt",
27+
"mswsock",
28+
"ntdll",
29+
"shell32",
30+
"user32",
31+
"userenv",
32+
"wsock32",
33+
"ws2_32",
34+
"winmm",
35+
]

megazords/full/moz.build

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2+
# vim: set filetype=python:
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
# Note that this crate, when used in app-services, directly creates the cdylib.
8+
# However, in moz-central it builds a staticlib. A new target in `../fenix-dylib`
9+
# takes this as a dep and creates the final cdylib.
10+
USE_LIBS += ["nss"]
11+
12+
UNIFIED_SOURCES += [
13+
"stub.cpp",
14+
]
15+
16+
# This is the name of the .a file created.
17+
RustLibrary("megazord")
18+
19+
# XXX - this doesn't really work - the tests fail due to missing `nss3`?
20+
RUST_TESTS = [
21+
"megazord",
22+
]

megazords/full/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use std::ffi::CString;
99
use std::os::raw::c_char;
1010

11+
// NOTE if you add or remove crates below here, please make a corresponding change in ../fenix-dylib/megazord_stub.c
1112
pub use autofill;
1213
pub use crashtest;
1314
pub use error_support;
@@ -26,6 +27,8 @@ pub use sync_manager;
2627
pub use tabs;
2728
pub use tracing_support;
2829
pub use viaduct;
30+
// NOTE if you add or remove crates above here, please make a corresponding change in ../fenix-dylib/megazord_stub.c
31+
2932
// TODO: Uncomment this code when webext-storage component is integrated in android
3033
// pub use webext_storage;
3134

megazords/full/stub.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5+
6+
// This is an intentionally empty file. It is necessary for the build system to
7+
// successfully convert a static rust library into a dynamic library on
8+
// Windows.

moz.build

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
# Note that this builds the cdylib for our megazord. See the comments
6+
# in megazords/full/moz.build.
7+
8+
UNIFIED_SOURCES += [
9+
"megazord_stub.c",
10+
]
11+
12+
# This name confusion is a reflection of some of the above. It should be
13+
# fixed, but may be easier/better to fix once in m-c.
14+
SharedLibrary("megazord-so")
15+
SHARED_LIBRARY_NAME = "megazord"
16+
17+
USE_LIBS += ["megazord", "mozpkix", "nspr"]
18+
19+
# copy-pasta from other moz.build files, are these the correct checks?
20+
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
21+
OS_LIBS += ["-framework CoreFoundation"]
22+
elif CONFIG["OS_TARGET"] == "WINNT":
23+
OS_LIBS += [
24+
"advapi32",
25+
"bcrypt",
26+
"mswsock",
27+
"ntdll",
28+
"shell32",
29+
"user32",
30+
"userenv",
31+
"wsock32",
32+
"ws2_32",
33+
"winmm",
34+
]

tools/embedded-uniffi-bindgen/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ authors = ["The Firefox Sync Developers <[email protected]>"]
55
edition = "2021"
66
license = "MPL-2.0"
77

8+
# A bin target needed when used in m-c.
9+
[[bin]]
10+
name = "embedded-uniffi-bindgen"
11+
812
[dependencies]
913
uniffi = { version = "0.29.0", features = ["cli"] }
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2+
# vim: set filetype=python:
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
HOST_RUST_PROGRAMS = ["embedded-uniffi-bindgen"]
8+
9+
# copy-pasta from other moz.build file.
10+
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
11+
OS_LIBS += ["-framework CoreFoundation"]
12+
elif CONFIG["OS_TARGET"] == "WINNT":
13+
OS_LIBS += [
14+
"advapi32",
15+
"wsock32",
16+
"ws2_32",
17+
"mswsock",
18+
"winmm",
19+
]

0 commit comments

Comments
 (0)