chore(main/nodejs-lts): use ninja

This will make the logs more human-friendly. Also building with ninja
should be bit faster
This commit is contained in:
Yaksh Bariya 2023-06-03 17:37:21 +05:30
parent 01cc39bd98
commit de5ce48c3f
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
4 changed files with 94 additions and 8 deletions

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Open Source, cross-platform JavaScript runtime environme
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="Yaksh Bariya <thunder-coding@termux.dev>"
TERMUX_PKG_VERSION=18.16.0
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://nodejs.org/dist/v${TERMUX_PKG_VERSION}/node-v${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=33d81a233e235a509adda4a4f2209008d04591979de6b3f0f67c1c906093f118
# Note that we do not use a shared libuv to avoid an issue with the Android
@ -22,6 +23,10 @@ termux_step_post_get_source() {
rm -Rf $TERMUX_PKG_HOSTBUILD_DIR
}
termux_step_pre_configure() {
termux_setup_ninja
}
termux_step_host_build() {
local ICU_VERSION=73.1
local ICU_TAR=icu4c-${ICU_VERSION//./_}-src.tgz
@ -65,7 +70,8 @@ termux_step_configure() {
export LINK_host=g++
LDFLAGS+=" -ldl"
# See note above TERMUX_PKG_DEPENDS why we do not use a shared libuv.
# See note above TERMUX_PKG_DEPENDS why we do not use a shared libuv
# When building with ninja, build.ninja is geenrated for both Debug and Release builds.
./configure \
--prefix=$TERMUX_PREFIX \
--dest-cpu=$DEST_CPU \
@ -74,15 +80,30 @@ termux_step_configure() {
--shared-openssl \
--shared-zlib \
--with-intl=system-icu \
--cross-compiling
--cross-compiling \
--ninja
export LD_LIBRARY_PATH=$TERMUX_PKG_HOSTBUILD_DIR/icu-installed/lib
perl -p -i -e "s@LIBS := \\$\\(LIBS\\)@LIBS := -L$TERMUX_PKG_HOSTBUILD_DIR/icu-installed/lib -lpthread -licui18n -licuuc -licudata -ldl -lz@" \
$TERMUX_PKG_SRCDIR/out/tools/v8_gypfiles/mksnapshot.host.mk \
$TERMUX_PKG_SRCDIR/out/tools/v8_gypfiles/torque.host.mk \
$TERMUX_PKG_SRCDIR/out/tools/v8_gypfiles/bytecode_builtins_list_generator.host.mk \
$TERMUX_PKG_SRCDIR/out/tools/v8_gypfiles/v8_libbase.host.mk \
$TERMUX_PKG_SRCDIR/out/tools/v8_gypfiles/gen-regexp-special-case.host.mk
sed -i -e "s|\-I$TERMUX_PREFIX/include|\-I$TERMUX_PKG_HOSTBUILD_DIR/icu-installed/include|g" \
$TERMUX_PKG_SRCDIR/out/Release/obj.host/tools/v8_gypfiles/*.ninja
sed -i -e "s|\-L$TERMUX_PREFIX/lib|\-L$TERMUX_PKG_HOSTBUILD_DIR/icu-installed/lib|g" \
$TERMUX_PKG_SRCDIR/out/Release/obj.host/tools/v8_gypfiles/*.ninja
}
termux_step_make() {
if [ "${TERMUX_DEBUG_BUILD}" = "true" ]; then
ninja -C out/Debug -j "${TERMUX_MAKE_PROCESSES}"
else
ninja -C out/Release -j "${TERMUX_MAKE_PROCESSES}"
fi
}
termux_step_make_install() {
if [ "${TERMUX_DEBUG_BUILD}" = "true" ]; then
python tools/install.py install "" "${TERMUX_PREFIX}" out/Debug/
else
python tools/install.py install "" "${TERMUX_PREFIX}" out/Release/
fi
}
termux_step_create_debscripts() {

View File

@ -0,0 +1,26 @@
diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py
index 3db3771ac9..2e0a021703 100644
--- a/tools/gyp/pylib/gyp/generator/ninja.py
+++ b/tools/gyp/pylib/gyp/generator/ninja.py
@@ -42,7 +42,7 @@ generator_default_variables = {
# the start of a string, while $| is used for variables that can appear
# anywhere in a string.
"INTERMEDIATE_DIR": "$!INTERMEDIATE_DIR",
- "SHARED_INTERMEDIATE_DIR": "$!PRODUCT_DIR/gen",
+ "SHARED_INTERMEDIATE_DIR": "$!PRODUCT_DIR/$|OBJ/gen",
"PRODUCT_DIR": "$!PRODUCT_DIR",
"CONFIGURATION_NAME": "$|CONFIGURATION_NAME",
# Special variables that may be used by gyp 'rule' targets.
@@ -285,6 +285,12 @@ class NinjaWriter:
CONFIGURATION_NAME = "$|CONFIGURATION_NAME"
path = path.replace(CONFIGURATION_NAME, self.config_name)
+ obj = "obj"
+ if self.toolset != "target":
+ obj += "." + self.toolset
+
+ path = path.replace("$|OBJ", obj)
+
return path
def ExpandRuleVariables(self, path, root, dirname, source, ext, name):

View File

@ -0,0 +1,38 @@
--- a/tools/install.py
+++ b/tools/install.py
@@ -140,10 +140,9 @@ def subdir_files(path, dest, action):
for subdir, files_in_path in ret.items():
action(files_in_path, subdir + '/')
-def files(action):
+def files(action, output_prefix):
is_windows = sys.platform == 'win32'
output_file = 'node'
- output_prefix = 'out/Release/'
if is_windows:
output_file += '.exe'
@@ -319,7 +318,9 @@ def run(args):
if len(args) > 3:
node_prefix = args[3]
-
+ output_prefix = 'out/Release/'
+ if len(args) > 4:
+ output_prefix = args[4]
# install_path thus becomes the base target directory.
install_path = dst_dir + node_prefix + '/'
@@ -334,10 +335,10 @@ def run(args):
return
else:
if cmd == 'install':
- files(install)
+ files(install, output_prefix)
return
if cmd == 'uninstall':
- files(uninstall)
+ files(uninstall, output_prefix)
return
raise RuntimeError('Bad command: %s\n' % cmd)

View File

@ -135,6 +135,7 @@ PACKAGES+=" ruby"
# Needed by host build of package nodejs.
PACKAGES+=" libc-ares-dev"
PACKAGES+=" libc-ares-dev:i386"
PACKAGES+=" libicu-dev"
# Needed by php.