spilt script out

This commit is contained in:
sstent
2012-06-22 14:35:03 -04:00
parent e2c1f5fe1b
commit ddac6109c0
37 changed files with 6177 additions and 0 deletions

View File

@@ -0,0 +1,281 @@
/*!
* socket.io-node
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var fs = require('fs')
, socket = require('../lib/io')
, uglify = require('uglify-js')
, activeXObfuscator = require('active-x-obfuscator');
/**
* License headers.
*
* @api private
*/
var template = '/*! Socket.IO.%ext% build:' + socket.version + ', %type%. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */\n'
, development = template.replace('%type%', 'development').replace('%ext%', 'js')
, production = template.replace('%type%', 'production').replace('%ext%', 'min.js');
/**
* If statements, these allows you to create serveride & client side compatible
* code using specially designed `if` statements that remove serverside
* designed code from the source files
*
* @api private
*/
var starttagIF = '// if node'
, endtagIF = '// end node';
/**
* The modules that are required to create a base build of Socket.IO.
*
* @const
* @type {Array}
* @api private
*/
var base = [
'io.js'
, 'util.js'
, 'events.js'
, 'json.js'
, 'parser.js'
, 'transport.js'
, 'socket.js'
, 'namespace.js'
];
/**
* The available transports for Socket.IO. These are mapped as:
*
* - `key` the name of the transport
* - `value` the dependencies for the transport
*
* @const
* @type {Object}
* @api public
*/
var baseTransports = {
'websocket': ['transports/websocket.js']
, 'flashsocket': [
'transports/websocket.js'
, 'transports/flashsocket.js'
, 'vendor/web-socket-js/swfobject.js'
, 'vendor/web-socket-js/web_socket.js'
]
, 'htmlfile': ['transports/xhr.js', 'transports/htmlfile.js']
/* FIXME: re-enable me once we have multi-part support
, 'xhr-multipart': ['transports/xhr.js', 'transports/xhr-multipart.js'] */
, 'xhr-polling': ['transports/xhr.js', 'transports/xhr-polling.js']
, 'jsonp-polling': [
'transports/xhr.js'
, 'transports/xhr-polling.js'
, 'transports/jsonp-polling.js'
]
};
/**
* Builds a custom Socket.IO distribution based on the transports that you
* need. You can configure the build to create development build or production
* build (minified).
*
* @param {Array} transports The transports that needs to be bundled.
* @param {Object} [options] Options to configure the building process.
* @param {Function} callback Last argument should always be the callback
* @callback {String|Boolean} err An optional argument, if it exists than an error
* occurred during the build process.
* @callback {String} result The result of the build process.
* @api public
*/
var builder = module.exports = function () {
var transports, options, callback, error = null
, args = Array.prototype.slice.call(arguments, 0)
, settings = {
minify: true
, node: false
, custom: []
};
// Fancy pancy argument support this makes any pattern possible mainly
// because we require only one of each type
args.forEach(function (arg) {
var type = Object.prototype.toString.call(arg)
.replace(/\[object\s(\w+)\]/gi , '$1' ).toLowerCase();
switch (type) {
case 'array':
return transports = arg;
case 'object':
return options = arg;
case 'function':
return callback = arg;
}
});
// Add defaults
options = options || {};
transports = transports || Object.keys(baseTransports);
// Merge the data
for(var option in options) {
settings[option] = options[option];
}
// Start creating a dependencies chain with all the required files for the
// custom Socket.IO bundle.
var files = [];
base.forEach(function (file) {
files.push(__dirname + '/../lib/' + file);
});
transports.forEach(function (transport) {
var dependencies = baseTransports[transport];
if (!dependencies) {
error = 'Unsupported transport `' + transport + '` supplied as argument.';
return;
}
// Add the files to the files list, but only if they are not added before
dependencies.forEach(function (file) {
var path = __dirname + '/../lib/' + file;
if (!~files.indexOf(path)) files.push(path);
})
});
// check to see if the files tree compilation generated any errors.
if (error) return callback(error);
var results = {};
files.forEach(function (file) {
fs.readFile(file, function (err, content) {
if (err) error = err;
results[file] = content;
// check if we are done yet, or not.. Just by checking the size of the result
// object.
if (Object.keys(results).length !== files.length) return;
// we are done, did we error?
if (error) return callback(error);
// concatinate the file contents in order
var code = development
, ignore = 0;
files.forEach(function (file) {
code += results[file];
});
// check if we need to add custom code
if (settings.custom.length) {
settings.custom.forEach(function (content) {
code += content;
});
}
code = activeXObfuscator(code);
// Search for conditional code blocks that need to be removed as they
// where designed for a server side env. but only if we don't want to
// make this build node compatible.
if (!settings.node) {
code = code.split('\n').filter(function (line) {
// check if there are tags in here
var start = line.indexOf(starttagIF) >= 0
, end = line.indexOf(endtagIF) >= 0
, ret = ignore;
// ignore the current line
if (start) {
ignore++;
ret = ignore;
}
// stop ignoring the next line
if (end) {
ignore--;
}
return ret == 0;
}).join('\n');
}
// check if we need to process it any further
if (settings.minify) {
var ast = uglify.parser.parse(code);
ast = uglify.uglify.ast_mangle(ast);
ast = uglify.uglify.ast_squeeze(ast);
code = production + uglify.uglify.gen_code(ast, { ascii_only: true });
}
callback(error, code);
})
})
};
/**
* Builder version is also the current client version
* this way we don't have to do another include for the
* clients version number and we can just include the builder.
*
* @type {String}
* @api public
*/
builder.version = socket.version;
/**
* A list of all build in transport types.
*
* @type {Object}
* @api public
*/
builder.transports = baseTransports;
/**
* Command line support, this allows us to generate builds without having
* to load it as module.
*/
if (!module.parent){
// the first 2 are `node` and the path to this file, we don't need them
var args = process.argv.slice(2);
// build a development build
builder(args.length ? args : false, { minify:false }, function (err, content) {
if (err) return console.error(err);
fs.write(
fs.openSync(__dirname + '/../dist/socket.io.js', 'w')
, content
, 0
, 'utf8'
);
console.log('Successfully generated the development build: socket.io.js');
});
// and build a production build
builder(args.length ? args : false, function (err, content) {
if (err) return console.error(err);
fs.write(
fs.openSync(__dirname + '/../dist/socket.io.min.js', 'w')
, content
, 0
, 'utf8'
);
console.log('Successfully generated the production build: socket.io.min.js');
});
}

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,323 @@
#!/usr/bin/env node
// -*- js -*-
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
var fs = require("fs");
var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
jsp = uglify.parser,
pro = uglify.uglify;
var options = {
ast: false,
mangle: true,
mangle_toplevel: false,
no_mangle_functions: false,
squeeze: true,
make_seqs: true,
dead_code: true,
verbose: false,
show_copyright: true,
out_same_file: false,
max_line_length: 32 * 1024,
unsafe: false,
reserved_names: null,
defines: { },
lift_vars: false,
codegen_options: {
ascii_only: false,
beautify: false,
indent_level: 4,
indent_start: 0,
quote_keys: false,
space_colon: false,
inline_script: false
},
make: false,
output: true // stdout
};
var args = jsp.slice(process.argv, 2);
var filename;
out: while (args.length > 0) {
var v = args.shift();
switch (v) {
case "-b":
case "--beautify":
options.codegen_options.beautify = true;
break;
case "-i":
case "--indent":
options.codegen_options.indent_level = args.shift();
break;
case "-q":
case "--quote-keys":
options.codegen_options.quote_keys = true;
break;
case "-mt":
case "--mangle-toplevel":
options.mangle_toplevel = true;
break;
case "-nmf":
case "--no-mangle-functions":
options.no_mangle_functions = true;
break;
case "--no-mangle":
case "-nm":
options.mangle = false;
break;
case "--no-squeeze":
case "-ns":
options.squeeze = false;
break;
case "--no-seqs":
options.make_seqs = false;
break;
case "--no-dead-code":
options.dead_code = false;
break;
case "--no-copyright":
case "-nc":
options.show_copyright = false;
break;
case "-o":
case "--output":
options.output = args.shift();
break;
case "--overwrite":
options.out_same_file = true;
break;
case "-v":
case "--verbose":
options.verbose = true;
break;
case "--ast":
options.ast = true;
break;
case "--unsafe":
options.unsafe = true;
break;
case "--max-line-len":
options.max_line_length = parseInt(args.shift(), 10);
break;
case "--reserved-names":
options.reserved_names = args.shift().split(",");
break;
case "--lift-vars":
options.lift_vars = true;
break;
case "-d":
case "--define":
var defarg = args.shift();
try {
var defsym = function(sym) {
// KEYWORDS_ATOM doesn't include NaN or Infinity - should we check
// for them too ?? We don't check reserved words and the like as the
// define values are only substituted AFTER parsing
if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) {
throw "Don't define values for inbuilt constant '"+sym+"'";
}
return sym;
},
defval = function(v) {
if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) {
return [ "string", RegExp.$1 ];
}
else if (!isNaN(parseFloat(v))) {
return [ "num", parseFloat(v) ];
}
else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) {
return [ "name", v ];
}
else if (!v.match(/"/)) {
return [ "string", v ];
}
else if (!v.match(/'/)) {
return [ "string", v ];
}
throw "Can't understand the specified value: "+v;
};
if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) {
var sym = defsym(RegExp.$1),
val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ];
options.defines[sym] = val;
}
else {
throw "The --define option expects SYMBOL[=value]";
}
} catch(ex) {
sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n");
process.exit(1);
}
break;
case "--define-from-module":
var defmodarg = args.shift(),
defmodule = require(defmodarg),
sym,
val;
for (sym in defmodule) {
if (defmodule.hasOwnProperty(sym)) {
options.defines[sym] = function(val) {
if (typeof val == "string")
return [ "string", val ];
if (typeof val == "number")
return [ "num", val ];
if (val === true)
return [ 'name', 'true' ];
if (val === false)
return [ 'name', 'false' ];
if (val === null)
return [ 'name', 'null' ];
if (val === undefined)
return [ 'name', 'undefined' ];
sys.print("ERROR: In option --define-from-module "+defmodarg+"\n");
sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n");
process.exit(1);
return null;
}(defmodule[sym]);
}
}
break;
case "--ascii":
options.codegen_options.ascii_only = true;
break;
case "--make":
options.make = true;
break;
case "--inline-script":
options.codegen_options.inline_script = true;
break;
default:
filename = v;
break out;
}
}
if (options.verbose) {
pro.set_logger(function(msg){
sys.debug(msg);
});
}
jsp.set_logger(function(msg){
sys.debug(msg);
});
if (options.make) {
options.out_same_file = false; // doesn't make sense in this case
var makefile = JSON.parse(fs.readFileSync(filename || "Makefile.uglify.js").toString());
output(makefile.files.map(function(file){
var code = fs.readFileSync(file.name);
if (file.module) {
code = "!function(exports, global){global = this;\n" + code + "\n;this." + file.module + " = exports;}({})";
}
else if (file.hide) {
code = "(function(){" + code + "}());";
}
return squeeze_it(code);
}).join("\n"));
}
else if (filename) {
fs.readFile(filename, "utf8", function(err, text){
if (err) throw err;
output(squeeze_it(text));
});
}
else {
var stdin = process.openStdin();
stdin.setEncoding("utf8");
var text = "";
stdin.on("data", function(chunk){
text += chunk;
});
stdin.on("end", function() {
output(squeeze_it(text));
});
}
function output(text) {
var out;
if (options.out_same_file && filename)
options.output = filename;
if (options.output === true) {
out = process.stdout;
} else {
out = fs.createWriteStream(options.output, {
flags: "w",
encoding: "utf8",
mode: 0644
});
}
out.write(text.replace(/;*$/, ";"));
if (options.output !== true) {
out.end();
}
};
// --------- main ends here.
function show_copyright(comments) {
var ret = "";
for (var i = 0; i < comments.length; ++i) {
var c = comments[i];
if (c.type == "comment1") {
ret += "//" + c.value + "\n";
} else {
ret += "/*" + c.value + "*/";
}
}
return ret;
};
function squeeze_it(code) {
var result = "";
if (options.show_copyright) {
var tok = jsp.tokenizer(code), c;
c = tok();
result += show_copyright(c.comments_before);
}
try {
var ast = time_it("parse", function(){ return jsp.parse(code); });
if (options.lift_vars) {
ast = time_it("lift", function(){ return pro.ast_lift_variables(ast); });
}
if (options.mangle) ast = time_it("mangle", function(){
return pro.ast_mangle(ast, {
toplevel : options.mangle_toplevel,
defines : options.defines,
except : options.reserved_names,
no_functions : options.no_mangle_functions
});
});
if (options.squeeze) ast = time_it("squeeze", function(){
ast = pro.ast_squeeze(ast, {
make_seqs : options.make_seqs,
dead_code : options.dead_code,
keep_comps : !options.unsafe
});
if (options.unsafe)
ast = pro.ast_squeeze_more(ast);
return ast;
});
if (options.ast)
return sys.inspect(ast, null, null);
result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
if (!options.codegen_options.beautify && options.max_line_length) {
result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
}
return result;
} catch(ex) {
sys.debug(ex.stack);
sys.debug(sys.inspect(ex));
sys.debug(JSON.stringify(ex));
process.exit(1);
}
};
function time_it(name, cont) {
if (!options.verbose)
return cont();
var t1 = new Date().getTime();
try { return cont(); }
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
};

