diff --git a/tur-electron/electron-30/0001-electron-getversion-from-file.patch b/tur-electron/electron-30/0001-electron-getversion-from-file.patch new file mode 100644 index 0000000..5e74656 --- /dev/null +++ b/tur-electron/electron-30/0001-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-30/0002-v8-fix-trap-handler.patch b/tur-electron/electron-30/0002-v8-fix-trap-handler.patch new file mode 100644 index 0000000..b3bab79 --- /dev/null +++ b/tur-electron/electron-30/0002-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-30/0003-cares-config.patch b/tur-electron/electron-30/0003-cares-config.patch new file mode 100644 index 0000000..1eaab11 --- /dev/null +++ b/tur-electron/electron-30/0003-cares-config.patch @@ -0,0 +1,24 @@ +--- a/third_party/electron_node/deps/cares/config/linux/ares_config.h ++++ b/third_party/electron_node/deps/cares/config/linux/ares_config.h +@@ -59,10 +59,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 +@@ -128,7 +128,7 @@ + #define HAVE_GETNAMEINFO 1 + + /* Define to 1 if you have the getservbyport_r function. */ +-#define HAVE_GETSERVBYPORT_R 1 ++// #define HAVE_GETSERVBYPORT_R 1 + + /* Define to 1 if you have the `gettimeofday' function. */ + #define HAVE_GETTIMEOFDAY 1 diff --git a/tur-electron/electron-30/0004-electron-disable-sandbox.patch b/tur-electron/electron-30/0004-electron-disable-sandbox.patch new file mode 100644 index 0000000..77e586e --- /dev/null +++ b/tur-electron/electron-30/0004-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-30/0005-node-as-posix.patch b/tur-electron/electron-30/0005-node-as-posix.patch new file mode 100644 index 0000000..7120590 --- /dev/null +++ b/tur-electron/electron-30/0005-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-30/0006-gtk-fix-dynamic-loaded-libraries.patch b/tur-electron/electron-30/0006-gtk-fix-dynamic-loaded-libraries.patch new file mode 100644 index 0000000..8c4cd7e --- /dev/null +++ b/tur-electron/electron-30/0006-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-30/0007-add-missing-function-for-extension_action_api.patch b/tur-electron/electron-30/0007-add-missing-function-for-extension_action_api.patch new file mode 100644 index 0000000..7307e18 --- /dev/null +++ b/tur-electron/electron-30/0007-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-30/0008-compiler-warnings.patch b/tur-electron/electron-30/0008-compiler-warnings.patch new file mode 100644 index 0000000..61d7622 --- /dev/null +++ b/tur-electron/electron-30/0008-compiler-warnings.patch @@ -0,0 +1,14 @@ +--- a/build/config/compiler/BUILD.gn ++++ b/build/config/compiler/BUILD.gn +@@ -1913,6 +1913,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-30/0100-z-iwyu-blink-include-atomic.patch b/tur-electron/electron-30/0100-z-iwyu-blink-include-atomic.patch new file mode 100644 index 0000000..e24e98d --- /dev/null +++ b/tur-electron/electron-30/0100-z-iwyu-blink-include-atomic.patch @@ -0,0 +1,20 @@ +https://github.com/chromium/chromium/commit/8be4d17beb71c29118c3337268f3e7b3930a657f + +--- a/third_party/blink/renderer/bindings/core/v8/script_streamer.cc ++++ b/third_party/blink/renderer/bindings/core/v8/script_streamer.cc +@@ -4,6 +4,7 @@ + + #include "third_party/blink/renderer/bindings/core/v8/script_streamer.h" + ++#include + #include + #include + +@@ -60,7 +61,6 @@ + #include "third_party/blink/renderer/platform/wtf/shared_buffer.h" + #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" + #include "third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h" +-#include "third_party/libc++/src/include/__atomic/atomic.h" + + namespace blink { + namespace { diff --git a/tur-electron/electron-30/0101-new_tab_page-add-missing-dep-to-cr_components-history_clusters.patch b/tur-electron/electron-30/0101-new_tab_page-add-missing-dep-to-cr_components-history_clusters.patch new file mode 100644 index 0000000..a28e8be --- /dev/null +++ b/tur-electron/electron-30/0101-new_tab_page-add-missing-dep-to-cr_components-history_clusters.patch @@ -0,0 +1,12 @@ +https://github.com/chromium/chromium/commit/18681c656c989a954657a559b9c123f046b04250 + +--- a/chrome/browser/resources/new_tab_page/BUILD.gn ++++ b/chrome/browser/resources/new_tab_page/BUILD.gn +@@ -101,6 +101,7 @@ + "//ui/webui/resources/cr_components/color_change_listener:build_ts", + "//ui/webui/resources/cr_components/customize_themes:build_ts", + "//ui/webui/resources/cr_components/help_bubble:build_ts", ++ "//ui/webui/resources/cr_components/history_clusters:build_ts", + "//ui/webui/resources/cr_components/most_visited:build_ts", + "//ui/webui/resources/cr_components/omnibox:build_ts", + "//ui/webui/resources/cr_components/page_image_service:build_ts", diff --git a/tur-electron/electron-30/0102-fix-missing-build-deps.patch b/tur-electron/electron-30/0102-fix-missing-build-deps.patch new file mode 100644 index 0000000..4f2fb2e --- /dev/null +++ b/tur-electron/electron-30/0102-fix-missing-build-deps.patch @@ -0,0 +1,12 @@ +https://github.com/chromium/chromium/commit/a976cb05b4024b7a6452d1541378d718cdfe33e6 + +--- a/chrome/browser/devtools/BUILD.gn ++++ b/chrome/browser/devtools/BUILD.gn +@@ -113,6 +113,7 @@ + "//chrome/browser/autofill:autofill", + "//components/autofill/content/browser:browser", + "//components/autofill/core/browser:browser", ++ "//components/enterprise/buildflags", + "//components/paint_preview/buildflags:buildflags", + "//content/public/browser", + "//net", diff --git a/tur-electron/electron-30/build.sh b/tur-electron/electron-30/build.sh new file mode 100644 index 0000000..8bc65bb --- /dev/null +++ b/tur-electron/electron-30/build.sh @@ -0,0 +1,356 @@ +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=124.0.6367.207 +TERMUX_PKG_VERSION=30.0.6 +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 + python $TERMUX_SCRIPTDIR/common-files/apply-chromium-patches.py --electron -v $_CHROMIUM_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 libffi7 libfontconfig1:i386 libffi7: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 + + # 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 + # Cherry-pick LWG3545 for NDK r26 + patch -p1 < $TERMUX_SCRIPTDIR/common-files/chromium-patches/sysroot-patches/libcxx-17-lwg3545.diff + 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(\"//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 = "17" +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_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 +" >> $_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 electron_license chromium_licenses -k 0 || \ + ninja -C $TERMUX_PKG_BUILDDIR/out/Release 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-30/toolchain.gn.in b/tur-electron/electron-30/toolchain.gn.in new file mode 100644 index 0000000..6c26578 --- /dev/null +++ b/tur-electron/electron-30/toolchain.gn.in @@ -0,0 +1,32 @@ +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@ + use_gold = @HOST_USE_GOLD@ + 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@ + use_gold = @V8_USE_GOLD@ + sysroot = "@V8_SYSROOT@" + } +}