The source code of the Berry interpreter is written using the ISO C99 standard, and the core code does not rely on third-party libraries, so it has strong versatility. Take the Ubuntu system as an example, execute the following command in the terminal to install the Berry interpreter:
apt install git gcc g++ make libreadline-dev
git clone https://github.com/berry-lang/berry
The Makefile provided in the GitHub repository is built using the GCC compiler. Other compilers can also compile the Berry interpreter correctly. The currently tested and available compilers include GCC, Clang, MSVC, ARMCC and ICCARM. The compiler that compiles the Berry interpreter should have the following characteristics:
C compiler that supports the C99 standard
C++ compiler supporting C++11 standard (only for native compilation)
32 or 64 bit target platform
The C++ compiler is only used to compile map_build tools, so there is no need to provide a C++ cross compiler for the Berry interpreter when cross-compiling, but the user should prepare a native C++ compiler (unless the user can obtain the map_build tool executable file).
The following is how to port the Berry interpreter to the user’s project:
Add all source files in the src directory to the user project, and the directory should be added to the include path
Users need to implement by themselves default files other than berry.c in the directory. If conditions permit, they don’t need to modify them
Use map_build tool to generate constant object code and then compile
3. Platform Support¶
Currently Berry interpreter has been tested on some platforms. Windows, Linux and MacOS operating systems running on X86 CPUs can run normally. Embedded platforms that have been tested include Cortex M3/M0/M4/M7. The Berry interpreter should be able to run well on the basis of the necessary C runtime library. At present, when only Berry language core is compiled, the interpreter code generated by the ARMCC compiler is only about 40KiB, and the interpreter can run on a device with only 8KiB of RAM.