View File

@@ -0,0 +1,185 @@
#!/usr/bin/env node
/*!
* ws: a node.js websocket client
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var WebSocket = require('../')
, fs = require('fs')
, program = require('commander')
, util = require('util')
, events = require('events')
, readline = require('readline');
/**
* InputReader - processes console input
*/
function Console() {
this.stdin = process.stdin;
this.stdout = process.stdout;
this.readlineInterface = readline.createInterface(this.stdin, this.stdout);
var self = this;
this.readlineInterface.on('line', function(data) {
self.emit('line', data);
});
this.readlineInterface.on('close', function() {
self.emit('close');
});
this._resetInput = function() {
self.clear();
}
}
util.inherits(Console, events.EventEmitter);
Console.Colors = {
Red: '\033[31m',
Green: '\033[32m',
Yellow: '\033[33m',
Blue: '\033[34m',
Default: '\033[39m'
};
Console.prototype.prompt = function() {
this.readlineInterface.prompt();
}
Console.prototype.print = function(msg, color) {
this.clear();
color = color || Console.Colors.Default;
this.stdout.write(color + msg + Console.Colors.Default + '\n');
this.prompt();
}
Console.prototype.clear = function() {
this.stdout.write('\033[2K\033[E');
}
Console.prototype.pause = function() {
this.stdin.on('keypress', this._resetInput);
}
Console.prototype.resume = function() {
this.stdin.removeListener('keypress', this._resetInput);
}
/**
* The actual application
*/
var version = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version;
program
.version(version)
.usage('[options] <url>')
.option('-l, --listen <port>', 'listen on port')
.option('-c, --connect <url>', 'connect to a websocket server')
.option('-p, --protocol <version>', 'optional protocol version')
.option('-o, --origin <origin>', 'optional origin')
.parse(process.argv);
if (program.listen && program.connect) {
console.error('\033[33merror: use either --listen or --connect\033[39m');
process.exit(-1);
}
else if (program.listen) {
var wsConsole = new Console();
wsConsole.pause();
var options = {};
if (program.protocol) options.protocolVersion = program.protocol;
if (program.origin) options.origin = program.origin;
var ws = null;
var wss = new WebSocket.Server({port: program.listen}, function() {
wsConsole.print('listening on port ' + program.listen + ' (press CTRL+C to quit)', Console.Colors.Green);
wsConsole.clear();
});
wsConsole.on('close', function() {
if (ws) {
try {
ws.close();
}
catch (e) {}
}
process.exit(0);
});
wsConsole.on('line', function(data) {
if (ws) {
ws.send(data, {mask: true});
wsConsole.prompt();
}
});
wss.on('connection', function(newClient) {
if (ws) {
// limit to one client
newClient.terminate();
return;
};
ws = newClient;
wsConsole.resume();
wsConsole.prompt();
wsConsole.print('client connected', Console.Colors.Green);
ws.on('close', function() {
wsConsole.print('disconnected', Console.Colors.Green);
wsConsole.clear();
wsConsole.pause();
ws = null;
});
ws.on('error', function(code, description) {
wsConsole.print('error: ' + code + (description ? ' ' + description : ''), Console.Colors.Yellow);
});
ws.on('message', function(data, flags) {
wsConsole.print('< ' + data, Console.Colors.Blue);
});
});
wss.on('error', function(error) {
wsConsole.print('error: ' + error.toString(), Console.Colors.Yellow);
process.exit(-1);
});
}
else if (program.connect) {
var wsConsole = new Console();
var options = {};
if (program.protocol) options.protocolVersion = program.protocol;
if (program.origin) options.origin = program.origin;
var ws = new WebSocket(program.connect, options);
ws.on('open', function() {
wsConsole.print('connected (press CTRL+C to quit)', Console.Colors.Green);
wsConsole.on('line', function(data) {
ws.send(data, {mask: true});
wsConsole.prompt();
});
});
ws.on('close', function() {
wsConsole.print('disconnected', Console.Colors.Green);
wsConsole.clear();
process.exit();
});
ws.on('error', function(code, description) {
wsConsole.print('error: ' + code + (description ? ' ' + description : ''), Console.Colors.Yellow);
process.exit(-1);
});
ws.on('message', function(data, flags) {
wsConsole.print('< ' + data, Console.Colors.Blue);
});
wsConsole.on('close', function() {
if (ws) {
try {
ws.close();
}
catch(e) {}
process.exit();
}
});
}
else {
console.error('\033[33merror: use either --listen or --connect\033[39m');
process.exit(-1);
}

