new package: txikijs

This commit is contained in:
Tee KOBAYASHI 2022-01-09 11:24:03 +09:00 committed by Leonid Pliushch
parent 216046f902
commit f3742cb7fe
6 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,7 +101,7 @@
src/worker.c
src/xhr.c
${CMAKE_CURRENT_BINARY_DIR}/js.c
- ../deps/quickjs/src/cutils.c
+ deps/quickjs/src/cutils.c
)
set_target_properties(tjs PROPERTIES

74
packages/txikijs/build.sh Normal file
View File

@ -0,0 +1,74 @@
TERMUX_PKG_HOMEPAGE=https://github.com/saghul/txiki.js
TERMUX_PKG_DESCRIPTION="A small and powerful JavaScript runtime"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
_COMMIT=ffa4b191eeb23984d502b183a1f521be717f1eb5
TERMUX_PKG_VERSION=2021.11.16
TERMUX_PKG_SRCURL=https://github.com/saghul/txiki.js.git
TERMUX_PKG_GIT_BRANCH=master
TERMUX_PKG_DEPENDS="libcurl"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="-DBUILD_NATIVE=OFF"
TERMUX_PKG_HOSTBUILD=true
# Build failure for i686:
# [...]/txikijs/src/deps/wasm3/source/./extra/wasi_core.h:46:1:
# fatal error: static_assert failed due to requirement
# '__alignof(long long) == 8' "non-wasi data layout"
# _Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
# ^ ~~~~~~~~~~~~~~~~~~~~~~
TERMUX_PKG_BLACKLISTED_ARCHES="i686"
termux_step_post_get_source() {
git fetch --unshallow
git checkout $_COMMIT
local version="$(git log -1 --format=%cs | sed 's/-/./g')"
if [ "$version" != "$TERMUX_PKG_VERSION" ]; then
echo -n "ERROR: The specified version \"$TERMUX_PKG_VERSION\""
echo " is different from what is expected to be: \"$version\""
return 1
fi
}
termux_step_host_build() {
find $TERMUX_PKG_SRCDIR -mindepth 1 -maxdepth 1 ! -name '.git*' \
-exec cp -a \{\} ./ \;
termux_setup_cmake
cmake .
make -j $TERMUX_MAKE_PROCESSES
}
termux_step_pre_configure() {
_NEED_DUMMY_LIBPTHREAD_A=
_LIBPTHREAD_A=$TERMUX_PREFIX/lib/libpthread.a
if [ ! -e $_LIBPTHREAD_A ]; then
_NEED_DUMMY_LIBPTHREAD_A=true
echo '!<arch>' > $_LIBPTHREAD_A
fi
_NEED_DUMMY_LIBRT_A=
_LIBRT_A=$TERMUX_PREFIX/lib/librt.a
if [ ! -e $_LIBRT_A ]; then
_NEED_DUMMY_LIBRT_A=true
echo '!<arch>' > $_LIBRT_A
fi
}
termux_step_post_configure() {
export PATH=$TERMUX_PKG_HOSTBUILD_DIR:$PATH
}
termux_step_make_install() {
install -Dm700 -t $TERMUX_PREFIX/bin tjs
}
termux_step_post_make_install() {
if [ $_NEED_DUMMY_LIBPTHREAD_A ]; then
rm -f $_LIBPTHREAD_A
fi
if [ $_NEED_DUMMY_LIBRT_A ]; then
rm -f $_LIBRT_A
fi
}

View File

@ -0,0 +1,11 @@
--- a/deps/libuv/src/unix/core.c
+++ b/deps/libuv/src/unix/core.c
@@ -1125,7 +1125,7 @@
/* No temp environment variables defined */
#if defined(__ANDROID__)
- buf = "/data/local/tmp";
+ buf = "@TERMUX_PREFIX@/tmp";
#else
buf = "/tmp";
#endif

View File

@ -0,0 +1,11 @@
--- a/deps/libuv/src/unix/internal.h
+++ b/deps/libuv/src/unix/internal.h
@@ -79,7 +79,7 @@
# define UV__PATH_MAX 8192
#endif
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && __ANDROID_API__ < 16
int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
# ifdef pthread_sigmask
# undef pthread_sigmask

View File

@ -0,0 +1,18 @@
--- a/deps/wasm3/source/m3_api_wasi.c
+++ b/deps/wasm3/source/m3_api_wasi.c
@@ -672,6 +672,7 @@
while (1) {
ssize_t retlen = 0;
+#if !defined __ANDROID__ || __ANDROID_API__ >= 28
#if defined(__wasi__) || defined(__APPLE__) || defined(__ANDROID_API__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
size_t reqlen = M3_MIN (buf_len, 256);
# if defined(__APPLE__) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
@@ -685,6 +686,7 @@
if (RtlGenRandom(buf, buf_len) == TRUE) {
m3ApiReturn(__WASI_ERRNO_SUCCESS);
}
+#endif
#else
m3ApiReturn(__WASI_ERRNO_NOSYS);
#endif

View File

@ -0,0 +1,11 @@
--- a/src/js/CMakeLists.txt
+++ b/src/js/CMakeLists.txt
@@ -24,7 +24,7 @@
${JS_PATH}/worker-bootstrap.js
)
-set(CUSTOM_QJSC "${CMAKE_CURRENT_BINARY_DIR}/qjsc" CACHE STRING "Custom path to QJSC")
+set(CUSTOM_QJSC "qjsc" CACHE STRING "Custom path to QJSC")
add_custom_command(
COMMAND
${CUSTOM_QJSC}