LogoPear Docs
ReferencesBareModules

bare-make

Opinionated build system generator based on CMake

stable

bare-make — Opinionated build system generator based on CMake.

npm i bare-make

Usage

Like CMake, builds happen in three steps: You first generate a build system, then run the build system, and finally install the built artefacts. To perform the steps programmatically from JavaScript, do:

const make = require('bare-make')

await make.generate()
await make.build()
await make.install()

The steps can also be performed interactively from the command line using the included CLI:

bare-make generate
bare-make build
bare-make install

Testing

To run tests for projects that use enable_testing() and add_test(), do:

await make.test()

Tests can also be run from the command line:

bare-make test

API

errors

new errors(msg: string, code: string, fn?: MakeError)

Source

Construct a MakeError with the given message and code.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.
codestringThe error code, assigned to err.code.
fn?MakeErrorThe function to omit from the captured stack trace (default the MakeError constructor).

errors.BUILD_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'BUILD_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

errors.GENERATE_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'GENERATE_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

errors.INSTALL_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'INSTALL_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

errors.TEST_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'TEST_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

errors.UNKNOWN_TOOLCHAIN(msg: string): MakeError

Source

Create a MakeError with code 'UNKNOWN_TOOLCHAIN'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

Functions

build(opts?: BuildOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?BuildOptionsOptions; build defaults to 'build' (unset when preset is set), parallel to 0, and clean and verbose to false.

Throws

  • BUILD_FAILED — the build exits with a non-zero status.

generate(opts?: GenerateOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?GenerateOptionsOptions; source defaults to '.', build to 'build', platform and arch to the host, cache to true, and the build-type flags (debug, fuzz, withDebugSymbols, withMinimalSize, verbose) to false.

Throws

  • UNKNOWN_TOOLCHAIN — no toolchain is available for the resolved platform-arch target.
  • GENERATE_FAILED — build system generation exits with a non-zero status.

install(opts?: InstallOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?InstallOptionsOptions; build defaults to 'build', prefix to 'prebuilds', and link, strip, and verbose to false.

Throws

  • INSTALL_FAILED — the install exits with a non-zero status.

test(opts?: TestOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?TestOptionsOptions; build defaults to 'build', timeout to 30 seconds, parallel to -1, and verbose to false.

Throws

  • TEST_FAILED — one or more tests fail.

bare-make/errors

MakeError

new MakeError(msg: string, code: string, fn?: MakeError)

Source

Construct a MakeError with the given message and code.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.
codestringThe error code, assigned to err.code.
fn?MakeErrorThe function to omit from the captured stack trace (default the MakeError constructor).

MakeError.BUILD_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'BUILD_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

MakeError.GENERATE_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'GENERATE_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

MakeError.INSTALL_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'INSTALL_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

MakeError.TEST_FAILED(msg: string): MakeError

Source

Create a MakeError with code 'TEST_FAILED'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

MakeError.UNKNOWN_TOOLCHAIN(msg: string): MakeError

Source

Create a MakeError with code 'UNKNOWN_TOOLCHAIN'.

Parameters

ParameterTypeDefaultDescription
msgstringHuman-readable error message.

bare-make/build

Functions

build.build(opts?: BuildOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?BuildOptionsOptions; build defaults to 'build' (unset when preset is set), parallel to 0, and clean and verbose to false.

Throws

  • BUILD_FAILED — the build exits with a non-zero status.

Types

BuildOptions

interface BuildOptions {
  build?: string
  clean?: boolean
  cwd?: string
  parallel?: number
  preset?: string
  stdio?: Pipe
  target?: string
  verbose?: boolean
}
Source

Options for build().

bare-make/generate

Functions

generate.generate(opts?: GenerateOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?GenerateOptionsOptions; source defaults to '.', build to 'build', platform and arch to the host, cache to true, and the build-type flags (debug, fuzz, withDebugSymbols, withMinimalSize, verbose) to false.

Throws

  • UNKNOWN_TOOLCHAIN — no toolchain is available for the resolved platform-arch target.
  • GENERATE_FAILED — build system generation exits with a non-zero status.

Types

GenerateOptions

interface GenerateOptions {
  arch?: string
  build?: string
  cache?: boolean
  cwd?: string
  debug?: boolean
  define?: string[]
  environment?: string
  fuzz?: boolean
  platform?: string
  preset?: string
  sanitize?: string
  simulator?: boolean
  source?: string
  stdio?: Pipe
  verbose?: boolean
  withDebugSymbols?: boolean
  withMinimalSize?: boolean
}
Source

Options for generate().

bare-make/install

Functions

install.install(opts?: InstallOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?InstallOptionsOptions; build defaults to 'build', prefix to 'prebuilds', and link, strip, and verbose to false.

Throws

  • INSTALL_FAILED — the install exits with a non-zero status.

Types

InstallOptions

interface InstallOptions {
  build?: string
  component?: string
  cwd?: string
  link?: boolean
  parallel?: boolean
  prefix?: string
  stdio?: Pipe
  strip?: boolean
  verbose?: boolean
}
Source

Options for install().

bare-make/test

Functions

test.test(opts?: TestOptions): Promise<void>

Source

Parameters

ParameterTypeDefaultDescription
opts?TestOptionsOptions; build defaults to 'build', timeout to 30 seconds, parallel to -1, and verbose to false.

Throws

  • TEST_FAILED — one or more tests fail.

Types

TestOptions

interface TestOptions {
  build?: string
  cwd?: string
  parallel?: number
  preset?: string
  stdio?: Pipe
  timeout?: number
  verbose?: boolean
}
Source

Options for test().

See also

On this page