View File

@@ -0,0 +1,349 @@
# We borrow heavily from the kernel build setup, though we are simpler since
# we don't have Kconfig tweaking settings on us.
# The implicit make rules have it looking for RCS files, among other things.
# We instead explicitly write all the rules we care about.
# It's even quicker (saves ~200ms) to pass -r on the command line.
MAKEFLAGS=-r
# The source directory tree.
srcdir := ..
abs_srcdir := $(abspath $(srcdir))
# The name of the builddir.
builddir_name ?= .
# The V=1 flag on command line makes us verbosely print command lines.
ifdef V
quiet=
else
quiet=quiet_
endif
# Specify BUILDTYPE=Release on the command line for a release build.
BUILDTYPE ?= Release
# Directory all our build output goes into.
# Note that this must be two directories beneath src/ for unit tests to pass,
# as they reach into the src/ directory for data with relative paths.
builddir ?= $(builddir_name)/$(BUILDTYPE)
abs_builddir := $(abspath $(builddir))
depsdir := $(builddir)/.deps
# Object output directory.
obj := $(builddir)/obj
abs_obj := $(abspath $(obj))
# We build up a list of every single one of the targets so we can slurp in the
# generated dependency rule Makefiles in one pass.
all_deps :=
# C++ apps need to be linked with g++.
#
# Note: flock is used to seralize linking. Linking is a memory-intensive
# process so running parallel links can often lead to thrashing. To disable
# the serialization, override LINK via an envrionment variable as follows:
#
# export LINK=g++
#
# This will allow make to invoke N linker processes as specified in -jN.
LINK ?= flock $(builddir)/linker.lock $(CXX)
CC.target ?= $(CC)
CFLAGS.target ?= $(CFLAGS)
CXX.target ?= $(CXX)
CXXFLAGS.target ?= $(CXXFLAGS)
LINK.target ?= $(LINK)
LDFLAGS.target ?= $(LDFLAGS)
AR.target ?= $(AR)
ARFLAGS.target ?= crsT
# N.B.: the logic of which commands to run should match the computation done
# in gyp's make.py where ARFLAGS.host etc. is computed.
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
# to replicate this environment fallback in make as well.
CC.host ?= gcc
CFLAGS.host ?=
CXX.host ?= g++
CXXFLAGS.host ?=
LINK.host ?= g++
LDFLAGS.host ?=
AR.host ?= ar
ARFLAGS.host := crsT
# Define a dir function that can handle spaces.
# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
# "leading spaces cannot appear in the text of the first argument as written.
# These characters can be put into the argument value by variable substitution."
empty :=
space := $(empty) $(empty)
# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
replace_spaces = $(subst $(space),?,$1)
unreplace_spaces = $(subst ?,$(space),$1)
dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
# Flags to make gcc output dependency info. Note that you need to be
# careful here to use the flags that ccache and distcc can understand.
# We write to a dep file on the side first and then rename at the end
# so we can't end up with a broken dep file.
depfile = $(depsdir)/$(call replace_spaces,$@).d
DEPFLAGS = -MMD -MF $(depfile).raw
# We have to fixup the deps output in a few ways.
# (1) the file output should mention the proper .o file.
# ccache or distcc lose the path to the target, so we convert a rule of
# the form:
# foobar.o: DEP1 DEP2
# into
# path/to/foobar.o: DEP1 DEP2
# (2) we want missing files not to cause us to fail to build.
# We want to rewrite
# foobar.o: DEP1 DEP2 \
# DEP3
# to
# DEP1:
# DEP2:
# DEP3:
# so if the files are missing, they're just considered phony rules.
# We have to do some pretty insane escaping to get those backslashes
# and dollar signs past make, the shell, and sed at the same time.
# Doesn't work with spaces, but that's fine: .d files have spaces in
# their names replaced with other characters.
define fixup_dep
# The depfile may not exist if the input file didn't have any #includes.
touch $(depfile).raw
# Fixup path as in (1).
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
# Add extra rules as in (2).
# We remove slashes and replace spaces with new lines;
# remove blank lines;
# delete the first line and append a colon to the remaining lines.
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
grep -v '^$$' |\
sed -e 1d -e 's|$$|:|' \
>> $(depfile)
rm $(depfile).raw
endef
# Command definitions:
# - cmd_foo is the actual command to run;
# - quiet_cmd_foo is the brief-output summary of the command.
quiet_cmd_cc = CC($(TOOLSET)) $@
cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_cxx = CXX($(TOOLSET)) $@
cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_touch = TOUCH $@
cmd_touch = touch $@
quiet_cmd_copy = COPY $@
# send stderr to /dev/null to ignore messages when linking directories.
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@")
quiet_cmd_alink = AR($(TOOLSET)) $@
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^)
# Due to circular dependencies between libraries :(, we wrap the
# special "figure out circular dependencies" flags around the entire
# input list during linking.
quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
# We support two kinds of shared objects (.so):
# 1) shared_library, which is just bundling together many dependent libraries
# into a link line.
# 2) loadable_module, which is generating a module intended for dlopen().
#
# They differ only slightly:
# In the former case, we want to package all dependent code into the .so.
# In the latter case, we want to package just the API exposed by the
# outermost module.
# This means shared_library uses --whole-archive, while loadable_module doesn't.
# (Note that --whole-archive is incompatible with the --start-group used in
# normal linking.)
# Other shared-object link notes:
# - Set SONAME to the library filename so our binaries don't reference
# the local, absolute paths used on the link command-line.
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
# Define an escape_quotes function to escape single quotes.
# This allows us to handle quotes properly as long as we always use
# use single quotes and escape_quotes.
escape_quotes = $(subst ','\'',$(1))
# This comment is here just to include a ' to unconfuse syntax highlighting.
# Define an escape_vars function to escape '$' variable syntax.
# This allows us to read/write command lines with shell variables (e.g.
# $LD_LIBRARY_PATH), without triggering make substitution.
escape_vars = $(subst $$,$$$$,$(1))
# Helper that expands to a shell command to echo a string exactly as it is in
# make. This uses printf instead of echo because printf's behaviour with respect
# to escape sequences is more portable than echo's across different shells
# (e.g., dash, bash).
exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
# Helper to compare the command we're about to run against the command
# we logged the last time we ran the command. Produces an empty
# string (false) when the commands match.
# Tricky point: Make has no string-equality test function.
# The kernel uses the following, but it seems like it would have false
# positives, where one string reordered its arguments.
# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
# $(filter-out $(cmd_$@), $(cmd_$(1))))
# We instead substitute each for the empty string into the other, and
# say they're equal if both substitutions produce the empty string.
# .d files contain ? instead of spaces, take that into account.
command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
$(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
# Helper that is non-empty when a prerequisite changes.
# Normally make does this implicitly, but we force rules to always run
# so we can check their command lines.
# $? -- new prerequisites
# $| -- order-only dependencies
prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
# Helper that executes all postbuilds, and deletes the output file when done
# if any of the postbuilds failed.
define do_postbuilds
@E=0;\
for p in $(POSTBUILDS); do\
eval $$p;\
F=$$?;\
if [ $$F -ne 0 ]; then\
E=$$F;\
fi;\
done;\
if [ $$E -ne 0 ]; then\
rm -rf "$@";\
exit $$E;\
fi
endef
# do_cmd: run a command via the above cmd_foo names, if necessary.
# Should always run for a given target to handle command-line changes.
# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
# Third argument, if non-zero, makes it do POSTBUILDS processing.
# Note: We intentionally do NOT call dirx for depfile, since it contains ? for
# spaces already and dirx strips the ? characters.
define do_cmd
$(if $(or $(command_changed),$(prereq_changed)),
@$(call exact_echo, $($(quiet)cmd_$(1)))
@mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
$(if $(findstring flock,$(word 1,$(cmd_$1))),
@$(cmd_$(1))
@echo " $(quiet_cmd_$(1)): Finished",
@$(cmd_$(1))
)
@$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
@$(if $(2),$(fixup_dep))
$(if $(and $(3), $(POSTBUILDS)),
$(call do_postbuilds)
)
)
endef
# Declare the "all" target first so it is the default,
# even though we don't have the deps yet.
.PHONY: all
all:
# Use FORCE_DO_CMD to force a target to run. Should be coupled with
# do_cmd.
.PHONY: FORCE_DO_CMD
FORCE_DO_CMD:
TOOLSET := target
# Suffix rules, putting all outputs into $(obj).
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
# Try building from generated source, too.
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
$(findstring $(join ^,$(prefix)),\
$(join ^,bufferutil.target.mk)))),)
include bufferutil.target.mk
endif
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
$(findstring $(join ^,$(prefix)),\
$(join ^,validation.target.mk)))),)
include validation.target.mk
endif
quiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = /home/sstent/.node-gyp/0.6.19/tools/gyp_addon -fmake --ignore-environment "--toplevel-dir=." -I/home/sstent/git/node/app/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build/config.gypi -I/home/sstent/.node-gyp/0.6.19/tools/addon.gypi -I/home/sstent/.node-gyp/0.6.19/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/sstent/.node-gyp/0.6.19" "-Dmodule_root_dir=/home/sstent/git/node/app/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws" binding.gyp
Makefile: $(srcdir)/../../../../../../../../../.node-gyp/0.6.19/tools/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../../../../../../.node-gyp/0.6.19/common.gypi
$(call do_cmd,regen_makefile)
# "all" is a concatenation of the "all" targets from all the included
# sub-makefiles. This is just here to clarify.
all:
# Add in dependency-tracking rules. $(all_deps) is the list of every single
# target in our tree. Only consider the ones with .d (dependency) info:
d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
ifneq ($(d_files),)
# Rather than include each individual .d file, concatenate them into a
# single file which make is able to load faster. We split this into
# commands that take 512 files at a time to avoid overflowing the
# command line.
$(shell cat $(wordlist 1,512,$(d_files)) > $(depsdir)/all.deps)
ifneq ($(word 513,$(d_files)),)
$(error Found unprocessed dependency files (gyp didn't generate enough rules!))
endif
# make looks for ways to re-generate included makefiles, but in our case, we
# don't have a direct way. Explicitly telling make that it has nothing to do
# for them makes it go faster.
$(depsdir)/all.deps: ;
include $(depsdir)/all.deps
endif

View File

@@ -0,0 +1 @@
cmd_Release/bufferutil.node := ln -f "Release/obj.target/bufferutil.node" "Release/bufferutil.node" 2>/dev/null || (rm -rf "Release/bufferutil.node" && cp -af "Release/obj.target/bufferutil.node" "Release/bufferutil.node")

View File

@@ -0,0 +1 @@
cmd_Release/obj.target/bufferutil.node := flock ./Release/linker.lock g++ -shared -pthread -rdynamic -Wl,-soname=bufferutil.node -o Release/obj.target/bufferutil.node -Wl,--start-group Release/obj.target/bufferutil/src/bufferutil.o -Wl,--end-group

View File

@@ -0,0 +1,27 @@
cmd_Release/obj.target/bufferutil/src/bufferutil.o := g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' -I/home/sstent/.node-gyp/0.6.19/src -I/home/sstent/.node-gyp/0.6.19/deps/uv/include -I/home/sstent/.node-gyp/0.6.19/deps/v8/include -fPIC -Wall -pthread -O3 -O3 -fdata-sections -ffunction-sections -fno-strict-aliasing -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw -c -o Release/obj.target/bufferutil/src/bufferutil.o ../src/bufferutil.cc
Release/obj.target/bufferutil/src/bufferutil.o: ../src/bufferutil.cc \
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8.h \
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8stdint.h \
/home/sstent/.node-gyp/0.6.19/src/node.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares_version.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/uv-unix.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ngx-queue.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ev.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/eio.h \
/home/sstent/.node-gyp/0.6.19/src/node_object_wrap.h \
/home/sstent/.node-gyp/0.6.19/src/node_buffer.h
../src/bufferutil.cc:
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8.h:
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8stdint.h:
/home/sstent/.node-gyp/0.6.19/src/node.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares_version.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/uv-unix.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ngx-queue.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ev.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/eio.h:
/home/sstent/.node-gyp/0.6.19/src/node_object_wrap.h:
/home/sstent/.node-gyp/0.6.19/src/node_buffer.h:

View File

@@ -0,0 +1 @@
cmd_Release/obj.target/validation.node := flock ./Release/linker.lock g++ -shared -pthread -rdynamic -Wl,-soname=validation.node -o Release/obj.target/validation.node -Wl,--start-group Release/obj.target/validation/src/validation.o -Wl,--end-group

View File

@@ -0,0 +1,27 @@
cmd_Release/obj.target/validation/src/validation.o := g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' -I/home/sstent/.node-gyp/0.6.19/src -I/home/sstent/.node-gyp/0.6.19/deps/uv/include -I/home/sstent/.node-gyp/0.6.19/deps/v8/include -fPIC -Wall -pthread -O3 -O3 -fdata-sections -ffunction-sections -fno-strict-aliasing -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/validation/src/validation.o.d.raw -c -o Release/obj.target/validation/src/validation.o ../src/validation.cc
Release/obj.target/validation/src/validation.o: ../src/validation.cc \
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8.h \
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8stdint.h \
/home/sstent/.node-gyp/0.6.19/src/node.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares_version.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/uv-unix.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ngx-queue.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ev.h \
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/eio.h \
/home/sstent/.node-gyp/0.6.19/src/node_object_wrap.h \
/home/sstent/.node-gyp/0.6.19/src/node_buffer.h
../src/validation.cc:
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8.h:
/home/sstent/.node-gyp/0.6.19/deps/v8/include/v8stdint.h:
/home/sstent/.node-gyp/0.6.19/src/node.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/ares_version.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/uv-unix.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ngx-queue.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/ev.h:
/home/sstent/.node-gyp/0.6.19/deps/uv/include/uv-private/eio.h:
/home/sstent/.node-gyp/0.6.19/src/node_object_wrap.h:
/home/sstent/.node-gyp/0.6.19/src/node_buffer.h:

View File

@@ -0,0 +1 @@
cmd_Release/validation.node := ln -f "Release/obj.target/validation.node" "Release/validation.node" 2>/dev/null || (rm -rf "Release/validation.node" && cp -af "Release/obj.target/validation.node" "Release/validation.node")

View File

@@ -0,0 +1,6 @@
# This file is generated by gyp; do not edit.
export builddir_name ?= build/./.
.PHONY: all
all:
$(MAKE) bufferutil validation

View File

@@ -0,0 +1,111 @@
# This file is generated by gyp; do not edit.
TOOLSET := target
TARGET := bufferutil
DEFS_Debug := '-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64' \
'-DDEBUG' \
'-D_DEBUG'
# Flags passed to all source files.
CFLAGS_Debug := -fPIC \
-Wall \
-pthread \
-O3 \
-g \
-O0
# Flags passed to only C files.
CFLAGS_C_Debug :=
# Flags passed to only C++ files.
CFLAGS_CC_Debug := -fno-rtti \
-fno-exceptions
INCS_Debug := -I/home/sstent/.node-gyp/0.6.19/src \
-I/home/sstent/.node-gyp/0.6.19/deps/uv/include \
-I/home/sstent/.node-gyp/0.6.19/deps/v8/include
DEFS_Release := '-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64'
# Flags passed to all source files.
CFLAGS_Release := -fPIC \
-Wall \
-pthread \
-O3 \
-O3 \
-fdata-sections \
-ffunction-sections \
-fno-strict-aliasing
# Flags passed to only C files.
CFLAGS_C_Release :=
# Flags passed to only C++ files.
CFLAGS_CC_Release := -fno-rtti \
-fno-exceptions
INCS_Release := -I/home/sstent/.node-gyp/0.6.19/src \
-I/home/sstent/.node-gyp/0.6.19/deps/uv/include \
-I/home/sstent/.node-gyp/0.6.19/deps/v8/include
OBJS := $(obj).target/$(TARGET)/src/bufferutil.o
# Add to the list of files we specially track dependencies for.
all_deps += $(OBJS)
# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.
$(OBJS): TOOLSET := $(TOOLSET)
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
# Suffix rules, putting all outputs into $(obj).
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
# Try building from generated source, too.
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
# End of this set of suffix rules
### Rules for final target.
LDFLAGS_Debug := -pthread \
-rdynamic
LDFLAGS_Release := -pthread \
-rdynamic
LIBS :=
$(obj).target/bufferutil.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
$(obj).target/bufferutil.node: LIBS := $(LIBS)
$(obj).target/bufferutil.node: TOOLSET := $(TOOLSET)
$(obj).target/bufferutil.node: $(OBJS) FORCE_DO_CMD
$(call do_cmd,solink_module)
all_deps += $(obj).target/bufferutil.node
# Add target alias
.PHONY: bufferutil
bufferutil: $(builddir)/bufferutil.node
# Copy this to the executable output path.
$(builddir)/bufferutil.node: TOOLSET := $(TOOLSET)
$(builddir)/bufferutil.node: $(obj).target/bufferutil.node FORCE_DO_CMD
$(call do_cmd,copy)
all_deps += $(builddir)/bufferutil.node
# Short alias for building this executable.
.PHONY: bufferutil.node
bufferutil.node: $(obj).target/bufferutil.node $(builddir)/bufferutil.node
# Add executable to "all" target.
.PHONY: all
all: $(builddir)/bufferutil.node

View File

@@ -0,0 +1,15 @@
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"defines": [],
"include_dirs": [],
"libraries": [],
"default_configuration": "Release"
},
"variables": {
"target_arch": "x64",
"nodedir": "/home/sstent/.node-gyp/0.6.19",
"copy_dev_lib": "true"
}
}

