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

platform-tools

v0.3.1

Published

A toolchain to build and compile native dependencies with and for Node.

Downloads

9

Readme

platform-tools

A toolchain to build and compile native dependencies with and for Node.

Build Status Build status Join the chat at https://gitter.im/eljefedelrodeodeljefe/platform-tools

NPM

TL;DR

Compile C/C++ and native node addons with Node.js. Under the hood this is shelling out to gcc, clang and cl.exe in a similar way make does. To mitigate gyp and autotools dependencies node users (eventually) could use this.

Assume a file exit_with_1.c

int main(int argc, char const* argv[]) {
  return 1;
}

The below would be an example of emulating with Node.js

gcc -c exit_with_1
gcc -o exit_with_1.o
./exit_with_1
const platform_tools = require('platform-tools')
const spawn = require('child_process').spawn

let out = 'exit_with_1'
// first compile without linking
platform_tools.compile('exit_with_1.c', {output: `${out}.o`}, () => {
  // then link the object file (here an easy case)
  platform_tools.link(`${out}.o`, {output: out}, () => {
    // now execute the compiled binary and expect the C-program to end
    // with code 1
    const cp = spawn(out, [], {shell: true});
    cp.on('close', (code) => {
      assert(code === 1), 'Compiled binary exit_with_1 must exit with code 1')
    })
  })
})

Implementation Status

| Method | implemented | | --- | --- | | .compile(source [,options, cb]) | yes | | .compileAddon(source [,options, cb]) | yes | | .link(object [,options, cb]) | yes | | .config(library [,options, cb]) | yes |

Overview

(TBD)

Also this makes it easier for libarary authors and users, since compilation output will either be stored into a user specified location or by default into the current working directories build/ directory (precisely `${process.cwd()}/build`)

Technical Overview

Rquirements:

  • Node 4.5.0+
  • the default compiler for your system

Windows Users

Mote: since this repo wants to purposely increase Windows native addon usabilty please share if you have a hard time. However ue to the Microsoft inherent SDK and compiler strategy we need to assume prerequisites of you.

  • Windows SDK 10 standalone should be installed and in your %ProgramFiles(x86)%
  • Visual Studio 2015 should be installed and in your %ProgramFiles(x86)%

For background: To accomplish unix-like command-line behavior, e.g. gcc source_file.c -o source.exe && ./source.exe we need to assume the location of the most basic C/C++ headers in various locations on your Windows installation. The cl.exe binary does not assume any search paths on it's own, if it is not run through Visual Studio. Although that being quite a quirk for embedders and library authors, Windows compiler support is as good as Unix'.

Platform

This module is currently tested on:

| Platform | 0.10 | 0.12 | 4.0 | 5.0 | 6.0 | | --- | --- | --- | --- | ---| ---|---| | Mac OS X | - | - | yes | yes| yes | | BSDs| - | - | yes | yes| yes | | Linux | - | - | yes | yes | yes | | Windows | - | - | yes | yes | yes |

Roadmap

  • have more complex C/C++ files compile and link fully
  • ~~make native addons build~~
  • make node build
  • make v8 build
  • override values that the lib takes as assumption
  • gyp-file integration (chop-off comments and trailing commas -> then done?)
  • more sophisticated Windows search path fallbacks for not optimal installatons

API

PlatformTools

Kind: global class

platformTools.compile(source, cb) ⇒ Callback

Compiles a given source code file or array of files to the platforms object code.

Kind: instance method of PlatformTools

| Param | Type | Description | | --- | --- | --- | | source | String | Array.<String> | Path to source | | cb | function | Optional callback for completion |

platformTools.link(object, options, cb) ⇒ Callback

Links mutiple objects and libraries to a binary.

Kind: instance method of PlatformTools

| Param | Type | Description | | --- | --- | --- | | object | String | Array.<String> | Path for name of object code file | | options | Object | Options object | | cb | function | Optional callback |

platformTools.config(lib, cb) ⇒ Callback

Returns the necessary libraries to link against, similarly to pkg-config(1).

Kind: instance method of PlatformTools

| Param | Type | Description | | --- | --- | --- | | lib | String | Library to search dependencies against | | cb | function | Optional Callback upon completion |

platformTools.compileAddon(addonSrcFile, options, cb) ⇒ Callback

This method compiles node native addons end-to-end. Motivation behind this high level approach is past struggles with this technique, and especially different behaviors across platforms. Eventually this method should take care of all of the above. If the user has special cases, it is still possible to pass instructions via the options object and (item for roadmap) override certain common variables forcefully.

Kind: instance method of PlatformTools
Returns: Callback - returns optional callback

| Param | Type | Description | | --- | --- | --- | | addonSrcFile | String | Path to source file | | options | Object | Options object | | cb | function | |

License

MIT