From 224663defee48f79b623560d9765d8fc0914f9c7 Mon Sep 17 00:00:00 2001 From: Chongyun Lee <45286352+licy183@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:51:58 +0800 Subject: [PATCH] new package: electron-32 (#37) [skip ci] --- .../0002-compiler-use-android-target.patch | 24 ++ .../0003-compiler-disable-warnings.patch | 14 + .../0004-compiler-clang-lib-dir.patch | 45 ++ ...mpiler-custom-rust-abi-target-triple.patch | 42 ++ ...06-compiler-use-custom-libcxx-for-v8.patch | 20 + .../0007-script-add-ld-preload.patch | 23 + .../0008-remove-xorg-from-build-deps-2.patch | 13 + .../1001-chromium-disable-sandbox.patch | 95 ++++ .../1002-chromium-disable-shm.patch | 11 + .../1003-chromium-fix-type-for-inotify.patch | 11 + ...-headless-disable-sandbox-by-default.patch | 14 + .../electron-32/1005-chromium-impl-dns.patch | 92 ++++ .../1006-chromium-impl-scoped-file.patch | 40 ++ .../1007-chromium-impl-sysinfo.patch | 104 +++++ .../1008-chromium-no-futimes.patch | 11 + .../1009-chromium-no-glibc-version.patch | 15 + ...romium-no-priority-inheritance-locks.patch | 11 + .../1011-chromium-no-set-process-title.patch | 11 + .../1012-chromium-redefine-termios2.patch | 11 + ...m-crypt-fix-dynamic-loaded-libraries.patch | 14 + ...m-unity-fix-dynamic-loaded-libraries.patch | 11 + ...fix-dynamic-loaded-libraries.patch.disable | 50 +++ .../1016-chromium-ozone-wayland-memfd.patch | 14 + ...ium-x11-fix-dynamic-loaded-libraries.patch | 28 ++ .../1018-chromium-no-landlock.patch | 11 + .../1019-chromium-dummy-hid-service.patch | 51 +++ ...020-chromium-debug-build-stack_trace.patch | 19 + .../1501-v8-fix-compress-pointer-offset.patch | 11 + .../1502-v8-reimpl-page-allocator.patch | 13 + .../1503-v8-fix-trap-handler.patch | 26 ++ .../1601-angle-no-android-jni.patch | 11 + .../1701-swiftshader-no-spawn.patch | 11 + ...tshader-fix-dynamic-loaded-libraries.patch | 40 ++ .../1703-swiftshader-no-android.patch | 406 ++++++++++++++++++ .../2001-weston-memfd_create.patch | 14 + ...-weston-fix-dynamic-loaded-libraries.patch | 14 + .../2003-wayland-memfd_create.patch | 14 + .../2004-breakpad-no-elf_prstatus.patch | 18 + .../electron-32/2005-crashpad-fill-elf.patch | 18 + .../2006-crashpad-no-getdtablesize.patch | 11 + .../electron-32/2007-crashpad-no-memfd.patch | 22 + .../electron-32/2008-crashpad-no-spawn.patch | 28 ++ .../2009-cpuinfo-android-arm.patch | 13 + .../2010-dav1d-no-get-affinity.patch | 11 + ...11-dawn-fix-dynamic-loaded-libraries.patch | 24 ++ .../2012-dawn-no-android-jni.patch | 23 + .../2013-minigbm-no-android-log.patch | 20 + .../2014-perfetto-no-android-jni.patch | 11 + .../2015-perfetto-no-pthread_getname_np.patch | 20 + .../electron-32/2016-dawn-aligned-alloc.patch | 11 + .../2017-vk-layers-no-android-log.patch | 64 +++ .../electron-32/2018-unrar-no-lutimes.patch | 14 + .../electron-32/2019-tflite-no-atrace.patch | 20 + .../electron-32/2020-dav1d-config.patch | 60 +++ .../electron-32/2101-mix-no-execinfo.patch | 61 +++ .../2102-mix-egl-fix-include.patch | 47 ++ ...3-pulse-fix-dynamic-loaded-libraries.patch | 29 ++ .../7001-blink-font-constructor.patch | 11 + .../7002-blink-cxx11-narrowing.patch | 14 + .../8001-blink-include-bitset-2.patch | 11 + ...terial_color_utilities-include-cmath.patch | 10 + .../electron-32/8003-gfx-include-bitset.patch | 11 + .../9001-electron-getversion-from-file.patch | 12 + .../9002-v8-fix-trap-handler.patch | 11 + .../electron-32/9003-cares-config.patch | 55 +++ .../9004-electron-disable-sandbox.patch | 16 + .../electron-32/9005-node-as-posix.patch | 14 + ...006-gtk-fix-dynamic-loaded-libraries.patch | 53 +++ ...ng-function-for-extension_action_api.patch | 16 + tur-electron/electron-32/build.sh | 361 ++++++++++++++++ tur-electron/electron-32/toolchain.gn.in | 30 ++ 71 files changed, 2515 insertions(+) create mode 100644 tur-electron/electron-32/0002-compiler-use-android-target.patch create mode 100644 tur-electron/electron-32/0003-compiler-disable-warnings.patch create mode 100644 tur-electron/electron-32/0004-compiler-clang-lib-dir.patch create mode 100644 tur-electron/electron-32/0005-compiler-custom-rust-abi-target-triple.patch create mode 100644 tur-electron/electron-32/0006-compiler-use-custom-libcxx-for-v8.patch create mode 100644 tur-electron/electron-32/0007-script-add-ld-preload.patch create mode 100644 tur-electron/electron-32/0008-remove-xorg-from-build-deps-2.patch create mode 100644 tur-electron/electron-32/1001-chromium-disable-sandbox.patch create mode 100644 tur-electron/electron-32/1002-chromium-disable-shm.patch create mode 100644 tur-electron/electron-32/1003-chromium-fix-type-for-inotify.patch create mode 100644 tur-electron/electron-32/1004-chromium-headless-disable-sandbox-by-default.patch create mode 100644 tur-electron/electron-32/1005-chromium-impl-dns.patch create mode 100644 tur-electron/electron-32/1006-chromium-impl-scoped-file.patch create mode 100644 tur-electron/electron-32/1007-chromium-impl-sysinfo.patch create mode 100644 tur-electron/electron-32/1008-chromium-no-futimes.patch create mode 100644 tur-electron/electron-32/1009-chromium-no-glibc-version.patch create mode 100644 tur-electron/electron-32/1010-chromium-no-priority-inheritance-locks.patch create mode 100644 tur-electron/electron-32/1011-chromium-no-set-process-title.patch create mode 100644 tur-electron/electron-32/1012-chromium-redefine-termios2.patch create mode 100644 tur-electron/electron-32/1013-chromium-crypt-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/1014-chromium-unity-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/1015-chromium-gtk-fix-dynamic-loaded-libraries.patch.disable create mode 100644 tur-electron/electron-32/1016-chromium-ozone-wayland-memfd.patch create mode 100644 tur-electron/electron-32/1017-chromium-x11-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/1018-chromium-no-landlock.patch create mode 100644 tur-electron/electron-32/1019-chromium-dummy-hid-service.patch create mode 100644 tur-electron/electron-32/1020-chromium-debug-build-stack_trace.patch create mode 100644 tur-electron/electron-32/1501-v8-fix-compress-pointer-offset.patch create mode 100644 tur-electron/electron-32/1502-v8-reimpl-page-allocator.patch create mode 100644 tur-electron/electron-32/1503-v8-fix-trap-handler.patch create mode 100644 tur-electron/electron-32/1601-angle-no-android-jni.patch create mode 100644 tur-electron/electron-32/1701-swiftshader-no-spawn.patch create mode 100644 tur-electron/electron-32/1702-swiftshader-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/1703-swiftshader-no-android.patch create mode 100644 tur-electron/electron-32/2001-weston-memfd_create.patch create mode 100644 tur-electron/electron-32/2002-weston-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/2003-wayland-memfd_create.patch create mode 100644 tur-electron/electron-32/2004-breakpad-no-elf_prstatus.patch create mode 100644 tur-electron/electron-32/2005-crashpad-fill-elf.patch create mode 100644 tur-electron/electron-32/2006-crashpad-no-getdtablesize.patch create mode 100644 tur-electron/electron-32/2007-crashpad-no-memfd.patch create mode 100644 tur-electron/electron-32/2008-crashpad-no-spawn.patch create mode 100644 tur-electron/electron-32/2009-cpuinfo-android-arm.patch create mode 100644 tur-electron/electron-32/2010-dav1d-no-get-affinity.patch create mode 100644 tur-electron/electron-32/2011-dawn-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/2012-dawn-no-android-jni.patch create mode 100644 tur-electron/electron-32/2013-minigbm-no-android-log.patch create mode 100644 tur-electron/electron-32/2014-perfetto-no-android-jni.patch create mode 100644 tur-electron/electron-32/2015-perfetto-no-pthread_getname_np.patch create mode 100644 tur-electron/electron-32/2016-dawn-aligned-alloc.patch create mode 100644 tur-electron/electron-32/2017-vk-layers-no-android-log.patch create mode 100644 tur-electron/electron-32/2018-unrar-no-lutimes.patch create mode 100644 tur-electron/electron-32/2019-tflite-no-atrace.patch create mode 100644 tur-electron/electron-32/2020-dav1d-config.patch create mode 100644 tur-electron/electron-32/2101-mix-no-execinfo.patch create mode 100644 tur-electron/electron-32/2102-mix-egl-fix-include.patch create mode 100644 tur-electron/electron-32/2103-pulse-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/7001-blink-font-constructor.patch create mode 100644 tur-electron/electron-32/7002-blink-cxx11-narrowing.patch create mode 100644 tur-electron/electron-32/8001-blink-include-bitset-2.patch create mode 100644 tur-electron/electron-32/8002-material_color_utilities-include-cmath.patch create mode 100644 tur-electron/electron-32/8003-gfx-include-bitset.patch create mode 100644 tur-electron/electron-32/9001-electron-getversion-from-file.patch create mode 100644 tur-electron/electron-32/9002-v8-fix-trap-handler.patch create mode 100644 tur-electron/electron-32/9003-cares-config.patch create mode 100644 tur-electron/electron-32/9004-electron-disable-sandbox.patch create mode 100644 tur-electron/electron-32/9005-node-as-posix.patch create mode 100644 tur-electron/electron-32/9006-gtk-fix-dynamic-loaded-libraries.patch create mode 100644 tur-electron/electron-32/9007-add-missing-function-for-extension_action_api.patch create mode 100644 tur-electron/electron-32/build.sh create mode 100644 tur-electron/electron-32/toolchain.gn.in diff --git a/tur-electron/electron-32/0002-compiler-use-android-target.patch b/tur-electron/electron-32/0002-compiler-use-android-target.patch new file mode 100644 index 0000000..d719757 --- /dev/null +++ b/tur-electron/electron-32/0002-compiler-use-android-target.patch @@ -0,0 +1,24 @@ +--- a/build/config/compiler/BUILD.gn ++++ b/build/config/compiler/BUILD.gn +@@ -960,8 +960,8 @@ + } else if (current_cpu == "arm") { + if (is_clang && !is_android && !is_nacl && + !(is_chromeos_lacros && is_chromeos_device)) { +- cflags += [ "--target=arm-linux-gnueabihf" ] +- ldflags += [ "--target=arm-linux-gnueabihf" ] ++ cflags += [ "--target=armv7a-linux-android24" ] ++ ldflags += [ "--target=armv7a-linux-android24" ] + } + if (!is_nacl) { + cflags += [ +@@ -975,8 +975,8 @@ + } else if (current_cpu == "arm64") { + if (is_clang && !is_android && !is_nacl && !is_fuchsia && + !(is_chromeos_lacros && is_chromeos_device)) { +- cflags += [ "--target=aarch64-linux-gnu" ] +- ldflags += [ "--target=aarch64-linux-gnu" ] ++ cflags += [ "--target=aarch64-linux-android24" ] ++ ldflags += [ "--target=aarch64-linux-android24" ] + } + } else if (current_cpu == "mipsel" && !is_nacl) { + ldflags += [ "-Wl,--hash-style=sysv" ] diff --git a/tur-electron/electron-32/0003-compiler-disable-warnings.patch b/tur-electron/electron-32/0003-compiler-disable-warnings.patch new file mode 100644 index 0000000..6812ea5 --- /dev/null +++ b/tur-electron/electron-32/0003-compiler-disable-warnings.patch @@ -0,0 +1,14 @@ +--- a/build/config/compiler/BUILD.gn ++++ b/build/config/compiler/BUILD.gn +@@ -1919,6 +1912,11 @@ + } + } + ++ cflags += [ ++ "-Wno-unknown-warning-option", ++ "-Wno-unknown-pragmas", ++ ] ++ + # Rust warnings + + # Require `unsafe` blocks even in `unsafe` fns. This is intended to become diff --git a/tur-electron/electron-32/0004-compiler-clang-lib-dir.patch b/tur-electron/electron-32/0004-compiler-clang-lib-dir.patch new file mode 100644 index 0000000..e4ef8c3 --- /dev/null +++ b/tur-electron/electron-32/0004-compiler-clang-lib-dir.patch @@ -0,0 +1,45 @@ +--- a/build/config/clang/clang.gni ++++ b/build/config/clang/clang.gni +@@ -35,6 +35,9 @@ + # Set to true to enable output of ThinLTO index and import files used for + # creating a Chromium MLGO corpus in the ThinLTO case. + lld_emit_indexes_and_imports = false ++ ++ custom_toolchain_clang_base_path = "" ++ custom_toolchain_clang_version = "" + } + + # We don't really need to collect a corpus for the host tools, just for the target. +--- a/build/config/clang/BUILD.gn ++++ b/build/config/clang/BUILD.gn +@@ -5,6 +5,8 @@ + import("//build/config/rust.gni") + import("clang.gni") + ++import("//v8/gni/snapshot_toolchain.gni") ++ + if (is_ios) { + import("//build/config/ios/config.gni") # For `target_environment` + } +@@ -186,6 +186,21 @@ + } + + _clang_lib_dir = "$clang_base_path/lib/clang/$clang_version/lib" ++ ++ if (is_a_target_toolchain && current_toolchain != v8_snapshot_toolchain) { ++ _dir = "linux" ++ _clang_lib_dir = "$custom_toolchain_clang_base_path/lib/clang/$custom_toolchain_clang_version/lib" ++ if (current_cpu == "x64") { ++ _suffix = "-x86_64-android" ++ } else if (current_cpu == "arm") { ++ _suffix = "-arm-android" ++ } else if (current_cpu == "arm64") { ++ _suffix = "-aarch64-android" ++ } else { ++ assert(false) # Unhandled cpu type ++ } ++ } ++ + _lib_file = "${_prefix}clang_rt.${_libname}${_suffix}.${_ext}" + libs = [ "$_clang_lib_dir/$_dir/$_lib_file" ] + } diff --git a/tur-electron/electron-32/0005-compiler-custom-rust-abi-target-triple.patch b/tur-electron/electron-32/0005-compiler-custom-rust-abi-target-triple.patch new file mode 100644 index 0000000..0a46476 --- /dev/null +++ b/tur-electron/electron-32/0005-compiler-custom-rust-abi-target-triple.patch @@ -0,0 +1,42 @@ +--- a/build/config/rust.gni ++++ b/build/config/rust.gni +@@ -7,6 +7,8 @@ + import("//build/config/sanitizers/sanitizers.gni") + import("//build/toolchain/toolchain.gni") + ++import("//v8/gni/snapshot_toolchain.gni") ++ + if (is_android) { + import("//build/config/android/config.gni") + } +@@ -98,6 +100,8 @@ + # a platform. Mostly applicable to Windows, where new versions can handle ANSI + # escape sequences but it's not reliable in general. + force_rustc_color_output = false ++ ++ custom_target_rust_abi_target = "" + } + + # Use a separate declare_args so these variables' defaults can depend on the +@@ -165,7 +169,7 @@ + # TODO(crbug.com/1278030): To build unit tests for Android we need to build + # them as a dylib and put them into an APK. We should reuse all the same logic + # for gtests from the `//testing/test:test` template. +-can_build_rust_unit_tests = toolchain_has_rust && !is_android ++can_build_rust_unit_tests = toolchain_has_rust && !is_android && false + + # We want to store rust_sysroot as a source-relative variable for ninja + # portability. In practice if an external toolchain was specified, it might +@@ -280,6 +284,12 @@ + } + } + ++if (!toolchain_for_rust_host_build_tools && current_toolchain != v8_snapshot_toolchain && current_toolchain != host_toolchain) { ++ if (custom_target_rust_abi_target != "") { ++ rust_abi_target = custom_target_rust_abi_target ++ } ++} ++ + assert(!toolchain_has_rust || rust_abi_target != "") + + # This variable is passed to the Rust libstd build. diff --git a/tur-electron/electron-32/0006-compiler-use-custom-libcxx-for-v8.patch b/tur-electron/electron-32/0006-compiler-use-custom-libcxx-for-v8.patch new file mode 100644 index 0000000..5246897 --- /dev/null +++ b/tur-electron/electron-32/0006-compiler-use-custom-libcxx-for-v8.patch @@ -0,0 +1,20 @@ +--- a/build/config/c++/c++.gni ++++ b/build/config/c++/c++.gni +@@ -6,6 +6,8 @@ + import("//build/config/sanitizers/sanitizers.gni") + import("//build_overrides/build.gni") + ++import("//v8/gni/snapshot_toolchain.gni") ++ + declare_args() { + # Use in-tree libc++ (buildtools/third_party/libc++ and + # buildtools/third_party/libc++abi) instead of the system C++ library for C++ +@@ -42,6 +44,8 @@ + + use_custom_libcxx = + use_custom_libcxx || (use_custom_libcxx_for_host && !is_a_target_toolchain) ++use_custom_libcxx = ++ use_custom_libcxx || (use_custom_libcxx_for_host && current_toolchain == v8_snapshot_toolchain) + use_custom_libcxx = use_custom_libcxx && !is_nacl + + declare_args() { diff --git a/tur-electron/electron-32/0007-script-add-ld-preload.patch b/tur-electron/electron-32/0007-script-add-ld-preload.patch new file mode 100644 index 0000000..db109c4 --- /dev/null +++ b/tur-electron/electron-32/0007-script-add-ld-preload.patch @@ -0,0 +1,23 @@ +--- a/build/gn_run_binary.py ++++ b/build/gn_run_binary.py +@@ -23,7 +23,19 @@ + # The rest of the arguments are passed directly to the executable. + args = [path] + sys.argv[2:] + +-ret = subprocess.call(args) ++# Modified by Termux: When building for termux, this wrapper will ++# be used to run the binary which is built for host machine, using ++# the rootfs provided by Google. We need to set LD_PRELOAD with ++# libffi.so.7 as the host machine (Ubuntu 24.04) doesn't provide it. ++envs = os.environ.copy() ++if "./clang_x86_v8_arm/" in path or "./clang_x86/" in path: ++ base_sysroot = os.path.join(os.path.dirname(__file__), "linux", "debian_bullseye_i386-sysroot") ++ envs["LD_PRELOAD"] = base_sysroot + "/usr/lib/i386-linux-gnu/libffi.so.7" ++elif "./host/" in path or "./clang_x64_v8_arm64/" in path or "./clang_x64/" in path: ++ base_sysroot = os.path.join(os.path.dirname(__file__), "linux", "debian_bullseye_amd64-sysroot") ++ envs["LD_PRELOAD"] = base_sysroot + "/usr/lib/x86_64-linux-gnu/libffi.so.7" ++ ++ret = subprocess.call(args, env=envs) + if ret != 0: + if ret <= -100: + # Windows error codes such as 0xC0000005 and 0xC0000409 are much easier to diff --git a/tur-electron/electron-32/0008-remove-xorg-from-build-deps-2.patch b/tur-electron/electron-32/0008-remove-xorg-from-build-deps-2.patch new file mode 100644 index 0000000..867730f --- /dev/null +++ b/tur-electron/electron-32/0008-remove-xorg-from-build-deps-2.patch @@ -0,0 +1,13 @@ +This reverts https://github.com/chromium/chromium/commit/97c864b32a7f4d64f541e2b7bf9006d2f582082f + +--- a/build/install-build-deps.py ++++ b/build/install-build-deps.py +@@ -388,8 +388,6 @@ + "libxtst6", + "x11-utils", + "x11-xserver-utils", +- "xserver-xorg-core", +- "xserver-xorg-video-dummy", + "xvfb", + "zlib1g", + ] diff --git a/tur-electron/electron-32/1001-chromium-disable-sandbox.patch b/tur-electron/electron-32/1001-chromium-disable-sandbox.patch new file mode 100644 index 0000000..c93d447 --- /dev/null +++ b/tur-electron/electron-32/1001-chromium-disable-sandbox.patch @@ -0,0 +1,95 @@ +--- a/content/shell/app/shell_main_delegate.cc ++++ b/content/shell/app/shell_main_delegate.cc +@@ -90,6 +90,10 @@ + #include "content/shell/app/ios/shell_application_ios.h" + #endif + ++#ifdef __TERMUX__ ++#include "sandbox/policy/switches.h" ++#endif ++ + namespace { + + #if !BUILDFLAG(IS_FUCHSIA) +@@ -210,6 +214,15 @@ + base::CPU cpu_info; + #endif + ++// Disable sandbox on Termux. ++#ifdef __TERMUX__ ++ if (!base::CommandLine::ForCurrentProcess()->HasSwitch( ++ sandbox::policy::switches::kNoSandbox)) { ++ base::CommandLine::ForCurrentProcess()->AppendSwitch( ++ sandbox::policy::switches::kNoSandbox); ++ } ++#endif ++ + // Disable platform crash handling and initialize the crash reporter, if + // requested. + // TODO(crbug.com/1226159): Implement crash reporter integration for Fuchsia. +--- a/chrome/browser/ui/startup/bad_flags_prompt.cc ++++ b/chrome/browser/ui/startup/bad_flags_prompt.cc +@@ -60,10 +60,12 @@ + static const char* kBadFlags[] = { + network::switches::kIgnoreCertificateErrorsSPKIList, + // These flags disable sandbox-related security. ++#ifndef __TERMUX__ + sandbox::policy::switches::kDisableGpuSandbox, + sandbox::policy::switches::kDisableSeccompFilterSandbox, + sandbox::policy::switches::kDisableSetuidSandbox, + sandbox::policy::switches::kNoSandbox, ++#endif + #if BUILDFLAG(IS_WIN) + sandbox::policy::switches::kAllowThirdPartyModules, + #endif +--- a/chrome/app/chrome_main_delegate.cc ++++ b/chrome/app/chrome_main_delegate.cc +@@ -235,6 +235,10 @@ + #include "ui/gfx/switches.h" + #endif + ++#ifdef __TERMUX__ ++#include "sandbox/policy/switches.h" ++#endif ++ + base::LazyInstance::DestructorAtExit + g_chrome_content_gpu_client = LAZY_INSTANCE_INITIALIZER; + base::LazyInstance::DestructorAtExit +@@ -1037,6 +1041,14 @@ + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + ++// Disable sandbox on Termux. ++#ifdef __TERMUX__ ++ if (!command_line.HasSwitch(sandbox::policy::switches::kNoSandbox)) { ++ base::CommandLine::ForCurrentProcess()->AppendSwitch( ++ sandbox::policy::switches::kNoSandbox); ++ } ++#endif ++ + // Only allow disabling web security via the command-line flag if the user has + // specified a distinct profile directory. This still enables tests to disable + // web security by setting the kWebKitWebSecurityEnabled pref directly. +--- a/content/shell/browser/shell_content_browser_client.cc ++++ b/content/shell/browser/shell_content_browser_client.cc +@@ -131,6 +131,10 @@ + #include "media/mojo/services/media_foundation_preferences.h" + #endif // BUILDFLAG(IS_WIN) + ++#ifdef __TERMUX__ ++#include "sandbox/policy/switches.h" ++#endif ++ + namespace content { + + namespace { +@@ -405,6 +409,9 @@ + // to shell_main.cc that it's a browser test. + switches::kBrowserTest, + #endif ++#ifdef __TERMUX__ ++ sandbox::policy::switches::kNoSandbox ++#endif + switches::kCrashDumpsDir, + switches::kEnableCrashReporter, + switches::kExposeInternalsForTesting, diff --git a/tur-electron/electron-32/1002-chromium-disable-shm.patch b/tur-electron/electron-32/1002-chromium-disable-shm.patch new file mode 100644 index 0000000..dfe3830 --- /dev/null +++ b/tur-electron/electron-32/1002-chromium-disable-shm.patch @@ -0,0 +1,11 @@ +--- a/base/files/file_util_posix.cc ++++ b/base/files/file_util_posix.cc +@@ -1111,7 +1111,7 @@ + #if !BUILDFLAG(IS_ANDROID) + // This is implemented in file_util_android.cc for that platform. + bool GetShmemTempDir(bool executable, FilePath* path) { +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_AIX) ++#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_AIX)) && !defined(__TERMUX__) + bool disable_dev_shm = false; + #if !BUILDFLAG(IS_CHROMEOS) + disable_dev_shm = CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/tur-electron/electron-32/1003-chromium-fix-type-for-inotify.patch b/tur-electron/electron-32/1003-chromium-fix-type-for-inotify.patch new file mode 100644 index 0000000..a376780 --- /dev/null +++ b/tur-electron/electron-32/1003-chromium-fix-type-for-inotify.patch @@ -0,0 +1,11 @@ +--- a/base/files/file_path_watcher_inotify.cc ++++ b/base/files/file_path_watcher_inotify.cc +@@ -114,7 +114,7 @@ + class InotifyReader { + public: + // Watch descriptor used by AddWatch() and RemoveWatch(). +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || defined(__TERMUX__) + using Watch = uint32_t; + #else + using Watch = int; diff --git a/tur-electron/electron-32/1004-chromium-headless-disable-sandbox-by-default.patch b/tur-electron/electron-32/1004-chromium-headless-disable-sandbox-by-default.patch new file mode 100644 index 0000000..31de7dd --- /dev/null +++ b/tur-electron/electron-32/1004-chromium-headless-disable-sandbox-by-default.patch @@ -0,0 +1,14 @@ +--- a/headless/lib/headless_content_main_delegate.cc ++++ b/headless/lib/headless_content_main_delegate.cc +@@ -176,6 +176,11 @@ + if (!command_line->HasSwitch(::switches::kHeadless)) + command_line->AppendSwitch(::switches::kHeadless); + ++#ifdef __TERMUX__ ++ // Always pass no sandbox on Termux. ++ command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox); ++#endif ++ + // Use software rendering by default, but don't mess with gl and angle + // switches if user is overriding them. + if (!command_line->HasSwitch(::switches::kUseGL) && diff --git a/tur-electron/electron-32/1005-chromium-impl-dns.patch b/tur-electron/electron-32/1005-chromium-impl-dns.patch new file mode 100644 index 0000000..7f4f899 --- /dev/null +++ b/tur-electron/electron-32/1005-chromium-impl-dns.patch @@ -0,0 +1,92 @@ +--- a/net/dns/dns_config_service_linux.cc ++++ b/net/dns/dns_config_service_linux.cc +@@ -2,6 +2,10 @@ + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + ++#include ++ ++#ifndef __TERMUX__ ++ + #include "net/dns/dns_config_service_linux.h" + + #include +@@ -530,3 +534,8 @@ + } + + } // namespace net ++ ++#else // __TERMUX__ ++// XXX: Actually, Termux has no DNS config, fallback to use the stub of fushsia. ++#include "./dns_config_service_fuchsia.cc" ++#endif // __TERMUX__ +--- a/net/dns/dns_reloader.cc ++++ b/net/dns/dns_reloader.cc +@@ -31,7 +31,7 @@ + // an old musl bug that was fixed by musl c8fdcfe5, but Fuchsia's SDK doesn't + // have that change. + #if defined(__RES) && __RES >= 19991006 && !BUILDFLAG(IS_APPLE) && \ +- !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) ++ !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) && !defined(__TERMUX__) + // We define this so we don't need to restate the complex condition here twice + // below - it would be easy for the copies below to get out of sync. + #define USE_RES_NINIT +--- a/net/dns/public/resolv_reader.cc ++++ b/net/dns/public/resolv_reader.cc +@@ -32,6 +32,8 @@ + const struct __res_state& res) { + std::vector nameservers; + ++#ifndef __TERMUX__ ++ + if (!(res.options & RES_INIT)) + return absl::nullopt; + +@@ -88,6 +90,12 @@ + } + #endif + ++#else // __TERMUX__ ++ // From Android 8, getprop of net.dns%d has been invalid. So just ++ // assume the nameserver is 8.8.8.8. ++ nameservers.push_back(IPEndPoint(IPAddress(8, 8, 8, 8), 53)); ++#endif // __TERMUX__ ++ + return nameservers; + } + +--- a/net/dns/public/scoped_res_state.cc ++++ b/net/dns/public/scoped_res_state.cc +@@ -10,6 +10,15 @@ + #include "base/check.h" + #include "build/build_config.h" + ++#ifdef __TERMUX__ ++static int res_ninit(struct __res_state*) { ++ return 0; ++} ++static void res_nclose(struct __res_state*) { ++ return; ++} ++#endif ++ + namespace net { + + ScopedResState::ScopedResState() { +--- a/net/dns/public/scoped_res_state.h ++++ b/net/dns/public/scoped_res_state.h +@@ -11,6 +11,14 @@ + #include "net/base/net_export.h" + #include "third_party/abseil-cpp/absl/types/optional.h" + ++#ifdef __TERMUX__ ++// On Android NDK without JNI, there is no valid way to get nameservers. ++// So just provide a dummy struct and functions. ++struct __res_state { ++ int _dummy_state; ++}; ++#endif ++ + namespace net { + + // Helper class to open, read and close a __res_state. diff --git a/tur-electron/electron-32/1006-chromium-impl-scoped-file.patch b/tur-electron/electron-32/1006-chromium-impl-scoped-file.patch new file mode 100644 index 0000000..5a45888 --- /dev/null +++ b/tur-electron/electron-32/1006-chromium-impl-scoped-file.patch @@ -0,0 +1,40 @@ +--- a/base/files/scoped_file_linux.cc ++++ b/base/files/scoped_file_linux.cc +@@ -14,6 +14,26 @@ + #include "base/logging.h" + #include "base/strings/string_piece.h" + ++#ifdef __TERMUX__ ++#include ++#include ++#include ++static inline void termux_disable_fdsan() { ++ typedef void (*android_fdsan_error_level_ptr_t)(enum android_fdsan_error_level); ++ // For Android 11+. ++ void *lib_handle = dlopen("libc.so", RTLD_LAZY); ++ if (lib_handle) { ++ android_fdsan_error_level_ptr_t set_fdsan_error_level = ++ reinterpret_cast( ++ dlsym(lib_handle, "android_fdsan_set_error_level")); ++ if (set_fdsan_error_level != nullptr) { ++ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED); ++ } ++ dlclose(lib_handle); ++ } ++} ++#endif ++ + namespace { + + // We want to avoid any kind of allocations in our close() implementation, so we +@@ -65,6 +85,10 @@ + + void EnableFDOwnershipEnforcement(bool enabled) { + g_is_ownership_enforced = enabled; ++#ifdef __TERMUX__ ++ // Disable the Android native fdsan. ++ termux_disable_fdsan(); ++#endif + } + + void ResetFDOwnership() { diff --git a/tur-electron/electron-32/1007-chromium-impl-sysinfo.patch b/tur-electron/electron-32/1007-chromium-impl-sysinfo.patch new file mode 100644 index 0000000..1e6f6ad --- /dev/null +++ b/tur-electron/electron-32/1007-chromium-impl-sysinfo.patch @@ -0,0 +1,104 @@ +--- a/base/system/sys_info_linux.cc ++++ b/base/system/sys_info_linux.cc +@@ -126,7 +126,7 @@ + return std::string(); + } + +-#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_ANDROID) ++#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_ANDROID) && !defined(__TERMUX__) + // static + SysInfo::HardwareInfo SysInfo::GetHardwareInfoSync() { + static const size_t kMaxStringSize = 100u; +@@ -149,3 +149,81 @@ + #endif + + } // namespace base ++ ++#ifdef __TERMUX__ ++ ++#include ++#include ++ ++#include "base/logging.h" ++ ++#if 0 // (__ANDROID_API__ >= 21 /* 5.0 - Lollipop */) ++ ++namespace { ++ ++typedef int(SystemPropertyGetFunction)(const char*, char*); ++ ++SystemPropertyGetFunction* DynamicallyLoadRealSystemPropertyGet() { ++ // libc.so should already be open, get a handle to it. ++ void* handle = dlopen("libc.so", RTLD_NOLOAD); ++ if (!handle) { ++ LOG(FATAL) << "Cannot dlopen libc.so: " << dlerror(); ++ } ++ SystemPropertyGetFunction* real_system_property_get = ++ reinterpret_cast( ++ dlsym(handle, "__system_property_get")); ++ if (!real_system_property_get) { ++ LOG(FATAL) << "Cannot resolve __system_property_get(): " << dlerror(); ++ } ++ return real_system_property_get; ++} ++ ++static base::LazyInstance>::Leaky ++ g_lazy_real_system_property_get = LAZY_INSTANCE_INITIALIZER; ++ ++} // namespace ++ ++// Android 'L' removes __system_property_get from the NDK, however it is still ++// a hidden symbol in libc. Until we remove all calls of __system_property_get ++// from Chrome we work around this by defining a weak stub here, which uses ++// dlsym to but ensures that Chrome uses the real system ++// implementatation when loaded. http://crbug.com/392191. ++BASE_EXPORT int __system_property_get(const char* name, char* value) { ++ return g_lazy_real_system_property_get.Get().value()(name, value); ++} ++ ++#endif ++ ++namespace { ++ ++std::string HardwareManufacturerName() { ++ char device_model_str[PROP_VALUE_MAX]; ++ __system_property_get("ro.product.manufacturer", device_model_str); ++ return std::string(device_model_str); ++} ++ ++} // anonymous namespace ++ ++namespace base { ++ ++std::string SysInfo::HardwareModelName() { ++ char device_model_str[PROP_VALUE_MAX]; ++ __system_property_get("ro.product.model", device_model_str); ++ return std::string(device_model_str); ++} ++ ++// static ++SysInfo::HardwareInfo SysInfo::GetHardwareInfoSync() { ++ HardwareInfo info; ++ info.manufacturer = HardwareManufacturerName(); ++ info.model = HardwareModelName(); ++ DCHECK(IsStringUTF8(info.manufacturer)); ++ DCHECK(IsStringUTF8(info.model)); ++ return info; ++} ++ ++} ++ ++#endif // __TERMUX__ +--- a/base/system/sys_info.cc ++++ b/base/system/sys_info.cc +@@ -94,7 +94,7 @@ + #endif + + #if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_WIN) && \ +- !BUILDFLAG(IS_CHROMEOS) ++ !BUILDFLAG(IS_CHROMEOS) && !defined(__TERMUX__) + std::string SysInfo::HardwareModelName() { + return std::string(); + } diff --git a/tur-electron/electron-32/1008-chromium-no-futimes.patch b/tur-electron/electron-32/1008-chromium-no-futimes.patch new file mode 100644 index 0000000..01ea411 --- /dev/null +++ b/tur-electron/electron-32/1008-chromium-no-futimes.patch @@ -0,0 +1,11 @@ +--- a/base/files/file_posix.cc ++++ b/base/files/file_posix.cc +@@ -50,7 +50,7 @@ + } + + int CallFutimes(PlatformFile file, const struct timeval times[2]) { +-#ifdef __USE_XOPEN2K8 ++#if defined(__USE_XOPEN2K8) || (defined(__ANDROID__) && __ANDROID_API__ < 26) + // futimens should be available, but futimes might not be + // http://pubs.opengroup.org/onlinepubs/9699919799/ + diff --git a/tur-electron/electron-32/1009-chromium-no-glibc-version.patch b/tur-electron/electron-32/1009-chromium-no-glibc-version.patch new file mode 100644 index 0000000..338c4b6 --- /dev/null +++ b/tur-electron/electron-32/1009-chromium-no-glibc-version.patch @@ -0,0 +1,15 @@ +--- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc ++++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc +@@ -61,8 +61,10 @@ + + // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch + // of lacros-chrome is complete. +-#if defined(__GLIBC__) && (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) ++#ifdef __GLIBC__ + #include ++#endif + + #include "base/linux_util.h" + #include "base/strings/string_split.h" + diff --git a/tur-electron/electron-32/1010-chromium-no-priority-inheritance-locks.patch b/tur-electron/electron-32/1010-chromium-no-priority-inheritance-locks.patch new file mode 100644 index 0000000..253465a --- /dev/null +++ b/tur-electron/electron-32/1010-chromium-no-priority-inheritance-locks.patch @@ -0,0 +1,11 @@ +--- a/base/synchronization/lock_impl_posix.cc ++++ b/base/synchronization/lock_impl_posix.cc +@@ -59,7 +59,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 BUILDFLAG(IS_NACL) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) ++#if BUILDFLAG(IS_NACL) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || defined(__TERMUX__) + #define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 0 + #else + #define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 1 diff --git a/tur-electron/electron-32/1011-chromium-no-set-process-title.patch b/tur-electron/electron-32/1011-chromium-no-set-process-title.patch new file mode 100644 index 0000000..bc386f7 --- /dev/null +++ b/tur-electron/electron-32/1011-chromium-no-set-process-title.patch @@ -0,0 +1,11 @@ +--- a/base/process/set_process_title.cc ++++ b/base/process/set_process_title.cc +@@ -44,7 +44,7 @@ + + // TODO(jrg): Find out if setproctitle or equivalent is available on Android. + #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_SOLARIS) && \ +- !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_NACL) ++ !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_NACL) && !defined(__TERMUX__) + + void SetProcessTitleFromCommandLine(const char** main_argv) { + // Build a single string which consists of all the arguments separated diff --git a/tur-electron/electron-32/1012-chromium-redefine-termios2.patch b/tur-electron/electron-32/1012-chromium-redefine-termios2.patch new file mode 100644 index 0000000..d25b7a5 --- /dev/null +++ b/tur-electron/electron-32/1012-chromium-redefine-termios2.patch @@ -0,0 +1,11 @@ +--- a/services/device/serial/serial_io_handler_posix.cc ++++ b/services/device/serial/serial_io_handler_posix.cc +@@ -16,7 +16,7 @@ + #include "build/build_config.h" + #include "components/device_event_log/device_event_log.h" + +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if (BUILDFLAG(IS_LINUX) && !defined(__TERMUX__)) || BUILDFLAG(IS_CHROMEOS) + #include + #include + diff --git a/tur-electron/electron-32/1013-chromium-crypt-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/1013-chromium-crypt-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..28725ba --- /dev/null +++ b/tur-electron/electron-32/1013-chromium-crypt-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,14 @@ +--- a/components/os_crypt/sync/libsecret_util_linux.cc ++++ b/components/os_crypt/sync/libsecret_util_linux.cc +@@ -102,7 +102,11 @@ + if (libsecret_loaded_) + return true; + ++#ifdef __TERMUX__ ++ static void* handle = dlopen("libsecret-1.so", RTLD_NOW | RTLD_GLOBAL); ++#else + static void* handle = dlopen("libsecret-1.so.0", RTLD_NOW | RTLD_GLOBAL); ++#endif + if (!handle) { + // We wanted to use libsecret, but we couldn't load it. Warn, because + // either the user asked for this, or we autodetected it incorrectly. (Or diff --git a/tur-electron/electron-32/1014-chromium-unity-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/1014-chromium-unity-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..b64491d --- /dev/null +++ b/tur-electron/electron-32/1014-chromium-unity-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,11 @@ +--- a/chrome/browser/download/download_status_updater_linux.cc ++++ b/chrome/browser/download/download_status_updater_linux.cc +@@ -77,6 +77,8 @@ + if (!unity_lib) + unity_lib = dlopen("libunity.so.9", RTLD_LAZY); + if (!unity_lib) ++ unity_lib = dlopen("libunity.so", RTLD_LAZY); ++ if (!unity_lib) + return; + + unity_inspector_get_default_func inspector_get_default = diff --git a/tur-electron/electron-32/1015-chromium-gtk-fix-dynamic-loaded-libraries.patch.disable b/tur-electron/electron-32/1015-chromium-gtk-fix-dynamic-loaded-libraries.patch.disable new file mode 100644 index 0000000..f7d4f97 --- /dev/null +++ b/tur-electron/electron-32/1015-chromium-gtk-fix-dynamic-loaded-libraries.patch.disable @@ -0,0 +1,50 @@ +--- a/ui/gtk/gtk_compat.cc ++++ b/ui/gtk/gtk_compat.cc +@@ -62,27 +62,47 @@ + } + + void* GetLibGio() { ++#ifdef __TERMUX__ ++ static void* libgio = DlOpen("libgio-2.0.so"); ++#else + static void* libgio = DlOpen("libgio-2.0.so.0"); ++#endif + return libgio; + } + + void* GetLibGdkPixbuf() { ++#ifdef __TERMUX__ ++ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so"); ++#else + static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); ++#endif + return libgdk_pixbuf; + } + + void* GetLibGdk3() { ++#ifdef __TERMUX__ ++ static void* libgdk3 = DlOpen("libgdk-3.so"); ++#else + static void* libgdk3 = DlOpen("libgdk-3.so.0"); ++#endif + return libgdk3; + } + + void* GetLibGtk3(bool check = true) { ++#ifdef __TERMUX__ ++ static void* libgtk3 = DlOpen("libgtk-3.so", check); ++#else + static void* libgtk3 = DlOpen("libgtk-3.so.0", check); ++#endif + return libgtk3; + } + + void* GetLibGtk4(bool check = true) { ++#ifdef __TERMUX__ ++ static void* libgtk4 = DlOpen("libgtk-4.so", check); ++#else + static void* libgtk4 = DlOpen("libgtk-4.so.1", check); ++#endif + return libgtk4; + } + diff --git a/tur-electron/electron-32/1016-chromium-ozone-wayland-memfd.patch b/tur-electron/electron-32/1016-chromium-ozone-wayland-memfd.patch new file mode 100644 index 0000000..cd21003 --- /dev/null +++ b/tur-electron/electron-32/1016-chromium-ozone-wayland-memfd.patch @@ -0,0 +1,14 @@ +--- a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc ++++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc +@@ -22,6 +22,11 @@ + #include "ui/ozone/platform/wayland/host/wayland_seat.h" + #include "ui/ozone/platform/wayland/host/wayland_window.h" + ++#if defined __ANDROID__ && __ANDROID_API__ < 30 ++#include ++#define memfd_create(name,flags) syscall(SYS_memfd_create,name,flags) ++#endif ++ + namespace ui { + namespace { + diff --git a/tur-electron/electron-32/1017-chromium-x11-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/1017-chromium-x11-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..7963702 --- /dev/null +++ b/tur-electron/electron-32/1017-chromium-x11-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,28 @@ +--- a/ui/base/x/x11_cursor_loader.cc ++++ b/ui/base/x/x11_cursor_loader.cc +@@ -138,7 +138,11 @@ + void operator()(void* ptr) const { dlclose(ptr); } + }; + ++#ifdef __TERMUX__ ++ std::unique_ptr lib(dlopen("libXcursor.so", RTLD_LAZY)); ++#else + std::unique_ptr lib(dlopen("libXcursor.so.1", RTLD_LAZY)); ++#endif + if (!lib) + return ""; + +--- a/ui/gfx/x/xlib_support.cc ++++ b/ui/gfx/x/xlib_support.cc +@@ -42,7 +42,11 @@ + CHECK(xlib_loader->Load("libX11.so.6")); + + auto* xlib_xcb_loader = GetXlibXcbLoader(); ++#ifdef __TERMUX__ ++ CHECK(xlib_xcb_loader->Load("libX11-xcb.so")); ++#else + CHECK(xlib_xcb_loader->Load("libX11-xcb.so.1")); ++#endif + + CHECK(xlib_loader->XInitThreads()); + diff --git a/tur-electron/electron-32/1018-chromium-no-landlock.patch b/tur-electron/electron-32/1018-chromium-no-landlock.patch new file mode 100644 index 0000000..c6ed91e --- /dev/null +++ b/tur-electron/electron-32/1018-chromium-no-landlock.patch @@ -0,0 +1,11 @@ +--- a/content/app/content_main_runner_impl.cc ++++ b/content/app/content_main_runner_impl.cc +@@ -1059,7 +1059,7 @@ + } + #endif // BUILDFLAG(USE_ZYGOTE) + +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if (BUILDFLAG(IS_LINUX) && !defined(__TERMUX__)) || BUILDFLAG(IS_CHROMEOS) + if (process_type.empty()) { + // Check if Landlock is supported. + sandbox::policy::SandboxLinux::ReportLandlockStatus(); diff --git a/tur-electron/electron-32/1019-chromium-dummy-hid-service.patch b/tur-electron/electron-32/1019-chromium-dummy-hid-service.patch new file mode 100644 index 0000000..c72634a --- /dev/null +++ b/tur-electron/electron-32/1019-chromium-dummy-hid-service.patch @@ -0,0 +1,51 @@ +--- a/services/device/hid/hid_service.cc ++++ b/services/device/hid/hid_service.cc +@@ -26,6 +26,39 @@ + #include "services/device/hid/hid_service_win.h" + #elif BUILDFLAG(IS_FUCHSIA) + #include "services/device/hid/hid_service_fuchsia.h" ++#elif defined(__TERMUX__) ++ ++#include "base/notreached.h" ++#include "services/device/hid/hid_connection.h" ++ ++namespace device { ++ ++class HidServiceDummy : public HidService { ++ public: ++ HidServiceDummy() = default; ++ ~HidServiceDummy() = default; ++ ++ HidServiceDummy(const HidServiceDummy&) = delete; ++ HidServiceDummy& operator=(const HidServiceDummy&) = delete; ++ ++ private: ++ // HidService implementation. ++ void Connect(const std::string& device_id, ++ bool allow_protected_reports, ++ bool allow_fido_reports, ++ ConnectCallback callback) override { ++ // TODO(https://crbug.com/1311019): Implement this. ++ NOTIMPLEMENTED_LOG_ONCE(); ++ std::move(callback).Run(nullptr); ++ } ++ base::WeakPtr GetWeakPtr() override { ++ return weak_factory_.GetWeakPtr(); ++ } ++ ++ base::WeakPtrFactory weak_factory_{this}; ++}; ++ ++} // namespace device + #endif + + namespace device { +@@ -74,6 +107,8 @@ + return std::make_unique(); + #elif BUILDFLAG(IS_FUCHSIA) + return std::make_unique(); ++#elif defined(__TERMUX__) ++ return std::make_unique(); + #else + return nullptr; + #endif diff --git a/tur-electron/electron-32/1020-chromium-debug-build-stack_trace.patch b/tur-electron/electron-32/1020-chromium-debug-build-stack_trace.patch new file mode 100644 index 0000000..67a5db8 --- /dev/null +++ b/tur-electron/electron-32/1020-chromium-debug-build-stack_trace.patch @@ -0,0 +1,19 @@ +--- a/base/debug/stack_trace_posix.cc ++++ b/base/debug/stack_trace_posix.cc +@@ -1062,14 +1062,14 @@ + #endif + } + +-#if defined(HAVE_BACKTRACE) + void StackTrace::OutputToStreamWithPrefixImpl( + std::ostream* os, + cstring_view prefix_string) const { ++#if defined(HAVE_BACKTRACE) + StreamBacktraceOutputHandler handler(os); + ProcessBacktrace(trace_, count_, prefix_string, &handler); +-} + #endif ++} + + namespace internal { + diff --git a/tur-electron/electron-32/1501-v8-fix-compress-pointer-offset.patch b/tur-electron/electron-32/1501-v8-fix-compress-pointer-offset.patch new file mode 100644 index 0000000..db7926e --- /dev/null +++ b/tur-electron/electron-32/1501-v8-fix-compress-pointer-offset.patch @@ -0,0 +1,11 @@ +--- a/v8/include/v8-internal.h ++++ b/v8/include/v8-internal.h +@@ -242,7 +242,7 @@ + + #ifdef V8_COMPRESS_POINTERS + +-#ifdef V8_TARGET_OS_ANDROID ++#if defined(V8_TARGET_OS_ANDROID) && !defined(__TERMUX__) + // The size of the virtual memory reservation for an external pointer table. + // This determines the maximum number of entries in a table. Using a maximum + // size allows omitting bounds checks on table accesses if the indices are diff --git a/tur-electron/electron-32/1502-v8-reimpl-page-allocator.patch b/tur-electron/electron-32/1502-v8-reimpl-page-allocator.patch new file mode 100644 index 0000000..41fd83c --- /dev/null +++ b/tur-electron/electron-32/1502-v8-reimpl-page-allocator.patch @@ -0,0 +1,13 @@ +--- a/v8/include/v8-platform.h ++++ b/v8/include/v8-platform.h +@@ -925,7 +925,9 @@ + * Allows the embedder to manage memory page allocations. + * Returning nullptr will cause V8 to use the default page allocator. + */ +- virtual PageAllocator* GetPageAllocator() = 0; ++ virtual PageAllocator* GetPageAllocator() { ++ return nullptr; ++ } + + /** + * Allows the embedder to specify a custom allocator used for zones. diff --git a/tur-electron/electron-32/1503-v8-fix-trap-handler.patch b/tur-electron/electron-32/1503-v8-fix-trap-handler.patch new file mode 100644 index 0000000..507a635 --- /dev/null +++ b/tur-electron/electron-32/1503-v8-fix-trap-handler.patch @@ -0,0 +1,26 @@ +--- a/v8/src/trap-handler/trap-handler.h ++++ b/v8/src/trap-handler/trap-handler.h +@@ -19,7 +19,7 @@ + + // X64 on Linux, Windows, MacOS, FreeBSD. + #if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \ +- ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_DARWIN || \ ++ (V8_OS_LINUX || V8_OS_WIN || V8_OS_DARWIN || \ + V8_OS_FREEBSD) + #define V8_TRAP_HANDLER_SUPPORTED true + // Arm64 (non-simulator) on Mac. +@@ -41,14 +41,6 @@ + #define V8_TRAP_HANDLER_SUPPORTED false + #endif + +-#if V8_OS_ANDROID && V8_TRAP_HANDLER_SUPPORTED +-// It would require some careful security review before the trap handler +-// can be enabled on Android. Android may do unexpected things with signal +-// handling and crash reporting that could open up security holes in V8's +-// trap handling. +-#error "The V8 trap handler should not be enabled on Android" +-#endif +- + // Setup for shared library export. + #if defined(BUILDING_V8_SHARED) && defined(V8_OS_WIN) + #define TH_EXPORT_PRIVATE __declspec(dllexport) diff --git a/tur-electron/electron-32/1601-angle-no-android-jni.patch b/tur-electron/electron-32/1601-angle-no-android-jni.patch new file mode 100644 index 0000000..5c582fb --- /dev/null +++ b/tur-electron/electron-32/1601-angle-no-android-jni.patch @@ -0,0 +1,11 @@ +--- a/third_party/angle/src/common/platform.h ++++ b/third_party/angle/src/common/platform.h +@@ -17,7 +17,7 @@ + #elif defined(__APPLE__) + # define ANGLE_PLATFORM_APPLE 1 + # define ANGLE_PLATFORM_POSIX 1 +-#elif defined(ANDROID) ++#elif (defined(ANDROID) && !defined(__TERMUX__)) + # define ANGLE_PLATFORM_ANDROID 1 + # define ANGLE_PLATFORM_POSIX 1 + #elif defined(__ggp__) diff --git a/tur-electron/electron-32/1701-swiftshader-no-spawn.patch b/tur-electron/electron-32/1701-swiftshader-no-spawn.patch new file mode 100644 index 0000000..eb95338 --- /dev/null +++ b/tur-electron/electron-32/1701-swiftshader-no-spawn.patch @@ -0,0 +1,11 @@ +--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h ++++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h +@@ -166,7 +166,7 @@ + #define HAVE_POSIX_FALLOCATE 1 + + /* Define to 1 if you have the `posix_spawn' function. */ +-#define HAVE_POSIX_SPAWN 1 ++/* #define HAVE_POSIX_SPAWN 1 */ + + /* Define to 1 if you have the `pread' function. */ + #define HAVE_PREAD 1 diff --git a/tur-electron/electron-32/1702-swiftshader-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/1702-swiftshader-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..d801af4 --- /dev/null +++ b/tur-electron/electron-32/1702-swiftshader-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,40 @@ +--- a/third_party/swiftshader/src/WSI/libWaylandClient.cpp ++++ b/third_party/swiftshader/src/WSI/libWaylandClient.cpp +@@ -56,7 +56,11 @@ + } + else + { ++#ifdef __TERMUX__ ++ libwl = loadLibrary("libwayland-client.so"); ++#else + libwl = loadLibrary("libwayland-client.so.0"); ++#endif + } + + return LibWaylandClientExports(libwl); +--- a/third_party/swiftshader/src/WSI/libXCB.cpp ++++ b/third_party/swiftshader/src/WSI/libXCB.cpp +@@ -55,7 +55,11 @@ + } + else + { ++#ifdef __TERMUX__ ++ libxcb = loadLibrary("libxcb.so"); ++#else + libxcb = loadLibrary("libxcb.so.1"); ++#endif + } + + if(getProcAddress(RTLD_DEFAULT, "xcb_shm_query_version")) // Search the global scope for pre-loaded XCB library. +@@ -64,7 +68,11 @@ + } + else + { ++#ifdef __TERMUX__ ++ libshm = loadLibrary("libxcb-shm.so"); ++#else + libshm = loadLibrary("libxcb-shm.so.0"); ++#endif + } + + return LibXcbExports(libxcb, libshm); diff --git a/tur-electron/electron-32/1703-swiftshader-no-android.patch b/tur-electron/electron-32/1703-swiftshader-no-android.patch new file mode 100644 index 0000000..45d0444 --- /dev/null +++ b/tur-electron/electron-32/1703-swiftshader-no-android.patch @@ -0,0 +1,406 @@ +diff -uNr a/third_party/swiftshader/src/Vulkan/VkGetProcAddress.cpp b/third_party/swiftshader/src/Vulkan/VkGetProcAddress.cpp +--- a/third_party/swiftshader/src/Vulkan/VkGetProcAddress.cpp ++++ b/third_party/swiftshader/src/Vulkan/VkGetProcAddress.cpp +@@ -19,7 +19,7 @@ + #include + #include + +-#ifdef __ANDROID__ ++#if (defined(__ANDROID__) && !defined(__TERMUX__)) + # include + # include + # include +@@ -105,7 +105,7 @@ + MAKE_VULKAN_INSTANCE_ENTRY(vkSubmitDebugUtilsMessageEXT), + // VK_EXT_tooling_info + MAKE_VULKAN_INSTANCE_ENTRY(vkGetPhysicalDeviceToolProperties), +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + // VK_KHR_surface + MAKE_VULKAN_INSTANCE_ENTRY(vkDestroySurfaceKHR), + MAKE_VULKAN_INSTANCE_ENTRY(vkGetPhysicalDeviceSurfaceSupportKHR), +@@ -310,7 +310,7 @@ + MAKE_VULKAN_DEVICE_ENTRY(vkQueueInsertDebugUtilsLabelEXT), + MAKE_VULKAN_DEVICE_ENTRY(vkSetDebugUtilsObjectNameEXT), + MAKE_VULKAN_DEVICE_ENTRY(vkSetDebugUtilsObjectTagEXT), +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + MAKE_VULKAN_DEVICE_ENTRY(vkGetSwapchainGrallocUsageANDROID), + MAKE_VULKAN_DEVICE_ENTRY(vkGetSwapchainGrallocUsage2ANDROID), + MAKE_VULKAN_DEVICE_ENTRY(vkAcquireImageANDROID), +@@ -535,7 +535,7 @@ + MAKE_VULKAN_DEVICE_ENTRY(vkCmdWriteTimestamp2KHR), + MAKE_VULKAN_DEVICE_ENTRY(vkQueueSubmit2KHR), + } }, +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + // VK_KHR_swapchain + { + VK_KHR_SWAPCHAIN_EXTENSION_NAME, +@@ -680,7 +680,7 @@ + + } // namespace vk + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + + extern "C" hwvulkan_module_t HAL_MODULE_INFO_SYM; + +diff -uNr a/third_party/swiftshader/src/Vulkan/VkImage.cpp b/third_party/swiftshader/src/Vulkan/VkImage.cpp +--- a/third_party/swiftshader/src/Vulkan/VkImage.cpp ++++ b/third_party/swiftshader/src/Vulkan/VkImage.cpp +@@ -25,7 +25,7 @@ + #include "Device/Blitter.hpp" + #include "Device/ETC_Decoder.hpp" + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + # include + + # include "VkDeviceMemoryExternalAndroid.hpp" +@@ -135,7 +135,7 @@ + // VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID, are not enumerated in the official Vulkan headers. + switch((int)(nextInfo->sType)) + { +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + case VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID: + { + const VkExternalFormatANDROID *externalFormatAndroid = reinterpret_cast(nextInfo); +@@ -317,7 +317,7 @@ + } + } + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + VkResult Image::prepareForExternalUseANDROID() const + { + VkExtent3D extent = getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0); +diff -uNr a/third_party/swiftshader/src/Vulkan/VkImage.hpp b/third_party/swiftshader/src/Vulkan/VkImage.hpp +--- a/third_party/swiftshader/src/Vulkan/VkImage.hpp ++++ b/third_party/swiftshader/src/Vulkan/VkImage.hpp +@@ -20,7 +20,7 @@ + + #include "marl/mutex.h" + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + # include // For VkSwapchainImageUsageFlagsANDROID and buffer_handle_t + #endif + +@@ -33,7 +33,7 @@ + class DeviceMemory; + class ImageView; + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + struct BackingMemory + { + bool externalMemory = false; +@@ -48,7 +48,7 @@ + Image(const VkImageCreateInfo *pCreateInfo, void *mem, Device *device); + void destroy(const VkAllocationCallbacks *pAllocator); + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + VkResult prepareForExternalUseANDROID() const; + #endif + +@@ -110,7 +110,7 @@ + void contentsChanged(const VkImageSubresourceRange &subresourceRange, ContentsChangedContext contentsChangedContext = DIRECT_MEMORY_ACCESS); + const Image *getSampledImage(const vk::Format &imageViewFormat) const; + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + void setBackingMemory(BackingMemory &bm) + { + backingMemory = bm; +@@ -162,7 +162,7 @@ + VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL; + VkImageUsageFlags usage = (VkImageUsageFlags)0; + Image *decompressedImage = nullptr; +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + BackingMemory backingMemory = {}; + #endif + +diff -uNr a/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.cpp b/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.cpp +--- a/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.cpp ++++ b/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.cpp +@@ -22,7 +22,7 @@ + #include + #include + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + # include + #endif + +@@ -971,7 +971,7 @@ + properties->combinedImageSamplerDescriptorCount = 1; // Need only one descriptor for YCbCr sampling. + } + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + void PhysicalDevice::getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const + { + properties->sharedImage = VK_FALSE; +diff -uNr a/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.hpp b/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.hpp +--- a/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.hpp ++++ b/third_party/swiftshader/src/Vulkan/VkPhysicalDevice.hpp +@@ -69,7 +69,7 @@ + void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const; + void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalBufferProperties *properties) const; + void getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const; +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + void getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const; + void getProperties(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkAndroidHardwareBufferUsageANDROID *properties) const; + #endif +diff -uNr a/third_party/swiftshader/src/Vulkan/VkQueue.cpp b/third_party/swiftshader/src/Vulkan/VkQueue.cpp +--- a/third_party/swiftshader/src/Vulkan/VkQueue.cpp ++++ b/third_party/swiftshader/src/Vulkan/VkQueue.cpp +@@ -189,7 +189,7 @@ + } + } + +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + VkResult Queue::present(const VkPresentInfoKHR *presentInfo) + { + // This is a hack to deal with screen tearing for now. +diff -uNr a/third_party/swiftshader/src/Vulkan/VkQueue.hpp b/third_party/swiftshader/src/Vulkan/VkQueue.hpp +--- a/third_party/swiftshader/src/Vulkan/VkQueue.hpp ++++ b/third_party/swiftshader/src/Vulkan/VkQueue.hpp +@@ -53,7 +53,7 @@ + + VkResult submit(uint32_t submitCount, SubmitInfo *pSubmits, Fence *fence); + VkResult waitIdle(); +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + VkResult present(const VkPresentInfoKHR *presentInfo); + #endif + +diff -uNr a/third_party/swiftshader/src/Vulkan/libVulkan.cpp b/third_party/swiftshader/src/Vulkan/libVulkan.cpp +--- a/third_party/swiftshader/src/Vulkan/libVulkan.cpp ++++ b/third_party/swiftshader/src/Vulkan/libVulkan.cpp +@@ -81,7 +81,7 @@ + #include "marl/thread.h" + #include "marl/tsa.h" + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + # include + + # include "commit.h" +@@ -105,7 +105,7 @@ + namespace { + + // Enable commit_id.py and #include commit.h for other platforms. +-#if defined(__ANDROID__) && defined(ENABLE_BUILD_VERSION_OUTPUT) ++#if defined(__ANDROID__) && !defined(__TERMUX__) && defined(ENABLE_BUILD_VERSION_OUTPUT) + void logBuildVersionInformation() + { + // TODO(b/144093703): Don't call __android_log_print() directly +@@ -140,7 +140,7 @@ + void initializeLibrary() + { + static bool doOnce = [] { +-#if defined(__ANDROID__) && defined(ENABLE_BUILD_VERSION_OUTPUT) ++#if defined(__ANDROID__) && !defined(__TERMUX__) && defined(ENABLE_BUILD_VERSION_OUTPUT) + logBuildVersionInformation(); + #endif // __ANDROID__ && ENABLE_BUILD_VERSION_OUTPUT + return true; +@@ -322,7 +322,7 @@ + { { VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION } }, + { { VK_EXT_DEBUG_UTILS_EXTENSION_NAME, VK_EXT_DEBUG_UTILS_SPEC_VERSION } }, + { { VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME, VK_EXT_HEADLESS_SURFACE_SPEC_VERSION } }, +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + { { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION } }, + { { VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME, VK_EXT_SURFACE_MAINTENANCE_1_SPEC_VERSION } }, + { { VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION } }, +@@ -376,7 +376,7 @@ + // Only 1.1 core version of this is supported. The extension has additional requirements + //{{ VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME, VK_KHR_VARIABLE_POINTERS_SPEC_VERSION }}, + { { VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME, VK_EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION } }, +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + // We fully support the KHR_swapchain v70 additions, so just track the spec version. + { { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_SPEC_VERSION } }, + #else +@@ -449,7 +449,7 @@ + { { VK_KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME, VK_KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION } }, + { { VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION } }, + { { VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME, VK_KHR_PIPELINE_LIBRARY_SPEC_VERSION } }, +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + { { VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME, VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION } }, + { { VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME, VK_EXT_SWAPCHAIN_MAINTENANCE_1_SPEC_VERSION } }, + #endif +@@ -2038,7 +2038,7 @@ + + const VkBaseInStructure *extensionCreateInfo = reinterpret_cast(pCreateInfo->pNext); + +-#ifdef __ANDROID__ ++#if (defined(__ANDROID__) && !defined(__TERMUX__)) + vk::BackingMemory backmem; + bool swapchainImage = false; + #endif +@@ -2049,7 +2049,7 @@ + // VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID, are not enumerated in the official Vulkan headers. + switch((int)(extensionCreateInfo->sType)) + { +-#ifdef __ANDROID__ ++#if (defined(__ANDROID__) && !defined(__TERMUX__)) + case VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID: + { + const VkSwapchainImageCreateInfoANDROID *swapImageCreateInfo = reinterpret_cast(extensionCreateInfo); +@@ -2109,7 +2109,7 @@ + + VkResult result = vk::Image::Create(pAllocator, pCreateInfo, pImage, vk::Cast(device)); + +-#ifdef __ANDROID__ ++#if (defined(__ANDROID__) && !defined(__TERMUX__)) + if(swapchainImage) + { + if(result != VK_SUCCESS) +@@ -2147,7 +2147,7 @@ + TRACE("(VkDevice device = %p, VkImage image = %p, const VkAllocationCallbacks* pAllocator = %p)", + device, static_cast(image), pAllocator); + +-#ifdef __ANDROID__ ++#if (defined(__ANDROID__) && !defined(__TERMUX__)) + vk::Image *img = vk::Cast(image); + if(img && img->hasExternalMemory()) + { +@@ -3573,7 +3573,7 @@ + /* Do nothing */ + break; + +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + case VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR: + { + const auto *swapchainInfo = reinterpret_cast(extInfo); +@@ -3783,7 +3783,7 @@ + vk::Cast(physicalDevice)->getProperties(properties); + } + break; +-#ifdef __ANDROID__ ++#if (defined(__ANDROID__) && !defined(__TERMUX__)) + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: + { + auto *properties = reinterpret_cast(extensionProperties); +@@ -4002,7 +4002,7 @@ + + VkBaseOutStructure *extensionProperties = reinterpret_cast(pImageFormatProperties->pNext); + +-#ifdef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + bool hasAHBUsage = false; + #endif + +@@ -4036,7 +4036,7 @@ + properties->identicalMemoryLayout = VK_TRUE; + } + break; +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID: + { + auto *properties = reinterpret_cast(extensionProperties); +@@ -4066,7 +4066,7 @@ + + vk::Cast(physicalDevice)->getImageFormatProperties(format, type, tiling, usage, flags, &pImageFormatProperties->imageFormatProperties); + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + if(hasAHBUsage) + { + // AHardwareBuffer_lock may only be called with a single layer. +@@ -4189,7 +4189,7 @@ + { + switch(extInfo->sType) + { +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + case VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID: + break; + #endif +@@ -4703,7 +4703,7 @@ + return vk::HeadlessSurfaceKHR::Create(pAllocator, pCreateInfo, pSurface); + } + +-#ifndef __ANDROID__ ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) + VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator) + { + TRACE("(VkInstance instance = %p, VkSurfaceKHR surface = %p, const VkAllocationCallbacks* pAllocator = %p)", +@@ -4921,7 +4921,7 @@ + + #endif // ! __ANDROID__ + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + + VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainUsage, uint64_t *grallocConsumerUsage, uint64_t *grallocProducerUsage) + { +--- a/third_party/swiftshader/src/System/Debug.cpp ++++ b/third_party/swiftshader/src/System/Debug.cpp +@@ -14,7 +14,7 @@ + + #include "Debug.hpp" + +-#if __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + # include + #endif + +@@ -55,7 +55,7 @@ + Disabled, + }; + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + [[maybe_unused]] void logv_android(Level level, const char *msg) + { + switch(level) +@@ -107,7 +107,7 @@ + char buffer[2048]; + vsnprintf(buffer, sizeof(buffer), format, args); + +-# if defined(__ANDROID__) ++# if defined(__ANDROID__) && !defined(__TERMUX__) + logv_android(level, buffer); + # elif defined(_WIN32) + logv_std(level, buffer); +--- a/third_party/swiftshader/src/Reactor/Debug.cpp ++++ b/third_party/swiftshader/src/Reactor/Debug.cpp +@@ -19,7 +19,7 @@ + #include + #include + +-#if __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + # include + #endif + +@@ -105,7 +105,7 @@ + Fatal, + }; + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + [[maybe_unused]] void logv_android(Level level, const char *msg) + { + switch(level) +@@ -156,7 +156,7 @@ + char buffer[2048]; + vsnprintf(buffer, sizeof(buffer), format, args); + +-# if defined(__ANDROID__) ++# if defined(__ANDROID__) && !defined(__TERMUX__) + logv_android(level, buffer); + # elif defined(_WIN32) + logv_std(level, buffer); diff --git a/tur-electron/electron-32/2001-weston-memfd_create.patch b/tur-electron/electron-32/2001-weston-memfd_create.patch new file mode 100644 index 0000000..c230e76 --- /dev/null +++ b/tur-electron/electron-32/2001-weston-memfd_create.patch @@ -0,0 +1,14 @@ +--- a/third_party/weston/src/shared/os-compatibility.c ++++ b/third_party/weston/src/shared/os-compatibility.c +@@ -38,6 +38,11 @@ + + #include "os-compatibility.h" + ++#if defined(__ANDROID__) && __ANDROID_API__ < 26 ++#include ++#define memfd_create(name,flags) syscall(SYS_memfd_create,name,flags) ++#endif ++ + #define READONLY_SEALS (F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE) + + int diff --git a/tur-electron/electron-32/2002-weston-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/2002-weston-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..25da257 --- /dev/null +++ b/tur-electron/electron-32/2002-weston-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,14 @@ +--- a/third_party/weston/src/libweston/backend-drm/drm-gbm.c ++++ b/third_party/weston/src/libweston/backend-drm/drm-gbm.c +@@ -61,7 +61,11 @@ + * only the gl-renderer module links to it, the call above won't make + * these symbols globally available, and loading the DRI driver fails. + * Workaround this by dlopen()'ing libglapi with RTLD_GLOBAL. */ ++#ifdef __TERMUX__ ++ dlopen("libglapi.so", RTLD_LAZY | RTLD_GLOBAL); ++#else + dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL); ++#endif + + gbm = gbm_create_device(fd); + diff --git a/tur-electron/electron-32/2003-wayland-memfd_create.patch b/tur-electron/electron-32/2003-wayland-memfd_create.patch new file mode 100644 index 0000000..fe1c3c5 --- /dev/null +++ b/tur-electron/electron-32/2003-wayland-memfd_create.patch @@ -0,0 +1,14 @@ +--- a/third_party/wayland/src/cursor/os-compatibility.c ++++ b/third_party/wayland/src/cursor/os-compatibility.c +@@ -42,6 +42,11 @@ + + #include "os-compatibility.h" + ++#if defined(__ANDROID__) && __ANDROID_API__ < 26 ++#include ++#define memfd_create(name,flags) syscall(SYS_memfd_create,name,flags) ++#endif ++ + #ifndef HAVE_MKOSTEMP + static int + set_cloexec_or_close(int fd) diff --git a/tur-electron/electron-32/2004-breakpad-no-elf_prstatus.patch b/tur-electron/electron-32/2004-breakpad-no-elf_prstatus.patch new file mode 100644 index 0000000..066ecf1 --- /dev/null +++ b/tur-electron/electron-32/2004-breakpad-no-elf_prstatus.patch @@ -0,0 +1,18 @@ +--- a/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc ++++ b/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc +@@ -194,6 +194,7 @@ + // + // The following code only works if notes are ordered as expected. + switch (type) { ++#if !defined(__ANDROID__) + case NT_PRSTATUS: { + if (description.length() != sizeof(elf_prstatus)) { + fprintf(stderr, "Found NT_PRSTATUS descriptor of unexpected size\n"); +@@ -231,6 +232,7 @@ + thread_infos_.push_back(info); + break; + } ++#endif + case NT_SIGINFO: { + if (description.length() != sizeof(siginfo_t)) { + fprintf(stderr, "Found NT_SIGINFO descriptor of unexpected size\n"); diff --git a/tur-electron/electron-32/2005-crashpad-fill-elf.patch b/tur-electron/electron-32/2005-crashpad-fill-elf.patch new file mode 100644 index 0000000..ccbda3a --- /dev/null +++ b/tur-electron/electron-32/2005-crashpad-fill-elf.patch @@ -0,0 +1,18 @@ +--- a/third_party/crashpad/crashpad/snapshot/elf/elf_symbol_table_reader.cc ++++ b/third_party/crashpad/crashpad/snapshot/elf/elf_symbol_table_reader.cc +@@ -17,6 +17,15 @@ + #include + + #include "snapshot/elf/elf_image_reader.h" ++ ++#ifndef ELF32_ST_VISIBILITY ++#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) ++#endif ++ ++/* For ELF64 the definitions are the same. */ ++#ifndef ELF64_ST_VISIBILITY ++#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) ++#endif + + namespace crashpad { + diff --git a/tur-electron/electron-32/2006-crashpad-no-getdtablesize.patch b/tur-electron/electron-32/2006-crashpad-no-getdtablesize.patch new file mode 100644 index 0000000..2f2c86e --- /dev/null +++ b/tur-electron/electron-32/2006-crashpad-no-getdtablesize.patch @@ -0,0 +1,11 @@ +--- a/third_party/crashpad/crashpad/util/posix/close_multiple.cc ++++ b/third_party/crashpad/crashpad/util/posix/close_multiple.cc +@@ -134,7 +134,7 @@ + // bionic/libc/bionic/ndk_cruft.cpp getdtablesize(). + int max_fd = implicit_cast(sysconf(_SC_OPEN_MAX)); + +-#if !BUILDFLAG(IS_ANDROID) ++#if !BUILDFLAG(IS_ANDROID) && !defined(__TERMUX__) + // getdtablesize() was removed effective Android 5.0.0 (API 21). Since it + // returns the same thing as the sysconf() above, just skip it. See + // https://android.googlesource.com/platform/bionic/+/462abab12b074c62c0999859e65d5a32ebb41951. diff --git a/tur-electron/electron-32/2007-crashpad-no-memfd.patch b/tur-electron/electron-32/2007-crashpad-no-memfd.patch new file mode 100644 index 0000000..83de50c --- /dev/null +++ b/tur-electron/electron-32/2007-crashpad-no-memfd.patch @@ -0,0 +1,22 @@ +--- a/third_party/crashpad/crashpad/util/file/file_io_posix.cc ++++ b/third_party/crashpad/crashpad/util/file/file_io_posix.cc +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -154,6 +155,11 @@ + } + + #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++ ++#if defined __ANDROID__ && __ANDROID_API__ < 30 ++#define memfd_create(name,flags) syscall(SYS_memfd_create,name,flags) ++#endif ++ + FileHandle LoggingOpenMemoryFileForReadAndWrite(const base::FilePath& name) { + DCHECK(name.value().find('/') == std::string::npos); + diff --git a/tur-electron/electron-32/2008-crashpad-no-spawn.patch b/tur-electron/electron-32/2008-crashpad-no-spawn.patch new file mode 100644 index 0000000..ebd18da --- /dev/null +++ b/tur-electron/electron-32/2008-crashpad-no-spawn.patch @@ -0,0 +1,28 @@ +--- a/third_party/crashpad/crashpad/util/posix/spawn_subprocess.cc ++++ b/third_party/crashpad/crashpad/util/posix/spawn_subprocess.cc +@@ -15,12 +15,15 @@ + #include "util/posix/spawn_subprocess.h" + + #include +-#include + #include + #include + #include + #include + ++#ifndef __TERMUX__ ++#include ++#endif ++ + #include "base/check.h" + #include "base/check_op.h" + #include "base/logging.h" +@@ -171,7 +174,7 @@ + char* const* envp_for_spawn = + envp ? const_cast(envp_c.data()) : environ; + +-#if BUILDFLAG(IS_ANDROID) && __ANDROID_API__ < 28 ++#if (BUILDFLAG(IS_ANDROID) || defined(__TERMUX__)) && __ANDROID_API__ < 28 + pid = fork(); + if (pid < 0) { + PLOG(FATAL) << "fork"; diff --git a/tur-electron/electron-32/2009-cpuinfo-android-arm.patch b/tur-electron/electron-32/2009-cpuinfo-android-arm.patch new file mode 100644 index 0000000..0755a90 --- /dev/null +++ b/tur-electron/electron-32/2009-cpuinfo-android-arm.patch @@ -0,0 +1,13 @@ +--- a/third_party/cpuinfo/src/src/arm/linux/init.c ++++ b/third_party/cpuinfo/src/src/arm/linux/init.c +@@ -14,6 +14,10 @@ + #include + #include + ++#ifdef __TERMUX__ ++#include ++#endif ++ + struct cpuinfo_arm_isa cpuinfo_isa = {0}; + + static struct cpuinfo_package package = {{0}}; diff --git a/tur-electron/electron-32/2010-dav1d-no-get-affinity.patch b/tur-electron/electron-32/2010-dav1d-no-get-affinity.patch new file mode 100644 index 0000000..b1eb0ae --- /dev/null +++ b/tur-electron/electron-32/2010-dav1d-no-get-affinity.patch @@ -0,0 +1,11 @@ +--- a/third_party/dav1d/libdav1d/src/cpu.c ++++ b/third_party/dav1d/libdav1d/src/cpu.c +@@ -87,7 +87,7 @@ + GetNativeSystemInfo(&system_info); + return system_info.dwNumberOfProcessors; + #endif +-#elif defined(HAVE_PTHREAD_GETAFFINITY_NP) && defined(CPU_COUNT) ++#elif defined(HAVE_PTHREAD_GETAFFINITY_NP) && defined(CPU_COUNT) && !defined(__ANDROID__) + cpu_set_t affinity; + if (!pthread_getaffinity_np(pthread_self(), sizeof(affinity), &affinity)) + return CPU_COUNT(&affinity); diff --git a/tur-electron/electron-32/2011-dawn-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/2011-dawn-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..7b1bc50 --- /dev/null +++ b/tur-electron/electron-32/2011-dawn-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,24 @@ +--- a/third_party/dawn/src/dawn/native/X11Functions.cpp ++++ b/third_party/dawn/src/dawn/native/X11Functions.cpp +@@ -34,13 +34,21 @@ + namespace dawn::native { + + X11Functions::X11Functions() { ++#ifdef __TERMUX__ ++ if (!mX11Lib.Open("libX11.so") || !mX11Lib.GetProc(&xSetErrorHandler, "XSetErrorHandler") || ++#else + if (!mX11Lib.Open("libX11.so.6") || !mX11Lib.GetProc(&xSetErrorHandler, "XSetErrorHandler") || ++#endif + !mX11Lib.GetProc(&xGetWindowAttributes, "XGetWindowAttributes") || + !mX11Lib.GetProc(&xSynchronize, "XSynchronize")) { + mX11Lib.Close(); + } + ++#ifdef __TERMUX__ ++ if (!mX11XcbLib.Open("libX11-xcb.so") || ++#else + if (!mX11XcbLib.Open("libX11-xcb.so.1") || ++#endif + !mX11XcbLib.GetProc(&xGetXCBConnection, "XGetXCBConnection")) { + mX11XcbLib.Close(); + } diff --git a/tur-electron/electron-32/2012-dawn-no-android-jni.patch b/tur-electron/electron-32/2012-dawn-no-android-jni.patch new file mode 100644 index 0000000..b7f7b93 --- /dev/null +++ b/tur-electron/electron-32/2012-dawn-no-android-jni.patch @@ -0,0 +1,23 @@ +--- a/third_party/dawn/include/dawn/native/VulkanBackend.h ++++ b/third_party/dawn/include/dawn/native/VulkanBackend.h +@@ -126,7 +126,7 @@ + ExternalImageExportInfoDmaBuf(); + }; + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + + // Descriptor for AHardwareBuffer image import + struct DAWN_NATIVE_EXPORT ExternalImageDescriptorAHardwareBuffer : ExternalImageDescriptorVk { +--- a/third_party/dawn/src/dawn/common/Platform.h ++++ b/third_party/dawn/src/dawn/common/Platform.h +@@ -62,7 +62,8 @@ + #elif defined(__linux__) + #define DAWN_PLATFORM_IS_LINUX 1 + #define DAWN_PLATFORM_IS_POSIX 1 +-#if defined(__ANDROID__) ++#include ++#if defined(__ANDROID__) && !defined(__TERMUX__) + #define DAWN_PLATFORM_IS_ANDROID 1 + #elif defined(DAWN_OS_CHROMEOS) + #define DAWN_PLATFORM_IS_CHROMEOS 1 diff --git a/tur-electron/electron-32/2013-minigbm-no-android-log.patch b/tur-electron/electron-32/2013-minigbm-no-android-log.patch new file mode 100644 index 0000000..05b9bd1 --- /dev/null +++ b/tur-electron/electron-32/2013-minigbm-no-android-log.patch @@ -0,0 +1,20 @@ +--- a/third_party/minigbm/src/drv.c ++++ b/third_party/minigbm/src/drv.c +@@ -15,7 +15,7 @@ + #include + #include + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + #include + #include + #endif +@@ -752,7 +752,7 @@ + + va_list args; + va_start(args, format); +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + int prio = ANDROID_LOG_ERROR; + switch (level) { + case DRV_LOGV: diff --git a/tur-electron/electron-32/2014-perfetto-no-android-jni.patch b/tur-electron/electron-32/2014-perfetto-no-android-jni.patch new file mode 100644 index 0000000..2ee28dd --- /dev/null +++ b/tur-electron/electron-32/2014-perfetto-no-android-jni.patch @@ -0,0 +1,11 @@ +--- a/third_party/perfetto/include/perfetto/base/build_config.h ++++ b/third_party/perfetto/include/perfetto/base/build_config.h +@@ -24,7 +24,7 @@ + #define PERFETTO_BUILDFLAG(flag) \ + (PERFETTO_BUILDFLAG_CAT(PERFETTO_BUILDFLAG_DEFINE_, flag)()) + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 1 + #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0 + #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0 diff --git a/tur-electron/electron-32/2015-perfetto-no-pthread_getname_np.patch b/tur-electron/electron-32/2015-perfetto-no-pthread_getname_np.patch new file mode 100644 index 0000000..dc6382c --- /dev/null +++ b/tur-electron/electron-32/2015-perfetto-no-pthread_getname_np.patch @@ -0,0 +1,20 @@ +--- a/third_party/perfetto/include/perfetto/ext/base/thread_utils.h ++++ b/third_party/perfetto/include/perfetto/ext/base/thread_utils.h +@@ -31,7 +31,7 @@ + #include + #endif + +-#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) ++#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) || defined(__ANDROID__) + #include + #endif + +@@ -59,7 +59,7 @@ + + inline bool GetThreadName(std::string& out_result) { + char buf[16] = {}; +-#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) ++#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) || defined(__ANDROID__) + if (prctl(PR_GET_NAME, buf) != 0) + return false; + #else diff --git a/tur-electron/electron-32/2016-dawn-aligned-alloc.patch b/tur-electron/electron-32/2016-dawn-aligned-alloc.patch new file mode 100644 index 0000000..9cef5ad --- /dev/null +++ b/tur-electron/electron-32/2016-dawn-aligned-alloc.patch @@ -0,0 +1,11 @@ +--- a/third_party/dawn/src/dawn/common/AlignedAlloc.cpp ++++ b/third_party/dawn/src/dawn/common/AlignedAlloc.cpp +@@ -42,7 +42,7 @@ + #if DAWN_PLATFORM_IS(WINDOWS) + return _aligned_malloc(size, alignment); + +-#elif DAWN_PLATFORM_IS(ANDROID) ++#elif DAWN_PLATFORM_IS(ANDROID) || defined(__TERMUX__) + // Currently std::aligned_alloc() is not supported on the Android build of Chromium. Luckily, + // memalign() on Android returns pointers which can safely be used with free(), so we can use it + // instead. diff --git a/tur-electron/electron-32/2017-vk-layers-no-android-log.patch b/tur-electron/electron-32/2017-vk-layers-no-android-log.patch new file mode 100644 index 0000000..a6c1497 --- /dev/null +++ b/tur-electron/electron-32/2017-vk-layers-no-android-log.patch @@ -0,0 +1,64 @@ +--- a/third_party/vulkan-validation-layers/src/layers/error_message/logging.h ++++ b/third_party/vulkan-validation-layers/src/layers/error_message/logging.h +@@ -33,7 +33,7 @@ + #include "generated/vk_layer_dispatch_table.h" + #include "generated/vk_object_types.h" + +-#if defined __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + #include + #define LOGCONSOLE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "VALIDATION", __VA_ARGS__)) + [[maybe_unused]] static const char *kForceDefaultCallbackKey = "debug.vvl.forcelayerlog"; +--- a/third_party/vulkan-validation-layers/src/layers/vk_layer_config.cpp ++++ b/third_party/vulkan-validation-layers/src/layers/vk_layer_config.cpp +@@ -74,7 +74,7 @@ + #endif + + std::string GetEnvironment(const char *variable) { +-#if !defined(__ANDROID__) && !defined(_WIN32) ++#if !(defined(__ANDROID__) && !defined(__TERMUX__)) && !defined(_WIN32) + const char *output = getenv(variable); + return output == NULL ? "" : output; + #elif defined(_WIN32) +--- a/third_party/vulkan-validation-layers/src/layers/utils/android_ndk_types.h ++++ b/third_party/vulkan-validation-layers/src/layers/utils/android_ndk_types.h +@@ -29,7 +29,9 @@ + + #pragma once + +-#if defined(__ANDROID__) && !defined(VK_USE_PLATFORM_ANDROID_KHR) ++#include ++ ++#if (defined(__ANDROID__) && !defined(__TERMUX__)) && !defined(VK_USE_PLATFORM_ANDROID_KHR) + #error "VK_USE_PLATFORM_ANDROID_KHR not defined for Android build!" + #endif + +--- a/third_party/vulkan-utility-libraries/src/src/layer/layer_settings_manager.cpp ++++ b/third_party/vulkan-utility-libraries/src/src/layer/layer_settings_manager.cpp +@@ -32,7 +32,7 @@ + #include + #include + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + static std::string GetAndroidProperty(const char *name) { + std::string output; + const prop_info *pi = __system_property_find(name); +@@ -51,7 +51,7 @@ + #endif + + static std::string GetEnvironment(const char *variable) { +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + std::string result = GetAndroidProperty(variable); + // Workaround for screenshot layer backward compatibility + if (result.empty() && std::string(variable) == "debug.vulkan.screenshot.frames") { +@@ -199,7 +199,7 @@ + } + #endif + +-#ifdef __ANDROID__ ++#if defined(__ANDROID__) && !defined(__TERMUX__) + std::string env_path = GetEnvironment("debug.vulkan.khronos_profiles.settings_path"); + #else + // Look for an environment variable override for the settings file location diff --git a/tur-electron/electron-32/2018-unrar-no-lutimes.patch b/tur-electron/electron-32/2018-unrar-no-lutimes.patch new file mode 100644 index 0000000..1eb2dd9 --- /dev/null +++ b/tur-electron/electron-32/2018-unrar-no-lutimes.patch @@ -0,0 +1,14 @@ +Origin: https://github.com/termux/termux-packages/blob/b6a1362cec0f5432629b433b389a70357059f79b/packages/unrar/os.hpp.patch + +diff -u -r ../unrar/os.hpp ./os.hpp +--- a/third_party/unrar/src/os.hpp 2017-06-10 13:59:52.000000000 +0000 ++++ b/third_party/unrar/src/os.hpp 2017-06-12 00:11:04.591100580 +0000 +@@ -154,7 +154,7 @@ + #define SAVE_LINKS + #endif + +-#if defined(__linux) || defined(__FreeBSD__) ++#if (defined(__linux) && !defined(__ANDROID__)) || defined(__FreeBSD__) + #include + #define USE_LUTIMES + #endif diff --git a/tur-electron/electron-32/2019-tflite-no-atrace.patch b/tur-electron/electron-32/2019-tflite-no-atrace.patch new file mode 100644 index 0000000..149d076 --- /dev/null +++ b/tur-electron/electron-32/2019-tflite-no-atrace.patch @@ -0,0 +1,20 @@ +--- a/third_party/tflite/src/tensorflow/lite/profiling/platform_profiler.cc ++++ b/third_party/tflite/src/tensorflow/lite/profiling/platform_profiler.cc +@@ -18,7 +18,7 @@ + + #include "tensorflow/lite/core/api/profiler.h" + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + #include "tensorflow/lite/profiling/atrace_profiler.h" + #elif defined(__APPLE__) + #include "TargetConditionals.h" +@@ -34,7 +34,7 @@ + namespace profiling { + + std::unique_ptr MaybeCreatePlatformProfiler() { +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + return MaybeCreateATraceProfiler(); + #elif defined(SIGNPOST_PLATFORM_PROFILER) + return MaybeCreateSignpostProfiler(); diff --git a/tur-electron/electron-32/2020-dav1d-config.patch b/tur-electron/electron-32/2020-dav1d-config.patch new file mode 100644 index 0000000..a889b28 --- /dev/null +++ b/tur-electron/electron-32/2020-dav1d-config.patch @@ -0,0 +1,60 @@ +Aarch64 Android compiles as `armv8-a` and don't have so much extensions. + +--- a/third_party/dav1d/config/linux/arm64/config.h ++++ b/third_party/dav1d/config/linux/arm64/config.h +@@ -29,7 +29,7 @@ + + #define ARCH_X86_64 0 + +-#define AS_ARCH_LEVEL armv8.6-a+crc ++// #define AS_ARCH_LEVEL armv8.6-a+crc + + #define CONFIG_16BPC 1 + +@@ -41,15 +41,15 @@ + + #define HAVE_ASM 1 + +-#define HAVE_AS_ARCHEXT_DOTPROD_DIRECTIVE 1 ++// #define HAVE_AS_ARCHEXT_DOTPROD_DIRECTIVE 1 + +-#define HAVE_AS_ARCHEXT_I8MM_DIRECTIVE 1 ++// #define HAVE_AS_ARCHEXT_I8MM_DIRECTIVE 1 + +-#define HAVE_AS_ARCHEXT_SVE2_DIRECTIVE 1 ++// #define HAVE_AS_ARCHEXT_SVE2_DIRECTIVE 1 + +-#define HAVE_AS_ARCHEXT_SVE_DIRECTIVE 1 ++// #define HAVE_AS_ARCHEXT_SVE_DIRECTIVE 1 + +-#define HAVE_AS_ARCH_DIRECTIVE 1 ++// #define HAVE_AS_ARCH_DIRECTIVE 1 + + #define HAVE_AS_FUNC 0 + +@@ -59,11 +59,11 @@ + + #define HAVE_DLSYM 1 + +-#define HAVE_DOTPROD 1 ++// #define HAVE_DOTPROD 1 + + #define HAVE_GETAUXVAL 1 + +-#define HAVE_I8MM 1 ++// #define HAVE_I8MM 1 + + #define HAVE_POSIX_MEMALIGN 1 + +@@ -71,9 +71,9 @@ + + // #define HAVE_PTHREAD_SETAFFINITY_NP 1 -- Controlled by Chomium + +-#define HAVE_SVE 1 ++// #define HAVE_SVE 1 + +-#define HAVE_SVE2 1 ++// #define HAVE_SVE2 1 + + #define HAVE_UNISTD_H 1 + diff --git a/tur-electron/electron-32/2101-mix-no-execinfo.patch b/tur-electron/electron-32/2101-mix-no-execinfo.patch new file mode 100644 index 0000000..df56f02 --- /dev/null +++ b/tur-electron/electron-32/2101-mix-no-execinfo.patch @@ -0,0 +1,61 @@ +--- a/v8/src/codegen/external-reference-table.cc ++++ b/v8/src/codegen/external-reference-table.cc +@@ -12,7 +12,9 @@ + + #if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID) + #define SYMBOLIZE_FUNCTION ++#if defined(__GLIBC__) + #include ++#endif + + #include + +@@ -118,7 +120,7 @@ + } + + const char* ExternalReferenceTable::ResolveSymbol(void* address) { +-#ifdef SYMBOLIZE_FUNCTION ++#if defined(SYMBOLIZE_FUNCTION) && defined(__GLIBC__) + char** names = backtrace_symbols(&address, 1); + const char* name = names[0]; + // The array of names is malloc'ed. However, each name string is static +--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h ++++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h +@@ -58,7 +58,7 @@ + #define HAVE_ERRNO_H 1 + + /* Define to 1 if you have the header file. */ +-#define HAVE_EXECINFO_H 1 ++// #define HAVE_EXECINFO_H 1 + + /* Define to 1 if you have the header file. */ + #define HAVE_FCNTL_H 1 +--- a/base/debug/stack_trace.cc ++++ b/base/debug/stack_trace.cc +@@ -249,7 +249,7 @@ + // Symbols are not expected to be reliable when gn args specifies + // symbol_level=0. + return false; +-#elif defined(__UCLIBC__) || defined(_AIX) ++#elif defined(__UCLIBC__) || defined(_AIX) || defined(__TERMUX__) + // StackTrace::OutputToStream() is not implemented under uclibc, nor AIX. + // See https://crbug.com/706728 + return false; +@@ -311,7 +311,7 @@ + + std::string StackTrace::ToStringWithPrefix(cstring_view prefix_string) const { + std::stringstream stream; +-#if !defined(__UCLIBC__) && !defined(_AIX) ++#if !defined(__UCLIBC__) && !defined(_AIX) && !defined(__TERMUX__) + OutputToStreamWithPrefix(&stream, prefix_string); + #endif + return stream.str(); +@@ -335,7 +335,7 @@ + } + + std::ostream& operator<<(std::ostream& os, const StackTrace& s) { +-#if !defined(__UCLIBC__) && !defined(_AIX) ++#if !defined(__UCLIBC__) && !defined(_AIX) && !defined(__TERMUX__) + s.OutputToStream(&os); + #else + os << "StackTrace::OutputToStream not implemented."; diff --git a/tur-electron/electron-32/2102-mix-egl-fix-include.patch b/tur-electron/electron-32/2102-mix-egl-fix-include.patch new file mode 100644 index 0000000..83c084e --- /dev/null +++ b/tur-electron/electron-32/2102-mix-egl-fix-include.patch @@ -0,0 +1,47 @@ +--- a/third_party/dawn/third_party/khronos/EGL-Registry/api/EGL/eglplatform.h ++++ b/third_party/dawn/third_party/khronos/EGL-Registry/api/EGL/eglplatform.h +@@ -88,7 +88,7 @@ + typedef struct gbm_bo *EGLNativePixmapType; + typedef void *EGLNativeWindowType; + +-#elif defined(__ANDROID__) || defined(ANDROID) ++#elif (defined(__ANDROID__) || defined(ANDROID)) && !defined(__TERMUX__) + + struct ANativeWindow; + struct egl_native_pixmap_t; + +--- a/third_party/khronos/EGL/eglplatform.h ++++ b/third_party/khronos/EGL/eglplatform.h +@@ -88,7 +88,7 @@ + typedef struct gbm_bo *EGLNativePixmapType; + typedef void *EGLNativeWindowType; + +-#elif defined(__ANDROID__) || defined(ANDROID) ++#elif (defined(__ANDROID__) || defined(ANDROID)) && !defined(__TERMUX__) + + struct ANativeWindow; + struct egl_native_pixmap_t; + +--- a/third_party/angle/third_party/glmark2/src/src/glad/include/EGL/eglplatform.h ++++ b/third_party/angle/third_party/glmark2/src/src/glad/include/EGL/eglplatform.h +@@ -88,7 +88,7 @@ + typedef struct gbm_bo *EGLNativePixmapType; + typedef void *EGLNativeWindowType; + +-#elif defined(__ANDROID__) || defined(ANDROID) ++#elif (defined(__ANDROID__) || defined(ANDROID)) && !defined(__TERMUX__) + + struct ANativeWindow; + struct egl_native_pixmap_t; + +--- a/third_party/angle/include/EGL/eglplatform.h ++++ b/third_party/angle/include/EGL/eglplatform.h +@@ -88,7 +88,7 @@ + typedef struct gbm_bo *EGLNativePixmapType; + typedef void *EGLNativeWindowType; + +-#elif defined(__ANDROID__) || defined(ANDROID) ++#elif (defined(__ANDROID__) || defined(ANDROID)) && !defined(__TERMUX__) + + struct ANativeWindow; + struct egl_native_pixmap_t; diff --git a/tur-electron/electron-32/2103-pulse-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/2103-pulse-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..18f726b --- /dev/null +++ b/tur-electron/electron-32/2103-pulse-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,29 @@ +--- a/media/audio/pulse/pulse_util.cc ++++ b/media/audio/pulse/pulse_util.cc +@@ -44,8 +44,12 @@ + + #if defined(DLOPEN_PULSEAUDIO) + static const base::FilePath::CharType kPulseLib[] = ++#ifdef __TERMUX__ ++ FILE_PATH_LITERAL("libpulse.so"); ++#else + FILE_PATH_LITERAL("libpulse.so.0"); + #endif ++#endif + + void DestroyMainloop(pa_threaded_mainloop* mainloop) { + pa_threaded_mainloop_stop(mainloop); +--- a/third_party/webrtc/modules/audio_device/linux/pulseaudiosymboltable_linux.cc ++++ b/third_party/webrtc/modules/audio_device/linux/pulseaudiosymboltable_linux.cc +@@ -30,7 +30,11 @@ + namespace webrtc { + namespace adm_linux_pulse { + ++#ifdef __TERMUX__ ++LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(PulseAudioSymbolTable, "libpulse.so") ++#else + LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(PulseAudioSymbolTable, "libpulse.so.0") ++#endif + #define X(sym) \ + LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(PulseAudioSymbolTable, sym) + PULSE_AUDIO_SYMBOLS_LIST diff --git a/tur-electron/electron-32/7001-blink-font-constructor.patch b/tur-electron/electron-32/7001-blink-font-constructor.patch new file mode 100644 index 0000000..020e795 --- /dev/null +++ b/tur-electron/electron-32/7001-blink-font-constructor.patch @@ -0,0 +1,11 @@ +--- a/third_party/blink/renderer/platform/fonts/palette_interpolation.cc ++++ b/third_party/blink/renderer/platform/fonts/palette_interpolation.cc +@@ -31,7 +31,7 @@ + color_interpolation_space, hue_interpolation_method, start_color, + end_color, percentage, alpha_multiplier); + +- FontPalette::FontPaletteOverride result_color_record(i, result_color); ++ FontPalette::FontPaletteOverride result_color_record{static_cast(i), result_color}; + result_color_records.push_back(result_color_record); + } + return result_color_records; diff --git a/tur-electron/electron-32/7002-blink-cxx11-narrowing.patch b/tur-electron/electron-32/7002-blink-cxx11-narrowing.patch new file mode 100644 index 0000000..0223478 --- /dev/null +++ b/tur-electron/electron-32/7002-blink-cxx11-narrowing.patch @@ -0,0 +1,14 @@ +--- a/chrome/browser/performance_manager/user_tuning/cpu_health_tracker.cc ++++ b/chrome/browser/performance_manager/user_tuning/cpu_health_tracker.cc +@@ -222,8 +222,9 @@ + return; + } + +- const CpuPercent total_system_cpu_usage{cpu_sample.value().cpu_utilization * +- 100}; ++ const CpuPercent total_system_cpu_usage{ ++ static_cast(cpu_sample.value().cpu_utilization * 100)}; ++ + if (GetHealthLevelForMeasurement(total_system_cpu_usage) != + HealthLevel::kHealthy) { + // Query for tab CPU usage to determine actionability diff --git a/tur-electron/electron-32/8001-blink-include-bitset-2.patch b/tur-electron/electron-32/8001-blink-include-bitset-2.patch new file mode 100644 index 0000000..eed31bf --- /dev/null +++ b/tur-electron/electron-32/8001-blink-include-bitset-2.patch @@ -0,0 +1,11 @@ +--- a/third_party/blink/renderer/platform/peerconnection/resolution_monitor.cc ++++ b/third_party/blink/renderer/platform/peerconnection/resolution_monitor.cc +@@ -2,6 +2,8 @@ + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + ++#include ++ + #include "third_party/blink/renderer/platform/peerconnection/resolution_monitor.h" + + #include "base/containers/span.h" diff --git a/tur-electron/electron-32/8002-material_color_utilities-include-cmath.patch b/tur-electron/electron-32/8002-material_color_utilities-include-cmath.patch new file mode 100644 index 0000000..d403a9d --- /dev/null +++ b/tur-electron/electron-32/8002-material_color_utilities-include-cmath.patch @@ -0,0 +1,10 @@ +--- a/third_party/material_color_utilities/src/cpp/utils/utils.h ++++ b/third_party/material_color_utilities/src/cpp/utils/utils.h +@@ -18,6 +18,7 @@ + #define CPP_UTILS_UTILS_H_ + + #include ++#include + #include + + namespace material_color_utilities { diff --git a/tur-electron/electron-32/8003-gfx-include-bitset.patch b/tur-electron/electron-32/8003-gfx-include-bitset.patch new file mode 100644 index 0000000..e5f8082 --- /dev/null +++ b/tur-electron/electron-32/8003-gfx-include-bitset.patch @@ -0,0 +1,11 @@ +--- a/ui/gfx/x/visual_manager.cc ++++ b/ui/gfx/x/visual_manager.cc +@@ -2,6 +2,8 @@ + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + ++#include ++ + #include "ui/gfx/x/visual_manager.h" + + #include "base/strings/string_number_conversions.h" diff --git a/tur-electron/electron-32/9001-electron-getversion-from-file.patch b/tur-electron/electron-32/9001-electron-getversion-from-file.patch new file mode 100644 index 0000000..5e74656 --- /dev/null +++ b/tur-electron/electron-32/9001-electron-getversion-from-file.patch @@ -0,0 +1,12 @@ +We pass `--no-history` to gclient, so there will be no version for electron. +--- a/electron/script/get-git-version.py ++++ b/electron/script/get-git-version.py +@@ -20,7 +20,7 @@ + + try: + output = subprocess.check_output( +- ['git', 'describe', '--tags', '--abbrev=0'], ++ ['cat', 'ELECTRON_VERSION'], + cwd=os.path.abspath(os.path.join(os.path.dirname(__file__), '..')), + stderr=subprocess.PIPE, + universal_newlines=True) diff --git a/tur-electron/electron-32/9002-v8-fix-trap-handler.patch b/tur-electron/electron-32/9002-v8-fix-trap-handler.patch new file mode 100644 index 0000000..b3bab79 --- /dev/null +++ b/tur-electron/electron-32/9002-v8-fix-trap-handler.patch @@ -0,0 +1,11 @@ +--- a/third_party/electron_node/deps/v8/src/trap-handler/trap-handler.h ++++ b/third_party/electron_node/deps/v8/src/trap-handler/trap-handler.h +@@ -19,7 +19,7 @@ + + // X64 on Linux, Windows, MacOS, FreeBSD. + #if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \ +- ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_DARWIN || \ ++ (V8_OS_LINUX || V8_OS_WIN || V8_OS_DARWIN || \ + V8_OS_FREEBSD) + #define V8_TRAP_HANDLER_SUPPORTED true + // Arm64 (non-simulator) on Mac. diff --git a/tur-electron/electron-32/9003-cares-config.patch b/tur-electron/electron-32/9003-cares-config.patch new file mode 100644 index 0000000..e5acd8b --- /dev/null +++ b/tur-electron/electron-32/9003-cares-config.patch @@ -0,0 +1,55 @@ +--- a/third_party/electron_node/deps/cares/config/linux/ares_config.h ++++ b/third_party/electron_node/deps/cares/config/linux/ares_config.h +@@ -50,10 +50,10 @@ + #define HAVE_ARPA_INET_H 1 + + /* Define to 1 if you have the header file. */ +-#define HAVE_ARPA_NAMESER_COMPAT_H 1 ++// #define HAVE_ARPA_NAMESER_COMPAT_H 1 + + /* Define to 1 if you have the header file. */ +-#define HAVE_ARPA_NAMESER_H 1 ++// #define HAVE_ARPA_NAMESER_H 1 + + /* Define to 1 if you have the header file. */ + #define HAVE_ASSERT_H 1 +@@ -116,10 +116,10 @@ + #define HAVE_GETNAMEINFO 1 + + /* Define to 1 if you have `getrandom` */ +-#define HAVE_GETRANDOM 1 ++// #define HAVE_GETRANDOM 1 + + /* Define to 1 if you have `getservbyport_r` */ +-#define HAVE_GETSERVBYPORT_R 1 ++// #define HAVE_GETSERVBYPORT_R 1 + + /* Define to 1 if you have `gettimeofday` */ + #define HAVE_GETTIMEOFDAY 1 +@@ -146,7 +146,7 @@ + #define HAVE_INTTYPES_H 1 + + /* Define to 1 if you have `ioctl` */ +-#define HAVE_IOCTL 1 ++// #define HAVE_IOCTL 1 + + /* Define to 1 if you have `ioctlsocket` */ + /* #undef HAVE_IOCTLSOCKET */ +@@ -158,7 +158,7 @@ + /* #undef HAVE_IOCTLSOCKET_FIONBIO */ + + /* ioctl() with FIONBIO support */ +-#define HAVE_IOCTL_FIONBIO 1 ++// #define HAVE_IOCTL_FIONBIO 1 + + /* Define to 1 if you have the header file. */ + /* #undef HAVE_IPHLPAPI_H */ +@@ -212,7 +212,7 @@ + #define HAVE_PIPE 1 + + /* Define to 1 if you have `pipe2` */ +-#define HAVE_PIPE2 1 ++// #define HAVE_PIPE2 1 + + /* Define to 1 if you have `poll` */ + #define HAVE_POLL 1 diff --git a/tur-electron/electron-32/9004-electron-disable-sandbox.patch b/tur-electron/electron-32/9004-electron-disable-sandbox.patch new file mode 100644 index 0000000..77e586e --- /dev/null +++ b/tur-electron/electron-32/9004-electron-disable-sandbox.patch @@ -0,0 +1,16 @@ +--- a/electron/shell/app/electron_main_delegate.cc ++++ b/electron/shell/app/electron_main_delegate.cc +@@ -256,8 +256,13 @@ + if (env->HasVar(kElectronEnableStackDumping)) + base::debug::EnableInProcessStackDumping(); + ++#ifndef __TERMUX__ + if (env->HasVar(kElectronDisableSandbox)) + command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox); ++#else ++ command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox); ++ command_line->AppendSwitch(sandbox::policy::switches::kDisableSeccompFilterSandbox); ++#endif + + tracing_sampler_profiler_ = + tracing::TracingSamplerProfiler::CreateOnMainThread(); diff --git a/tur-electron/electron-32/9005-node-as-posix.patch b/tur-electron/electron-32/9005-node-as-posix.patch new file mode 100644 index 0000000..7120590 --- /dev/null +++ b/tur-electron/electron-32/9005-node-as-posix.patch @@ -0,0 +1,14 @@ +--- a/third_party/electron_node/src/node_internals.h ++++ b/third_party/electron_node/src/node_internals.h +@@ -287,9 +287,9 @@ + + // Functions defined in node.cc that are exposed via the bootstrapper object + +-#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__) ++#if defined(__POSIX__) && !defined(__CloudABI__) + #define NODE_IMPLEMENTS_POSIX_CREDENTIALS 1 +-#endif // defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__) ++#endif // defined(__POSIX__) && !defined(__CloudABI__) + + namespace credentials { + bool SafeGetenv(const char* key, diff --git a/tur-electron/electron-32/9006-gtk-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-32/9006-gtk-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..8c4cd7e --- /dev/null +++ b/tur-electron/electron-32/9006-gtk-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,53 @@ +--- a/ui/gtk/gtk_compat.cc ++++ b/ui/gtk/gtk_compat.cc +@@ -62,22 +62,38 @@ + } + + void* GetLibGio() { ++#ifdef __TERMUX__ ++ static void* libgio = DlOpen("libgio-2.0.so"); ++#else + static void* libgio = DlOpen("libgio-2.0.so.0"); ++#endif + return libgio; + } + + void* GetLibGdk3() { ++#ifdef __TERMUX__ ++ static void* libgdk3 = DlOpen("libgdk-3.so"); ++#else + static void* libgdk3 = DlOpen("libgdk-3.so.0"); ++#endif + return libgdk3; + } + + void* GetLibGtk3(bool check = true) { ++#ifdef __TERMUX__ ++ static void* libgtk3 = DlOpen("libgtk-3.so", check); ++#else + static void* libgtk3 = DlOpen("libgtk-3.so.0", check); ++#endif + return libgtk3; + } + + void* GetLibGtk4(bool check = true) { ++#ifdef __TERMUX__ ++ static void* libgtk4 = DlOpen("libgtk-4.so", check); ++#else + static void* libgtk4 = DlOpen("libgtk-4.so.1", check); ++#endif + return libgtk4; + } + +@@ -124,7 +140,11 @@ + } // namespace + + void* GetLibGdkPixbuf() { ++#ifdef __TERMUX__ ++ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so"); ++#else + static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); ++#endif + return libgdk_pixbuf; + } + diff --git a/tur-electron/electron-32/9007-add-missing-function-for-extension_action_api.patch b/tur-electron/electron-32/9007-add-missing-function-for-extension_action_api.patch new file mode 100644 index 0000000..7307e18 --- /dev/null +++ b/tur-electron/electron-32/9007-add-missing-function-for-extension_action_api.patch @@ -0,0 +1,16 @@ +--- a/electron/shell/browser/extensions/api/extension_action/extension_action_api.cc ++++ b/electron/shell/browser/extensions/api/extension_action/extension_action_api.cc +@@ -154,6 +154,13 @@ + } + + ExtensionFunction::ResponseAction ++ExtensionActionOpenPopupFunction::RunExtensionAction() { ++ LOG(INFO) << "chrome.action.openPopup is not supported in Electron"; ++ ++ return RespondNow(NoArguments()); ++} ++ ++ExtensionFunction::ResponseAction + ExtensionActionGetBadgeTextFunction::RunExtensionAction() { + LOG(INFO) << "chrome.action.getBadgeText is not supported in Electron"; + diff --git a/tur-electron/electron-32/build.sh b/tur-electron/electron-32/build.sh new file mode 100644 index 0000000..5d61308 --- /dev/null +++ b/tur-electron/electron-32/build.sh @@ -0,0 +1,361 @@ +TERMUX_PKG_HOMEPAGE=https://github.com/electron/electron +TERMUX_PKG_DESCRIPTION="Build cross-platform desktop apps with JavaScript, HTML, and CSS" +TERMUX_PKG_LICENSE="MIT, BSD 3-Clause" +TERMUX_PKG_MAINTAINER="Chongyun Lee " +_CHROMIUM_VERSION=128.0.6613.186 +TERMUX_PKG_VERSION=32.2.1 +TERMUX_PKG_SRCURL=git+https://github.com/electron/electron +TERMUX_PKG_DEPENDS="electron-deps" +TERMUX_PKG_BUILD_DEPENDS="libnotify, libffi-static" +# Chromium doesn't support i686 on Linux. +TERMUX_PKG_BLACKLISTED_ARCHES="i686" + +__tur_setup_depot_tools() { + export DEPOT_TOOLS_UPDATE=0 + if [ ! -f "$TERMUX_PKG_CACHEDIR/.depot_tools-fetched" ];then + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $TERMUX_PKG_CACHEDIR/depot_tools + touch "$TERMUX_PKG_CACHEDIR/.depot_tools-fetched" + fi + export PATH="$TERMUX_PKG_CACHEDIR/depot_tools:$PATH" + export CHROMIUM_BUILDTOOLS_PATH="$TERMUX_PKG_SRCDIR/buildtools" +} + +termux_step_get_source() { + # Check whether we need to get source + if [ -f "$TERMUX_PKG_CACHEDIR/.electron-source-fetched" ]; then + local _fetched_source_version=$(cat $TERMUX_PKG_CACHEDIR/.electron-source-fetched) + if [ "$_fetched_source_version" = "$TERMUX_PKG_VERSION" ]; then + echo "[INFO]: Use pre-fetched source (version $_fetched_source_version)." + ln -sfr $TERMUX_PKG_CACHEDIR/tmp-checkout/src $TERMUX_PKG_SRCDIR + # Revert patches + shopt -s nullglob + local f + for f in $TERMUX_PKG_BUILDER_DIR/*.patch; do + echo "[INFO]: Reverting $(basename "$f")" + (sed "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" "$f" | patch -f --silent -R -p1 -d "$TERMUX_PKG_SRCDIR") || true + done + shopt -u nullglob + python $TERMUX_SCRIPTDIR/common-files/apply-chromium-patches.py --electron -C "$TERMUX_PKG_SRCDIR" -R -v $_CHROMIUM_VERSION || bash + return + fi + fi + + # Fetch depot_tools + __tur_setup_depot_tools + + # Install nodejs + termux_setup_nodejs + + # Get source + rm -rf "$TERMUX_PKG_CACHEDIR/tmp-checkout" + mkdir -p "$TERMUX_PKG_CACHEDIR/tmp-checkout" + pushd "$TERMUX_PKG_CACHEDIR/tmp-checkout" + gclient config --name "src/electron" --unmanaged https://github.com/electron/electron + gclient sync --with_branch_heads --with_tags --no-history --revision v$TERMUX_PKG_VERSION || bash + popd + + # Solve error like `.git/packed-refs is dirty` + cd "$TERMUX_PKG_CACHEDIR/tmp-checkout/src" + git pack-refs --all + cd electron + git pack-refs --all + + echo "$TERMUX_PKG_VERSION" > "$TERMUX_PKG_CACHEDIR/.electron-source-fetched" + ln -sfr $TERMUX_PKG_CACHEDIR/tmp-checkout/src $TERMUX_PKG_SRCDIR +} + +termux_step_post_get_source() { + echo "$TERMUX_PKG_VERSION" > $TERMUX_PKG_SRCDIR/electron/ELECTRON_VERSION +} + +termux_step_configure() { + cd $TERMUX_PKG_SRCDIR + termux_setup_ninja + termux_setup_nodejs + __tur_setup_depot_tools + + # Remove termux's dummy pkg-config + local _target_pkg_config=$(command -v pkg-config) + local _host_pkg_config="$(cat $_target_pkg_config | grep exec | awk '{print $2}')" + rm -rf $TERMUX_PKG_CACHEDIR/host-pkg-config-bin + mkdir -p $TERMUX_PKG_CACHEDIR/host-pkg-config-bin + ln -s $_host_pkg_config $TERMUX_PKG_CACHEDIR/host-pkg-config-bin/pkg-config + export PATH="$TERMUX_PKG_CACHEDIR/host-pkg-config-bin:$PATH" + + # Install deps + env -i PATH="$PATH" sudo apt update + env -i PATH="$PATH" sudo apt install lsb-release -yq + env -i PATH="$PATH" sudo apt install libfontconfig1 libfontconfig1:i386 -yq + env -i PATH="$PATH" sudo ./build/install-build-deps.sh --lib32 --no-syms --no-android --no-arm --no-chromeos-fonts --no-nacl --no-prompt + + # Setup rust toolchain and clang toolchain + ./tools/rust/update_rust.py + ./tools/clang/scripts/update.py + + # Install amd64 rootfs if necessary, it should have been installed by source hooks. + build/linux/sysroot_scripts/install-sysroot.py --sysroots-json-path=electron/script/sysroots.json --arch=amd64 + local _amd64_sysroot_path="$(pwd)/build/linux/$(ls build/linux | grep 'amd64-sysroot')" + + # Install i386 rootfs if necessary, it should have been installed by source hooks. + build/linux/sysroot_scripts/install-sysroot.py --sysroots-json-path=electron/script/sysroots.json --arch=i386 + local _i386_sysroot_path="$(pwd)/build/linux/$(ls build/linux | grep 'i386-sysroot')" + + local CARGO_TARGET_NAME="${TERMUX_ARCH}-linux-android" + if [[ "${TERMUX_ARCH}" == "arm" ]]; then + CARGO_TARGET_NAME="armv7-linux-androideabi" + fi + + # Link to system tools required by the build + mkdir -p third_party/node/linux/node-linux-x64/bin + ln -sf $(command -v node) third_party/node/linux/node-linux-x64/bin/ + + # Dummy librt.so + # Why not dummy a librt.a? Some of the binaries reference symbols only exists in Android + # for some reason, such as the `chrome_crashpad_handler`, which needs to link with + # libprotobuf_lite.a, but it is hard to remove the usage of `android/log.h` in protobuf. + echo "INPUT(-llog -liconv -landroid-shmem)" > "$TERMUX_PREFIX/lib/librt.so" + + # Dummy libpthread.a and libresolv.a + echo '!' > "$TERMUX_PREFIX/lib/libpthread.a" + echo '!' > "$TERMUX_PREFIX/lib/libresolv.a" + + # Symlink libffi.a to libffi_pic.a + ln -sfr $TERMUX_PREFIX/lib/libffi.a $TERMUX_PREFIX/lib/libffi_pic.a + + # Merge sysroots + if [ ! -d "$TERMUX_PKG_CACHEDIR/sysroot-$TERMUX_ARCH" ]; then + rm -rf $TERMUX_PKG_TMPDIR/sysroot + mkdir -p $TERMUX_PKG_TMPDIR/sysroot + pushd $TERMUX_PKG_TMPDIR/sysroot + mkdir -p usr/include usr/lib usr/bin + cp -R $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include/* usr/include + cp -R $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include/$TERMUX_HOST_PLATFORM/* usr/include + cp -R $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/* usr/lib/ + cp "$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/libc++_shared.so" usr/lib/ + cp "$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/libc++_static.a" usr/lib/ + cp "$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/libc++abi.a" usr/lib/ + cp -Rf $TERMUX_PREFIX/include/* usr/include + cp -Rf $TERMUX_PREFIX/lib/* usr/lib + ln -sf /data ./data + # This is needed to build crashpad + rm -rf $TERMUX_PREFIX/include/spawn.h + # This is needed to build cups + cp -Rf $TERMUX_PREFIX/bin/cups-config usr/bin/ + chmod +x usr/bin/cups-config + popd + mv $TERMUX_PKG_TMPDIR/sysroot $TERMUX_PKG_CACHEDIR/sysroot-$TERMUX_ARCH + fi + + # Construct args + local _clang_base_path="$PWD/third_party/llvm-build/Release+Asserts" + local _host_cc="$_clang_base_path/bin/clang" + local _host_cxx="$_clang_base_path/bin/clang++" + local _host_clang_version=$($_host_cc --version | grep -m1 version | sed -E 's|.*\bclang version ([0-9]+).*|\1|') + local _target_cpu _target_sysroot="$TERMUX_PKG_CACHEDIR/sysroot-$TERMUX_ARCH" + local _v8_toolchain_name _v8_current_cpu _v8_sysroot_path + if [ "$TERMUX_ARCH" = "aarch64" ]; then + _target_cpu="arm64" + _v8_current_cpu="x64" + _v8_sysroot_path="$_amd64_sysroot_path" + _v8_toolchain_name="clang_x64_v8_arm64" + elif [ "$TERMUX_ARCH" = "arm" ]; then + _target_cpu="arm" + _v8_current_cpu="x86" + _v8_sysroot_path="$_i386_sysroot_path" + _v8_toolchain_name="clang_x86_v8_arm" + elif [ "$TERMUX_ARCH" = "x86_64" ]; then + _target_cpu="x64" + _v8_current_cpu="x64" + _v8_sysroot_path="$_amd64_sysroot_path" + _v8_toolchain_name="clang_x64" + fi + + local _common_args_file=$TERMUX_PKG_TMPDIR/common-args-file + rm -f $_common_args_file + touch $_common_args_file + + echo " +import(\"$TERMUX_PKG_SRCDIR/electron/build/args/release.gn\") +override_electron_version = \"$TERMUX_PKG_VERSION\" +# Do not build with symbols +symbol_level = 0 +# Use our custom toolchain +clang_version = \"$_host_clang_version\" +use_sysroot = false +target_cpu = \"$_target_cpu\" +target_rpath = \"$TERMUX_PREFIX/lib\" +target_sysroot = \"$_target_sysroot\" +custom_toolchain = \"//build/toolchain/linux/unbundle:default\" +custom_toolchain_clang_base_path = \"$TERMUX_STANDALONE_TOOLCHAIN\" +custom_toolchain_clang_version = "18" +host_toolchain = \"$TERMUX_PKG_CACHEDIR/custom-toolchain:host\" +v8_snapshot_toolchain = \"$TERMUX_PKG_CACHEDIR/custom-toolchain:$_v8_toolchain_name\" +electron_js2c_toolchain = \"$TERMUX_PKG_CACHEDIR/custom-toolchain:$_v8_toolchain_name\" +clang_use_chrome_plugins = false +dcheck_always_on = false +chrome_pgo_phase = 0 +treat_warnings_as_errors = false +# Use system libraries as little as possible +use_bundled_fontconfig = false +use_system_freetype = false +use_system_libdrm = true +use_system_libffi = true +use_custom_libcxx = false +use_custom_libcxx_for_host = true +use_allocator_shim = false +use_partition_alloc_as_malloc = false +enable_backup_ref_ptr_slow_checks = false +enable_dangling_raw_ptr_checks = false +enable_dangling_raw_ptr_feature_flag = false +backup_ref_ptr_extra_oob_checks = false +enable_backup_ref_ptr_support = false +enable_pointer_compression_support = false +use_nss_certs = true +use_udev = false +use_alsa = false +use_libpci = false +use_pulseaudio = true +use_ozone = true +ozone_auto_platforms = false +ozone_platform = \"x11\" +ozone_platform_x11 = true +ozone_platform_wayland = true +ozone_platform_headless = true +angle_enable_vulkan = true +angle_enable_swiftshader = true +angle_enable_abseil = false +rtc_use_pipewire = false +use_vaapi = false +# See comments on Chromium package +enable_nacl = false +is_cfi = false +use_cfi_icall = false +use_thin_lto = false +# Enable rust +custom_target_rust_abi_target = \"$CARGO_TARGET_NAME\" +llvm_android_mainline = true +exclude_unwind_tables = false +" >> $_common_args_file + + if [ "$TERMUX_ARCH" = "arm" ]; then + echo "arm_arch = \"armv7-a\"" >> $_common_args_file + echo "arm_float_abi = \"softfp\"" >> $_common_args_file + fi + + # Use custom toolchain + mkdir -p $TERMUX_PKG_CACHEDIR/custom-toolchain + cp -f $TERMUX_PKG_BUILDER_DIR/toolchain.gn.in $TERMUX_PKG_CACHEDIR/custom-toolchain/BUILD.gn + sed -i "s|@HOST_CC@|$_host_cc|g + s|@HOST_CXX@|$_host_cxx|g + s|@HOST_LD@|$_host_cxx|g + s|@HOST_AR@|$(command -v llvm-ar)|g + s|@HOST_NM@|$(command -v llvm-nm)|g + s|@HOST_IS_CLANG@|true|g + s|@HOST_USE_GOLD@|false|g + s|@HOST_SYSROOT@|$_amd64_sysroot_path|g + " $TERMUX_PKG_CACHEDIR/custom-toolchain/BUILD.gn + sed -i "s|@V8_CC@|$_host_cc|g + s|@V8_CXX@|$_host_cxx|g + s|@V8_LD@|$_host_cxx|g + s|@V8_AR@|$(command -v llvm-ar)|g + s|@V8_NM@|$(command -v llvm-nm)|g + s|@V8_TOOLCHAIN_NAME@|$_v8_toolchain_name|g + s|@V8_CURRENT_CPU@|$_v8_current_cpu|g + s|@V8_V8_CURRENT_CPU@|$_target_cpu|g + s|@V8_IS_CLANG@|true|g + s|@V8_USE_GOLD@|false|g + s|@V8_SYSROOT@|$_v8_sysroot_path|g + " $TERMUX_PKG_CACHEDIR/custom-toolchain/BUILD.gn + + # Generate ninja files + mkdir -p $TERMUX_PKG_BUILDDIR/out/Release + cat $_common_args_file > $TERMUX_PKG_BUILDDIR/out/Release/args.gn + gn gen $TERMUX_PKG_BUILDDIR/out/Release +} + +termux_step_make() { + cd $TERMUX_PKG_BUILDDIR + ninja -C $TERMUX_PKG_BUILDDIR/out/Release electron:node_headers electron electron_license chromium_licenses + rm -rf "$TERMUX_PKG_CACHEDIR/sysroot-$TERMUX_ARCH" +} + +termux_step_make_install() { + cd $TERMUX_PKG_BUILDDIR + local _install_prefix=$TERMUX_PREFIX/opt/electron-$TERMUX_PKG_VERSION + mkdir -p $_install_prefix + + echo "$TERMUX_PKG_VERSION" > $TERMUX_PKG_BUILDDIR/out/Release/version + + local normal_files=( + # Binary files + electron + chrome_sandbox + chrome_crashpad_handler + + # Resource files + chrome_100_percent.pak + chrome_200_percent.pak + resources.pak + + # V8 Snapshot data + snapshot_blob.bin + v8_context_snapshot.bin + + # ICU Data + icudtl.dat + + # Angle + libEGL.so + libGLESv2.so + + # Vulkan + libvulkan.so.1 + libvk_swiftshader.so + vk_swiftshader_icd.json + + # FFmpeg + libffmpeg.so + + # VERSION file + version + ) + + cp "${normal_files[@]/#/out/Release/}" "$_install_prefix/" + + cp -Rf out/Release/angledata $_install_prefix/ + cp -Rf out/Release/locales $_install_prefix/ + cp -Rf out/Release/resources $_install_prefix/ + + chmod +x $_install_prefix/electron + + # Install LICENSE file + cp out/Release/LICENSE{,S.chromium.html} $_install_prefix/ +} + +termux_step_install_license() { + mkdir -p $TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME + cp out/Release/LICENSE{,S.chromium.html} $TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME/ +} + +termux_step_post_make_install() { + # Remove the dummy files + rm $TERMUX_PREFIX/lib/lib{{pthread,resolv,ffi_pic}.a,rt.so} +} + +termux_step_post_massage() { + # Except the deb file, we also create a zip file like electron release + local _TARGET_CPU="$TERMUX_ARCH" + if [ "$TERMUX_ARCH" = "aarch64" ]; then + _TARGET_CPU="arm64" + elif [ "$TERMUX_ARCH" = "x86_64" ]; then + _TARGET_CPU="x64" + elif [ "$TERMUX_ARCH" = "arm" ]; then + _TARGET_CPU="armv7l" + fi + + mkdir -p $TERMUX_SCRIPTDIR/output-electron + + pushd $TERMUX_PREFIX/opt/electron-$TERMUX_PKG_VERSION + zip -r $TERMUX_SCRIPTDIR/output-electron/electron-v$TERMUX_PKG_VERSION-linux-$_TARGET_CPU.zip ./* + popd +} diff --git a/tur-electron/electron-32/toolchain.gn.in b/tur-electron/electron-32/toolchain.gn.in new file mode 100644 index 0000000..2435138 --- /dev/null +++ b/tur-electron/electron-32/toolchain.gn.in @@ -0,0 +1,30 @@ +import("//build/config/sysroot.gni") +import("//build/toolchain/gcc_toolchain.gni") + +gcc_toolchain("host") { + cc = "@HOST_CC@" + cxx = "@HOST_CXX@" + ld = "@HOST_LD@" + ar = "@HOST_AR@" + nm = "@HOST_NM@" + toolchain_args = { + current_os = "linux" + current_cpu = "x64" + is_clang = @HOST_IS_CLANG@ + sysroot = "@HOST_SYSROOT@" + } +} +gcc_toolchain("@V8_TOOLCHAIN_NAME@") { + cc = "@V8_CC@" + cxx = "@V8_CXX@" + ld = "@V8_LD@" + ar = "@V8_AR@" + nm = "@V8_NM@" + toolchain_args = { + current_os = "linux" + current_cpu = "@V8_CURRENT_CPU@" + v8_current_cpu = "@V8_V8_CURRENT_CPU@" + is_clang = @V8_IS_CLANG@ + sysroot = "@V8_SYSROOT@" + } +}