View File

@@ -0,0 +1,111 @@
# This file is generated by gyp; do not edit.
TOOLSET := target
TARGET := validation
DEFS_Debug := '-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64' \
'-DDEBUG' \
'-D_DEBUG'
# Flags passed to all source files.
CFLAGS_Debug := -fPIC \
-Wall \
-pthread \
-O3 \
-g \
-O0
# Flags passed to only C files.
CFLAGS_C_Debug :=
# Flags passed to only C++ files.
CFLAGS_CC_Debug := -fno-rtti \
-fno-exceptions
INCS_Debug := -I/home/sstent/.node-gyp/0.6.19/src \
-I/home/sstent/.node-gyp/0.6.19/deps/uv/include \
-I/home/sstent/.node-gyp/0.6.19/deps/v8/include
DEFS_Release := '-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64'
# Flags passed to all source files.
CFLAGS_Release := -fPIC \
-Wall \
-pthread \
-O3 \
-O3 \
-fdata-sections \
-ffunction-sections \
-fno-strict-aliasing
# Flags passed to only C files.
CFLAGS_C_Release :=
# Flags passed to only C++ files.
CFLAGS_CC_Release := -fno-rtti \
-fno-exceptions
INCS_Release := -I/home/sstent/.node-gyp/0.6.19/src \
-I/home/sstent/.node-gyp/0.6.19/deps/uv/include \
-I/home/sstent/.node-gyp/0.6.19/deps/v8/include
OBJS := $(obj).target/$(TARGET)/src/validation.o
# Add to the list of files we specially track dependencies for.
all_deps += $(OBJS)
# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.
$(OBJS): TOOLSET := $(TOOLSET)
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
# Suffix rules, putting all outputs into $(obj).
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
# Try building from generated source, too.
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
# End of this set of suffix rules
### Rules for final target.
LDFLAGS_Debug := -pthread \
-rdynamic
LDFLAGS_Release := -pthread \
-rdynamic
LIBS :=
$(obj).target/validation.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
$(obj).target/validation.node: LIBS := $(LIBS)
$(obj).target/validation.node: TOOLSET := $(TOOLSET)
$(obj).target/validation.node: $(OBJS) FORCE_DO_CMD
$(call do_cmd,solink_module)
all_deps += $(obj).target/validation.node
# Add target alias
.PHONY: validation
validation: $(builddir)/validation.node
# Copy this to the executable output path.
$(builddir)/validation.node: TOOLSET := $(TOOLSET)
$(builddir)/validation.node: $(obj).target/validation.node FORCE_DO_CMD
$(call do_cmd,copy)
all_deps += $(builddir)/validation.node
# Short alias for building this executable.
.PHONY: validation.node
validation.node: $(obj).target/validation.node $(builddir)/validation.node
# Add executable to "all" target.
.PHONY: all
all: $(builddir)/validation.node

