Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Improve gyp build - now works kind of
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 6, 2011
1 parent f55f478 commit a979ab9
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,5 +17,6 @@ gyp/all.Makefile
gyp/js2c.host.mk gyp/js2c.host.mk
gyp/node.target.mk gyp/node.target.mk
gyp/node_js2c.host.mk gyp/node_js2c.host.mk
gyp/node_js2c.target.mk
out/ out/
Makefile Makefile
68 changes: 55 additions & 13 deletions gyp/all.gyp
Expand Up @@ -13,6 +13,8 @@
'variables': { 'variables': {
'v8_use_snapshot': 'true', 'v8_use_snapshot': 'true',
'target_arch': 'x64', 'target_arch': 'x64',
'node_use_dtrace': 'false',
'node_use_openssl': 'true'
}, },


'targets': [ 'targets': [
Expand All @@ -24,9 +26,14 @@
'../deps/http_parser/http_parser.gyp:http_parser', '../deps/http_parser/http_parser.gyp:http_parser',
'../deps/v8/tools/gyp/v8.gyp:v8', '../deps/v8/tools/gyp/v8.gyp:v8',
'../deps/uv/build/all.gyp:uv', '../deps/uv/build/all.gyp:uv',
'node_js2c#host' 'node_js2c#host',
], ],
'include_dirs': [ 'src' ],
'include_dirs': [
'../src',
'<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
],

'sources': [ 'sources': [
'../src/cares_wrap.cc', '../src/cares_wrap.cc',
'../src/handle_wrap.cc', '../src/handle_wrap.cc',
Expand All @@ -48,12 +55,28 @@
'../src/stream_wrap.cc', '../src/stream_wrap.cc',
'../src/tcp_wrap.cc', '../src/tcp_wrap.cc',
'../src/timer_wrap.cc', '../src/timer_wrap.cc',
'../src/process_wrap.cc',
],

'defines': [
'ARCH="<(target_arch)"',
'PLATFORM="<(OS)"',
'_LARGEFILE_SOURCE',
'_FILE_OFFSET_BITS=64',
], ],


'conditions': [ 'conditions': [
[ 'node_use_openssl=="true"', {
'libraries': [ '-lssl', '-lcrypto' ],
'defines': [ 'HAVE_OPENSSL=1' ]
}, {
'defines': [ 'HAVE_OPENSSL=0' ]
}],

[ 'OS=="win"', { [ 'OS=="win"', {
'defines': [ 'defines': [
'PTW32_STATIC_LIB' 'PTW32_STATIC_LIB',
'FD_SETSIZE=1024'
], ],
'libraries': [ 'libraries': [
'-lws2_32', '-lws2_32',
Expand All @@ -65,6 +88,7 @@
'../src/node_stdio_win32.cc' '../src/node_stdio_win32.cc'
] ]
},{ # POSIX },{ # POSIX
'defines': [ '__POSIX__' ],
'sources': [ 'sources': [
'../src/node_cares.cc', '../src/node_cares.cc',
'../src/node_net.cc', '../src/node_net.cc',
Expand All @@ -77,10 +101,8 @@
] ]
}], }],
[ 'OS=="mac"', { [ 'OS=="mac"', {
'sources': [ 'sources': [ '../src/platform_darwin.cc' ],
'../src/platform_darwin.cc', 'libraries': [ '-framework Carbon' ],
'../src/platform_darwin_proctitle.cc'
]
}] }]
] ]
}, },
Expand Down Expand Up @@ -135,22 +157,42 @@
'../lib/vm.js', '../lib/vm.js',
], ],
}, },

