npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

buildcheck

v0.0.6

Published

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

Downloads

11,039,340

Readme

Description

Build environment checking for node.js.

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

Note: Obsolete and/or exotic build environments or platforms not supported by node.js are not supported.

Requirements

  • node.js -- v10.0.0 or newer
  • Supported compilers:
    • gcc
    • clang
    • MSVC 2013+ and Windows SDK 8.1+

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.checkHeader('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

The exported value is 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. Note: this is ignored on Windows. Default: process.env.CC or 'cc'

    • compilerCXX - string - C++ compiler command to use. Note: this is ignored on Windows. Default: process.env.CXX or 'c++'

    • msvs_version - mixed - A string or number containing the year of the Visual Studio compiler to use. Note: this is for Windows only. Default: newest version installed

  • checkDeclared(< string >lang, < string >symbolName[, < object >options]) - boolean - Checks if a symbol symbolName is declared where lang is either 'c' or 'c++'. Returns true if symbol exists, false otherwise. options may contain:

    • headers - array - A list of headers to try when checking if the symbol is declared. checkFunction() will always first try without a library. If not supplied, a default list of common (platform-specific) headers will be used.

    • searchLibs - array - A list of library names (without the '-l' prefix) to try when checking if the symbol is declared. checkDeclared() will always first try without a library.

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

    • searchLibs - array - A list of library names (without the '-l' prefix) to try when checking for this function. checkFunction() will always first try without a library.
  • checkFeature(< string >featureName) - mixed - Executes a special test for a "feature" and returns the result. Supported values for featureName:

    • 'strerror_r' - Returns an object containing:

      • declared - boolean - Whether strerror_r() is declared

      • returnsCharPtr - boolean - If strerror_r() is declared, whether it returns char* (a GNU extension) or not.

  • checkHeader(< string >lang, < string >headerName) - boolean - Checks if the header headerName exists and is usable where lang is either 'c' or 'c++'. Returns true if the header exists and is usable, false otherwise.

  • defines([< string >lang[, < boolean >rendered]]) - array - Returns a list of features, functions, headers, and symbols known to be defined by this build environment instance. lang is either 'c' or 'c++' If lang is not set, defines for both 'c' and 'c++' will be returned. If rendered is true (defaults to false), autoconf-style defines (e.g. "HAVE_FOO=1") will be returned instead. Defines coming from features utilize base strings/names from autoconf for better compatibility.

  • libs([< string >lang]) - array - Returns a list of ('-l'-prefixed) libraries known to be required for features and functions defined by this build environment instance. lang is either 'c' or 'c++' If lang is not set, defines for both 'c' and 'c++' will be returned.

  • 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.