gypjs
v0.0.1
Published
Build tool for C/C++
Downloads
3
Readme
gyp.js
Node.js native addon build tool
gyp.js
is a fork for node-gyp
a cross-platform command-line tool written in Node.js for compiling
native addon modules for Node.js.
The goal of gyp.js
is provide an easy-to-use build tool for C/C++ developers for various platforms.
Features:
- Easy to use, consistent interface
- Same commands to build your module on every platform
Installation
You can install with npm
:
$ npm install -g gypjs
You will also need to install:
- On Unix:
python
(v2.7
recommended,v3.x.x
is not supported)make
- A proper C/C++ compiler toolchain, like GCC
- On Windows:
- [Python][windows-python] ([
v2.7.3
][windows-python-v2.7.3] recommended,v3.x.x
is not supported) - Windows XP/Vista/7:
- Microsoft Visual Studio C++ 2010 ([Express][msvc2010] version works well)
- For 64-bit builds of node and native modules you will also need the [Windows 7 64-bit SDK][win7sdk]
- If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first.
- If you get errors that the 64-bit compilers are not installed you may also need the [compiler update for the Windows SDK 7.1]
- Windows 7/8:
- Microsoft Visual Studio C++ 2012 for Windows Desktop ([Express][msvc2012] version works well)
- [Python][windows-python] ([
If you have multiple Python versions installed, you can identify which Python
version gyp.js
uses by setting the '--python' variable:
$ gypjs --python /path/to/python2.7
If gyp.js
is called by way of npm
and you have multiple versions of
Python installed, then you can set npm
's 'python' config key to the appropriate
value:
$ npm config set python /path/to/executable/python2.7
Note that OS X is just a flavour of Unix and so needs python
, make
, and C/C++.
An easy way to obtain these is to install XCode from Apple,
and then use it to install the command line tools (under Preferences -> Downloads).
Examples
Hello world!
Let's make a "Hello world!" executable console in C and build it.
Write a package.gyp
file with this content:
{
'targets': [
{
'target_name': 'hello',
'type': 'executable',
'sources': [
'hello.c',
],
},
],
}
Write a hello.c
file with this content:
#include <stdio.h>
int main(void)
{
printf("Hello, world!\n");
return 0;
}
The next step is to generate the appropriate project build files for the current
platform. Use configure
for that:
$ gypjs configure
Note: The configure
step looks for the package.gyp
file in the current
directory to processs. See below for instructions on creating the package.gyp
file.
Now you will have either a Makefile
(on Unix platforms) or a vcxproj
file
(on Windows) in the build/
directory. Next invoke the build
command:
$ gypjs build
Now, you can find our executable file in build/Release/
.