View File

@@ -0,0 +1,17 @@
{
"author": "",
"name": "serverstats",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "git://github.com/einaros/ws.git"
},
"engines": {
"node": ">0.4.0"
},
"dependencies": {
"express": "~3.0.0"
},
"devDependencies": {},
"optionalDependencies": {}
}

View File

@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: Tahoma, Geneva, sans-serif;
}
div {
display: inline;
}
</style>
<script>
function updateStats(memuse) {
document.getElementById('rss').innerHTML = memuse.rss;
document.getElementById('heapTotal').innerHTML = memuse.heapTotal;
document.getElementById('heapUsed').innerHTML = memuse.heapUsed;
}
var host = window.document.location.host.replace(/:.*/, '');
var ws = new WebSocket('ws://' + host + ':8080');
ws.onmessage = function (event) {
updateStats(JSON.parse(event.data));
};
</script>
</head>
<body>
<strong>Server Stats</strong><br>
RSS: <div id='rss'></div><br>
Heap total: <div id='heapTotal'></div><br>
Heap used: <div id='heapUsed'></div><br>
</body>
</html>

View File

@@ -0,0 +1,21 @@
var WebSocketServer = require('../../').Server
, http = require('http')
, express = require('express')
, app = express();
app.use(express.static(__dirname + '/public'));
var server = http.createServer(app);
server.listen(8080);
var wss = new WebSocketServer({server: server});
wss.on('connection', function(ws) {
var id = setInterval(function() {
ws.send(JSON.stringify(process.memoryUsage()), function() { /* ignore errors */ });
}, 100);
console.log('started client interval');
ws.on('close', function() {
console.log('stopping client interval');
clearInterval(id);
})
});

