Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

WIDL NAN Command Line Options

Kenny Yuan edited this page Sep 11, 2016 · 1 revision

List of WIDL-NAN Command-Line Options

./node_modules/widl-nan/bin/widl-nan.js -h

  Usage: widl-nan [options] [widl] [widl...]

  Options:

    -h, --help        output usage information
    -V, --version     output the version number
    -c, --clean       cleanup generated files under `gen` directory
    -d, --dest [dir]  destination directory of generated C++ code
    -i, --init        init the directory to make it ready for node-gyp build
    -o, --override    allow override C++ implementation files (those generated files without the 'nan__' prefix)

A few explanations

  • To build a Node.js addon, WIDL-NAN generate 3 sets of C++ files:
    1. Nan wrapper files: these files are named with nan__ (2 underbars) prefix, the number of them depends on the number of interfaces defined in *.widl files. e.g. for interface FooBar{}; the generated files would be gen/nan__foo_bar.h and gen/nan__foo_bar.cpp
    2. Implementation files: these files are name without nan__ prefix, there name suggest which interface they're implementing. e.g. for interface FooBar{}; the generated files would be gen/dont-build/foo_bar.h & gen/dont-build/foo_bar.cpp. These files are only with skeletons that are supposed to be filled up by developers. If there is -i/--init option specified, WIDL-NAN will copy these files under gen/dont-build/ into project root.
    3. Helper files, e.g. to make it easy to use Promise/Array/Dictionary/etc., there are a few helpers generated.
  • binding.gyp, addon.cpp & implementation files are necessary for node-gyp build/rebuild, those files will be always generated in gen/dont-build/ directory, and will be copied to project root if there is -i/--init option specified. The -i/--init option is supposed to use only once in most cases.
  • When the interface defined in *.widl files are changed, WIDL-NAN will overwrite NAN wrapper files in gen/ directory and gen/dont-build/ directory. Developers are expected to manually merge the difference between old implementation files & new implementation files (the generated skeletons for implementation files are always generated in gen/dont-build directory for developer's reference)
Clone this wiki locally