Skip to content
Jason Karns edited this page Jan 6, 2019 · 3 revisions

Build definitions are simple shell scripts that get sourced in the node-build environment so they can invoke functions that fetch necessary packages and compile them into the destination directory.

The basic invocation from a build definition is the function to download and install a package from a tarball:

install_package PACKAGE_NAME PACKAGE_URL#SHA2 [BUILD_STEPS...] [--if CONDITION]

PACKAGE_URL specifies the location of the tarball where the package is published. After download, its signature verified against the optional SHA2 checksum.

PACKAGE_NAME is the name of the directory to cd into after extracting the tarball. The subsequent BUILD_STEPS will be executed within that directory.

Alternatively, a package may be retrieved via git or SVN:

install_git PACKAGE_NAME GIT_URL BRANCH [...]
install_svn PACKAGE_NAME SVN_URL REVISION [...]

BUILD_STEPS is a list of operations to run in order to complete the installation of a Node version. If empty, the list defaults to "standard".

CONDITION is a way to specify that this package is optional and will only be installed if the function of the same name returns a success status. Some condition functions used in built-in definitions are:

  • has_broken_mac_openssl: true for Apple-patched openssl v0.9.8

Build steps

Pre-build steps:

  • ldflags_dirs: Ensures that directories listed in LDFLAGS exist. Necessary workaround for some Node versions.
  • autoconf: Runs autoconf. Prerequisite for "standard" step when fetching Node versions from git/SVN.
  • binary: Defines precompiled binaries for given platforms.

Build steps:

  • standard: ./configure + make. This is the default.
  • jxcore_v8: selects v8 as jxcore's js engine.
  • jxcore_spidermonkey: selects spidermonkey as jxcore's js engine.
  • jxcore_npm: installs jxcore's custom npmjx instead of npm.

Post-build steps:

Constraints

These constraints should appear in the beginning of the build definition to check whether the system is compatible with the Node version:

Hooks

Before and after installing each package, node-build invokes these functions:

before_install_package PACKAGE_NAME
after_install_package PACKAGE_NAME

You can take advantage of this by defining these functions in the definition itself and filtering by package name as necessary:

before_install_package() {
  local package_name="$1"
  case "$package_name" in
  node-* )
    # do something for all Node packages
    ;;
  esac
}

install_package ...

Warnings

Many definitions leverage the before/after hooks for emitting warnings. In particular, for warning about node versions that are End-Of-Life or are in LTS-Maintenance mode (only receiving security patches).

Example:

before_install_package() {
  build_package_warn_lts_maintenance "$1"
}
Clone this wiki locally