new package: electron-for-code-oss (#24691)

This commit is contained in:
termux-pacman-bot
2025-05-12 11:36:19 +00:00
parent cba6adfbed
commit 5dfa7d61ff
10 changed files with 845 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
--- a/tools/v8_context_snapshot/BUILD.gn
+++ b/tools/v8_context_snapshot/BUILD.gn
@@ -35,7 +35,7 @@
]
}
-if (use_v8_context_snapshot) {
+if (use_v8_context_snapshot && false) {
if (v8_snapshot_toolchain == current_toolchain) {
action("generate_v8_context_snapshot") {
script = "//build/gn_run_binary.py"
@@ -113,3 +113,20 @@
}
}
}
+
+if (use_v8_context_snapshot) {
+ if (v8_snapshot_toolchain == current_toolchain) {
+ action("generate_v8_context_snapshot") {
+ script = "//v8/tools/run.py"
+ output_file = "$root_build_dir/$v8_context_snapshot_filename"
+ output_path = rebase_path(output_file, root_build_dir)
+ args = [
+ "bash", "-c",
+ "cp -f" + " " +
+ "@TERMUX_PREFIX@/opt/electron-host-tools-for-code-oss/$output_path" + " " +
+ "$output_path",
+ ]
+ outputs = [ output_file ]
+ }
+ }
+}
--- a/electron/BUILD.gn
+++ b/electron/BUILD.gn
@@ -1460,6 +1460,8 @@
outputs = [ "$root_build_dir/chromedriver.zip" ]
}
+if (false) {
+
mksnapshot_deps = [
":licenses",
"//v8:mksnapshot($v8_snapshot_toolchain)",
@@ -1479,6 +1481,8 @@
outputs = [ "$root_build_dir/mksnapshot.zip" ]
}
+}
+
copy("hunspell_dictionaries") {
sources = hunspell_dictionaries + hunspell_licenses
outputs = [ "$target_gen_dir/electron_hunspell/{{source_file_part}}" ]

View File

@@ -0,0 +1,119 @@
--- a/build/compiled_action.gni
+++ b/build/compiled_action.gni
@@ -120,6 +120,52 @@
}
}
+template("compiled_action_prebuilt") {
+ assert(defined(invoker.tool), "tool must be defined for $target_name")
+ assert(defined(invoker.outputs), "outputs must be defined for $target_name")
+ assert(defined(invoker.args), "args must be defined for $target_name")
+
+ assert(!defined(invoker.sources),
+ "compiled_action doesn't take a sources arg. Use inputs instead.")
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ "depfile",
+ "inputs",
+ "outputs",
+ "testonly",
+ "visibility",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ if (!defined(inputs)) {
+ inputs = []
+ }
+
+ script = "//build/gn_run_binary.py"
+
+ # Constuct the host toolchain version of the tool.
+ host_tool = invoker.tool + "($host_toolchain)"
+
+ # Get the path to the executable. Currently, this assumes that the tool
+ # does not specify output_name so that the target name is the name to use.
+ # If that's not the case, we'll need another argument to the script to
+ # specify this, since we can't know what the output name is (it might be in
+ # another file not processed yet).
+ host_executable =
+ "@TERMUX_PREFIX@/opt/electron-host-tools-for-code-oss/host/" +
+ get_label_info(host_tool, "name") + _host_executable_suffix
+
+ # The script takes as arguments the binary to run, and then the arguments
+ # to pass it.
+ args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args
+ }
+}
+
template("compiled_action_foreach") {
assert(defined(invoker.sources), "sources must be defined for $target_name")
assert(defined(invoker.tool), "tool must be defined for $target_name")
--- a/chrome/browser/new_tab_page/chrome_colors/BUILD.gn
+++ b/chrome/browser/new_tab_page/chrome_colors/BUILD.gn
@@ -20,7 +20,7 @@
]
}
-compiled_action("generate_chrome_colors_info") {
+compiled_action_prebuilt("generate_chrome_colors_info") {
tool = ":generate_colors_info"
outputs = [ "$target_gen_dir/generated_colors_info.h" ]
args = rebase_path(outputs, root_build_dir)
--- a/third_party/blink/renderer/platform/BUILD.gn
+++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -117,7 +117,7 @@
]
}
-compiled_action("character_data") {
+compiled_action_prebuilt("character_data") {
tool = ":character_data_generator"
outputs = [ "$blink_platform_output_dir/character_property_data.cc" ]
args = rebase_path(outputs, root_build_dir)
--- a/net/data/ssl/chrome_root_store/BUILD.gn
+++ b/net/data/ssl/chrome_root_store/BUILD.gn
@@ -4,7 +4,7 @@
import("//build/compiled_action.gni")
# Generate C++ include file for the Chrome root store.
-compiled_action("gen_root_store_inc") {
+compiled_action_prebuilt("gen_root_store_inc") {
tool = "//net/tools/root_store_tool:root_store_tool"
inputs = [
--- a/net/http/BUILD.gn
+++ b/net/http/BUILD.gn
@@ -6,7 +6,7 @@
import("//net/features.gni")
# Generates a header file based on the real preload list.
-compiled_action("generate_transport_security_state") {
+compiled_action_prebuilt("generate_transport_security_state") {
tool = "//net/tools/transport_security_state_generator"
# Inputs in order expected by the command line of the tool.
--- a/components/url_formatter/spoof_checks/top_domains/BUILD.gn
+++ b/components/url_formatter/spoof_checks/top_domains/BUILD.gn
@@ -36,7 +36,7 @@
}
}
-compiled_action("generate_top_domains_trie") {
+compiled_action_prebuilt("generate_top_domains_trie") {
tool = ":top_domain_generator"
# Inputs in order expected by the command line of the tool.
@@ -118,7 +118,7 @@
# TODO(crbug/915921): Combine this and the previous one into a
# compiled_action_foreach target.
-compiled_action("generate_top_domain_list_variables_file") {
+compiled_action_prebuilt("generate_top_domain_list_variables_file") {
tool = ":make_top_domain_list_variables"
# Inputs in order expected by the command line of the tool.

View File

@@ -0,0 +1,98 @@
--- a/v8/BUILD.gn
+++ b/v8/BUILD.gn
@@ -2127,7 +2127,9 @@
"tools/gcmole/:*",
]
+if (false) {
deps = [ ":torque($toolchain)" ]
+}
script = "tools/run.py"
@@ -2169,8 +2171,14 @@
]
}
+if (false) {
+ arg0_prefix = "./"
+} else {
+ arg0_prefix = "@TERMUX_PREFIX@/opt/electron-host-tools-for-code-oss/"
+}
+
args = [
- "./" + rebase_path(
+ arg0_prefix + rebase_path(
get_label_info(":torque($toolchain)", "root_out_dir") + "/torque",
root_build_dir),
"-o",
@@ -2325,9 +2334,18 @@
action("generate_bytecode_builtins_list") {
script = "tools/run.py"
outputs = [ "$target_gen_dir/builtins-generated/bytecodes-builtins-list.h" ]
+if (false) {
deps = [ ":bytecode_builtins_list_generator($v8_generator_toolchain)" ]
+}
+
+if (false) {
+ arg0_prefix = "./"
+} else {
+ arg0_prefix = "@TERMUX_PREFIX@/opt/electron-host-tools-for-code-oss/"
+}
+
args = [
- "./" + rebase_path(
+ arg0_prefix + rebase_path(
get_label_info(
":bytecode_builtins_list_generator($v8_generator_toolchain)",
"root_out_dir") + "/bytecode_builtins_list_generator",
@@ -2355,7 +2373,9 @@
suffix = "_$name"
}
action("run_mksnapshot_" + name) {
+if (false) {
deps = [ ":mksnapshot($v8_snapshot_toolchain)" ]
+}
script = "tools/run.py"
@@ -2365,8 +2385,14 @@
data = []
+if (false) {
+ arg0_prefix = "./"
+} else {
+ arg0_prefix = "@TERMUX_PREFIX@/opt/electron-host-tools-for-code-oss/"
+}
+
args = [
- "./" + rebase_path(get_label_info(":mksnapshot($v8_snapshot_toolchain)",
+ arg0_prefix + rebase_path(get_label_info(":mksnapshot($v8_snapshot_toolchain)",
"root_out_dir") + "/mksnapshot",
root_build_dir),
"--turbo_instruction_scheduling",
@@ -7187,14 +7213,22 @@
script = "tools/run.py"
+if (false) {
deps = [ ":gen-regexp-special-case($v8_generator_toolchain)" ]
+}
output_file = "$target_gen_dir/src/regexp/special-case.cc"
outputs = [ output_file ]
+if (false) {
+ arg0_prefix = "./"
+} else {
+ arg0_prefix = "@TERMUX_PREFIX@/opt/electron-host-tools-for-code-oss/"
+}
+
args = [
- "./" + rebase_path(
+ arg0_prefix + rebase_path(
get_label_info(
":gen-regexp-special-case($v8_generator_toolchain)",
"root_out_dir") + "/gen-regexp-special-case",

View File

@@ -0,0 +1,27 @@
--- a/third_party/pdfium/BUILD.gn
+++ b/third_party/pdfium/BUILD.gn
@@ -219,7 +219,23 @@
]
}
-component("pdfium") {
+group("pdfium") {
+ public_deps = [ ":pdfium_public_headers" ]
+ public_configs = [
+ ":pdfium_public_config",
+ ":pdfium_prebuilt",
+ ]
+}
+
+config("pdfium_prebuilt") {
+ lib_dirs = [ ]
+ libs = [ "@TERMUX_PREFIX@/opt/electron-host-tools-for-code-oss/obj/third_party/pdfium/libpdfium.a" ]
+
+ configs = [ ":pdfium_public_config" ]
+ visibility = [ ":pdfium" ]
+}
+
+component("pdfium_1") {
output_name = "pdfium"
libs = []
configs += [ ":pdfium_strict_config" ]

View File

@@ -0,0 +1,81 @@
--- a/electron/js2c_toolchain.gni
+++ b/electron/js2c_toolchain.gni
@@ -4,6 +4,8 @@
declare_args() {
electron_js2c_toolchain = ""
+
+ prebuilt_js2c_binary = ""
}
if (electron_js2c_toolchain == "") {
--- a/electron/BUILD.gn
+++ b/electron/BUILD.gn
@@ -231,8 +231,13 @@
":electron_sandboxed_renderer_bundle",
":electron_utility_bundle",
":electron_worker_bundle",
+ ]
+
+if (prebuilt_js2c_binary == "") {
+ deps += [
"//third_party/electron_node:node_js2c($electron_js2c_toolchain)",
]
+}
sources = [
"$target_gen_dir/js2c/browser_init.js",
@@ -248,10 +253,14 @@
outputs = [ "$root_gen_dir/electron_natives.cc" ]
script = "build/js2c.py"
+ node_js2c_binary = prebuilt_js2c_binary
+if (node_js2c_binary == "") {
out_dir =
get_label_info(":anything($electron_js2c_toolchain)", "root_out_dir")
+ node_js2c_binary = rebase_path("$out_dir/node_js2c")
+}
args = [
- rebase_path("$out_dir/node_js2c"),
+ node_js2c_binary,
rebase_path("$root_gen_dir"),
] + rebase_path(outputs, root_gen_dir) +
rebase_path(sources, root_gen_dir)
--- a/third_party/electron_node/BUILD.gn
+++ b/third_party/electron_node/BUILD.gn
@@ -101,8 +101,12 @@
"//electron:generate_config_gypi",
":node_js2c_original_fs",
":node_js2c_inputs",
+ ]
+if (prebuilt_js2c_binary == "") {
+ deps += [
":node_js2c($electron_js2c_toolchain)"
]
+}
config_gypi = [ "$root_gen_dir/config.gypi" ]
inputs = library_files + get_target_outputs(":node_js2c_original_fs") + config_gypi
outputs = [
@@ -110,8 +114,12 @@
]
script = "//electron/build/run-in-dir.py"
+ node_js2c_binary = prebuilt_js2c_binary
+if (prebuilt_js2c_binary == "") {
out_dir = get_label_info(":anything($electron_js2c_toolchain)", "root_out_dir")
- args = [ rebase_path("$target_gen_dir/js2c_inputs"), rebase_path("$out_dir/node_js2c") ] +
+ node_js2c_binary = rebase_path("$out_dir/node_js2c")
+}
+ args = [ rebase_path("$target_gen_dir/js2c_inputs"), node_js2c_binary ] +
rebase_path(outputs) + library_files + fs_files + original_fs_files + rebase_path(config_gypi)
}
@@ -226,7 +234,7 @@
}
}
-if (current_toolchain == electron_js2c_toolchain) {
+if (current_toolchain == electron_js2c_toolchain && prebuilt_js2c_binary == "") {
executable("node_js2c") {
defines = []
sources = [

View File

@@ -0,0 +1,409 @@
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="@licy183"
_CHROMIUM_VERSION=128.0.6613.186
TERMUX_PKG_VERSION=32.2.6
TERMUX_PKG_SRCURL=git+https://github.com/electron/electron
TERMUX_PKG_DEPENDS="atk, cups, dbus, fontconfig, gtk3, krb5, libc++, libdrm, libevdev, libxkbcommon, libminizip, libnss, libwayland, libx11, mesa, openssl, pango, pulseaudio, zlib"
TERMUX_PKG_BUILD_DEPENDS="electron-host-tools-for-code-oss, libnotify, libffi-static"
# Chromium doesn't support i686 on Linux.
TERMUX_PKG_EXCLUDED_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_PKG_CACHEDIR/depot_tools/ensure_bootstrap
}
termux_step_get_source() {
# 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
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
ln -sfr $TERMUX_PKG_CACHEDIR/tmp-checkout/src $TERMUX_PKG_SRCDIR
}
termux_step_post_get_source() {
# Apply patches related to chromium
local f
for f in $(find "$TERMUX_PKG_BUILDER_DIR/../electron-host-tools-for-code-oss/cr-patches" -maxdepth 1 -type f -name *.patch | sort); do
echo "Applying patch: $(basename $f)"
patch --silent -p1 < "$f"
done
# Apply patches related to electron
local f
for f in $(find "$TERMUX_PKG_BUILDER_DIR/../electron-host-tools-for-code-oss/electron-patches" -maxdepth 1 -type f -name *.patch | sort); do
echo "Applying patch: $(basename $f)"
patch --silent -p1 < "$f"
done
# Apply patches for jumbo build
local f
for f in $(find "$TERMUX_PKG_BUILDER_DIR/../electron-host-tools-for-code-oss/jumbo-patches" -maxdepth 1 -type f -name *.patch | sort); do
echo "Applying patch: $(basename $f)"
patch --silent -p1 < "$f"
done
# Use prebuilt swiftshader
mv $TERMUX_PKG_SRCDIR/third_party/swiftshader $TERMUX_PKG_SRCDIR/third_party/swiftshader.unused
mkdir -p $TERMUX_PKG_SRCDIR/third_party/swiftshader/
cp -Rf $TERMUX_PKG_BUILDER_DIR/third_party_override/swiftshader/* $TERMUX_PKG_SRCDIR/third_party/swiftshader/
# Install version file
echo "$TERMUX_PKG_VERSION" > $TERMUX_PKG_SRCDIR/electron/ELECTRON_VERSION
}
termux_step_configure() {
cd $TERMUX_PKG_SRCDIR
termux_setup_ninja
__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"
# 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
# Install nodejs
if [ ! -f "third_party/node/linux/node-linux-x64/bin/node" ]; then
./third_party/node/update_node_binaries
fi
termux_setup_nodejs
./third_party/node/update_npm_deps
# 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 '!<arch>' > "$TERMUX_PREFIX/lib/libpthread.a"
echo '!<arch>' > "$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_clang_base_path="$TERMUX_STANDALONE_TOOLCHAIN"
local _target_cc="$_target_clang_base_path/bin/clang"
local _target_clang_version=$($_target_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="arm64"
_v8_sysroot_path="$_amd64_sysroot_path"
_v8_toolchain_name="host"
elif [ "$TERMUX_ARCH" = "arm" ]; then
# Install i386 rootfs and deps
build/linux/sysroot_scripts/install-sysroot.py --arch=i386
local _i386_sysroot_path="$(pwd)/build/linux/$(ls build/linux | grep 'i386-sysroot')"
_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="host"
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 = \"$_target_clang_base_path\"
custom_toolchain_clang_version = \"$_target_clang_version\"
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 = false
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 = false
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
# Enable jumbo build (unified build)
use_jumbo_build = true
# Compile pdfium as a static library
pdf_is_complete_lib = true
# Use prebuilt js2c
prebuilt_js2c_binary = \"$TERMUX_PREFIX/opt/electron-host-tools-for-code-oss/$_v8_toolchain_name/node_js2c\"
" >> $_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
rm -rf $TERMUX_PKG_CACHEDIR/custom-toolchain
mkdir -p $TERMUX_PKG_CACHEDIR/custom-toolchain
cp -f $TERMUX_PKG_BUILDER_DIR/toolchain-template/host-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_SYSROOT@|$_amd64_sysroot_path|g
s|@V8_CURRENT_CPU@|$_target_cpu|g
" $TERMUX_PKG_CACHEDIR/custom-toolchain/BUILD.gn
if [ "$_v8_toolchain_name" != "host" ]; then
cat $TERMUX_PKG_BUILDER_DIR/toolchain-template/v8-toolchain.gn.in >> $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_SYSROOT@|$_v8_sysroot_path|g
" $TERMUX_PKG_CACHEDIR/custom-toolchain/BUILD.gn
fi
# 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
export cr_v8_toolchain="$_v8_toolchain_name"
}
termux_step_make() {
cd $TERMUX_PKG_BUILDDIR
# Build v8 snapshot and tools
time ninja -C out/Release \
v8_context_snapshot \
run_mksnapshot_default \
run_torque \
generate_bytecode_builtins_list \
v8:run_gen-regexp-special-case
# Build host tools
time ninja -C out/Release \
character_data \
gen_root_store_inc \
generate_transport_security_state \
generate_top_domains_trie
# Build node_js2c
time ninja -C out/Release \
third_party/electron_node:node_js2c_exec
# Build swiftshader
time ninja -C out/Release \
third_party/swiftshader/src/Vulkan:icd_file \
third_party/swiftshader/src/Vulkan:swiftshader_libvulkan
# Build pdfium
time ninja -C out/Release \
third_party/pdfium \
third_party/pdfium:pdfium_public_headers
# Build node headers of electron
time ninja -C out/Release \
electron:node_headers
# Build electron binary
time ninja -C out/Release electron
# Build licenses
time ninja -C out/Release \
electron_license \
chromium_licenses
}
termux_step_make_install() {
cd $TERMUX_PKG_BUILDDIR
local _install_prefix=$TERMUX_PREFIX/lib/code-oss
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
# Rename the binary file
mv $_install_prefix/electron $_install_prefix/code-oss
# Remove the default resources
rm -rf $_install_prefix/resources/*
# 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}
}

View File

@@ -0,0 +1,27 @@
import("vulkan.gni")
action("swiftshader_libvulkan") {
_lib_name = "libvk_swiftshader.so"
output_file = "${root_build_dir}/${_lib_name}"
script = "//v8/tools/run.py"
args = [
"bash", "-c",
"cp -f" + " " +
"/data/data/com.termux/files/usr/opt/electron-host-tools-for-code-oss/$_lib_name" + " " +
"$output_file",
]
outputs = [ output_file ]
}
action("icd_file") {
_icd_file_name = "vk_swiftshader_icd.json"
output_icd_file = "${root_out_dir}/${_icd_file_name}"
script = "//v8/tools/run.py"
args = [
"bash", "-c",
"cp -f" + " " +
"/data/data/com.termux/files/usr/opt/electron-host-tools-for-code-oss/$_icd_file_name" + " " +
"$output_icd_file",
]
outputs = [ output_icd_file ]
}

View File

@@ -0,0 +1 @@
swiftshader_icd_file_name = "vk_swiftshader_icd.json"

View File

@@ -0,0 +1,17 @@
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"
v8_current_cpu = "@V8_CURRENT_CPU@"
is_clang = @HOST_IS_CLANG@
sysroot = "@HOST_SYSROOT@"
}
}

View File

@@ -0,0 +1,14 @@
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@"
}
}