build: allow to specify custom tags
authorMaciej Małecki <me@mmalecki.com>
Fri, 21 Dec 2012 01:56:47 +0000 (02:56 +0100)
committerisaacs <i@izs.me>
Thu, 27 Dec 2012 04:15:17 +0000 (20:15 -0800)
When building custom `node` versions (e.g., floating features/fixes from
different versions) it's often useful to specify a custom tag which
easily identifies build when invoking `node -v`.

Introduce a way to specify this tag in `node_version.h` file or by
running `./configure --tag="<tag>"`. Insert it right after the patch
version (and before `-pre`, if build is not a release).

configure
node.gyp
src/node_version.h

index 7211682..aa8c998 100755 (executable)
--- a/configure
+++ b/configure
@@ -182,6 +182,11 @@ parser.add_option("--unsafe-optimizations",
     dest="unsafe_optimizations",
     help=optparse.SUPPRESS_HELP)
 
+parser.add_option("--tag",
+    action="store",
+    dest="tag",
+    help="Custom build tag")
+
 (options, args) = parser.parse_args()
 
 
@@ -394,6 +399,11 @@ def configure_node(o):
   else:
     o['variables']['node_use_etw'] = 'false'
 
+  if options.tag:
+    o['variables']['node_tag'] = '-' + options.tag
+  else:
+    o['variables']['node_tag'] = ''
+
 
 def configure_libz(o):
   o['variables']['node_shared_zlib'] = b(options.shared_zlib)
index 82af2fe..2473879 100644 (file)
--- a/node.gyp
+++ b/node.gyp
         'NODE_WANT_INTERNALS=1',
         'ARCH="<(target_arch)"',
         'PLATFORM="<(OS)"',
+        'NODE_TAG="<(node_tag)"',
       ],
 
       'conditions': [
index 7ba88b3..c611332 100644 (file)
 #define NODE_MAJOR_VERSION 0
 #define NODE_MINOR_VERSION 8
 #define NODE_PATCH_VERSION 17
+
+#ifndef NODE_TAG
+# define NODE_TAG ""
+#endif
+
 #define NODE_VERSION_IS_RELEASE 0
 
 #ifndef NODE_STRINGIFY
 #if NODE_VERSION_IS_RELEASE
 # define NODE_VERSION_STRING  NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \
                               NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
-                              NODE_STRINGIFY(NODE_PATCH_VERSION)
+                              NODE_STRINGIFY(NODE_PATCH_VERSION)     \
+                              NODE_TAG
 #else
 # define NODE_VERSION_STRING  NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \
                               NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
-                              NODE_STRINGIFY(NODE_PATCH_VERSION) "-pre"
+                              NODE_STRINGIFY(NODE_PATCH_VERSION)     \
+                              NODE_TAG "-pre"
 #endif
 
 #define NODE_VERSION "v" NODE_VERSION_STRING