Skip to content

Commit

Permalink
firefox: use mach build
Browse files Browse the repository at this point in the history
  • Loading branch information
licy183 committed Mar 11, 2024
1 parent 5575b62 commit c4009e4
Show file tree
Hide file tree
Showing 27 changed files with 509 additions and 474 deletions.
11 changes: 11 additions & 0 deletions x11-packages/firefox/0001-configure-treat-termux-as-linux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -500,7 +500,7 @@
abi = None
sub_configure_alias = triplet
if "android" in os:
- canonical_os = "Android"
+ canonical_os = "GNU"
canonical_kernel = "Linux"
elif os.startswith("linux"):
canonical_os = "GNU"
11 changes: 11 additions & 0 deletions x11-packages/firefox/0002-configure-fix-arm-options.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/build/moz.configure/arm.configure
+++ b/build/moz.configure/arm.configure
@@ -7,7 +7,7 @@

@depends(target.os)
def arm_option_defaults(os):
- if os == "Android":
+ if True:
arch = "armv7-a"
thumb = "yes"
fpu = "neon"
44 changes: 44 additions & 0 deletions x11-packages/firefox/0003-configure-fix-rustflags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -514,17 +514,27 @@
assert_rust_compile(host, rustc_target, rustc)
return rustc_target

+option("--custom-rust-target-triple", nargs=1, help="Customize Rust Target Triple")
+
+@depends("--custom-rust-target-triple")
+def get_custom_rust_target_triple(custom_rust_target_triple):
+ if custom_rust_target_triple:
+ return custom_rust_target_triple[0]
+ return None

@depends(
- rustc, target, c_compiler, rust_supported_targets, arm_target, when=rust_compiler
+ get_custom_rust_target_triple, rustc, target, c_compiler, rust_supported_targets, arm_target, when=rust_compiler
)
@checking("for rust target triplet")
def rust_target_triple(
- rustc, target, compiler_info, rust_supported_targets, arm_target
+ custom_rust_target_triple, rustc, target, compiler_info, rust_supported_targets, arm_target
):
- rustc_target = detect_rustc_target(
- target, compiler_info, arm_target, rust_supported_targets
- )
+ if custom_rust_target_triple:
+ rustc_target = custom_rust_target_triple
+ else:
+ rustc_target = detect_rustc_target(
+ target, compiler_info, arm_target, rust_supported_targets
+ )
assert_rust_compile(target, rustc_target, rustc)
return rustc_target

@@ -599,8 +609,6 @@

# ==============================================================

-option(env="RUSTFLAGS", nargs=1, help="Rust compiler flags")
-set_config("RUSTFLAGS", depends("RUSTFLAGS")(lambda flags: flags))


# Rust compiler flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1981,17 +1981,7 @@

@depends(cxx_compiler, target)
def needs_libstdcxx_newness_check(cxx_compiler, target):
- # We only have to care about this on Linux and MinGW.
- if cxx_compiler.type == "clang-cl":
- return
-
- if target.kernel not in ("Linux", "WINNT"):
- return
-
- if target.os == "Android":
- return
-
- return True
+ return


def die_on_old_libstdcxx():
22 changes: 22 additions & 0 deletions x11-packages/firefox/0005-configure-do-not-append-sysroot.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1256,7 +1256,7 @@
):
wrapper = list(compiler_wrapper or ())
flags = []
- if sysroot.path:
+ if False:
if host_or_target.kernel == "Darwin":
# While --sysroot and -isysroot are roughly equivalent, when not using
# -isysroot on mac, clang takes the SDKROOT environment variable into
--- a/build/moz.configure/pkg.configure
+++ b/build/moz.configure/pkg.configure
@@ -56,7 +56,7 @@
@imports(_from="os", _import="environ")
@imports(_from="os", _import="pathsep")
def pkg_config_vars(target, sysroot_path, multiarch_dir):
- if sysroot_path and target.kernel != "Darwin":
+ if False:
pkgconfig_dirs = [
"usr/lib/pkgconfig",
"usr/lib/{}/pkgconfig".format(multiarch_dir),
11 changes: 11 additions & 0 deletions x11-packages/firefox/0006-configure-do-not-enable-alsa.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -174,7 +174,7 @@
@depends(target)
def midir_linux_support(target):
return (
- target.kernel == "Linux" and target.os != "Android" and target.cpu != "riscv64"
+ False
)


11 changes: 11 additions & 0 deletions x11-packages/firefox/0007-configure-fix-autoconf-on-android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -6,7 +6,7 @@
[

case "$target" in
-*-android*|*-linuxandroid*)
+no-android)
dnl $extra_android_flags will be set for us by Python configure.
dnl $_topsrcdir/build/android is a hack for versions of rustc < 1.68
LDFLAGS="$extra_android_flags -L$_topsrcdir/build/android $LDFLAGS"
88 changes: 88 additions & 0 deletions x11-packages/firefox/0008-fix-marcos.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
--- a/dom/media/systemservices/VideoEngine.cpp
+++ b/dom/media/systemservices/VideoEngine.cpp
@@ -30,7 +30,7 @@
#define LOG(args) MOZ_LOG(gVideoEngineLog, mozilla::LogLevel::Debug, args)
#define LOG_ENABLED() MOZ_LOG_TEST(gVideoEngineLog, mozilla::LogLevel::Debug)

