bare-make
Opinionated build system generator based on CMake
bare-make — Opinionated build system generator based on CMake.
npm i bare-makeUsage
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 installTesting
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 testAPI
errors
new errors(msg: string, code: string, fn?: MakeError)
Source
Construct a MakeError with the given message and code.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
code | string | — | The error code, assigned to err.code. |
fn? | MakeError | — | The 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
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
errors.GENERATE_FAILED(msg: string): MakeError
Source
Create a MakeError with code 'GENERATE_FAILED'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
errors.INSTALL_FAILED(msg: string): MakeError
Source
Create a MakeError with code 'INSTALL_FAILED'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
errors.TEST_FAILED(msg: string): MakeError
Source
Create a MakeError with code 'TEST_FAILED'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
errors.UNKNOWN_TOOLCHAIN(msg: string): MakeError
Source
Create a MakeError with code 'UNKNOWN_TOOLCHAIN'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
Functions
build(opts?: BuildOptions): Promise<void>
Source
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | BuildOptions | — | Options; 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
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | GenerateOptions | — | Options; 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 resolvedplatform-archtarget.GENERATE_FAILED— build system generation exits with a non-zero status.
install(opts?: InstallOptions): Promise<void>
Source
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | InstallOptions | — | Options; 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
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | TestOptions | — | Options; 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
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
code | string | — | The error code, assigned to err.code. |
fn? | MakeError | — | The 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
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
MakeError.GENERATE_FAILED(msg: string): MakeError
Source
Create a MakeError with code 'GENERATE_FAILED'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
MakeError.INSTALL_FAILED(msg: string): MakeError
Source
Create a MakeError with code 'INSTALL_FAILED'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
MakeError.TEST_FAILED(msg: string): MakeError
Source
Create a MakeError with code 'TEST_FAILED'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
MakeError.UNKNOWN_TOOLCHAIN(msg: string): MakeError
Source
Create a MakeError with code 'UNKNOWN_TOOLCHAIN'.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | string | — | Human-readable error message. |
bare-make/build
Functions
build.build(opts?: BuildOptions): Promise<void>
Source
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | BuildOptions | — | Options; 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
}Options for build().
bare-make/generate
Functions
generate.generate(opts?: GenerateOptions): Promise<void>
Source
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | GenerateOptions | — | Options; 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 resolvedplatform-archtarget.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
}Options for generate().
bare-make/install
Functions
install.install(opts?: InstallOptions): Promise<void>
Source
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | InstallOptions | — | Options; 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
}Options for install().
bare-make/test
Functions
test.test(opts?: TestOptions): Promise<void>
Source
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
opts? | TestOptions | — | Options; 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
}Options for test().
See also
- Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.