Port Firefox

This commit is contained in:
Wildan M 2026-01-27 15:38:31 +07:00
parent 762a9ce339
commit c64b32ba02
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
4 changed files with 188 additions and 22 deletions

View File

@ -1,5 +1,25 @@
#TODO missing script for building
# TODO: Using patched mozjs from servo, maybe move patcehs into to upstream patches?
[source]
tar = "https://ftp.mozilla.org/pub/nspr/releases/v4.9.6/src/nspr-4.9.6.tar.gz"
# tar = "https://ftp.mozilla.org/pub/nspr/releases/v4.9.6/src/nspr-4.9.6.tar.gz"
git = "https://github.com/willnode/mozjs"
branch = "redox"
shallow_clone = true
[build]
template = "custom"
script = """
export HOST_CC="cc"
export CC="$GNU_TARGET-gcc"
export CXX="$GNU_TARGET-g++"
export LDFLAGS="-shared"
export CFLAGS="-fPIC"
COOKBOOK_CONFIGURE_FLAGS+=(
--enable-optimize
--disable-debug
--enable-64bit
--with-pthreads
ac_cv_path_LD="$LD"
)
COOKBOOK_MAKE_JOBS=1
COOKBOOK_CONFIGURE="$COOKBOOK_SOURCE/mozjs-sys/mozjs/nsprpub/configure"
cookbook_configure
"""

View File

@ -1,3 +1,24 @@
mk_add_options MOZ_OBJDIR=COOKBOOK_BUILD
ac_add_options --target=TARGET
ac_add_options --disable-debug
ac_add_options --disable-tests
ac_add_options --target="{TARGET}"
ac_add_options --enable-bootstrap
ac_add_options --disable-audio-backends
ac_add_options --disable-crashreporter
ac_add_options --disable-updater
ac_add_options --disable-dbus
ac_add_options --disable-gecko-profiler
ac_add_options --disable-profiling
ac_add_options --disable-dmd # dark matter detector
ac_add_options --without-wasm-sandboxed-libraries # need clang wasi
# TODO: cairo-gtk3-x11-wayland or separate cairo-gtk3-wayland-only
ac_add_options --enable-default-toolkit=cairo-gtk3-x11-only
ac_add_options --enable-bootstrap=-clang # only use our clang
ac_add_options --enable-optimize
ac_add_options --with-system-nspr
ac_add_options --with-gl-provider=EGL
export MOZ_REQUIRE_SIGNING=
export MOZ_TELEMETRY_REPORTING=
export CC="TARGET_CC"
export CXX="TARGET_CXX"

View File

@ -1,31 +1,70 @@
#TODO missing script for mach: https://firefox-source-docs.mozilla.org/setup/linux_build.html
#TODO wrong compilation on gecko-profiler (bindgen/clang-sys)
# mach: https://firefox-source-docs.mozilla.org/setup/linux_build.html
# dependencies: https://packages.gentoo.org/packages/www-client/firefox/dependencies
# feature flags: https://wiki.gentoo.org/wiki/Firefox#USE_flags
[source]
tar = "https://ftp.mozilla.org/pub/firefox/releases/115.13.0esr/source/firefox-115.13.0esr.source.tar.xz"
tar = "https://ftp.mozilla.org/pub/firefox/releases/140.7.0esr/source/firefox-140.7.0esr.source.tar.xz"
[build]
template = "custom"
dependencies = [
"fontconfig",
"atk",
"cairo",
# "fontconfig",
# "atk",
# "cairo",
"dbus",
"libffi",
"freetype2",
"gdk-pixbuf",
"glib",
# "libffi",
# "freetype2",
# "gdk-pixbuf",
# "glib",
"gtk3",
"pango",
"sqlite3",
"nss-nspr",
"startup-notification",
"zlib",
"ffmpeg6",
"expat",
"libepoxy",
"pipewire",
"libxkbcommon-x11",
"libice",
"mesa-x11",
"x11proto-kb",
"xcb-proto",
"xextproto",
"nspr",
"libxrandr",
"libsm",
# TODO: Should separate clang library and runtime
"llvm21.clang"
# "sqlite3",
# "nss-nspr",
# "startup-notification",
# "zlib",
# "ffmpeg6",
# "expat",
# "libepoxy",
# "pipewire",
]
dev-dependencies = [
"host:llvm21",
"host:llvm21.dev",
"host:llvm21.runtime",
"host:llvm21.clang",
]
script = """
DYNAMIC_INIT
export MOZCONFIG="${COOKBOOK_RECIPE}/mozconfig"
cat ${COOKBOOK_RECIPE}/mozconfig > mozconfig
sed -i "s|COOKBOOK_BUILD|${COOKBOOK_BUILD}|g" mozconfig
sed -i "s|TARGET_CC|${CC}|g" mozconfig
sed -i "s|TARGET_CXX|${CXX}|g" mozconfig
sed -i "s|TARGET|${TARGET}|g" mozconfig
export MOZCONFIG="${COOKBOOK_BUILD}/mozconfig"
export PYTHONDONTWRITEBYTECODE=1
if [[ -z "$CI" ]]; then export MACH_NO_TERMINAL_FOOTER=1; fi;
# clang-sys specifics
PREFIX_INCLUDE="$COOKBOOK_HOST_SYSROOT/$TARGET/include"
export CLANGFLAGS="-I $PREFIX_INCLUDE/c++/13.2.0 -I $PREFIX_INCLUDE/c++/13.2.0/$TARGET -I $PREFIX_INCLUDE/c++/13.2.0/backward"
export CLANGFLAGS="$CLANGFLAGS -I $PREFIX_INCLUDE -I $COOKBOOK_SYSROOT/lib/clang/21/include -D__redox__"
export BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_redox="-target x86_64-unknown-redox -nostdinc $CLANGFLAGS"
export LLVM_CONFIG_PATH="$COOKBOOK_TOOLCHAIN/bin/llvm-config"
# Don't poison the stage1 compiler (host -> host)
unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS STRIP
(cd ${COOKBOOK_SOURCE} && ./mach build)
rsync -a ./dist ${COOKBOOK_STAGE}
"""