-#if defined(ANDROID)
+#if defined(ANDROID) && !defined(__TERMUX__)
int VideoEngine::SetAndroidObjects() {
LOG(("%s", __PRETTY_FUNCTION__));

--- a/ipc/chromium/src/base/lock_impl_posix.cc
+++ b/ipc/chromium/src/base/lock_impl_posix.cc
@@ -22,7 +22,7 @@
// Lock::PriorityInheritanceAvailable still must be checked as the code may
// compile but the underlying platform still may not correctly support priority
// inheritance locks.
-#if defined(ANDROID)
+#if defined(ANDROID) || defined(__TERMUX__)
# define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 0
#else
# define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 1
--- a/js/src/ctypes/libffi/src/closures.c
+++ b/js/src/ctypes/libffi/src/closures.c
@@ -112,7 +112,7 @@
#else /* !NetBSD with PROT_MPROTECT */

#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
-# if __linux__ && !defined(__ANDROID__)
+# if __linux__ && !defined(__TERMUX__)
/* This macro indicates it may be forbidden to map anonymous memory
with both write and execute permission. Code compiled when this
option is defined will attempt to map such pages once, but if it
--- a/memory/build/malloc_decls.h
+++ b/memory/build/malloc_decls.h
@@ -39,7 +39,7 @@
// consistent declare certain functions as `throw()`, though.

// Bionic and OS X don't seem to care about `throw()`ness.
-# if defined(ANDROID) || defined(XP_DARWIN)
+# if defined(__TERMUX__) || defined(XP_DARWIN)
# undef NOTHROW_MALLOC_DECL
# define NOTHROW_MALLOC_DECL MALLOC_DECL
// Some places don't care about the distinction.
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -57,7 +57,7 @@
#define PREF_AUDIOIPC_STACK_SIZE "media.audioipc.stack_size"
#define PREF_AUDIOIPC_SHM_AREA_SIZE "media.audioipc.shm_area_size"

-#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(XP_WIN)
+#if (defined(XP_LINUX) && !defined(__TERMUX__)) || defined(XP_MACOSX) || defined(XP_WIN)
# define MOZ_CUBEB_REMOTING
#endif

--- a/mozglue/misc/ConditionVariable_posix.cpp
+++ b/mozglue/misc/ConditionVariable_posix.cpp
@@ -23,7 +23,7 @@
// Android 4.4 or earlier & macOS 10.12 has the clock functions, but not
// pthread_condattr_setclock.
#if defined(HAVE_CLOCK_MONOTONIC) && \
- !(defined(__ANDROID__) && __ANDROID_API__ < 21) && !defined(__APPLE__)
+ defined(__TERMUX__)
# define CV_USE_CLOCK_API
#endif

--- a/mozglue/misc/StackWalk.cpp
+++ b/mozglue/misc/StackWalk.cpp
@@ -692,7 +692,7 @@
stackEnd = __libc_stack_end;
# elif defined(XP_DARWIN)
stackEnd = pthread_get_stackaddr_np(pthread_self());
-# elif defined(ANDROID)
+# elif defined(__TERMUX__)
pthread_attr_t sattr;
pthread_attr_init(&sattr);
pthread_getattr_np(pthread_self(), &sattr);
--- a/nsprpub/pr/src/pthreads/ptsynch.c
+++ b/nsprpub/pr/src/pthreads/ptsynch.c
@@ -953,7 +953,7 @@
#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \
|| (defined(FREEBSD) && __FreeBSD_version < 1200059) \
|| defined(OPENBSD) || defined(BSDI) \
- || defined(DARWIN)
+ || defined(DARWIN) || defined(__TERMUX__)
/* union semun is defined by including <sys/sem.h> */
#else
/* according to X/OPEN we have to define it ourselves */
File renamed without changes.
23 changes: 23 additions & 0 deletions x11-packages/firefox/0011-use-UnderrunHandlerNoop.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
UnderrunHandlerLinux not working due to SELinux rules

--- a/dom/media/UnderrunHandlerLinux.cpp
+++ b/dom/media/UnderrunHandlerLinux.cpp
@@ -12,6 +12,8 @@
#include "audio_thread_priority.h"
#include "nsDebug.h"

+#ifndef __TERMUX__
+
namespace mozilla {

Atomic<bool, MemoryOrdering::ReleaseAcquire> gRealtimeLimitReached;
@@ -76,3 +78,9 @@
}

} // namespace mozilla
+
+#else
+
+#include "UnderrunHandlerNoop.cpp"
+
+#endif
20 changes: 20 additions & 0 deletions x11-packages/firefox/0012-do-not-use-adaptive-mutex.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/memory/build/Mutex.h
+++ b/memory/build/Mutex.h
@@ -57,7 +57,7 @@
}
#elif defined(XP_DARWIN)
mMutex = OS_UNFAIR_LOCK_INIT;
-#elif defined(XP_LINUX) && !defined(ANDROID)
+#elif defined(XP_LINUX) && !defined(__TERMUX__)
pthread_mutexattr_t attr;
if (pthread_mutexattr_init(&attr) != 0) {
return false;
@@ -173,7 +173,7 @@

# if defined(XP_DARWIN)
# define STATIC_MUTEX_INIT OS_UNFAIR_LOCK_INIT
-# elif defined(XP_LINUX) && !defined(ANDROID)
+# elif defined(XP_LINUX) && !defined(__TERMUX__)
# define STATIC_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
# else
# define STATIC_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
53 changes: 53 additions & 0 deletions x11-packages/firefox/0013-fix-rust-compile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
--- a/toolkit/components/extensions/storage/moz.build
+++ b/toolkit/components/extensions/storage/moz.build
@@ -17,7 +17,7 @@
# a delegate for consumers to use instead. Android Components can then provide
# an implementation of the delegate that's backed by the Rust component. For
# details, please see bug 1626506, comment 4.
-if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android":
+if False:
EXPORTS.mozilla.extensions.storage += [
"ExtensionStorageComponents.h",
]
--- a/toolkit/library/rust/shared/Cargo.toml
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -104,7 +104,6 @@
# 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" }
--- a/toolkit/library/rust/shared/lib.rs
+++ b/toolkit/library/rust/shared/lib.rs
@@ -50,21 +50,16 @@

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(not(target_os = "android"))]
extern crate suggest;