'actions': [ 'actions': [
{ {
'action_name': 'node_js2c', 'action_name': 'node_js2c',

'inputs': [ 'inputs': [
'../tools/js2c.py', '../tools/js2c.py',
'<@(library_files)', '<@(library_files)',
], ],

'outputs': [ 'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/node_natives.h', '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
], ],
'action': [
'python', # FIXME can the following conditions be shorted by just setting
'../tools/js2c.py', # macros.py into some variable which then gets included in the
'<@(_outputs)', # action?
'<@(library_files)'
], 'conditions': [
[ 'node_use_dtrace=="true"', {
'action': [
'python',
'../tools/js2c.py',
'<@(_outputs)',
'<@(library_files)'
],
}, { # No Dtrace
'action': [
'python',
'../tools/js2c.py',
'<@(_outputs)',
'<@(library_files)',
'../src/macros.py'
],
}]
]
}, },
], ],
}, # end node_js2c }, # end node_js2c
Expand Down
11 changes: 11 additions & 0 deletions src/macros.py
@@ -0,0 +1,11 @@
# This file is used by tools/js2c.py to preprocess out the DTRACE symbols in
# builds that don't support DTrace. This is not used in builds that support
# DTrace.
macro DTRACE_HTTP_CLIENT_REQUEST(x) = ;
macro DTRACE_HTTP_CLIENT_RESPONSE(x) = ;
macro DTRACE_HTTP_SERVER_REQUEST(x) = ;
macro DTRACE_HTTP_SERVER_RESPONSE(x) = ;
macro DTRACE_NET_SERVER_CONNECTION(x) = ;
macro DTRACE_NET_STREAM_END(x) = ;
macro DTRACE_NET_SOCKET_READ(x) = ;
macro DTRACE_NET_SOCKET_WRITE(x) = ;
6 changes: 6 additions & 0 deletions src/node.cc
Expand Up @@ -2068,8 +2068,10 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
// process.version // process.version
process->Set(String::NewSymbol("version"), String::New(NODE_VERSION)); process->Set(String::NewSymbol("version"), String::New(NODE_VERSION));


#ifdef NODE_PREFIX
// process.installPrefix // process.installPrefix
process->Set(String::NewSymbol("installPrefix"), String::New(NODE_PREFIX)); process->Set(String::NewSymbol("installPrefix"), String::New(NODE_PREFIX));
#endif


// process.moduleLoadList // process.moduleLoadList
module_load_list = Persistent<Array>::New(Array::New()); module_load_list = Persistent<Array>::New(Array::New());
Expand Down Expand Up @@ -2317,8 +2319,12 @@ static void ParseArgs(int argc, char **argv) {
printf("%s\n", NODE_VERSION); printf("%s\n", NODE_VERSION);
exit(0); exit(0);
} else if (strcmp(arg, "--vars") == 0) { } else if (strcmp(arg, "--vars") == 0) {
#ifdef NODE_PREFIX
printf("NODE_PREFIX: %s\n", NODE_PREFIX); printf("NODE_PREFIX: %s\n", NODE_PREFIX);
#endif
#ifdef NODE_CFLAGS
printf("NODE_CFLAGS: %s\n", NODE_CFLAGS); printf("NODE_CFLAGS: %s\n", NODE_CFLAGS);
#endif
exit(0); exit(0);
} else if (strstr(arg, "--max-stack-size=") == arg) { } else if (strstr(arg, "--max-stack-size=") == arg) {
const char *p = 0; const char *p = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/node_version.h
Expand Up @@ -19,8 +19,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE. // USE OR OTHER DEALINGS IN THE SOFTWARE.



#if 0 /* commenting out to build via gyp faster */
#include "node_config.h" #include "node_config.h"

This comment has been minimized.

Copy link
@marook

marook Aug 23, 2011

'$ node --vars' doesen't report NODE_PREFIX and NODE_CFLAGS when 'node_config.h' is not included. NODE_PREFIX and NODE_CFLAGS not set causes my '$ npm install libxmljs' build to fail because i've installed node to ~/.local.

maybe the '#if 0' should be removed?

#endif


#ifndef NODE_VERSION_H #ifndef NODE_VERSION_H
#define NODE_VERSION_H #define NODE_VERSION_H
Expand Down

0 comments on commit a979ab9

Please sign in to comment.