Skip to content

napi-bindings/quickjs-build

Repository files navigation

QuickJS JavaScript Engine

QuickJS Build Matrix

Version 2022-03-07

Introduction

QuickJS is a small and embeddable Javascript engine. 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, 210 KiB of x86 code for a simple hello world program.
  • Fast interpreter with very low startup time: runs the 69000 tests of the ECMAScript Test Suite in about 95 seconds on a single core of a desktop PC. The complete life cycle of a runtime instance completes in less than 300 microseconds.
  • 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 implemented in Javascript.
  • Small built-in standard library with C library wrappers.

This reposistory is a mrirror of the original work that you can find here.

Building

The main purpose of this reposistory is to build QuickJS static library that you could include on your C / C++ project. On release you can find the build for the following operating systems:

  • Windows
  • Ubuntu 20.04
  • Ubuntu 18.04
  • Linux arm64
  • macOS

If you want to build the QuickJS library on your own the first step is to clone this repository:

> git clone https://github.com/napi-bindings/quickjs-build.git

Building on Windows

You will need to install GCC for Windows and CMake.

Install GCC compiler

  • Download the mingw from this link.
  • Be sure that gcc in in your path of execution.

Install CMake

  • Download the right version for your system from this link.
  • Be sure that cmake is in your path of execution.

Configure and build

Open your shell and execute the commands reported below:

mkdir ./build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-G "MinGW Makefiles" \
-S ./ \
-B ./build
cmake --build ./build

-DCMAKE_BUILD_TYPE could be set with one of the following two values:

  • Release
  • Debug

Building on Unix-like platform

You will need to install C / C++ compiler and CMake.

Prerequisistes to build on Linux

These steps were tested on:

  • Ubuntu 18.04
  • Ubuntu 20.04

First, you will need to install dependencies:

sudo apt-get update
sudo apt-get install build-essential -y
sudo apt-get install cmake -y

Prerequisites to build on macOS

These steps were tested on macOS Catalina (10.15).

First, you will need to install dependencies:

  • Install Xcode
    • You also need to install the XCode Command Line Tools by running xcode-select --install. Alternatively, if you already have the full Xcode installed, you can find them under the menu Xcode -> Open Developer Tool -> More Developer Tools.... This step will install clang, clang++, and make.
  • Install Homebrew
  • Install and cmake running the following command:
brew install cmake

Configure and build

Open your shell and execute the commands reported below:

mkdir ./build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-G "Unix Makefiles" \
-S ./ \
-B ./build
cmake --build ./build

-DCMAKE_BUILD_TYPE could be set with one of the following two values:

  • Release
  • Debug

References

Team

Nicola Del Gobbo

https://github.com/NickNaso/

https://www.npmjs.com/~nicknaso

https://twitter.com/NickNaso

Acknowledgements

Thank you to all people that encourage me every day.

License

Licensed under Apache license V2