Source code

Revision control

Copy as Markdown

Other Tools

# 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/.
# There are 2 parts to our megazord - a staticlib in megazords/full, then this
# build file to create the final dyib .so
# See the comments in megazords/full/moz.build.
# This name confusion is a reflection of the 2 megazord parts. It should be
# fixed after we land in m-c.
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android" or CONFIG["MOZ_LIBMEGAZORD_ARTIFACTS"]:
SharedLibrary("megazord-so")
else:
SharedLibrary("megazord-so", output_category="uniffi-target")
SHARED_LIBRARY_NAME = "megazord"
USE_LIBS += ["megazord", "mozpkix", "nspr"]
megazord_symbols = "/toolkit/components/uniffi-bindgen-gecko-js/megazord.symbols"
megazord_profile = "dev-megazord" if CONFIG["MOZ_DEBUG_RUST"] else "release-megazord"
megazord_archive = (
f"!/{CONFIG['RUST_TARGET']}/{megazord_profile}"
f"/{CONFIG['LIB_PREFIX']}megazord.{CONFIG['LIB_SUFFIX']}"
)
megazord_generator = "/python/mozbuild/mozbuild/action/generate_archive_symbols.py"
if CONFIG["OS_TARGET"] == "WINNT":
GeneratedFile(
"megazord.def",
script=megazord_generator,
inputs=[megazord_archive, megazord_symbols],
flags=["--format=def"],
)
SYMBOLS_FILE = "!megazord.def"
else:
# The version script below controls what the shared library exports, which
# on these targets does not make the linker keep the archive members that
# define those symbols. Naming each one as an undefined root does.
GeneratedFile(
"megazord.rsp",
script=megazord_generator,
inputs=[megazord_archive, megazord_symbols],
flags=[f"--format={'macho' if CONFIG['OS_TARGET'] == 'Darwin' else 'elf'}"],
)
LDFLAGS += ["-Wl,@megazord.rsp"]
EXTRA_LINK_DEPS += ["!megazord.rsp"]
SYMBOLS_FILE = megazord_symbols
# copy-pasta from other moz.build files.
if CONFIG["OS_TARGET"] == "Darwin":
OS_LIBS += ["-framework CoreFoundation"]
elif CONFIG["OS_TARGET"] == "WINNT":
OS_LIBS += [
"advapi32",
"bcrypt",
"mswsock",
"ntdll",
"shell32",
"user32",
"userenv",
"wsock32",
"ws2_32",
"winmm",
]
# rpath so libmegazord's co-located NSS and sqlite deps resolve at load time
# (e.g. JVM unit tests loading it from the extracted libsForTests directory).
# Windows has no rpath and relies on the loader search path instead.
if CONFIG["OS_TARGET"] == "Linux":
LDFLAGS += ["-Wl,-rpath=$ORIGIN"]
elif CONFIG["OS_TARGET"] == "Darwin":
LDFLAGS += ["-Wl,-rpath,@loader_path"]