Node.js: added check for libunit version at compile time.
This commit is contained in:
@@ -123,6 +123,7 @@ fi
|
|||||||
|
|
||||||
NXT_NODE_TMP=${NXT_BUILD_DIR}/src/${NXT_NODE}/unit-http
|
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_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 \
|
NXT_NODE_EXPORTS="export UNIT_SRC_PATH=${PWD}/src \
|
||||||
&& export UNIT_BUILD_PATH=${PWD}/${NXT_BUILD_DIR} \
|
&& export UNIT_BUILD_PATH=${PWD}/${NXT_BUILD_DIR} \
|
||||||
&& export UNIT_LIB_STATIC_PATH=${PWD}/${NXT_BUILD_DIR}/libunit.a"
|
&& 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} && \\
|
${NXT_NODE_EXPORTS} && \\
|
||||||
cd ${NXT_NODE_TMP} && ${NXT_NODE_GYP} configure build clean
|
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/
|
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
|
${NXT_NODE_TARBALL}: ${NXT_NODE}-copy
|
||||||
tar -zcvf ${NXT_NODE_TARBALL} -C ${NXT_NODE_TMP} .
|
tar -zcvf ${NXT_NODE_TARBALL} -C ${NXT_NODE_TMP} .
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
DEFAULT_VERSION := $(shell grep 'define NXT_VERSION' ../../src/nxt_main.h \
|
DEFAULT_VERSION := $(shell grep 'define NXT_VERSION' ../../src/nxt_main.h \
|
||||||
| sed -e 's/^.*"\(.*\)".*/\1/')
|
| sed -e 's/^.*"\(.*\)".*/\1/')
|
||||||
|
|
||||||
|
DEFAULT_VERNUM := $(shell grep 'define NXT_VERNUM' ../../src/nxt_main.h \
|
||||||
|
| sed -e 's/[^0-9]//g')
|
||||||
|
|
||||||
VERSION ?= $(DEFAULT_VERSION)
|
VERSION ?= $(DEFAULT_VERSION)
|
||||||
|
VERNUM ?= $(DEFAULT_VERNUM)
|
||||||
NPM ?= npm
|
NPM ?= npm
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -11,6 +15,7 @@ default:
|
|||||||
|
|
||||||
copy:
|
copy:
|
||||||
cp -rp ../../src/nodejs/unit-http .
|
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
|
mv unit-http/binding_pub.gyp unit-http/binding.gyp
|
||||||
sed -e 's/"version"\s*:.*/"version": "${VERSION}.0",/' \
|
sed -e 's/"version"\s*:.*/"version": "${VERSION}.0",/' \
|
||||||
unit-http/package.json > unit-http/package.json.tmp
|
unit-http/package.json > unit-http/package.json.tmp
|
||||||
|
|||||||
@@ -4,14 +4,15 @@
|
|||||||
"description": "HTTP module for NGINX Unit",
|
"description": "HTTP module for NGINX Unit",
|
||||||
"main": "http.js",
|
"main": "http.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
"unit.h",
|
||||||
|
"version.h",
|
||||||
"addon.cpp",
|
"addon.cpp",
|
||||||
"binding.gyp",
|
"unit.cpp",
|
||||||
"http_server.js",
|
|
||||||
"http.js",
|
"http.js",
|
||||||
|
"http_server.js",
|
||||||
"package.json",
|
"package.json",
|
||||||
"socket.js",
|
"socket.js",
|
||||||
"unit.cpp",
|
"binding.gyp",
|
||||||
"unit.h",
|
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -6,18 +6,23 @@
|
|||||||
#ifndef _NXT_NODEJS_UNIT_H_INCLUDED_
|
#ifndef _NXT_NODEJS_UNIT_H_INCLUDED_
|
||||||
#define _NXT_NODEJS_UNIT_H_INCLUDED_
|
#define _NXT_NODEJS_UNIT_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#include <node_api.h>
|
#include <node_api.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
#include <nxt_unit.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_response.h>
|
||||||
#include <nxt_unit_request.h>
|
#include <nxt_unit_request.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user