lint/style cleanup and build support updates

This commit is contained in:
Mark Cavage 2012-09-20 19:38:46 +00:00
parent 868f0f953f
commit 2579c251fb
9 changed files with 224 additions and 101 deletions

View File

@ -39,15 +39,24 @@ JSL_FILES_NODE = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSSTYLE_FLAGS = -f tools/jsstyle.conf
CLEAN_FILES += node_modules $(SHRINKWRAP) cscope.files
include ./tools/mk/Makefile.defs
# Repo-specific targets
#
.PHONY: all
all:
all: $(TAP) $(REPO_DEPS)
$(NPM) rebuild
$(TAP): | $(NPM_EXEC)
$(NPM) install
.PHONY: test
test:
$(NPM) test
CLEAN_FILES += $(TAP) ./node_modules/tap
include ./Makefile.deps
include ./Makefile.targ
.PHONY: test
test: $(TAP)
$(TAP) test/*.test.js
include ./tools/mk/Makefile.deps
include ./tools/mk/Makefile.targ

View File

@ -1,46 +0,0 @@
#
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
#
# Makefile.deps: Makefile for including common tools as dependencies
#
#
# javascriptlint
#
JSL_SCRIPT = deps/javascriptlint/build/install/jsl
JSL = python $(JSL_SCRIPT)
$(JSL_SCRIPT): | deps/javascriptlint/.git
cd deps/javascriptlint && make install
deps/javascriptlint/.git:
git submodule update --init deps/javascriptlint
#
# jsstyle
#
JSSTYLE_SCRIPT = deps/jsstyle/jsstyle
JSSTYLE = $(JSSTYLE_SCRIPT)
deps/jsstyle/jsstyle:
git submodule update --init deps/jsstyle
#
# restdown
#
RESTDOWN = python deps/restdown/bin/restdown
$(RESTDOWN): | deps/restdown/.git
deps/restdown/.git:
git submodule update --init deps/restdown
#
# The restdown submodule should be updated before we build "docs".
#
docs: $(RESTDOWN)
#
# JSL and JSSTYLE must be around before we build "check".
#
check: $(JSL_SCRIPT) $(JSSTYLE)

2
deps/javascriptlint vendored

@ -1 +1 @@
Subproject commit 5693fd3ce6f31f66f85bfde275ab64e609ea04d0
Subproject commit e1bd0abfd424811af469d1ece3af131d95443924

View File

@ -773,8 +773,9 @@ Client.prototype._send = function _send(message, expect, emitter, callback) {
function _continuePagedSearch(msg) {
// this function looks for a paged control in the response msg
// and continue searching or not according to RFC 2696 - http://www.ietf.org/rfc/rfc2696.txt
if (util.isArray(msg.controls) && msg.controls.length > 0) {
// and continue searching or not according to RFC 2696:
// http://www.ietf.org/rfc/rfc2696.txt
if (Array.isArray(msg.controls) && msg.controls.length > 0) {
log.trace('message has %d controls', msg.controls.length);
for (var i = 0; i < msg.controls.length; i++) {
@ -786,7 +787,8 @@ Client.prototype._send = function _send(message, expect, emitter, callback) {
if (resControl.value.cookie && resControl.value.cookie.length > 0) {
log.trace('paged search: received cookie in response');
if (util.isArray(message.controls) && message.controls.length > 0) {
if (Array.isArray(message.controls) &&
message.controls.length > 0) {
for (var j = 0; j < message.controls.length; j++) {
var reqControl = message.controls[j];
@ -809,8 +811,7 @@ Client.prototype._send = function _send(message, expect, emitter, callback) {
}
}
}
}
else {
} else {
log.debug('paged search done');
}
}
@ -819,7 +820,6 @@ Client.prototype._send = function _send(message, expect, emitter, callback) {
// not a paged search or all pages received
return false;
} // end function _continuePagedSearch(msg)
function messageCallback(msg) {
@ -838,7 +838,7 @@ Client.prototype._send = function _send(message, expect, emitter, callback) {
return _done(event, msg);
} else if (_continuePagedSearch(msg)) {
// page search continued, just return for now
return;
return undefined;
} else {
delete conn.ldap.messages[message.messageID];

View File

@ -84,6 +84,8 @@ function createPool(options) {
client.removeAllListeners('error');
callback(null);
});
return undefined;
});
},

View File

@ -25,15 +25,15 @@
},
"dependencies": {
"asn1": "0.1.11",
"assert-plus": "0.1.0",
"assert-plus": "0.1.2",
"buffertools": "1.1.0",
"bunyan": "0.13.5",
"bunyan": "0.14.0",
"dtrace-provider": "0.2.0",
"nopt": "1.0.10",
"pooling": "0.2.2"
"pooling": "0.3.1"
},
"devDependencies": {
"tap": "0.2.5",
"tap": "0.3.1",
"node-uuid": "1.3.3"
},
"scripts": {

43
tools/mk/Makefile.defs Normal file
View File

@ -0,0 +1,43 @@
# -*- mode: makefile -*-
#
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
#
# Makefile.defs: common defines.
#
# NOTE: This makefile comes from the "eng" repo. It's designed to be dropped
# into other repos as-is without requiring any modifications. If you find
# yourself changing this file, you should instead update the original copy in
# eng.git and then update your repo to use the new version.
#
# This makefile defines some useful defines. Include it at the top of
# your Makefile.
#
# Definitions in this Makefile:
#
# TOP The absolute path to the project directory. The top dir.
# BRANCH The current git branch.
# TIMESTAMP The timestamp for the build. This can be set via
# the TIMESTAMP envvar (used by MG-based builds).
# STAMP A build stamp to use in built package names.
#
TOP := $(shell pwd)
#
# Mountain Gorilla-spec'd versioning.
# See "Package Versioning" in MG's README.md:
# <https://mo.joyent.com/mountain-gorilla/blob/master/README.md#L139-200>
#
# Need GNU awk for multi-char arg to "-F".
_AWK := $(shell (which gawk >/dev/null && echo gawk) \
|| (which nawk >/dev/null && echo nawk) \
|| echo awk)
BRANCH := $(shell git symbolic-ref HEAD | $(_AWK) -F/ '{print $$3}')
ifeq ($(TIMESTAMP),)
TIMESTAMP := $(shell date -u "+%Y%m%dT%H%M%SZ")
endif
_GITDESCRIBE := g$(shell git describe --all --long --dirty | $(_AWK) -F'-g' '{print $$NF}')
STAMP := $(BRANCH)-$(TIMESTAMP)-$(_GITDESCRIBE)
# node-gyp will print build info useful for debugging with V=1
export V=1

44
tools/mk/Makefile.deps Normal file
View File

@ -0,0 +1,44 @@
# -*- mode: makefile -*-
#
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
#
# Makefile.deps: Makefile for including common tools as dependencies
#
# NOTE: This makefile comes from the "eng" repo. It's designed to be dropped
# into other repos as-is without requiring any modifications. If you find
# yourself changing this file, you should instead update the original copy in
# eng.git and then update your repo to use the new version.
#
# This file is separate from Makefile.targ so that teams can choose
# independently whether to use the common targets in Makefile.targ and the
# common tools here.
#
#
# javascriptlint
#
JSL_EXEC ?= deps/javascriptlint/build/install/jsl
JSL ?= $(JSL_EXEC)
$(JSL_EXEC): | deps/javascriptlint/.git
cd deps/javascriptlint && make install
distclean::
if [[ -f deps/javascriptlint/Makefile ]]; then \
cd deps/javascriptlint && make clean; \
fi
#
# jsstyle
#
JSSTYLE_EXEC ?= deps/jsstyle/jsstyle
JSSTYLE ?= $(JSSTYLE_EXEC)
$(JSSTYLE_EXEC): | deps/jsstyle/.git
#
# restdown
#
RESTDOWN_EXEC ?= deps/restdown/bin/restdown
RESTDOWN ?= python2.6 $(RESTDOWN_EXEC)
$(RESTDOWN_EXEC): | deps/restdown/.git

View File

@ -1,3 +1,4 @@
# -*- mode: makefile -*-
#
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
#
@ -57,12 +58,13 @@
# JSL_FILES_NODE JavaScript files to check with Node config file.
# JSL_FILES_WEB JavaScript files to check with Web config file.
#
# SMF_MANIFESTS XML files to check for validity using the SMF DTD.
#
# You can also override these variables:
#
# BASH Path to bash (default: bash)
#
# CSCOPE_DIRS Directories to search for source files for the cscope
# index. (default: ".")
#
# JSL Path to JavaScriptLint (default: "jsl")
#
# JSL_FLAGS_NODE Additional flags to pass through to JSL
@ -78,19 +80,31 @@
# Defaults for the various tools we use.
#
BASH ?= bash
BASHSTYLE ?= tools/bashstyle
CP ?= cp
CSCOPE ?= cscope
CSCOPE_DIRS ?= .
JSL ?= jsl
JSSTYLE ?= jsstyle
MKDIR ?= mkdir -p
MV ?= mv
RESTDOWN ?= restdown
RESTDOWN_FLAGS ?=
RMTREE ?= rm -rf
JSL_FLAGS ?= --nologo --nosummary
ifeq ($(shell uname -s),SunOS)
TAR ?= gtar
else
TAR ?= tar
endif
#
# Defaults for other fixed values.
#
DOC_BUILD = build/docs/public
BUILD = build
DISTCLEAN_FILES += $(BUILD)
DOC_BUILD = $(BUILD)/docs/public
#
# Configure JSL_FLAGS_{NODE,WEB} based on JSL_CONF_{NODE,WEB}.
@ -103,33 +117,95 @@ ifneq ($(origin JSL_CONF_WEB), undefined)
JSL_FLAGS_WEB += --conf=$(JSL_CONF_WEB)
endif
.PHONY: check-jsl check-jsl-node check-jsl-web
check-jsl: check-jsl-node check-jsl-web
#
# Targets. For descriptions on what these are supposed to do, see the
# Joyent Engineering Guide.
#
check-jsl-node: $(JSL_FILES_NODE:%=%.jslnodechk)
#
# Instruct make to keep around temporary files. We have rules below that
# automatically update git submodules as needed, but they employ a deps/*/.git
# temporary file. Without this directive, make tries to remove these .git
# directories after the build has completed.
#
.SECONDARY: $($(wildcard deps/*):%=%/.git)
check-jsl-web: $(JSL_FILES_WEB:%=%.jslwebchk)
#
# This rule enables other rules that use files from a git submodule to have
# those files depend on deps/module/.git and have "make" automatically check
# out the submodule as needed.
#
deps/%/.git:
git submodule update --init deps/$*
%.jslnodechk: % $(JSL_SCRIPT)
$(JSL) $(JSL_FLAGS) $(JSL_FLAGS_NODE) $<
#
# These recipes make heavy use of dynamically-created phony targets. The parent
# Makefile defines a list of input files like BASH_FILES. We then say that each
# of these files depends on a fake target called filename.bashchk, and then we
# define a pattern rule for those targets that runs bash in check-syntax-only
# mode. This mechanism has the nice properties that if you specify zero files,
# the rule becomes a noop (unlike a single rule to check all bash files, which
# would invoke bash with zero files), and you can check individual files from
# the command line with "make filename.bashchk".
#
.PHONY: check-bash
check-bash: $(BASH_FILES:%=%.bashchk) $(BASH_FILES:%=%.bashstyle)
%.jslwebchk: % $(JSL_SCRIPT)
$(JSL) $(JSL_FLAGS) $(JSL_FLAGS_WEB) $<
%.bashchk: %
$(BASH) -n $^
%.bashstyle: %
$(BASHSTYLE) $^
#
# The above approach can be slow when there are many files to check because it
# requires that "make" invoke the check tool once for each file, rather than
# passing in several files at once. For the JavaScript check targets, we define
# a variable for the target itself *only if* the list of input files is
# non-empty. This avoids invoking the tool if there are no files to check.
#
JSL_NODE_TARGET = $(if $(JSL_FILES_NODE), check-jsl-node)
.PHONY: check-jsl-node
check-jsl-node: $(JSL_EXEC)
$(JSL) $(JSL_FLAGS) $(JSL_FLAGS_NODE) $(JSL_FILES_NODE)
JSL_WEB_TARGET = $(if $(JSL_FILES_WEB), check-jsl-web)
.PHONY: check-jsl-web
check-jsl-web: $(JSL_EXEC)
$(JSL) $(JSL_FLAGS) $(JSL_FLAGS_WEB) $(JSL_FILES_WEB)
.PHONY: check-jsl
check-jsl: $(JSL_NODE_TARGET) $(JSL_WEB_TARGET)
JSSTYLE_TARGET = $(if $(JSSTYLE_FILES), check-jsstyle)
.PHONY: check-jsstyle
check-jsstyle: $(JSSTYLE_FILES:%=%.jsstylechk)
%.jsstylechk: % $(JSSTYLE_SCRIPT)
$(JSSTYLE) $(JSSTYLE_FLAGS) $<
check-jsstyle: $(JSSTYLE_EXEC)
$(JSSTYLE) $(JSSTYLE_FLAGS) $(JSSTYLE_FILES)
.PHONY: check
check: check-jsl check-jsstyle
check: check-jsl $(JSSTYLE_TARGET) check-bash
@echo check ok
.PHONY: clean
clean:
clean::
-$(RMTREE) $(CLEAN_FILES)
.PHONY: distclean
distclean:: clean
-$(RMTREE) $(DISTCLEAN_FILES)
CSCOPE_FILES = cscope.in.out cscope.out cscope.po.out
CLEAN_FILES += $(CSCOPE_FILES)
.PHONY: xref
xref: cscope.files
$(CSCOPE) -bqR
.PHONY: cscope.files
cscope.files:
find $(CSCOPE_DIRS) -name '*.c' -o -name '*.h' -o -name '*.cc' \
-o -name '*.js' -o -name '*.s' -o -name '*.cpp' > $@
#
# The "docs" target is complicated because we do several things here:
#
@ -148,11 +224,11 @@ clean:
# identify the subdirectories in docs/media, recreate them in
# $(DOC_BUILD)/media, then do the same with the files.
#
DOC_MEDIA_DIRS := $(shell find docs/branding/media -type d | grep -v "^docs/branding/media$$")
DOC_MEDIA_DIRS := $(DOC_MEDIA_DIRS:docs/branding/media/%=%)
DOC_MEDIA_DIRS := $(shell find docs/media -type d 2>/dev/null | grep -v "^docs/media$$")
DOC_MEDIA_DIRS := $(DOC_MEDIA_DIRS:docs/media/%=%)
DOC_MEDIA_DIRS_BUILD := $(DOC_MEDIA_DIRS:%=$(DOC_BUILD)/media/%)
DOC_MEDIA_FILES := $(shell find docs/branding/media -type f)
DOC_MEDIA_FILES := $(shell find docs/media -type f 2>/dev/null)
DOC_MEDIA_FILES := $(DOC_MEDIA_FILES:docs/media/%=%)
DOC_MEDIA_FILES_BUILD := $(DOC_MEDIA_FILES:%=$(DOC_BUILD)/media/%)
@ -163,8 +239,8 @@ DOC_MEDIA_FILES_BUILD := $(DOC_MEDIA_FILES:%=$(DOC_BUILD)/media/%)
#
.PHONY: docs
docs: \
$(DOC_FILES:%.md=$(DOC_BUILD)/%.html) \
$(DOC_FILES:%.md=$(DOC_BUILD)/%.json) \
$(DOC_FILES:%.restdown=$(DOC_BUILD)/%.html) \
$(DOC_FILES:%.restdown=$(DOC_BUILD)/%.json) \
$(DOC_MEDIA_FILES_BUILD)
#
@ -172,16 +248,16 @@ docs: \
# files in DOC_BUILD are up to date.
#
.PRECIOUS: \
$(DOC_FILES:%.md=docs/%.html) \
$(DOC_FILES:%.md=docs/%json)
$(DOC_FILES:%.restdown=docs/%.html) \
$(DOC_FILES:%.restdown=docs/%json)
#
# We do clean those intermediate files, as well as all of DOC_BUILD.
#
CLEAN_FILES += \
$(DOC_BUILD) \
$(DOC_FILES:%.md=docs/%.html) \
$(DOC_FILES:%.md=docs/%.json)
$(DOC_FILES:%.restdown=docs/%.html) \
$(DOC_FILES:%.restdown=docs/%.json)
#
# Before installing the files, we must make sure the directories exist. The |
@ -193,18 +269,13 @@ $(DOC_MEDIA_FILES_BUILD): | $(DOC_MEDIA_DIRS_BUILD)
$(DOC_BUILD)/%: docs/% | $(DOC_BUILD)
$(CP) $< $@
$(RM) $<
docs/%.json docs/%.html: docs/%.md | $(DOC_BUILD)
$(RESTDOWN) -b ./docs/branding -m $(DOC_BUILD) $<
docs/%.json docs/%.html: docs/%.restdown | $(DOC_BUILD) $(RESTDOWN_EXEC)
$(RESTDOWN) $(RESTDOWN_FLAGS) -m $(DOC_BUILD) $<
$(DOC_BUILD):
$(MKDIR) $@
info:
echo "DOC_MEDIA_FILES is '$(DOC_MEDIA_FILES)'"
echo "DOC_MEDIA_FILES_BUILD is '$(DOC_MEDIA_FILES_BUILD)'"
$(DOC_MEDIA_DIRS_BUILD):
$(MKDIR) $@