diff options
author | Juan M. Lasca <juanmlasca@gmail.com> | 2022-08-05 06:12:15 +0100 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2022-08-06 20:16:04 +0700 |
commit | 9bcaf9107a464794d7f84a446349ccf12d488d43 (patch) | |
tree | 687ce5ddecdb3085f10a52aa7cd604cf0e14fc75 /development/quickjs | |
parent | 1de921aa9f548768a3e8ebc2a7654583e327ec9e (diff) |
development/quickjs: Added (a small and embeddable JS engine)
Signed-off-by: Dave Woodfall <dave@slackbuilds.org>
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'development/quickjs')
-rw-r--r-- | development/quickjs/README | 37 | ||||
-rw-r--r-- | development/quickjs/patches/01-Makefile.patch | 108 | ||||
-rw-r--r-- | development/quickjs/patches/02-qjsc.c.patch | 12 | ||||
-rw-r--r-- | development/quickjs/quickjs.SlackBuild | 102 | ||||
-rw-r--r-- | development/quickjs/quickjs.info | 10 | ||||
-rw-r--r-- | development/quickjs/slack-desc | 19 |
6 files changed, 288 insertions, 0 deletions
diff --git a/development/quickjs/README b/development/quickjs/README new file mode 100644 index 000000000000..ebc589068a71 --- /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 ES2020 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 ES2020 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 ES2020 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 000000000000..2e3650369b2a --- /dev/null +++ b/development/quickjs/patches/01-Makefile.patch @@ -0,0 +1,108 @@ +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-2021-03-27/Makefile 2021-03-27 07:00:32.000000000 -0300 ++++ quickjs-2021-03-27-modified/Makefile 2022-08-02 21:52:01.476250120 -0300 +@@ -36,12 +36,14 @@ + + ifdef CONFIG_DARWIN + # use clang instead of gcc +-CONFIG_CLANG=y ++#CONFIG_CLANG=y + CONFIG_DEFAULT_AR=y + endif + + # installation directory + prefix=/usr/local ++libdir=$(prefix)/lib ++CFLAGS_EXTRA= + + # use the gprof profiler + #CONFIG_PROFILE=y +@@ -66,7 +68,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 +@@ -87,7 +89,7 @@ + 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 +@@ -107,12 +109,15 @@ + DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard snprintf behavior + endif + ++DEFINES += -DCONFIG_LIBDIR=\"$(libdir)\" ++ ++CFLAGS+=$(CFLAGS_EXTRA) + CFLAGS+=$(DEFINES) + CFLAGS_DEBUG=$(CFLAGS) -O0 + CFLAGS_SMALL=$(CFLAGS) -Os + CFLAGS_OPT=$(CFLAGS) -O2 + CFLAGS_NOLTO:=$(CFLAGS_OPT) +-LDFLAGS=-g ++#LDFLAGS=-g + ifdef CONFIG_LTO + CFLAGS_SMALL+=-flto + CFLAGS_OPT+=-flto +@@ -157,14 +162,14 @@ + ifdef CONFIG_ASAN + PROGS+= + else +-PROGS+=examples/hello examples/hello_module examples/test_fib ++#PROGS+=examples/hello examples/hello_module examples/test_fib + ifndef CONFIG_DARWIN +-PROGS+=examples/fib.so examples/point.so ++#PROGS+=examples/fib.so examples/point.so + endif + 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 + +@@ -187,6 +192,9 @@ + qjs$(EXE): $(QJS_OBJS) + $(CC) $(LDFLAGS) $(LDEXPORT) -o $@ $^ $(LIBS) + ++libquickjs.so: $(QJS_LIB_OBJS) ++ $(CC) -shared $(LDFLAGS) -fPIC $(LDEXPORT) -o $@ $^ $(LIBS) ++ + qjs-debug$(EXE): $(patsubst %.o, %.debug.o, $(QJS_OBJS)) + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) + +@@ -299,13 +307,15 @@ + + 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" ++ mkdir -p "$(DESTDIR)/$(libdir)/quickjs" ++ install -m644 libquickjs.a "$(DESTDIR)/$(libdir)/quickjs" ++ install -m644 libquickjs.so "$(DESTDIR)/$(libdir)/quickjs" ++ ln -s quickjs/libquickjs.so "$(DESTDIR)/$(libdir)/libquickjs.so" + ifdef CONFIG_LTO +- install -m644 libquickjs.lto.a "$(DESTDIR)$(prefix)/lib/quickjs" ++ install -m644 libquickjs.lto.a "$(DESTDIR)/$(libdir)/quickjs" + endif + 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 000000000000..fb1bb58d4e54 --- /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-2021-03-27/qjsc.c 2021-03-27 07:00:32.000000000 -0300 ++++ quickjs-2021-03-27-modified/qjsc.c 2022-07-31 19:54:12.464023282 -0300 +@@ -420,7 +420,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 000000000000..66a73604abb8 --- /dev/null +++ b/development/quickjs/quickjs.SlackBuild @@ -0,0 +1,102 @@ +#!/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:-20210327} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} + +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-2021-03-27.tar.xz +mv $PRGNAM-2021-03-27 $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 000000000000..2adcb2495cc0 --- /dev/null +++ b/development/quickjs/quickjs.info @@ -0,0 +1,10 @@ +PRGNAM="quickjs" +VERSION="20210327" +HOMEPAGE="https://bellard.org/quickjs" +DOWNLOAD="https://bellard.org/quickjs/quickjs-2021-03-27.tar.xz" +MD5SUM="135182a626aa0c87a49aa2bf58fd39bf" +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 000000000000..0d810848319a --- /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: |