Jump to content
Vincent Parrett

Looking for CBuilder/VS help on C open source project

Recommended Posts

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!

  • Like 1

Share this post


Link to post
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

What about Lazarus pas2js  

 

This screen capture Shows the source in the js.pas.  Its hid in the co..\pas2js\Demos   

 

 

LAZpas2JS.png

Share this post


Link to post
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
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
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 by pyscripter

Share this post


Link to post

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!

  • Like 1

Share this post


Link to post
5 minutes ago, Vincent Parrett said:

Iron Python

Another abandonware of Microsoft!  It first sounded real good.

Share this post


Link to post
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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×