diff options
Diffstat (limited to 'development/quickjs')
-rw-r--r-- | development/quickjs/README | 37 | ||||
-rw-r--r-- | development/quickjs/patches/01-Makefile.patch | 116 | ||||
-rw-r--r-- | development/quickjs/patches/02-qjsc.c.patch | 12 | ||||
-rw-r--r-- | development/quickjs/quickjs.SlackBuild | 103 | ||||
-rw-r--r-- | development/quickjs/quickjs.info | 10 | ||||
-rw-r--r-- | development/quickjs/slack-desc | 19 |
6 files changed, 297 insertions, 0 deletions
diff --git a/development/quickjs/README b/development/quickjs/README new file mode 100644 index 0000000000..3ffa3044b1 --- /dev/null +++ b/development/quickjs/README @@ -0,0 +1,37 @@ +QuickJS is a small and embeddable Javascript engine by Fabrice Bellard +and Charlie Gordon. It supports the ES2023 specification including +modules, asynchronous generators, proxies and BigInt. +It optionally supports mathematical extensions such as big decimal +floating point numbers (BigDecimal), big binary floating point numbers +(BigFloat) and operator overloading. + +Main Features: +* Small and easily embeddable: just a few C files, no external + dependency. +* Fast interpreter with very low startup time +* Almost complete ES2023 support including modules, asynchronous + generators and full Annex B support (legacy web compatibility). +* Passes nearly 100% of the ECMAScript Test Suite tests when selecting + the ES2023 features. +* Can compile Javascript sources to executables with no external + dependency. +* Garbage collection using reference counting (to reduce memory usage + and have deterministic behavior) with cycle removal. +* Mathematical extensions: BigDecimal, BigFloat, operator overloading, + bigint mode, math mode. +* Command line interpreter with contextual colorization in JS. +* Small built-in standard library with C library wrappers. + +NOTE: +In order to adhere to Slackware standards the source is patched to: +* change library paths in the compiler +* build a shared library +Since the default behaviour of the compiler is to output statically +linked binaries, an aditional shared library is provided so that users +may produce C files from Javascript source code +(e.g.: qjsc -e in.js -o out.c), and then compile and link dynamically, +e.g.: + cc -I /usr/include/quickjs out.c -o executable -lquickjs +I believe this is the less intrussive set of changes to achieve those +goals. + diff --git a/development/quickjs/patches/01-Makefile.patch b/development/quickjs/patches/01-Makefile.patch new file mode 100644 index 0000000000..10eb343fb3 --- /dev/null +++ b/development/quickjs/patches/01-Makefile.patch @@ -0,0 +1,116 @@ +01-Makefile.patch, changes: +* on x86_64 systems, install libraries in /usr/lib64 +* added shared library target +* added CFLAGS_EXTRA to pass $SLKCFLAGS (can be improved) +* avoid building examples +* disabled debug information + +--- quickjs-2024-01-13/Makefile 2024-01-13 07:20:39.000000000 -0300 ++++ quickjs-2024-01-13m/Makefile 2024-02-04 02:01:09.732016372 -0300 +@@ -39,6 +39,8 @@ + # installation directory + PREFIX?=/usr/local + ++CFLAGS+=$(CFLAGS_EXTRA) ++ + # use the gprof profiler + #CONFIG_PROFILE=y + # use address sanitizer +@@ -69,7 +71,7 @@ + ifdef CONFIG_CLANG + HOST_CC=clang + CC=$(CROSS_PREFIX)clang +- CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d ++ CFLAGS+= -Wall -MMD -MF $(OBJDIR)/$(@F).d + CFLAGS += -Wextra + CFLAGS += -Wno-sign-compare + CFLAGS += -Wno-missing-field-initializers +@@ -92,13 +94,13 @@ + HOST_CC=gcc + CC=cosmocc + # cosmocc does not correct support -MF +- CFLAGS=-g -Wall #-MMD -MF $(OBJDIR)/$(@F).d ++ CFLAGS= -Wall #-MMD -MF $(OBJDIR)/$(@F).d + CFLAGS += -Wno-array-bounds -Wno-format-truncation + AR=cosmoar + else + HOST_CC=gcc + CC=$(CROSS_PREFIX)gcc +- CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d ++ CFLAGS+= -Wall -MMD -MF $(OBJDIR)/$(@F).d + CFLAGS += -Wno-array-bounds -Wno-format-truncation + ifdef CONFIG_LTO + AR=$(CROSS_PREFIX)gcc-ar +@@ -127,7 +129,7 @@ + ifdef CONFIG_COSMO + LDFLAGS+=-s # better to strip by default + else +-LDFLAGS+=-g ++LDFLAGS+= + endif + ifdef CONFIG_LTO + CFLAGS_SMALL+=-flto +@@ -176,16 +178,16 @@ + + # examples + ifeq ($(CROSS_PREFIX),) +-PROGS+=examples/hello ++#PROGS+=examples/hello + ifndef CONFIG_ASAN +-PROGS+=examples/hello_module ++#PROGS+=examples/hello_module + endif + ifdef CONFIG_SHARED_LIBS +-PROGS+=examples/test_fib examples/fib.so examples/point.so ++#PROGS+=examples/test_fib examples/fib.so examples/point.so + endif + endif + +-all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS) ++all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS) libquickjs.so + + QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/libregexp.o $(OBJDIR)/libunicode.o $(OBJDIR)/cutils.o $(OBJDIR)/quickjs-libc.o $(OBJDIR)/libbf.o + +@@ -213,6 +215,9 @@ + qjsc$(EXE): $(OBJDIR)/qjsc.o $(QJS_LIB_OBJS) + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) + ++libquickjs.so: $(QJS_LIB_OBJS) ++ $(CC) -shared -fPIC $(LDFLAGS) -o $@ $^ $(LIBS) ++ + ifneq ($(CROSS_PREFIX),) + + $(QJSC): $(OBJDIR)/qjsc.host.o \ +@@ -221,11 +226,11 @@ + + endif #CROSS_PREFIX + +-QJSC_DEFINES:=-DCONFIG_CC=\"$(QJSC_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\" ++QJSC_DEFINES:=-DCONFIG_CC=\"$(QJSC_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\" -DCONFIG_LIBDIR=\"$(LIBDIR)\" + ifdef CONFIG_LTO + QJSC_DEFINES+=-DCONFIG_LTO + endif +-QJSC_HOST_DEFINES:=-DCONFIG_CC=\"$(HOST_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\" ++QJSC_HOST_DEFINES:=-DCONFIG_CC=\"$(HOST_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\" -DCONFIG_LIBDIR=\"$(LIBDIR)\" + + $(OBJDIR)/qjsc.o: CFLAGS+=$(QJSC_DEFINES) + $(OBJDIR)/qjsc.host.o: CFLAGS+=$(QJSC_HOST_DEFINES) +@@ -319,14 +324,12 @@ + + install: all + mkdir -p "$(DESTDIR)$(PREFIX)/bin" +- $(STRIP) qjs qjsc ++ $(STRIP) qjs qjsc libquickjs.so + install -m755 qjs qjsc "$(DESTDIR)$(PREFIX)/bin" + ln -sf qjs "$(DESTDIR)$(PREFIX)/bin/qjscalc" +- mkdir -p "$(DESTDIR)$(PREFIX)/lib/quickjs" +- install -m644 libquickjs.a "$(DESTDIR)$(PREFIX)/lib/quickjs" +-ifdef CONFIG_LTO +- install -m644 libquickjs.lto.a "$(DESTDIR)$(PREFIX)/lib/quickjs" +-endif ++ mkdir -p "$(DESTDIR)$(LIBDIR)/quickjs" ++ install -m644 libquickjs.a "$(DESTDIR)$(LIBDIR)/quickjs" ++ install -m755 libquickjs.so "$(DESTDIR)$(LIBDIR)" + mkdir -p "$(DESTDIR)$(PREFIX)/include/quickjs" + install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(PREFIX)/include/quickjs" + diff --git a/development/quickjs/patches/02-qjsc.c.patch b/development/quickjs/patches/02-qjsc.c.patch new file mode 100644 index 0000000000..13d725fba2 --- /dev/null +++ b/development/quickjs/patches/02-qjsc.c.patch @@ -0,0 +1,12 @@ +This is a simple patch to compile on 64 bit systems. +--- quickjs-2024-01-13/qjsc.c 2024-01-13 07:20:39.000000000 -0300 ++++ quickjs-2024-01-13m/qjsc.c 2024-02-04 01:43:19.516094810 -0300 +@@ -419,7 +419,7 @@ + pstrcpy(lib_dir, sizeof(lib_dir), exe_dir); + } else { + snprintf(inc_dir, sizeof(inc_dir), "%s/include/quickjs", CONFIG_PREFIX); +- snprintf(lib_dir, sizeof(lib_dir), "%s/lib/quickjs", CONFIG_PREFIX); ++ snprintf(lib_dir, sizeof(lib_dir), "%s/quickjs", CONFIG_LIBDIR); + } + + lto_suffix = ""; diff --git a/development/quickjs/quickjs.SlackBuild b/development/quickjs/quickjs.SlackBuild new file mode 100644 index 0000000000..c798c85dd9 --- /dev/null +++ b/development/quickjs/quickjs.SlackBuild @@ -0,0 +1,103 @@ +#!/bin/bash + +# Slackware build script for quickjs + +# Copyright 2022 Juan M. Lasca <juanmlasca@gmail.com> +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cd $(dirname $0) ; CWD=$(pwd) + +PRGNAM=quickjs +VERSION=${VERSION:-2024.01.13} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} +SRCVERSION=${VERSION//./-} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$SRCVERSION.tar.xz +mv $PRGNAM-$SRCVERSION $PRGNAM-$VERSION +cd $PRGNAM-$VERSION +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +patch -p1 < $CWD/patches/01-Makefile.patch || exit 1; +patch -p1 < $CWD/patches/02-qjsc.c.patch || exit 1; + +make install \ + DESTDIR=$PKG \ + CFLAGS_EXTRA="$SLKCFLAGS" \ + PREFIX=/usr \ + LIBDIR=/usr/lib${LIBDIRSUFFIX} + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/examples +cp -a \ + doc/jsbignum.html doc/quickjs.html \ + LICENSE Changelog TODO \ + $PKG/usr/doc/$PRGNAM-$VERSION +cp -a examples/*.c examples/*.js $PKG/usr/doc/$PRGNAM-$VERSION/examples +cp -a tests $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/development/quickjs/quickjs.info b/development/quickjs/quickjs.info new file mode 100644 index 0000000000..2f902dfab3 --- /dev/null +++ b/development/quickjs/quickjs.info @@ -0,0 +1,10 @@ +PRGNAM="quickjs" +VERSION="2024.01.13" +HOMEPAGE="https://bellard.org/quickjs" +DOWNLOAD="https://bellard.org/quickjs/quickjs-2024-01-13.tar.xz" +MD5SUM="ea9fa8c503c4125dff9fd42c38b891d0" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="Juan M. Lasca" +EMAIL="juanmlasca@gmail.com" diff --git a/development/quickjs/slack-desc b/development/quickjs/slack-desc new file mode 100644 index 0000000000..0d81084831 --- /dev/null +++ b/development/quickjs/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +quickjs: quickjs (a small and embeddable Javascript engine) +quickjs: +quickjs: QuickJS is a small and embeddable Javascript engine by Fabrice +quickjs: Bellard and Charlie Gordon. It supports the ES2020 specification +quickjs: including modules, asynchronous generators, proxies and BigInt. +quickjs: It optionally supports mathematical extensions such as big decimal +quickjs: floating point numbers (BigDecimal), big binary floating point +quickjs: numbers (BigFloat) and operator overloading. +quickjs: +quickjs: https://bellard.org/quickjs +quickjs: |