View File

@ -0,0 +1,86 @@
diff --color -ruwN source/build/moz.configure/init.configure source-new/build/moz.configure/init.configure
--- source/build/moz.configure/init.configure 2026-01-07 04:09:42.000000000 +0700
+++ source-new/build/moz.configure/init.configure 2026-01-27 12:48:28.508789372 +0700
@@ -511,6 +511,8 @@
canonical_os = canonical_kernel = "NetBSD"
elif os.startswith("openbsd"):
canonical_os = canonical_kernel = "OpenBSD"
+ elif os.startswith("redox"):
+ canonical_os = canonical_kernel = "Redox"
elif os.startswith("solaris"):
canonical_os = canonical_kernel = "SunOS"
elif os.startswith("wasi") and allow_wasi:
@@ -934,6 +936,14 @@
set_define("XP_FREEBSD", target_is_freebsd)
+@depends(target)
+def target_is_redox(target):
+ if target.kernel == "Redox":
+ return True
+
+
+set_define("XP_REDOX", target_is_redox)
+
@depends(target)
def target_is_solaris(target):
diff --color -ruwN source/mozglue/misc/PlatformMutex.h source-new/mozglue/misc/PlatformMutex.h
--- source/mozglue/misc/PlatformMutex.h 2026-01-07 04:09:50.000000000 +0700
+++ source-new/mozglue/misc/PlatformMutex.h 2026-01-27 13:12:16.262181670 +0700
@@ -48,7 +48,7 @@
PlatformData* platformData();
-#if !defined(XP_WIN) && !defined(__wasi__)
+#if !defined(XP_WIN) && !defined(__wasi__) && !defined(__redox__)
void* platformData_[sizeof(pthread_mutex_t) / sizeof(void*)];
static_assert(sizeof(pthread_mutex_t) / sizeof(void*) != 0 &&
sizeof(pthread_mutex_t) % sizeof(void*) == 0,
diff --color -ruwN source/python/mozbuild/mozbuild/configure/constants.py source-new/python/mozbuild/mozbuild/configure/constants.py
--- source/python/mozbuild/mozbuild/configure/constants.py 2026-01-07 04:09:50.000000000 +0700
+++ source-new/python/mozbuild/mozbuild/configure/constants.py 2026-01-27 09:16:48.349211711 +0700
@@ -40,6 +40,7 @@
"NetBSD",
"OpenBSD",
"OSX",
+ "Redox",
"SunOS",
"WINNT",
"WASI",
@@ -55,6 +56,7 @@
"Linux",
"NetBSD",
"OpenBSD",
+ "Redox",
"SunOS",
"WINNT",
"WASI",
@@ -146,6 +148,7 @@
"Linux": "__linux__",
"NetBSD": "__NetBSD__",
"OpenBSD": "__OpenBSD__",
+ "Redox": "__redox__",
"SunOS": "__sun__",
"WINNT": "_WIN32 || __CYGWIN__",
"WASI": "__wasi__",
diff --color -ruwN source/xpcom/build/BinaryPath.h source-new/xpcom/build/BinaryPath.h
--- source/xpcom/build/BinaryPath.h 2026-01-07 04:09:59.000000000 +0700
+++ source-new/xpcom/build/BinaryPath.h 2026-01-27 12:51:20.922621049 +0700
@@ -133,11 +133,15 @@
return rv;
}
-#elif defined(ANDROID)
+#elif defined(ANDROID) || defined(XP_REDOX)
static nsresult Get(char aResult[MAXPATHLEN]) {
// On Android, we use the MOZ_ANDROID_LIBDIR variable that is set by the
// Java bootstrap code.
+#if defined(XP_REDOX)
+ const char* libDir = getenv("MOZ_REDOX_LIBDIR");
+#else
const char* libDir = getenv("MOZ_ANDROID_LIBDIR");
+#endif
if (!libDir) {
return NS_ERROR_FAILURE;
}