-#[cfg(not(target_os = "android"))]
mod reexport_suggest {
suggest::uniffi_reexport_scaffolding!();
}
@@ -93,7 +88,6 @@
extern crate l10nregistry_ffi;
extern crate localization_ffi;

-#[cfg(not(target_os = "android"))]
extern crate viaduct;

extern crate gecko_logger;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
THREAD_PRIORITY_SCHEDULING is introduced in API 28, but Termux compiles as API 24

--- a/nsprpub/pr/src/pthreads/ptthread.c
+++ b/nsprpub/pr/src/pthreads/ptthread.c
@@ -37,6 +37,10 @@
#endif
#endif

+#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && defined(__TERMUX__) && __ANDROID_API__ < 28
+#undef _POSIX_THREAD_PRIORITY_SCHEDULING
+#endif
+
/*
* Record whether or not we have the privilege to set the scheduling
* policy and priority of threads. 0 means that privilege is available.
22 changes: 22 additions & 0 deletions x11-packages/firefox/0015-skia-termux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/gfx/skia/skia/src/ports/SkDebug_stdio.cpp
+++ b/gfx/skia/skia/src/ports/SkDebug_stdio.cpp
@@ -8,7 +8,7 @@
#include "include/private/base/SkFeatures.h"
#include "include/private/base/SkLoadUserConfig.h"

-#if !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_ANDROID)
+#if (!defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_ANDROID)) || defined(__TERMUX__)

#include <stdarg.h>
#include <stdio.h>
--- a/gfx/skia/skia/src/ports/SkDebug_android.cpp
+++ b/gfx/skia/skia/src/ports/SkDebug_android.cpp
@@ -6,7 +6,7 @@
*/

#include "include/core/SkTypes.h"
-#if defined(SK_BUILD_FOR_ANDROID)
+#if defined(SK_BUILD_FOR_ANDROID) && !defined(__TERMUX__)

#include <stdio.h>

20 changes: 20 additions & 0 deletions x11-packages/firefox/0016-protobuf-no-android-log.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/toolkit/components/protobuf/src/google/protobuf/stubs/common.cc
+++ b/toolkit/components/protobuf/src/google/protobuf/stubs/common.cc
@@ -45,7 +45,7 @@
#include <windows.h>
#define snprintf _snprintf // see comment in strutil.cc
#endif
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(__TERMUX__)
#include <android/log.h>
#endif

@@ -121,7 +121,7 @@

namespace internal {

-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(__TERMUX__)
inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
const std::string& message) {
if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/intl/lwbrk/LineBreaker.cpp
+++ b/intl/lwbrk/LineBreaker.cpp
@@ -448,7 +448,13 @@
@@ -434,7 +434,13 @@
/* REGIONAL_INDICATOR = 39, [RI] */ CLASS_CHARACTER,
/* E_BASE = 40, [EB] */ CLASS_BREAKABLE,
/* E_MODIFIER = 41, [EM] */ CLASS_CHARACTER,
Expand Down

0 comments on commit c4009e4

Please sign in to comment.