Browse Source

Add command line arguments for accessing build flags.

node --cflags
node --libs

At the expense of some WAF nastiness.
v0.7.4-release
Ryan 16 years ago
parent
commit
b73264d9b3
  1. 22
      src/node.cc
  2. 3
      src/node.h
  3. 3
      src/node_version.h.in
  4. 26
      wscript

22
src/node.cc

@ -300,11 +300,18 @@ PrintHelp ( )
static void static void
ParseArgs (int *argc, char **argv) ParseArgs (int *argc, char **argv)
{ {
bool cflags = false, libs = false;
for (int i = 1; i < *argc; i++) { for (int i = 1; i < *argc; i++) {
const char *arg = argv[i]; const char *arg = argv[i];
if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
printf("%s\n", NODE_VERSION); printf("%s\n", NODE_VERSION);
exit(0); exit(0);
} else if (strcmp(arg, "--cflags") == 0) {
cflags = true;
continue;
} else if (strcmp(arg, "--libs") == 0) {
libs = true;
continue;
} else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) { } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
PrintHelp(); PrintHelp();
exit(0); exit(0);
@ -312,6 +319,21 @@ ParseArgs (int *argc, char **argv)
argv[i] = (char*)"--help"; argv[i] = (char*)"--help";
} }
} }
/* XXX Wow this is terrible code. */
bool should_exit = false;
if (cflags) {
should_exit = true;
printf("%s ", NODE_CFLAGS);
}
if (libs) {
should_exit = true;
printf("%s ", NODE_LIBFLAGS);
}
if (should_exit) {
printf("\n");
exit(0);
}
} }
int int

3
src/node.h

@ -7,11 +7,10 @@
#include <evcom.h> #include <evcom.h>
#include "object_wrap.h" #include "object_wrap.h"
#include "node_version.h"
namespace node { namespace node {
#define NODE_VERSION "0.1.7"
#define NODE_DEFINE_CONSTANT(target, constant) \ #define NODE_DEFINE_CONSTANT(target, constant) \
(target)->Set(v8::String::NewSymbol(#constant), \ (target)->Set(v8::String::NewSymbol(#constant), \
v8::Integer::New(constant)) v8::Integer::New(constant))

3
src/node_version.h.in

@ -0,0 +1,3 @@
#define NODE_VERSION "@VERSION@"
#define NODE_CFLAGS "@CCFLAGS@ @CPPFLAGS@ -I@PREFIX@/include"
#define NODE_LIBFLAGS "@LIBFLAGS@ -L@PREFIX@/lib -lnode@DEBUG_EXT@"

26
wscript

@ -4,7 +4,7 @@ import sys, os, shutil
from os.path import join, dirname, abspath from os.path import join, dirname, abspath
from logging import fatal from logging import fatal
VERSION="0.1.6" VERSION="0.1.7"
APPNAME="node.js" APPNAME="node.js"
import js2c import js2c
@ -260,7 +260,7 @@ def build(bld):
libnode.uselib_local = "evcom ev eio http_parser coupling" libnode.uselib_local = "evcom ev eio http_parser coupling"
libnode.uselib = "UDNS V8 EXECINFO PROFILER EFENCE DL" libnode.uselib = "UDNS V8 EXECINFO PROFILER EFENCE DL"
libnode.install_path = '${PREFIX}/lib' libnode.install_path = '${PREFIX}/lib'
bld.install_files('${PREFIX}/include/node/', 'config.h src/node.h src/object_wrap.h'); bld.install_files('${PREFIX}/include/node/', 'config.h src/node.h src/node_version.h src/object_wrap.h');
### node ### node
node = bld.new_task_gen("cxx", "program") node = bld.new_task_gen("cxx", "program")
@ -274,14 +274,13 @@ def build(bld):
def subflags(program): def subflags(program):
debug_ext = "" debug_ext = ""
if bld.env["USE_DEBUG"]: if program.target == "node_g": debug_ext = "_g"
debug_ext = "_g" x = { 'CCFLAGS' : " ".join(program.env["CCFLAGS"])
x = { 'CCFLAGS': " ".join(program.env["CCFLAGS"]) , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"])
, 'CPPFLAGS': " ".join(program.env["CPPFLAGS"]) , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"])
, 'LIBFLAGS': " ".join(program.env["LIBFLAGS"]) , 'VERSION' : VERSION
, 'VERSION': VERSION , 'PREFIX' : program.env["PREFIX"]
, 'PREFIX': program.env["PREFIX"] , 'DEBUG_EXT' : debug_ext
, 'DEBUG_EXT': debug_ext
} }
return x; return x;
@ -293,6 +292,11 @@ def build(bld):
pkgconfig.install_path = '${PREFIX}/lib/pkgconfig' pkgconfig.install_path = '${PREFIX}/lib/pkgconfig'
pkgconfig.dict = subflags(node) pkgconfig.dict = subflags(node)
# process file.pc.in -> file.pc
node_version = bld.new_task_gen('subst', before="cxx")
node_version.source = 'src/node_version.h.in'
node_version.target = 'src/node_version.h'
node_version.dict = subflags(node)
if bld.env["USE_DEBUG"]: if bld.env["USE_DEBUG"]:
node_g = node.clone("debug") node_g = node.clone("debug")
@ -305,4 +309,6 @@ def build(bld):
pkgconfig_g.dict = subflags(node_g) pkgconfig_g.dict = subflags(node_g)
pkgconfig_g.target = 'node_g.pc' pkgconfig_g.target = 'node_g.pc'
node_version_g = node_version.clone("debug")
node_version_g.dict = subflags(node_g)

Loading…
Cancel
Save