View File

@@ -0,0 +1,47 @@
/*!
* ws: a node.js websocket client
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
* MIT Licensed
*/
module.exports.BufferUtil = {
merge: function(mergedBuffer, buffers) {
var offset = 0;
for (var i = 0, l = buffers.length; i < l; ++i) {
var buf = buffers[i];
buf.copy(mergedBuffer, offset);
offset += buf.length;
}
},
mask: function(source, mask, output, offset, length) {
var maskNum = mask.readUInt32LE(0, true);
var i = 0;
for (; i < length - 3; i += 4) {
var num = maskNum ^ source.readUInt32LE(i, true);
if (num < 0) num = 4294967296 + num;
output.writeUInt32LE(num, offset + i, true);
}
switch (length % 4) {
case 3: output[offset + i + 2] = source[i + 2] ^ mask[2];
case 2: output[offset + i + 1] = source[i + 1] ^ mask[1];
case 1: output[offset + i] = source[i] ^ mask[0];
case 0:;
}
},
unmask: function(data, mask) {
var maskNum = mask.readUInt32LE(0, true);
var length = data.length;
var i = 0;
for (; i < length - 3; i += 4) {
var num = maskNum ^ data.readUInt32LE(i, true);
if (num < 0) num = 4294967296 + num;
data.writeUInt32LE(num, i, true);
}
switch (length % 4) {
case 3: data[i + 2] = data[i + 2] ^ mask[2];
case 2: data[i + 1] = data[i + 1] ^ mask[1];
case 1: data[i] = data[i] ^ mask[0];
case 0:;
}
}
}

