JS core of espruino

Posted on
  • Hi everyone.
    I've been navigating through the code if Espruino and the website for quite a while now (almost a week now), but I still could not end up with a solution to this.
    I'm working with some HW that is not supported by Espruino and would like to use it in my project.

    Unfortunately I could not find any interface in your code, nor any other way to separate the JS interpeter files from the rest. When I create the library it is always complaining about some extra calls that are missing,regardless what I include in the library.

    I've put a lot of effort into isolating the JS core interpreter from your project, but in the end there was absolutely no way to obtain a proper library with all and only the functions that handle JS.

    My guess about the most eligible files of the JS interpreter was this:
    espruino/src/jsparse.o
    espruino/src/jslex.o
    espruino/src/jsvar.o
    espruino/src/jsutils.o
    espruino/src/jsnative.o

    Is there any way to compile your Espruino project a standalone, BSP (board and hardware) independant library that I can use with a documented interface ?

  • The short answer is no... You could look at how the linux executable is built?

    If you're trying to compile for new hardware, the solution is to create a new BOARD.py file in the boards directory and to work from there - there is a small bit of documentation in the readme about it.

    You can implement your own version of jshardware.c if the board isn't STM32 based - jshardware.h is basically the hardware abstraction layer. Pretty much everything in src is stuff that you need I'm afraid.

    If you're trying to totally remove everything so you just have a JavaScript interpreter, with no REPL and no built-in libraries I think you're going to be in for a hard time I'm afraid.

  • @Gordon, @rm:

    I think it might depend on the eventual use of the library. If the goal is to have something that you could link with some other program and have it execute a string containing JavaScript, it may be possible.

    You can look at targets/linux/main.c: line 276. This is the location where the interpreter executes a file of JavaScript. You could take what you need from this file/location and create an interface for running an arbitrary string of JS.
    However, all it would do is execute the JS.. you would still need to find a way to get data back out to the running program if you want any feedback from the JS.

    I am not saying it is the cleanest way to do it, just that it is a way to do it.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

JS core of espruino

Posted by Avatar for rm @rm

Actions