New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

buildcheck

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buildcheck

Build environment checking (a la autoconf) for node.js

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1M
increased by0.32%
Maintainers
1
Weekly downloads
 
Created
Source

Description

Build environment checking for node.js.

This allows for autoconf-like functionality for node addons/build scripts.

Requirements

  • node.js -- v10.0.0 or newer
  • gcc or clang

Installation

npm install buildcheck

Examples

Check if a C function exists

'use strict';

const { BuildEnvironment } = require('buildcheck');

const buildEnv = new BuildEnvironment();

console.log(buildEnv.checkFunction('c', 'preadv2'));

Check if a C header is usable

'use strict';

const { BuildEnvironment } = require('buildcheck');

const buildEnv = new BuildEnvironment();

console.log(buildEnv.checkHeaders('c', ['linux/io_uring.h']));

Try to compile some C code

'use strict';

const { BuildEnvironment } = require('buildcheck');

const buildEnv = new BuildEnvironment();

// Should be a successful compile
console.log(buildEnv.tryCompile('c', 'int main() { return 0; }'));

// Should be a failed compile
console.log(buildEnv.tryCompile('c', 'int main() { return z; }'));

API

Exports

  • BuildEnvironment - The main class for dealing with a build environment.

BuildEnvironment

Methods
  • (constructor)([< object >config]) - Creates and returns a new BuildEnvironment instance. config may contain:

    • compilerC - string - C compiler command to use. Default: process.env.CC or 'cc'

    • compilerCPP - string - C++ compiler command to use. Default: process.env.CXX or 'c++'

  • checkFunction(< string >lang, < string >functionName[, < object >options]) - boolean - Checks if functionName exists and is linkable where lang is either 'c' or 'c++'. Returns true if function exists, false otherwise. options may contain:

    • headers - array - List of header names to include when testing for function availability. Surround header names with double quotes to get a result like #include "foo.h".

    • compilerParams - array - A list of compiler/linker flags to include when testing.

  • checkHeaders(< string >lang, < array >headerNames[, < array >compilerParams]) - boolean - Checks if the headers in headerNames exist and are usable where lang is either 'c' or 'c++'. compilerParams is an optional list of compiler/linker flags to include when testing. Returns true if the headers exist and are usable, false otherwise.

  • tryCompile(< string >lang, < string >code[, < array >compilerParams]) - mixed - Attempts to compile code where lang is either 'c' or 'c++'. compilerParams is an optional array of compiler/linker flags to include. Returns true on successful compilation, or an Error instance with an output property containing the compiler error output.

Keywords

FAQs

Package last updated on 13 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc