Skip to content

Commit 492565a

Browse files
authored
new package: electron-19.1.8 (#4)
1 parent ce19535 commit 492565a

File tree

6 files changed

+465
-0
lines changed

6 files changed

+465
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
We pass `--no-history` to gclient, so there will be no version for electron.
2+
--- a/electron/script/lib/get-version.js
3+
+++ b/electron/script/lib/get-version.js
4+
@@ -11,7 +11,7 @@
5+
// The only difference in the "git describe" technique is that technically a commit can "change" it's version
6+
// number if a tag is created / removed retroactively. i.e. the first time a commit is pushed it will be 1.2.3
7+
// and after the tag is made rebuilding the same commit will result in it being 1.2.4
8+
- const output = spawnSync('git', ['describe', '--tags', '--abbrev=0'], {
9+
+ const output = spawnSync('cat', ['ELECTRON_VERSION'], {
10+
cwd: path.resolve(__dirname, '..', '..')
11+
});
12+
if (output.status !== 0) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/third_party/electron_node/deps/v8/src/trap-handler/trap-handler.h
2+
+++ b/third_party/electron_node/deps/v8/src/trap-handler/trap-handler.h
3+
@@ -19,7 +19,7 @@
4+
5+
// X64 on Linux, Windows, MacOS, FreeBSD.
6+
#if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \
7+
- ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_MACOSX || \
8+
+ (V8_OS_LINUX || V8_OS_WIN || V8_OS_MACOSX || \
9+
V8_OS_FREEBSD)
10+
#define V8_TRAP_HANDLER_SUPPORTED true
11+
// Arm64 (non-simulator) on Mac.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--- a/third_party/electron_node/deps/cares/config/linux/ares_config.h
2+
+++ b/third_party/electron_node/deps/cares/config/linux/ares_config.h
3+
@@ -59,10 +59,10 @@
4+
#define HAVE_ARPA_INET_H 1
5+
6+
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
7+
-#define HAVE_ARPA_NAMESER_COMPAT_H 1
8+
+// #define HAVE_ARPA_NAMESER_COMPAT_H 1
9+
10+
/* Define to 1 if you have the <arpa/nameser.h> header file. */
11+
-#define HAVE_ARPA_NAMESER_H 1
12+
+// #define HAVE_ARPA_NAMESER_H 1
13+
14+
/* Define to 1 if you have the <assert.h> header file. */
15+
#define HAVE_ASSERT_H 1
16+
@@ -128,7 +128,7 @@
17+
#define HAVE_GETNAMEINFO 1
18+
19+
/* Define to 1 if you have the getservbyport_r function. */
20+
-#define HAVE_GETSERVBYPORT_R 1
21+
+// #define HAVE_GETSERVBYPORT_R 1
22+
23+
/* Define to 1 if you have the `gettimeofday' function. */
24+
#define HAVE_GETTIMEOFDAY 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- a/electron/shell/app/electron_main_delegate.cc
2+
+++ b/electron/shell/app/electron_main_delegate.cc
3+
@@ -262,7 +262,9 @@
4+
if (env->HasVar(kElectronEnableStackDumping))
5+
base::debug::EnableInProcessStackDumping();
6+
7+
+#ifndef __TERMUX__
8+
if (env->HasVar(kElectronDisableSandbox))
9+
+#endif
10+
command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox);
11+
12+
tracing_sampler_profiler_ =
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
TERMUX_PKG_HOMEPAGE=https://github.com/electron/electron
2+
TERMUX_PKG_DESCRIPTION="Build cross-platform desktop apps with JavaScript, HTML, and CSS"
3+
TERMUX_PKG_LICENSE="MIT, BSD 3-Clause"
4+
TERMUX_PKG_MAINTAINER="Chongyun Lee <[email protected]>"
5+
_CHROMIUM_VERSION=102.0.4961.0
6+
TERMUX_PKG_VERSION=19.1.8
7+
TERMUX_PKG_SRCURL=git+https://github.com/electron/electron
8+
TERMUX_PKG_DEPENDS="electron-deps"
9+
TERMUX_PKG_BUILD_DEPENDS="libnotify"
10+
# Chromium doesn't support i686 on Linux.
11+
TERMUX_PKG_BLACKLISTED_ARCHES="i686"
12+
13+
termux_step_get_source() {
14+
# Check whether we need to get source
15+
if [ -f "$TERMUX_PKG_CACHEDIR/.electron-source-fetched" ]; then
16+
local _fetched_source_version=$(cat $TERMUX_PKG_CACHEDIR/.electron-source-fetched)
17+
if [ "$_fetched_source_version" = "$TERMUX_PKG_VERSION" ]; then
18+
echo "[INFO]: Use pre-fetched source (version $_fetched_source_version)."
19+
ln -sfr $TERMUX_PKG_CACHEDIR/tmp-checkout/src $TERMUX_PKG_SRCDIR
20+
# Revert patches
21+
shopt -s nullglob
22+
local f
23+
for f in $TERMUX_PKG_BUILDER_DIR/*.patch; do
24+
echo "[INFO]: Reverting $(basename "$f")"
25+
(sed "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" "$f" | patch -f --silent -R -p1 -d "$TERMUX_PKG_SRCDIR") || true
26+
done
27+
shopt -u nullglob
28+
python $TERMUX_SCRIPTDIR/common-files/apply-chromium-patches.py -C "$TERMUX_PKG_SRCDIR" -R -v $_CHROMIUM_VERSION || bash
29+
return
30+
fi
31+
fi
32+
33+
# Fetch depot_tools
34+
if [ ! -f "$TERMUX_PKG_CACHEDIR/.depot_tools-fetched" ];then
35+
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $TERMUX_PKG_CACHEDIR/depot_tools
36+
touch "$TERMUX_PKG_CACHEDIR/.depot_tools-fetched"
37+
fi
38+
export PATH="$TERMUX_PKG_CACHEDIR/depot_tools:$PATH"
39+
40+
# Install nodejs
41+
termux_setup_nodejs
42+
43+
# Get source
44+
rm -rf "$TERMUX_PKG_CACHEDIR/tmp-checkout"
45+
mkdir -p "$TERMUX_PKG_CACHEDIR/tmp-checkout"
46+
pushd "$TERMUX_PKG_CACHEDIR/tmp-checkout"
47+
gclient config --name "src/electron" --unmanaged https://github.com/electron/electron
48+
gclient sync --with_branch_heads --with_tags --no-history --revision v$TERMUX_PKG_VERSION || bash
49+
popd
50+
51+
# Solve error like `.git/packed-refs is dirty`
52+
cd "$TERMUX_PKG_CACHEDIR/tmp-checkout/src"
53+
git pack-refs --all
54+
cd electron
55+
git pack-refs --all
56+
57+
echo "$TERMUX_PKG_VERSION" > "$TERMUX_PKG_CACHEDIR/.electron-source-fetched"
58+
ln -sfr $TERMUX_PKG_CACHEDIR/tmp-checkout/src $TERMUX_PKG_SRCDIR
59+
}
60+
61+
termux_step_post_get_source() {
62+
echo "$TERMUX_PKG_VERSION" > $TERMUX_PKG_SRCDIR/electron/ELECTRON_VERSION
63+
python $TERMUX_SCRIPTDIR/common-files/apply-chromium-patches.py -v $_CHROMIUM_VERSION
64+
}
65+
66+
termux_step_configure() {
67+
rm -rf $TERMUX_PREFIX/opt/electron-$TERMUX_PKG_VERSION
68+
69+
cd $TERMUX_PKG_SRCDIR
70+
termux_setup_gn
71+
termux_setup_ninja
72+
termux_setup_nodejs
73+
74+
# Remove termux's dummy pkg-config
75+
local _host_pkg_config="$(cat $(command -v pkg-config) | grep exec | awk '{print $2}')"
76+
rm -rf $TERMUX_PKG_TMPDIR/host-pkg-config-bin
77+
mkdir -p $TERMUX_PKG_TMPDIR/host-pkg-config-bin
78+
ln -s $_host_pkg_config $TERMUX_PKG_TMPDIR/host-pkg-config-bin
79+
export PATH="$TERMUX_PKG_TMPDIR/host-pkg-config-bin:$PATH"
80+
81+
env -i PATH="$PATH" sudo apt update
82+
env -i PATH="$PATH" sudo apt install libdrm-dev libjpeg-turbo8-dev libpng-dev fontconfig libfontconfig-dev libfontconfig1-dev libfreetype6-dev zlib1g-dev libcups2-dev libxkbcommon-dev libglib2.0-dev -yq
83+
env -i PATH="$PATH" sudo apt install libdrm-dev:i386 libjpeg-turbo8-dev:i386 libpng-dev:i386 libfontconfig-dev:i386 libfontconfig1-dev:i386 libfreetype6-dev:i386 zlib1g-dev:i386 libcups2-dev:i386 libglib2.0-dev:i386 libxkbcommon-dev:i386 -yq
84+
85+
# Install amd64 rootfs if necessary, it should have been installed by source hooks.
86+
build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
87+
88+
# Link to system tools required by the build
89+
mkdir -p third_party/node/linux/node-linux-x64/bin
90+
ln -sf $(command -v node) third_party/node/linux/node-linux-x64/bin/
91+
92+
_DUMMY_FILES=()
93+
94+
# Dummy librt.so
95+
# Why not dummy a librt.a? Some of the binaries reference symbols only exists in Android
96+
# for some reason, such as the `chrome_crashpad_handler`, which needs to link with
97+
# libprotobuf_lite.a, but it is hard to remove the usage of `android/log.h` in protobuf.
98+
echo "INPUT(-llog -liconv -landroid-shmem)" > "$TERMUX_PREFIX/lib/librt.so"
99+
_DUMMY_FILES+=("$TERMUX_PREFIX/lib/librt.so")
100+
101+
# Dummy libpthread.a
102+
echo '!<arch>' > "$TERMUX_PREFIX/lib/libpthread.a"
103+
_DUMMY_FILES+=("$TERMUX_PREFIX/lib/libpthread.a")
104+
105+
# Dummy libresolv.a
106+
echo '!<arch>' > "$TERMUX_PREFIX/lib/libresolv.a"
107+
_DUMMY_FILES+=("$TERMUX_PREFIX/lib/libresolv.a")
108+
109+
# Merge sysroots
110+
rm -rf $TERMUX_PKG_TMPDIR/sysroot
111+
mkdir -p $TERMUX_PKG_TMPDIR/sysroot
112+
pushd $TERMUX_PKG_TMPDIR/sysroot
113+
mkdir -p usr/include usr/lib usr/bin
114+
cp -R $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include/* usr/include
115+
cp -R $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include/$TERMUX_HOST_PLATFORM/* usr/include
116+
cp -R $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/* usr/lib/
117+
cp "$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/libc++_shared.so" usr/lib/
118+
cp "$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/libc++_static.a" usr/lib/
119+
cp "$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/libc++abi.a" usr/lib/
120+
cp -Rf $TERMUX_PREFIX/include/* usr/include
121+
cp -Rf $TERMUX_PREFIX/lib/* usr/lib
122+
ln -sf /data ./data
123+
# This is needed to build cups
124+
cp -Rf $TERMUX_PREFIX/bin/cups-config usr/bin/
125+
chmod +x usr/bin/cups-config
126+
popd
127+
128+
local _TARGET_CPU="$TERMUX_ARCH"
129+
if [ "$TERMUX_ARCH" = "aarch64" ]; then
130+
_TARGET_CPU="arm64"
131+
elif [ "$TERMUX_ARCH" = "x86_64" ]; then
132+
_TARGET_CPU="x64"
133+
fi
134+
135+
local _common_args_file=$TERMUX_PKG_TMPDIR/common-args-file
136+
rm -f $_common_args_file
137+
touch $_common_args_file
138+
139+
echo "
140+
import(\"//electron/build/args/release.gn\")
141+
# Do not build with symbols
142+
symbol_level = 0
143+
# Use our custom toolchain
144+
use_sysroot = true
145+
target_cpu = \"$_TARGET_CPU\"
146+
target_rpath = \"$TERMUX_PREFIX/lib\"
147+
target_sysroot = \"$TERMUX_PKG_TMPDIR/sysroot\"
148+
custom_toolchain = \"//build/toolchain/linux/unbundle:default\"
149+
clang_base_path = \"$TERMUX_STANDALONE_TOOLCHAIN\"
150+
clang_use_chrome_plugins = false
151+
dcheck_always_on = false
152+
chrome_pgo_phase = 0
153+
treat_warnings_as_errors = false
154+
# Use system libraries as little as possible
155+
use_bundled_fontconfig = false
156+
use_system_freetype = true
157+
use_system_libdrm = true
158+
use_custom_libcxx = false
159+
use_allocator_shim = false
160+
use_allocator = \"none\"
161+
use_nss_certs = true
162+
use_udev = false
163+
use_gnome_keyring = false
164+
use_alsa = false
165+
use_libpci = false
166+
use_pulseaudio = true
167+
use_ozone = true
168+
ozone_auto_platforms = false
169+
ozone_platform = \"x11\"
170+
ozone_platform_x11 = true
171+
ozone_platform_wayland = true
172+
ozone_platform_headless = true
173+
angle_enable_vulkan = true
174+
angle_enable_swiftshader = true
175+
rtc_use_pipewire = false
176+
use_vaapi_x11 = false
177+
# See comments on Chromium package
178+
enable_nacl = false
179+
" > $_common_args_file
180+
181+
# For aarch64, remove the `libatomic.a` in `NDK Toolchain` for x86_64
182+
if [ "$TERMUX_ARCH" = "aarch64" ]; then
183+
# When generating the v8 snapshot, GN will try to use `clang-14` from the ndk
184+
# toolchain, and then `lld` will fail because of the linkage with an *invalid*
185+
# `libatomic.a` which is located at `lib64/clang/x.y.z/lib/linux/x86_64`.
186+
local _clang_version="$($TERMUX_STANDALONE_TOOLCHAIN/bin/clang --version | head -n 1 | sed 's/.*version \([0-9]*.[0-9]*.[0-9]*\) .*/\1/g')"
187+
local _invalid_atomic="$TERMUX_STANDALONE_TOOLCHAIN/lib64/clang/$_clang_version/lib/linux/x86_64/libatomic.a"
188+
if [ -f "$_invalid_atomic" ]; then
189+
mv $_invalid_atomic{,.backup}
190+
fi
191+
fi
192+
193+
# For arm, remove the `libatomic.a` in `NDK Toolchain` for i686
194+
if [ "$TERMUX_ARCH" = "arm" ]; then
195+
echo "arm_arch = \"armv7-a\"" >> $_common_args_file
196+
echo "arm_float_abi = \"softfp\"" >> $_common_args_file
197+
# Install i386 rootfs if necessary, it should have been installed by source hooks.
198+
build/linux/sysroot_scripts/install-sysroot.py --arch=i386
199+
# Remove the *invalid* `libatomic.a`
200+
local _clang_version="$($TERMUX_STANDALONE_TOOLCHAIN/bin/clang --version | head -n 1 | sed 's/.*version \([0-9]*.[0-9]*.[0-9]*\) .*/\1/g')"
201+
local _invalid_atomic="$TERMUX_STANDALONE_TOOLCHAIN/lib64/clang/$_clang_version/lib/linux/i386/libatomic.a"
202+
if [ -f "$_invalid_atomic" ]; then
203+
mv $_invalid_atomic{,.backup}
204+
fi
205+
fi
206+
207+
# When building for x64, these variables must be set to tell
208+
# GN that we are at cross-compiling.
209+
if [ "$TERMUX_ARCH" = "x86_64" ]; then
210+
mkdir -p $TERMUX_PKG_TMPDIR/host-toolchain
211+
local _sysroot_path="$(pwd)/build/linux/$(ls build/linux | grep 'amd64-sysroot')"
212+
pushd $TERMUX_PKG_TMPDIR/host-toolchain
213+
sed "s|@COMPILER@|$(command -v clang-13)|" $TERMUX_PKG_BUILDER_DIR/wrapper-compiler.in |
214+
sed "s|@NEW_SYSROOT@|$_sysroot_path|;s|@TERMUX_PREFIX@|$TERMUX_PREFIX|" > ./wrapper_cc
215+
sed "s|@COMPILER@|$(command -v clang++-13)|" $TERMUX_PKG_BUILDER_DIR/wrapper-compiler.in |
216+
sed "s|@NEW_SYSROOT@|$_sysroot_path|;s|@TERMUX_PREFIX@|$TERMUX_PREFIX|" > ./wrapper_cxx
217+
chmod +x ./wrapper_cc ./wrapper_cxx
218+
popd
219+
220+
export BUILD_CC=$TERMUX_PKG_TMPDIR/host-toolchain/wrapper_cc
221+
export BUILD_CXX=$TERMUX_PKG_TMPDIR/host-toolchain/wrapper_cxx
222+
export BUILD_AR=$(command -v llvm-ar)
223+
export BUILD_NM=$(command -v llvm-nm)
224+
225+
export BUILD_CFLAGS="--target=x86_64-linux-gnu"
226+
export BUILD_CPPFLAGS=""
227+
export BUILD_CXXFLAGS="--target=x86_64-linux-gnu"
228+
export BUILD_LDFLAGS="--target=x86_64-linux-gnu"
229+
230+
echo "host_toolchain = \"//build/toolchain/linux/unbundle:host\"" >> $_common_args_file
231+
echo "v8_snapshot_toolchain = \"//build/toolchain/linux/unbundle:host\"" >> $_common_args_file
232+
fi
233+
234+
mkdir -p $TERMUX_PKG_BUILDDIR/out/Release
235+
cat $_common_args_file > $TERMUX_PKG_BUILDDIR/out/Release/args.gn
236+
gn gen $TERMUX_PKG_BUILDDIR/out/Release --export-compile-commands || bash
237+
}
238+
239+
termux_step_make() {
240+
cd $TERMUX_PKG_BUILDDIR
241+
ninja -C $TERMUX_PKG_BUILDDIR/out/Release electron electron_license chromium_licenses || bash
242+
}
243+
244+
termux_step_make_install() {
245+
cd $TERMUX_PKG_BUILDDIR
246+
local _install_prefix=$TERMUX_PREFIX/opt/electron-$TERMUX_PKG_VERSION
247+
mkdir -p $_install_prefix
248+
249+
echo "$TERMUX_PKG_VERSION" > $TERMUX_PKG_BUILDDIR/out/Release/version
250+
251+
local normal_files=(
252+
# Binary files
253+
electron
254+
chrome_sandbox
255+
chrome_crashpad_handler
256+
257+
# Resource files
258+
chrome_100_percent.pak
259+
chrome_200_percent.pak
260+
resources.pak
261+
262+
# V8 Snapshot data
263+
snapshot_blob.bin
264+
v8_context_snapshot.bin
265+
266+
# ICU Data
267+
icudtl.dat
268+
269+
# Angle
270+
libEGL.so
271+
libGLESv2.so
272+
273+
# Vulkan
274+
libvulkan.so.1
275+
libvk_swiftshader.so
276+
vk_swiftshader_icd.json
277+
278+
# FFmpeg
279+
libffmpeg.so
280+
281+
# VERSION file
282+
version
283+
284+
# LICENSE files
285+
LICENSE
286+
LICENSES.chromium.html
287+
)
288+
289+
cp "${normal_files[@]/#/out/Release/}" "$_install_prefix/"
290+
291+
cp -Rf out/Release/angledata $_install_prefix/
292+
cp -Rf out/Release/locales $_install_prefix/
293+
cp -Rf out/Release/resources $_install_prefix/
294+
295+
chmod +x $_install_prefix/electron
296+
297+
# Install LICENSE file
298+
mkdir -p $TERMUX_PREFIX/share/doc/electron-$TERMUX_PKG_VERSION
299+
cp out/Release/LICENSE{,S.chromium.html} $TERMUX_PREFIX/share/doc/electron-$TERMUX_PKG_VERSION
300+
}
301+
302+
termux_step_post_make_install() {
303+
# Remove the dummy files
304+
rm "${_DUMMY_FILES[@]}"
305+
unset _DUMMY_FILES
306+
307+
# Recover the toolchain
308+
for _arch in i386 x86_64; do
309+
local _clang_version="$($TERMUX_STANDALONE_TOOLCHAIN/bin/clang --version | head -n 1 | sed 's/.*version \([0-9]*.[0-9]*.[0-9]*\) .*/\1/g')"
310+
local _invalid_atomic="$TERMUX_STANDALONE_TOOLCHAIN/lib64/clang/$_clang_version/lib/linux/$_arch/libatomic.a"
311+
if [ -f "$_invalid_atomic.backup" ]; then
312+
mv $_invalid_atomic{.backup,}
313+
fi
314+
done
315+
unset _arch
316+
}
317+
318+
termux_step_post_massage() {
319+
# Except the deb file, we also create a zip file like electron release
320+
local _TARGET_CPU="$TERMUX_ARCH"
321+
if [ "$TERMUX_ARCH" = "aarch64" ]; then
322+
_TARGET_CPU="arm64"
323+
elif [ "$TERMUX_ARCH" = "x86_64" ]; then
324+
_TARGET_CPU="x64"
325+
elif [ "$TERMUX_ARCH" = "arm" ]; then
326+
_TARGET_CPU="armv7l"
327+
fi
328+
329+
mkdir -p $TERMUX_SCRIPTDIR/output-electron
330+
331+
pushd $TERMUX_PREFIX/opt/electron-$TERMUX_PKG_VERSION
332+
zip -r $TERMUX_SCRIPTDIR/output-electron/electron-v$TERMUX_PKG_VERSION-linux-$_TARGET_CPU.zip ./*
333+
popd
334+
}

0 commit comments

Comments
 (0)