summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--auto/modules/nodejs11
-rw-r--r--pkg/npm/Makefile5
-rw-r--r--src/nodejs/unit-http/package.json9
-rw-r--r--src/nodejs/unit-http/unit.h9
4 files changed, 26 insertions, 8 deletions
diff --git a/auto/modules/nodejs b/auto/modules/nodejs
index d140eff1..e0208f5d 100644
--- a/auto/modules/nodejs
+++ b/auto/modules/nodejs
@@ -123,6 +123,7 @@ fi
NXT_NODE_TMP=${NXT_BUILD_DIR}/src/${NXT_NODE}/unit-http
NXT_NODE_TARBALL=${NXT_BUILD_DIR}/${NXT_NODE}-unit-http.tar.gz
+NXT_NODE_VERSION_FILE=${NXT_NODE_TMP}/version.h
NXT_NODE_EXPORTS="export UNIT_SRC_PATH=${PWD}/src \
&& export UNIT_BUILD_PATH=${PWD}/${NXT_BUILD_DIR} \
&& export UNIT_LIB_STATIC_PATH=${PWD}/${NXT_BUILD_DIR}/libunit.a"
@@ -149,9 +150,15 @@ ${NXT_NODE}: ${NXT_NODE}-copy $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC
${NXT_NODE_EXPORTS} && \\
cd ${NXT_NODE_TMP} && ${NXT_NODE_GYP} configure build clean
-${NXT_NODE}-copy:
+${NXT_NODE}-copy: ${NXT_NODE_VERSION_FILE}
mkdir -p ${NXT_BUILD_DIR}/src/
- cp -rp src/nodejs/ ${NXT_BUILD_DIR}/src/${NXT_NODE}
+ cp -rp src/nodejs/* ${NXT_BUILD_DIR}/src/${NXT_NODE}
+
+${NXT_NODE_VERSION_FILE}: src/nxt_main.h
+ mkdir -p ${NXT_NODE_TMP}
+ $echo -n '#define NXT_NODE_VERNUM ' > $NXT_NODE_VERSION_FILE
+ grep 'define NXT_VERNUM' src/nxt_main.h \\
+ | sed -e 's/[^0-9]//g' >> $NXT_NODE_VERSION_FILE
${NXT_NODE_TARBALL}: ${NXT_NODE}-copy
tar -zcvf ${NXT_NODE_TARBALL} -C ${NXT_NODE_TMP} .
diff --git a/pkg/npm/Makefile b/pkg/npm/Makefile
index 2696c226..dfa9ccdc 100644
--- a/pkg/npm/Makefile
+++ b/pkg/npm/Makefile
@@ -3,7 +3,11 @@
DEFAULT_VERSION := $(shell grep 'define NXT_VERSION' ../../src/nxt_main.h \
| sed -e 's/^.*"\(.*\)".*/\1/')
+DEFAULT_VERNUM := $(shell grep 'define NXT_VERNUM' ../../src/nxt_main.h \
+ | sed -e 's/[^0-9]//g')
+
VERSION ?= $(DEFAULT_VERSION)
+VERNUM ?= $(DEFAULT_VERNUM)
NPM ?= npm
default:
@@ -11,6 +15,7 @@ default:
copy:
cp -rp ../../src/nodejs/unit-http .
+ echo '#define NXT_NODE_VERNUM ${VERNUM}' > unit-http/version.h
mv unit-http/binding_pub.gyp unit-http/binding.gyp
sed -e 's/"version"\s*:.*/"version": "${VERSION}.0",/' \
unit-http/package.json > unit-http/package.json.tmp
diff --git a/src/nodejs/unit-http/package.json b/src/nodejs/unit-http/package.json
index 6a2cd27c..13c91018 100644
--- a/src/nodejs/unit-http/package.json
+++ b/src/nodejs/unit-http/package.json
@@ -4,14 +4,15 @@
"description": "HTTP module for NGINX Unit",
"main": "http.js",
"files": [
+ "unit.h",
+ "version.h",
"addon.cpp",
- "binding.gyp",
- "http_server.js",
+ "unit.cpp",
"http.js",
+ "http_server.js",
"package.json",
"socket.js",
- "unit.cpp",
- "unit.h",
+ "binding.gyp",
"README.md"
],
"scripts": {
diff --git a/src/nodejs/unit-http/unit.h b/src/nodejs/unit-http/unit.h
index 5f541cc4..8baeb967 100644
--- a/src/nodejs/unit-http/unit.h
+++ b/src/nodejs/unit-http/unit.h
@@ -6,18 +6,23 @@
#ifndef _NXT_NODEJS_UNIT_H_INCLUDED_
#define _NXT_NODEJS_UNIT_H_INCLUDED_
-
#include <node_api.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include "version.h"
#include <nxt_unit.h>
+
+#if NXT_UNIT_VERNUM != NXT_NODE_VERNUM
+#error "libunit version mismatch."
+#endif
+
#include <nxt_unit_response.h>
#include <nxt_unit_request.h>
+
#ifdef __cplusplus
} /* extern "C" */
#endif