Improve gyp build - now works kind of
authorRyan Dahl <ry@tinyclouds.org>
Thu, 4 Aug 2011 23:40:07 +0000 (16:40 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Sat, 6 Aug 2011 10:12:06 +0000 (03:12 -0700)
.gitignore
gyp/all.gyp
src/macros.py [new file with mode: 0644]
src/node.cc
src/node_version.h

index 4d94a04..cd220fc 100644 (file)
@@ -17,5 +17,6 @@ gyp/all.Makefile
 gyp/js2c.host.mk
 gyp/node.target.mk
 gyp/node_js2c.host.mk
+gyp/node_js2c.target.mk
 out/
 Makefile
index f08afca..2a15f7c 100644 (file)
@@ -13,6 +13,8 @@
   'variables': {
     'v8_use_snapshot': 'true',
     'target_arch': 'x64',
+    'node_use_dtrace': 'false',
+    'node_use_openssl': 'true'
   },
 
   'targets': [
         '../deps/http_parser/http_parser.gyp:http_parser',
         '../deps/v8/tools/gyp/v8.gyp:v8',
         '../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': [
         '../src/cares_wrap.cc',
         '../src/handle_wrap.cc',
         '../src/stream_wrap.cc',
         '../src/tcp_wrap.cc',
         '../src/timer_wrap.cc',
+        '../src/process_wrap.cc',
+      ],
+
+      'defines': [
+        'ARCH="<(target_arch)"',
+        'PLATFORM="<(OS)"',
+        '_LARGEFILE_SOURCE',
+        '_FILE_OFFSET_BITS=64',
       ],
 
       'conditions': [
+        [ 'node_use_openssl=="true"', {
+          'libraries': [ '-lssl', '-lcrypto' ],
+          'defines': [ 'HAVE_OPENSSL=1' ]
+        }, {
+          'defines': [ 'HAVE_OPENSSL=0' ]
+        }],
+
         [ 'OS=="win"', {
           'defines': [
-            'PTW32_STATIC_LIB'
+            'PTW32_STATIC_LIB',
+            'FD_SETSIZE=1024'
           ],
           'libraries': [
             '-lws2_32',
@@ -65,6 +88,7 @@
             '../src/node_stdio_win32.cc'
           ]
         },{ # POSIX
+          'defines': [ '__POSIX__' ],
           'sources': [
             '../src/node_cares.cc',
             '../src/node_net.cc',
           ]
         }],
         [ 'OS=="mac"', {
-          'sources': [
-            '../src/platform_darwin.cc', 
-            '../src/platform_darwin_proctitle.cc'
-          ]
+          'sources': [ '../src/platform_darwin.cc' ],
+          'libraries': [ '-framework Carbon' ],
         }]
       ]
     },
           '../lib/vm.js',
         ],
       },
+
       'actions': [
         {
           'action_name': 'node_js2c',
+
           'inputs': [
             '../tools/js2c.py',
             '<@(library_files)',
           ],
+
           'outputs': [
             '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
           ],
-          'action': [
-            'python',
-            '../tools/js2c.py',
-            '<@(_outputs)',
-            '<@(library_files)'
-          ],
+
+          # FIXME can the following conditions be shorted by just setting
+          # macros.py into some variable which then gets included in the
+          # action?
+
+          '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
diff --git a/src/macros.py b/src/macros.py
new file mode 100644 (file)
index 0000000..0e03a16
--- /dev/null
@@ -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) = ;
index 413baf1..384d39a 100644 (file)
@@ -2068,8 +2068,10 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
   // process.version
   process->Set(String::NewSymbol("version"), String::New(NODE_VERSION));
 
+#ifdef NODE_PREFIX
   // process.installPrefix
   process->Set(String::NewSymbol("installPrefix"), String::New(NODE_PREFIX));
+#endif
 
   // process.moduleLoadList
   module_load_list = Persistent<Array>::New(Array::New());
@@ -2317,8 +2319,12 @@ static void ParseArgs(int argc, char **argv) {
       printf("%s\n", NODE_VERSION);
       exit(0);
     } else if (strcmp(arg, "--vars") == 0) {
+#ifdef NODE_PREFIX
       printf("NODE_PREFIX: %s\n", NODE_PREFIX);
+#endif
+#ifdef NODE_CFLAGS
       printf("NODE_CFLAGS: %s\n", NODE_CFLAGS);
+#endif
       exit(0);
     } else if (strstr(arg, "--max-stack-size=") == arg) {
       const char *p = 0;
index 5196c1c..bb2e901 100644 (file)
@@ -19,8 +19,9 @@
 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 // USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-
+#if 0 /* commenting out to build via gyp faster */
 #include "node_config.h"
+#endif
 
 #ifndef NODE_VERSION_H
 #define NODE_VERSION_H