Permalink
Browse files

OS-1846 platform node executes proto code during build

  • Loading branch information...
1 parent b9cadd2 commit 24adcab1674b7a2d1a3214fcc09df5f87c5b667e @wesolows wesolows committed Jan 31, 2013
Showing with 55 additions and 58 deletions.
  1. +5 −0 Makefile.defs
  2. +21 −14 node.js/Makefile
  3. +0 −44 node.js/build_require_platform_node_version.sh
  4. +29 −0 node.js/genversionjs.c
View
@@ -36,6 +36,11 @@ GXX = $(DESTDIR)/usr/bin/g++
GCC.64 = $(GCC) -m64
GXX.64 = $(GXX) -m64
+GCC.host = /opt/local/bin/gcc
+GXX.host = /opt/local/bin/g++
+GCC.host.64 = $(GCC.host) -m64
+GXX.host.64 = $(GXX.host) -m64
+
SYSINCDIRS = /usr/include
SYSLIBDIRS = /usr/lib /lib
View
@@ -26,6 +26,9 @@ VER = node-v0.8.14
include ../Makefile.defs
+NODE_ROOT = $(DESTDIR)/usr/node/$(MAJOR_VER)
+VERSIONJS = $(NODE_ROOT)/node_modules/platform_node_version.js
+
CFLAGS += -Wno-unknown-pragmas
#
@@ -65,30 +68,34 @@ AUTOCONF_ENV += CXXFLAGS="$(CPPFLAGS) $(CFLAGS)"
# patch to the python configure program is also required to make this work.
#
AUTOCONF_ENV += LDFLAGS.host="-Wl,-i"
-AUTOCONF_ENV += CXX.host="/opt/local/bin/g++"
-AUTOCONF_ENV += CC.host="/opt/local/bin/gcc"
-AUTOCONF_ENV += CXX_host="/opt/local/bin/g++"
-AUTOCONF_ENV += CC_host="/opt/local/bin/gcc"
-AUTOCONF_ENV += LINK.host="/opt/local/bin/g++"
+AUTOCONF_ENV += CXX.host="$(GXX.host)"
+AUTOCONF_ENV += CC.host="$(GCC.host)"
+AUTOCONF_ENV += CXX_host="$(GXX.host)"
+AUTOCONF_ENV += CC_host="$(GCC.host)"
+AUTOCONF_ENV += LINK.host="$(GXX.host)"
OVERRIDES += $(AUTOCONF_ENV)
AUTOCONF_OUT = build/default/config.h
PATCHES = Patches/*
+CLEANFILES += genversionjs
all: all_autoconf
+#
+# We build a host tool against the installed header so that we can spew a
+# JavaScript file containing the version of the installed node.js binary.
+#
+genversionjs: genversionjs.c install_autoconf
+ $(GCC.host) -o $@ -include $(NODE_ROOT)/include/node/node_version.h $<
+
# - platform_node_version.js is autogenerated with the current node version
# - we move man pages as we want them in /usr/node/0.8/man
-install: install_autoconf
- mkdir -p $(DESTDIR)/usr/node/$(MAJOR_VER)/node_modules
- ./build_require_platform_node_version.sh \
- $(DESTDIR) \
- $(DESTDIR)/usr/node/$(MAJOR_VER)/bin/node \
- $(DESTDIR)/usr/node/$(MAJOR_VER)/node_modules/platform_node_version.js
- rm -rf $(DESTDIR)/usr/node/$(MAJOR_VER)/man
- mv $(DESTDIR)/usr/node/$(MAJOR_VER)/share/man \
- $(DESTDIR)/usr/node/$(MAJOR_VER)/
+install: install_autoconf genversionjs
+ mkdir -p $(NODE_ROOT)/node_modules
+ ./genversionjs > $(VERSIONJS)
+ rm -rf $(NODE_ROOT)/man
+ mv $(NODE_ROOT)/share/man $(NODE_ROOT)/
include ../Makefile.targ
@@ -1,44 +0,0 @@
-#!/usr/bin/bash
-#
-# Copyright (c) 2012 Joyent Inc., All rights reserved.
-#
-
-set -o errexit
-set -o pipefail
-
-DESTDIR=$1
-NODE=$2
-OUT=$3
-
-if [[ -z ${NODE} || ! -x ${NODE} || -z ${OUT} || -n $4 ]]; then
- echo "Usage: $0 <proto> <node> <output>" >&2
- exit 1
-fi
-
-VER=$(LD_LIBRARY_PATH=${DESTDIR}/lib:${DESTDIR}/usr/lib \
- ${NODE} -e 'console.log(process.version)')
-
-cat >${OUT} <<EOF
-// This file was autogenerated, do not edit manually.
-//
-// Copyright (c) 2012 Joyent Inc., All rights reserved.
-//
-
-var required_version='${VER}';
-var util = require('util');
-
-exports.assert = function () {
- // this allows overriding for development
- if (process.env.DISABLE_NODE_VERSION_CHECK) {
- return;
- }
- if (process.version !== required_version) {
- throw new Error(util.format('You must be running node %s to use this '
- + 'platform library. You are currently using version %s '
- + '("%s %s ...").', required_version, process.version,
- process.execPath, process.argv[1]));
- }
-};
-EOF
-
-exit 0
View
@@ -0,0 +1,29 @@
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+ /* CSTYLED */
+ static const char *version_js =
+"// This file was autogenerated, do not edit manually.\n"
+"//\n"
+"// Copyright (c) 2013 Joyent Inc., All rights reserved.\n"
+"//\n\n"
+"var required_version='%s';\n"
+"var util = require('util');\n\n"
+"exports.assert = function () {\n"
+"\t// this allows overriding for development\n"
+"\tif (process.env.DISABLE_NODE_VERSION_CHECK) {\n"
+"\t\treturn;\n"
+"\t}\n"
+"\tif (process.version !== required_version) {\n"
+"\t\tthrow new Error(util.format('You must be running node %%s to use this '\n"
+"\t\t + 'platform library. You are currently using version %%s '\n"
+"\t\t + '(\"%%s %%s ...\").', required_version, process.version,\n"
+"\t\t process.execPath, process.argv[1]));\n"
+"\t}\n"
+"};\n";
+
+ (void) printf(version_js, NODE_VERSION);
+ return (0);
+}

0 comments on commit 24adcab

Please sign in to comment.