Vincent Parrett 847 Posted yesterday at 08:00 AM Hi All I'm looking at getting QuickJS working in Delphi. Sadly my C skills are not at the level needed to get anything to build in CBuilder or Visual Studio these days - it's not the same language I used 30+ years ago. There are a bunch of forks of this project, and I am pretty sure I have tried them all but have yet to get a completely successful build - probably because I don't know what I am doing. Ideally I'd like to be able to generate Win32/Win64 object files that I can link into delphi, or if that isn't feasible then a dll that I can load. Prefer C++ Builder but failing that Visual Studo 2022 is also an option. The C code apears to be written for GCC and supports Win32 via MINGW. I am willing to sponsor someone to work on this if needed. DM me if interested. Timeframe is asap! 1 Share this post Link to post
Kas Ob. 147 Posted yesterday at 09:31 AM Also i can't help here, but have question; Are these repositories referring to the same QuickJS ? https://github.com/mengmo/QuickJS-Windows-Build https://github.com/Coldzer0/QuickJS-Pascal Share this post Link to post
Vincent Parrett 847 Posted yesterday at 01:04 PM 3 hours ago, Kas Ob. said: Are these repositories referring to the same QuickJS ? Kindof - there are a bunch of "forks" of quickjs out there - QuickJS-Windows-Build is one - but it's very out of date and I couldn't get it to build. Share this post Link to post
pyscripter 791 Posted yesterday at 01:28 PM @Vincent ParrettOut of curiosity, what are you using QuickJS for? Share this post Link to post
Pat Foley 54 Posted yesterday at 05:02 PM What about Lazarus pas2js This screen capture Shows the source in the js.pas. Its hid in the co..\pas2js\Demos Share this post Link to post
Anders Melander 2023 Posted yesterday at 07:17 PM 2 hours ago, Pat Foley said: What about Lazarus pas2js QuickJS is a javascript engine while pas2js is a transpiler that emits javascript. Not even remotely the same thing. Share this post Link to post
Vincent Parrett 847 Posted 20 hours ago 9 hours ago, pyscripter said: Out of curiosity, what are you using QuickJS for? I'm looking to replace MS ActiveScripting in FinalBuilder. Share this post Link to post
pyscripter 791 Posted 19 hours ago (edited) 1 hour ago, Vincent Parrett said: MS ActiveScripting Wow. Once, I had very high hopes for this technology, but it became another abandonware of Microsoft. Have you considered using python (pyscripter/python4delphi: Free components that wrap up Python into Delphi and Lazarus (FPC))? I guess though you were using JScript and you want to stick to JavaScript. For JavaScript there is also Microsoft's ChacraCore, which used to be the JavaScript engine of the old Edge browser. There is a good Delphi wrapper. See also the blog. Edited 18 hours ago by pyscripter Share this post Link to post
Vincent Parrett 847 Posted 19 hours ago Yes, ActiveScripting has been abandoned by Microsoft - which would be fine if they just made sure it continued to work for a while, but they recently completely broke it - https://www.finalbuilder.com/resources/blogs/finalbuilder-and-automise-on-windows-11-24h2 We have a ton of existing javascript, as do our customers (each action has events customers can write scripts on), so it's not simply a a case of swapping out scripting languages. I did look at p4d a while ago but ran into issues - I don't remember the specifics (something around threading - finalbuilder is multi threaded). It's on my todo list to look at again when time permits. We currently have iron python support, but have been telling customers not to use it for some time due to memory issues. Swapping that out for for P4D might sound like a no brainer but Iron Python allows people to use .net framework classes. What ever happens, we're going to have some unhappy customers. Tech debt sucks! 1 Share this post Link to post
pyscripter 791 Posted 18 hours ago 5 minutes ago, Vincent Parrett said: Iron Python Another abandonware of Microsoft! It first sounded real good. Share this post Link to post
Pat Foley 54 Posted 18 hours ago 5 hours ago, Anders Melander said: QuickJS is a javascript engine while pas2js is a transpiler that emits javascript. Not even remotely the same thing. You are right. The files to look at is web.pas has var dom, console, and window. The js.pas uses JSValue and parses JSON objects unsure if the eval can do multiline. Share this post Link to post
Keesver 25 Posted 14 hours ago We are actively using and developing an QuickJS integration with Delphi. Works brilliantly (QuickJS that is). I can give you support with the compiling of the code. Currently we are using QuickJS-ng (GitHub - quickjs-ng/quickjs: QuickJS, the Next Generation: a mighty JavaScript engine) but this code is still close to the original version made by Fabrice Bellard. For the compilation, we use Linux (running under WSL) and the right compilers (ChatGpt is your friend here). Anyway this MakeFile works for us (save it to MakeFile_Win64): CC = x86_64-w64-mingw32-gcc CFLAGS = -O2 -fPIC -Wall -D_GNU_SOURCE -DCONFIG_VERSION=\"V16\" LDFLAGS = -static -shared SRC = quickjs.c libunicode.c libregexp.c cutils.c xsum.c quickjs-libc.c OBJ = $(SRC:.c=.o) all: quickjs64.dll quickjs64.dll: $(OBJ) $(CC) $(LDFLAGS) -o $@ $^ clean: del *.o *.dll Then run: make -f MakeFile_Win64 (this requires QuickJS-ng, for QuickJS you need to change the listed source files a little) If you need updated pascal files, you can checkout this repo: https://github.com/a-dato/quickJS-Rtti.git. Share this post Link to post
Keesver 25 Posted 14 hours ago One of the reasons behind QuickJS-ng was to make it compatible with CMake and Windows (see this page: Building | QuickJS-NG). It is actively maintained but is still close to the original source made by Fabrice. Share this post Link to post
pmcgee 27 Posted 8 hours ago @Keesver how do you create a QuickJS_32.dll ? Share this post Link to post
Vincent Parrett 847 Posted 6 hours ago @Keesver thanks, this looks promising. Another dev was able to get it compiling with CBuilder Win64x - however my immediate need is Win32 - any idea what changes need to be made to get quickjs-ng compiling for Win32? I'm also keen to take some changes from https://github.com/koush/quickjs to enable debugging at some point. Share this post Link to post
Keesver 25 Posted 6 hours ago With a little help of ChatGpt: CC = i686-w64-mingw32-gcc CFLAGS = -O2 -fPIC -Wall -D_GNU_SOURCE -DCONFIG_VERSION=\"V16\" LDFLAGS = -static -shared SRC = quickjs.c libunicode.c libregexp.c cutils.c xsum.c quickjs-libc.c OBJ = $(SRC:.c=.o) all: quickjs32.dll quickjs32.dll: $(OBJ) $(CC) $(LDFLAGS) -o $@ $^ clean: rm *.o *.dll Just tested it, this makefile works when run from Linux under WSL (I'm not using Windows as using WSL works really well) Share this post Link to post
Keesver 25 Posted 6 hours ago (edited) For the original QuickJS, this makefile seems to work: CC = i686-w64-mingw32-gcc-posix CFLAGS = -O2 -fPIC -Wall -D_GNU_SOURCE -DCONFIG_VERSION=\"V16\" LDFLAGS = -static -shared -lpthread SRC = quickjs.c libunicode.c libregexp.c cutils.c dtoa.c quickjs-libc.c OBJ = $(SRC:.c=.o) all: quickjs32.dll quickjs32.dll: $(OBJ) $(CC) $(LDFLAGS) -o $@ $^ clean: rm *.o *.dll But this requires the POSIX version of gcc which can be insalled in Ubuntu using: sudo apt install gcc-mingw-w64-i686 This compiler supports the POSIX threading functions required by QuickJS. Edited 6 hours ago by Keesver Share this post Link to post