View File

@@ -0,0 +1,12 @@
/*!
* ws: a node.js websocket client
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
* MIT Licensed
*/
module.exports.Validation = {
isValidUTF8: function(buffer) {
return true;
}
};

View File

@@ -0,0 +1,5 @@
npm-debug.log
node_modules
.*.swp
.lock-*
build/

View File

@@ -0,0 +1,3 @@
# tinycolor #
This is a no-fuzz, barebone, zero muppetry color module for node.js.

View File

@@ -0,0 +1,3 @@
require('./tinycolor');
console.log('this should be red and have an underline!'.grey.underline);
console.log('this should have a blue background!'.bgBlue);

View File

@@ -0,0 +1,27 @@
{
"author": {
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"name": "tinycolor",
"description": "a to-the-point color module for node",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git://github.com/einaros/tinycolor.git"
},
"engines": {
"node": ">=0.4.0"
},
"dependencies": {},
"devDependencies": {},
"main": "tinycolor",
"_id": "tinycolor@0.0.1",
"optionalDependencies": {},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"_from": "tinycolor@0.x"
}

View File

@@ -0,0 +1,31 @@
var styles = {
'bold': ['\033[1m', '\033[22m'],
'italic': ['\033[3m', '\033[23m'],
'underline': ['\033[4m', '\033[24m'],
'inverse': ['\033[7m', '\033[27m'],
'black': ['\033[30m', '\033[39m'],
'red': ['\033[31m', '\033[39m'],
'green': ['\033[32m', '\033[39m'],
'yellow': ['\033[33m', '\033[39m'],
'blue': ['\033[34m', '\033[39m'],
'magenta': ['\033[35m', '\033[39m'],
'cyan': ['\033[36m', '\033[39m'],
'white': ['\033[37m', '\033[39m'],
'default': ['\033[39m', '\033[39m'],
'grey': ['\033[90m', '\033[39m'],
'bgBlack': ['\033[40m', '\033[49m'],
'bgRed': ['\033[41m', '\033[49m'],
'bgGreen': ['\033[42m', '\033[49m'],
'bgYellow': ['\033[43m', '\033[49m'],
'bgBlue': ['\033[44m', '\033[49m'],
'bgMagenta': ['\033[45m', '\033[49m'],
'bgCyan': ['\033[46m', '\033[49m'],
'bgWhite': ['\033[47m', '\033[49m'],
'bgDefault': ['\033[49m', '\033[49m']
}
Object.keys(styles).forEach(function(style) {
Object.defineProperty(String.prototype, style, {
get: function() { return styles[style][0] + this + styles[style][1]; },
enumerable: false
});
});