diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..a8149a8 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,27 @@ +module.exports = { + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 2 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ] + } +}; diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..8ff0e32 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,46 @@ +{ + "disallowKeywordsOnNewLine": [ "else" ], + "disallowMixedSpacesAndTabs": true, + "disallowMultipleLineStrings": true, + "disallowMultipleVarDecl": true, + "disallowNewlineBeforeBlockStatements": true, + "disallowQuotedKeysInObjects": true, + "disallowSpaceAfterObjectKeys": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "disallowSpacesInCallExpression": true, + "disallowTrailingComma": true, + "disallowTrailingWhitespace": true, + "disallowYodaConditions": true, + + "requireCommaBeforeLineBreak": true, + "requireOperatorBeforeLineBreak": true, + "requireSpaceAfterBinaryOperators": true, + "requireSpaceAfterKeywords": [ "if", "for", "while", "else", "try", "catch" ], + "requireSpaceAfterLineComment": true, + "requireSpaceBeforeBinaryOperators": true, + "requireSpaceBeforeBlockStatements": true, + "requireSpaceBeforeKeywords": [ "else", "catch" ], + "requireSpaceBeforeObjectValues": true, + "requireSpaceBetweenArguments": true, + "requireSpacesInAnonymousFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInFunctionDeclaration": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInConditionalExpression": true, + "requireSpacesInForStatement": true, + "requireSpacesInsideArrayBrackets": "all", + "requireSpacesInsideObjectBrackets": "all", + "requireDotNotation": false, + + "maximumLineLength": 80, + "validateIndentation": 2, + "validateLineBreaks": "LF", + "validateParameterSeparator": ", ", + "validateQuoteMarks": "'" +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cb3e106 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +SRC_FILES= +SRC_FILES+= lib/*.js +SRC_FILES+= lib/**/*.js +SRC_FILES+= lib/**/**/*.js +SRC_FILES+= lib/**/**/**/*.js + +SRC_FILES+= bin/gyp +SRC_FILES+= test/*.js + +lint: + eslint $(SRC_FILES) + +format: + eslint --fix $(SRC_FILES) + +.PHONY: lint format diff --git a/lib/gyp.js b/lib/gyp.js index 4e32ffa..7ddae65 100644 --- a/lib/gyp.js +++ b/lib/gyp.js @@ -43,7 +43,7 @@ function debugOutput(mode, message) { throw new Error(''); } catch (e) { const prefix = e.stack.split('\n')[2].replace(/^\s*at\s*/g, ''); - console.log(`${mode.toUpperCase()}:${prefix} ${message}`); + gyp.bindings.log(`${mode.toUpperCase()}:${prefix} ${message}`); } } } @@ -79,7 +79,7 @@ function load(buildFiles, format, defaultVariables = {}, includes = [], * named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, * avoiding collisions with user and automatic variables. */ - defaultVariables['GENERATOR'] = format + defaultVariables['GENERATOR'] = format; defaultVariables['GENERATOR_FLAVOR'] = params['flavor'] || ''; /* Format can be a custom JS file, or by default the name of a module @@ -136,7 +136,7 @@ function load(buildFiles, format, defaultVariables = {}, includes = [], buildFiles, defaultVariables, includes.slice(), depth, generatorInputInfo, check, circularCheck, duplicateBasenameCheck, - params['root_targets']) + params['root_targets']); return [ generator ].concat(result); } @@ -173,105 +173,6 @@ function shlexEnv(envName) { return flags || []; } -function formatOpt(opt, value) { - if (/^--/.test(opt)) - return `${opt}=${value}`; - return opt + value; -} - -function regenerateAppendFlag(flag, values, predicate, envName, options) { - /* - * Regenerate a list of command line flags, for an option of action='append'. - * The |env_name|, if given, is checked in the environment and used to - * generate an initial list of options, then the options that were specified - * on the command line (given in |values|) are appended. This matches the - * handling of environment variables and command line flags where command line - * flags override the environment, while not requiring the environment to be - * set when the flags are used again. - */ - - const flags = []; - if (options.use_environment && envName) { - const s = shlexEnv(envName); - for (let i = 0; i < s.length;i++) { - const flagValue = s[i]; - const value = formatOpt(flag, predicate(flagValue)); - - const index = flags.indexOf(value); - if (index !== -1) - flags.splice(index, 1); - - flags.push(value); - } - } - if (values) { - for (let i = 0; i < values.length; i++) { - const flagValue = values[i]; - flags.push(formatOpt(flag, predicate(flagValue))); - } - } - return flags; -} - -function regenerateFlags(options) { - /* Given a parsed options object, and taking the environment variables into - * account, returns a list of flags that should regenerate an equivalent - * options object (even in the absence of the environment variables.) - * - * Any path options will be normalized relative to depth. - * - * The format flag is not included, as it is assumed the calling generator - * will set that as appropriate. - */ - function fixPath(path) { - path = gyp.common.fixIfRelativePath(path, options.depth); - - // PORT: os.path.curdir - if (!path) - return '.'; - return path; - } - - function noop(value) { - return value; - } - - // We always want to ignore the environment when regenerating, to avoid - // duplicate or changed flags in the environment at the time of regeneration. - const flags = [ '--ignore-environment' ]; - const meta = options._regenerationMetadata; - Object.keys(meta).forEach((name) => { - const metadata = meta[name]; - - const opt = metadata['opt']; - const value = options.name; - const valuePredicate = metadata['type'] === 'path' ? fixPath : noop; - const action = metadata['action']; - const envName = metadata['envName']; - if (action === 'append') { - flags = flags.concat(regenerateAppendFlag(opt, value, valuePredicate, - envName, options)); - } else if (action === 'store' || !action) { - if (value) - flags.push(formatOpt(opt, valuePredicate(value))); - else if (options.use_environment && envName && process.env[envName]) - flags.push(formatOpt(opt, valuePredicate(process.env[envName]))); - } else if (action === 'store_true' || action === 'store_false') { - if (action === 'store_true' && value || - action === 'store_false' && !value) { - flags.append(opt); - } else if (options.use_environment && envName) { - console.error(`Warning: environment regeneration unimplemented for ` + - `${action} flag "${opt}" env_name "${envName}"`); - } - } else { - console.error(`Warning: regeneration unimplemented for action ` + - `${action} flag "${opt}"`); - } - }); - return flags; -} - function RegeneratableOptionParser() { this.options = {}; this.letters = {}; @@ -333,7 +234,7 @@ RegeneratableOptionParser.prototype.setUsage = function setUsage(usage) { }; RegeneratableOptionParser.prototype.printHelp = function printHelp() { - console.error(this.usage); + gyp.bindings.error(this.usage); let max = 0; Object.keys(this.options).forEach((name) => { @@ -356,7 +257,7 @@ RegeneratableOptionParser.prototype.printHelp = function printHelp() { desc += ' '; desc += `${option.help}`; - console.error(desc); + gyp.bindings.error(desc); }); process.exit(0); }; @@ -498,9 +399,9 @@ gyp.main = function main(args) { * deprecated. */ parser.addOption('no-duplicate-basename-check', { - dest: 'duplicate_basename_check', action: 'store_false', - default: true, regenerate: false, - help: 'don\'t check for duplicate basenames' }); + dest: 'duplicate_basename_check', action: 'store_false', + default: true, regenerate: false, + help: 'don\'t check for duplicate basenames' }); parser.addOption('suffix', 'S', { dest: 'suffix', default: '', help: 'suffix to add to generated files' }); parser.addOption('toplevel-dir', { dest: 'toplevel_dir', action: 'store', @@ -564,7 +465,7 @@ gyp.main = function main(args) { // Do an extra check to avoid work when we're not debugging. if (gyp.debug[DEBUG_GENERAL]) { - debugOutput(DEBUG_GENERAL, 'running with these options:') + debugOutput(DEBUG_GENERAL, 'running with these options:'); Object.keys(options).sort().forEach((option) => { const value = options[option]; if (option[0] === '_') @@ -609,7 +510,7 @@ gyp.main = function main(args) { if (homeDotGyp) { const defaultInclude = path.join(homeDotGyp, 'include.gypi'); if (fs.existsSync(defaultInclude)) { - console.log(`Using overrides found in ${defaultInclude}`); + gyp.bindings.log(`Using overrides found in ${defaultInclude}`); includes.push(defaultInclude); } } diff --git a/lib/gyp/bindings.js b/lib/gyp/bindings.js index 6d68a2f..b46c8fb 100644 --- a/lib/gyp/bindings.js +++ b/lib/gyp/bindings.js @@ -1,6 +1,5 @@ 'use strict'; -const util = require('util'); const path = require('path'); const fs = require('fs'); const execSync = require('child_process').execSync; @@ -34,3 +33,11 @@ exports.process = { platform: process.platform, exit: (code) => process.exit(code) }; + +exports.log = function log(message) { + process.stdout.write(message + '\n'); +}; + +exports.error = function error(message) { + process.stderr.write(message + '\n'); +}; diff --git a/lib/gyp/common.js b/lib/gyp/common.js index 1697f13..2f29215 100644 --- a/lib/gyp/common.js +++ b/lib/gyp/common.js @@ -232,32 +232,34 @@ function parseQualifiedTarget(target) { // NOTE: rsplit is used to disambiguate the Windows drive letter separator. let buildFile; if (/:/.test(target)) { - let _; - [ _, buildFile, target ] = target.match(/^(.*?)(?::([^:]*))?$/); + const match = target.match(/^(.*?)(?::([^:]*))?$/); + buildFile = match[1]; + target = match[2]; } else { buildFile = undefined; } let toolset; if (/#/.test(target)) { - let _; - [ _, target, toolset ] = target.match(/^(.*?)(?:#([^:]*))?$/); + const match = target.match(/^(.*?)(?:#([^:]*))?$/); + target = match[1]; + toolset = match[2]; } else { toolset = undefined; } return [ buildFile, target, toolset ]; -}; +} exports.parseQualifiedTarget = parseQualifiedTarget; -exports.findQualifiedTargets = function findQualifiedTargets(target, flatList) { +exports.findQualifiedTargets = function findQualifiedTargets() { throw new Error('Not implemented'); }; exports.buildFile = function (fullyQualifiedTarget) { // Extracts the build file from the fully qualified target. return parseQualifiedTarget(fullyQualifiedTarget)[0]; -} +}; // // Python shims diff --git a/lib/gyp/generator/ninja/index.js b/lib/gyp/generator/ninja/index.js index dad18a2..3cb9027 100644 --- a/lib/gyp/generator/ninja/index.js +++ b/lib/gyp/generator/ninja/index.js @@ -4,7 +4,6 @@ const gyp = require('../../../gyp'); const Writer = require('./writer'); const path = gyp.bindings.path; -const fs = gyp.bindings.fs; const process = gyp.bindings.process; const generatorDefaultVariables = { @@ -50,7 +49,7 @@ exports.generatorFilelistPaths = undefined; exports.generatorSupportsMultipleToolsets = gyp.common.crossCompileRequested(); -function calculateVariables(defaultVariables, params) { +function calculateVariables(defaultVariables) { function setdef(key, val) { if (!defaultVariables.hasOwnProperty(key)) defaultVariables[key] = val; @@ -64,11 +63,11 @@ function calculateVariables(defaultVariables, params) { setdef('LIB_DIR', generatorDefaultVariables['PRODUCT_DIR']); } else if (process.platform === 'win32') { // TODO(indutny): MSVS_VERSION, MSVS_OS_BITS - setdef('OS', 'win') + setdef('OS', 'win'); defaultVariables['EXECUTABLE_SUFFIX'] = '.exe'; - defaultVariables['STATIC_LIB_PREFIX'] = '' + defaultVariables['STATIC_LIB_PREFIX'] = ''; defaultVariables['STATIC_LIB_SUFFIX'] = '.lib'; - defaultVariables['SHARED_LIB_PREFIX'] = '' + defaultVariables['SHARED_LIB_PREFIX'] = ''; defaultVariables['SHARED_LIB_SUFFIX'] = '.dll'; } else { setdef('OS', process.platform); @@ -76,10 +75,10 @@ function calculateVariables(defaultVariables, params) { setdef('SHARED_LIB_DIR', path.join('$!PRODUCT_DIR', 'lib')); setdef('LIB_DIR', path.join('$!PRODUCT_DIR', 'obj')); } -}; +} exports.calculateVariables = calculateVariables; -function Ninja({ index, outDir, target, targetDict, ninjas, config } = extra) { +function Ninja({ index, outDir, target, targetDict, ninjas, config }) { const [ buildFile, targetName, toolset ] = gyp.common.parseQualifiedTarget(target); @@ -87,7 +86,7 @@ function Ninja({ index, outDir, target, targetDict, ninjas, config } = extra) { if (toolset !== 'target') obj += '.' + toolset; - this.index = 0; + this.index = index; this.ninjas = ninjas; this.config = config; @@ -162,7 +161,6 @@ Ninja.prototype.type = function type() { }; Ninja.prototype.output = function output() { - const targetDict = this.targetDict; let res = []; let vars = gyp.common.shallowCopy(generatorDefaultVariables); @@ -272,7 +270,7 @@ Ninja.prototype.vars = function vars() { // TODO(indutny): library_dirs libs = libs.concat(targetDict.libraries || []); if (this.flavor === 'win32') { - libs = gyp.platform.win.adjustLibraries(libs) + libs = gyp.platform.win.adjustLibraries(libs); } const prepare = (list) => { return list.map(v => this.expand(v)).join(' ').trim(); @@ -563,8 +561,8 @@ NinjaMain.prototype.defaults = function defaults() { this.params.build_files.forEach((buildFile) => { this.targetList.forEach((target) => { - const [ targetBuildFile, _1, _2 ] = - gyp.common.parseQualifiedTarget(target); + const targetBuildFile = + gyp.common.parseQualifiedTarget(target)[0]; if (targetBuildFile !== buildFile) return; @@ -579,7 +577,7 @@ NinjaMain.prototype.defaults = function defaults() { main.sectionEnd('defaults'); main.finalize(); -} +}; exports.generateOutput = function generateOutput(targetList, targetDicts, data, params) { diff --git a/lib/gyp/input.js b/lib/gyp/input.js index dcbb848..5414bfa 100644 --- a/lib/gyp/input.js +++ b/lib/gyp/input.js @@ -32,7 +32,7 @@ const basePathSections = [ 'inputs', 'libraries', 'outputs', - 'sources', + 'sources' ]; let pathSections = {}; @@ -299,7 +299,7 @@ function processToolsetsInDict(data) { newTarget['toolset'] = build; newTargetList.push(target); }); - target['toolset'] = toolsets[0] + target['toolset'] = toolsets[0]; newTargetList.push(target); } }); @@ -385,11 +385,11 @@ function loadTargetBuildFile(buildFilePath, data, auxData, variables, includes, // Apply "pre"/"early" variable expansions and condition evaluations. processVariablesAndConditionsInDict( - buildFileData, 'PHASE_EARLY', variables, buildFilePath) + buildFileData, 'PHASE_EARLY', variables, buildFilePath); // Since some toolsets might have been defined conditionally, perform // a second round of toolsets expansion now. - processToolsetsInDict(buildFileData) + processToolsetsInDict(buildFileData); // Look at each project's target_defaults dict, and merge settings into // targets. @@ -567,7 +567,7 @@ function expandVariables(input, phase, variables, buildFile) { } else if (phase === 'PHASE_LATELATE') { variableRe = LATELATE_VARIABLE_RE; } else { - throw new Error(`Unexpected phase: ${PHASE}`); + throw new Error(`Unexpected phase: ${phase}`); } let inputStr = String(input); @@ -746,7 +746,12 @@ function expandVariables(input, phase, variables, buildFile) { let p; try { - p = execSync(contents); + if (useShell) { + p = execSync(contents); + } else { + // TODO(indutny): implement me + throw new Error('Array commands not implemented yet'); + } } catch (e) { e.message += `\nCall to '${contents} failed while in ${buildFile}`; throw e; @@ -907,7 +912,7 @@ function evalCondition(condition, conditionsKey, phase, variables, buildFile) { const trueDict = condition[i + 1]; if (typeof trueDict !== 'object') { - throw new Error(`${conditionsKey} ${condExpr} must be followed by a ` + throw new Error(`${conditionsKey} ${condExpr} must be followed by a ` + `dictionary, not ${typeof trueDict}`); } @@ -948,7 +953,7 @@ function evalSingleCondition(condExpr, trueDict, falseDict, phase, variables, buildFile); if (typeof condExprExpanded !== 'string' && typeof condExprExpanded !== 'number') { - throw new Error(`Variable expansion in this context permits str and int ` + + throw new Error('Variable expansion in this context permits str and int ' + `only, found ${typeof condExprExpanded}`); } @@ -1044,7 +1049,7 @@ function loadVariablesFromVariablesDict(variables, theDict, theDictKey) { return; Object.keys(vars).forEach((key) => { - const value = vars[key]; + let value = vars[key]; if (typeof value !== 'string' && typeof value !== 'number' && !Array.isArray(value)) { @@ -1112,7 +1117,7 @@ function processVariablesAndConditionsInDict(theDict, phase, variablesIn, const expanded = expandVariables(value, phase, variables, buildFile); if (typeof expanded !== 'string' && typeof expanded !== 'number') { throw new Error( - `Variable expansion in this context permits str and int ` + + 'Variable expansion in this context permits str and int ' + `only, found ${typeof expanded} for ${key}`); } theDict[key] = expanded; @@ -1216,7 +1221,7 @@ function processVariablesAndConditionsInList(theList, phase, variables, continue; } else { throw new Error( - `Variable expansion in this context permits strings and ` + + 'Variable expansion in this context permits strings and ' + `lists only, found ${typeof expanded} at ${index}`); } } else if (typeof item !== 'number') { @@ -1319,8 +1324,8 @@ function expandWildcardDependencies(targets, data) { */ Object.keys(targets).forEach((target) => { + // TODO(indutny): toolsets? const targetDict = targets[target]; - const toolset = targetDict['toolset']; const targetBuildFile = gyp.common.buildFile(target); dependencySections.forEach((dependencyKey) => { @@ -1531,7 +1536,7 @@ DependencyGraphNode.prototype.flattenToList = function flattenToList() { } return Array.from(flatList.values()); -} +}; DependencyGraphNode.prototype.findCycles = function findCycles() { /* @@ -1544,7 +1549,7 @@ DependencyGraphNode.prototype.findCycles = function findCycles() { node.dependents.forEach((child) => { const i = path.indexOf(child); if (i !== -1) { - results.push([ child ].concat(path.slice(0, index + 1))); + results.push([ child ].concat(path.slice(0, i + 1))); } else { visited.add(child); visit(child, [ child ].concat(path)); @@ -1558,8 +1563,8 @@ DependencyGraphNode.prototype.findCycles = function findCycles() { return results; }; -DependencyGraphNode.prototype.directDependencies = - function directDependencies(dependencies) { + +function directDependencies(dependencies) { // Returns a list of just direct dependencies. if (!dependencies) dependencies = []; @@ -1571,10 +1576,10 @@ DependencyGraphNode.prototype.directDependencies = }); return dependencies; -}; +} +DependencyGraphNode.prototype.directDependencies = directDependencies; -DependencyGraphNode.prototype._addImportedDependencies = - function _addImportedDependencies(targets, dependencies) { +function _addImportedDependencies(targets, dependencies) { /* Given a list of direct dependencies, adds indirect dependencies that * other dependencies have declared to export their settings. * @@ -1605,8 +1610,8 @@ DependencyGraphNode.prototype._addImportedDependencies = // dependency that exported them. This is done to more closely match // the depth-first method used by DeepDependencies. let addIndex = 1; - (dependencyDict['export_dependent_settings'] || []) - .forEach((importedDependency) => { + const exportSettings = dependencyDict['export_dependent_settings'] || []; + exportSettings.forEach((importedDependency) => { if (dependencies.indexOf(importedDependency) === -1) { dependencies.splice(index + addIndex, 0, importedDependency); addIndex++; @@ -1616,20 +1621,22 @@ DependencyGraphNode.prototype._addImportedDependencies = } return dependencies; -}; +} +DependencyGraphNode.prototype._addImportedDependencies = + _addImportedDependencies; -DependencyGraphNode.prototype.directAndImportedDependencies = - function directAndImportedDependencies(targets, dependencies) { +function directAndImportedDependencies(targets, dependencies) { /* Returns a list of a target's direct dependencies and all indirect * dependencies that a dependency has advertised settings should be exported * through the dependency for. */ dependencies = this.directDependencies(dependencies); return this._addImportedDependencies(targets, dependencies); -}; +} +DependencyGraphNode.prototype.directAndImportedDependencies = + directAndImportedDependencies; -DependencyGraphNode.prototype.deepDependencies = - function deepDependencies(dependencies) { +function deepDependencies(dependencies) { /* Returns an OrderedSet of all of a target's dependencies, recursively. */ if (!dependencies) { // Using a list to get ordered output and a set to do fast "is it @@ -1650,11 +1657,11 @@ DependencyGraphNode.prototype.deepDependencies = }); return dependencies; -}; +} +DependencyGraphNode.prototype.deepDependencies = deepDependencies; -DependencyGraphNode.prototype._linkDependenciesInternal = - function _linkDependenciesInternal(targets, includeSharedLibraries, - dependencies, initial = true) { +function _linkDependenciesInternal(targets, includeSharedLibraries, + dependencies, initial = true) { /* Returns an OrderedSet of dependency targets that are linked * into this target. * @@ -1688,7 +1695,7 @@ DependencyGraphNode.prototype._linkDependenciesInternal = throw new Error('Missing \'target_name\' field in target.'); if (!targets[this.ref].hasOwnProperty('type')) { - throw new Error(`Missing 'type' field in target ` + + throw new Error('Missing \'type\' field in target ' + `${targets[this.ref]['target_name']}`); } @@ -1753,10 +1760,11 @@ DependencyGraphNode.prototype._linkDependenciesInternal = } return dependencies; -}; +} +DependencyGraphNode.prototype._linkDependenciesInternal = + _linkDependenciesInternal; -DependencyGraphNode.prototype.dependenciesForLinkSettings = - function dependenciesForLinkSettings(targets) { +function dependenciesForLinkSettings(targets) { /* * Returns a list of dependency targets whose link_settings should be merged * into this target. @@ -1769,23 +1777,25 @@ DependencyGraphNode.prototype.dependenciesForLinkSettings = const includeSharedLibraries = targets[this.ref]['allow_sharedlib_linksettings_propagation'] !== false; return this._linkDependenciesInternal(targets, includeSharedLibraries); -}; +} +DependencyGraphNode.prototype.dependenciesForLinkSettings = + dependenciesForLinkSettings; -DependencyGraphNode.prototype.dependenciesToLinkAgainst = - function dependenciesToLinkAgainst(targets) { +function dependenciesToLinkAgainst(targets) { /* * Returns a list of dependency targets that are linked into this target. */ return this._linkDependenciesInternal(targets, true); -}; +} +DependencyGraphNode.prototype.dependenciesToLinkAgainst = + dependenciesToLinkAgainst; function buildDependencyList(targets) { // Create a DependencyGraphNode for each target. Put it into a dict for easy // access. const dependencyNodes = {}; Object.keys(targets).forEach((target) => { - const spec = targets[target]; if (!dependencyNodes.hasOwnProperty(target)) dependencyNodes[target] = new DependencyGraphNode(target); }); @@ -1805,7 +1815,7 @@ function buildDependencyList(targets) { dependencies.forEach((dependency) => { const dependencyNode = dependencyNodes[dependency]; if (!dependencyNode) { - throw new Error(`Dependency '${dependency}' not found while ` + throw new Error(`Dependency '${dependency}' not found while ` + `trying to load target ${target}`); } // TODO(indutny): method for this @@ -1887,7 +1897,7 @@ function verifyNoGYPFileCircularDependencies(targets) { // Files that have no dependencies are treated as dependent on root_node. const rootNode = new DependencyGraphNode(undefined); - dependencyNodes.forEach((buildFileNode, k) => { + dependencyNodes.forEach((buildFileNode) => { if (buildFileNode.dependencies.length === 0) { buildFileNode.dependencies.push(rootNode); rootNode.dependents.push(buildFileNode); @@ -1936,7 +1946,7 @@ function doDependentSettings(key, flatList, targets, dependencyNodes) { dependencies = dependencyNodes[target].dependenciesForLinkSettings(targets); } else { - throw new Error(`DoDependentSettings doesn't know how to determine ` + + throw new Error('DoDependentSettings doesn\'t know how to determine ' + `dependencies for ${key}`); } @@ -2024,8 +2034,8 @@ function adjustStaticLibraryDependencies(flatList, targets, dependencyNodes, // Note: flat_list is already sorted in the order from dependencies to // dependents. if (sortDependencies && targetDict.hasOwnProperty('dependencies')) { - targetDict['dependencies'] = flatList.slice().reverse() - .filter((dep) => { + const deps = flatList.slice().reverse(); + targetDict['dependencies'] = deps.filter((dep) => { return targetDict['dependencies'].indexOf(dep) !== -1; }); } @@ -2169,7 +2179,7 @@ function mergeDicts(to, fro, toFile, froFile) { if (badMerge) { throw TypeError( - `Attempt to merge dict value of type $[typeof v} ` + + `Attempt to merge dict value of type ${typeof v} ` + `into incompatible type ${typeof to[k]} ` + `for key ${k}`); } @@ -2257,7 +2267,7 @@ function mergeDicts(to, fro, toFile, froFile) { mergeDicts(to[k], v, toFile, froFile); } else { throw new Error( - `Attempt to merge dict value of unsupported type ` + 'Attempt to merge dict value of unsupported type ' + `${typeof v} for key ${k}`); } }); @@ -2369,7 +2379,7 @@ function setUpConfigurations(target, targetDict) { keyBase = key.slice(0, -1); else keyBase = key; - if (nonConfigurationKeys.indexOf(key) === -1) + if (nonConfigurationKeys.indexOf(keyBase) === -1) deleteKeys.push(key); }); deleteKeys.forEach((key) => { @@ -2423,7 +2433,7 @@ function processListFiltersInDict(name, theDict) { const lists = []; const delLists = []; Object.keys(theDict).forEach((key) => { - const value = theDict[key]; + let value = theDict[key]; const operation = key[key.length - 1]; if (operation !== '!' && operation !== '/') return; @@ -2597,8 +2607,8 @@ function validateTargetType(target, targetDict) { if (targetDict['standalone_static_library'] && targetType !== 'static_library') { throw new Error(`Target ${target} has type ${targetType} but ` + - `standalone_static_library flag is only valid for ` + - `static_library type.`); + 'standalone_static_library flag is only valid for ' + + 'static_library type.'); } } @@ -2633,11 +2643,11 @@ function validateSourcesInTarget(target, targetDict, buildFile, }); if (error) { - console.log( - `static library ${target} has several files with the same basename:\n` + - error + - `libtool on Mac cannot handle that. Use --no-duplicate-basename-check ` + - `to disable this validation.`); + gyp.bindings.log( + `static library ${target} has several files with the same basename:\n` + + error + + 'libtool on Mac cannot handle that. Use ' + + '--no-duplicate-basename-check to disable this validation.'); throw new Error('Duplicate basenames in sources section, see list above'); } } @@ -2679,7 +2689,7 @@ function validateRulesInTarget(target, targetDict, extraSourcesForRules) { // Make sure rule_sources isn't already there. It's going to be // created below if needed. if (rule.hasOwnProperty('rule_sources')) { - throw new Error(`rule_sources must not exists in input, ` + + throw new Error('rule_sources must not exists in input, ' + `target ${target}, rule ${ruleName}`); } @@ -2688,7 +2698,7 @@ function validateRulesInTarget(target, targetDict, extraSourcesForRules) { sourceKeys.forEach((sourceKey) => { (targetDict[sourceKey] || []).forEach((source) => { // PORT: os.path.splitext - let [ sourceRoot, sourceExtension ] = gyp.common.splitext(source); + let sourceExtension = path.extname(source); if (sourceExtension[0] === '.') sourceExtension = sourceExtension.slice(1); if (sourceExtension === ruleExtension) @@ -2721,18 +2731,18 @@ function validateRunAsInTarget(target, targetDict, buildFile) { } const workingDirectory = runAs['working_directory']; if (workingDirectory && typeof workingDirectory !== 'string') { - throw new Error(`The 'working_directory' for 'run_as' in target ` + + throw new Error('The \'working_directory\' for \'run_as\' in target ' + `${targetName} from file ${buildFile} should be a string.`); } const environment = runAs['environment']; if (environment && typeof environment !== 'object') { - throw new Error(`The 'environment' for 'run_as' in target ` + + throw new Error('The \'environment\' for \'run_as\' in target ' + `${targetName} from file ${buildFile} should be a ` + - `dictionary.`); + 'dictionary.'); } } -function validateActionsInTarget(target, targetDict, buildFile) { +function validateActionsInTarget(target, targetDict) { /* Validates the inputs to the actions in a target. */ const targetName = targetDict['target_name']; const actions = targetDict['actions'] || []; @@ -2740,7 +2750,7 @@ function validateActionsInTarget(target, targetDict, buildFile) { const actionName = action['action_name']; if (!actionName) { throw new Error(`Anonymous action in target ${targetName}. ` + - `An action must have an 'action_name' field.`); + 'An action must have an \'action_name\' field.'); } const inputs = action['inputs']; if (!inputs) @@ -2840,7 +2850,9 @@ function verifyNoCollidingTargets(targets) { targets.forEach((target) => { // Separate out 'path/to/file.gyp, 'target_name' from // 'path/to/file.gyp:target_name'. - const [ _, tpath, name ] = target.match(/^(.*?)(?::([^:]*))?$/); + const match = target.match(/^(.*?)(?::([^:]*))?$/); + const tpath = match[1]; + const name = match[2]; // Separate out 'path/to', 'file.gyp' from 'path/to/file.gyp'. let subdir = path.dirname(tpath); const gyp = path.basename(tpath); @@ -2910,7 +2922,7 @@ function load(buildFiles, variables, includes, depth, generatorInputInfo, check, }); // Build a dict to access each target's subdict by qualified name. - const targets = buildTargetsDict(data); + let targets = buildTargetsDict(data); // Fully qualify all dependency links. qualifyDependencies(targets); @@ -2968,9 +2980,11 @@ function load(buildFiles, variables, includes, depth, generatorInputInfo, check, verifyNoCollidingTargets(flatList); // Handle dependent settings of various types. - [ 'all_dependent_settings', + [ + 'all_dependent_settings', 'direct_dependent_settings', - 'link_settings' ].forEach((settingsType) => { + 'link_settings' + ].forEach((settingsType) => { doDependentSettings(settingsType, flatList, targets, dependencyNodes); // Take out the dependent settings now that they've been published to all diff --git a/lib/gyp/platform/darwin.js b/lib/gyp/platform/darwin.js index d5df64a..f4db074 100644 --- a/lib/gyp/platform/darwin.js +++ b/lib/gyp/platform/darwin.js @@ -13,7 +13,7 @@ darwin.compilerFlags = function compilerFlags(xc) { if (xc.CLANG_WARN_CONSTANT_CONVERSION === 'YES') cflags.push('-Wconstant-conversion'); if (xc.GCC_CHAR_IS_UNSIGNED_CHAR === 'YES') - cflags.push('-funsigned-char') + cflags.push('-funsigned-char'); if (xc.GCC_CW_ASM_SYNTAX !== 'NO') cflags.push('-fasm-blocks'); if (xc.GCC_OPTIMIZATION_LEVEL) @@ -25,7 +25,7 @@ darwin.compilerFlags = function compilerFlags(xc) { if (xc.ARCHS && xc.ARCHS.length === 1) cflags.push(`-arch ${xc.ARCHS[0]}`); else - cflags.push('-arch i386') + cflags.push('-arch i386'); if (xc.GCC_C_LANGUAGE_STANDARD === 'ansi') cflags_c.push('-ansi'); diff --git a/lib/gyp/platform/unix.js b/lib/gyp/platform/unix.js index 79b01d7..c67ad68 100644 --- a/lib/gyp/platform/unix.js +++ b/lib/gyp/platform/unix.js @@ -1,3 +1,5 @@ +'use strict'; + const gyp = require('../../gyp'); const process = gyp.bindings.process; @@ -26,8 +28,8 @@ unix.ninjaRules = function ninjaRules(n, useCxx) { `${useCxx ? '$ldflags_cc $cflags_cc' : '$ldflags_c $cflags_c'} ` + (process.platform === 'darwin' ? '$in ' : - `-Wl,--start-group $in -Wl,--end-group `) + - `$cflags -o $out $solibs $libs`, + '-Wl,--start-group $in -Wl,--end-group ') + + '$cflags -o $out $solibs $libs', pool: 'link_pool', description: 'LINK $out' }); @@ -37,8 +39,8 @@ unix.ninjaRules = function ninjaRules(n, useCxx) { `${useCxx ? '$ldflags_cc $cflags_cc' : '$ldflags_c $cflags_c'} ` + (process.platform === 'darwin' ? '$in ' : - `-Wl,--start-group $in -Wl,--end-group `) + - `$cflags -o $out $solibs $libs`, + '-Wl,--start-group $in -Wl,--end-group ') + + '$cflags -o $out $solibs $libs', pool: 'link_pool', description: 'SOLINK $out' }); diff --git a/lib/gyp/platform/win.js b/lib/gyp/platform/win.js index 79645a7..8e6c64d 100644 --- a/lib/gyp/platform/win.js +++ b/lib/gyp/platform/win.js @@ -1,7 +1,5 @@ 'use strict'; -const gyp = require('../../gyp'); - const win = exports; win.ninjaRules = function ninjaRules(n) { @@ -67,18 +65,18 @@ win.adjustLibraries = function adjustLibraries(libs) { const suffix = '.lib' + quoted; if (!lib.toLowerCase().endsWith(suffix)) lib = lib.substr(0, lib.length - !!quoted) + suffix; - return lib + return lib; }); -} +}; -function SettingsWrapper(settings, flags) { +function settingsWrapper(settings, flags) { return function(name, options) { options = options || {}; const append = function(value) { if (value !== undefined) { switch (typeof options.map) { - case 'function': value = options.map(value); break; - case 'object': value = options.map[value]; break; + case 'function': value = options.map(value); break; + case 'object': value = options.map[value]; break; } if (value !== undefined && options.prefix) value = options.prefix + value; @@ -94,7 +92,7 @@ function SettingsWrapper(settings, flags) { } else { append(value); } - } + }; } function expandMSBuildMacros(value) { @@ -105,7 +103,7 @@ function expandMSBuildMacros(value) { function compilerFlags(compiler) { let cflags = []; if (compiler) { - let cl = SettingsWrapper(compiler, cflags); + let cl = settingsWrapper(compiler, cflags); cl('Optimization', { map: {'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix: '/O', defvalue: '2' }); @@ -114,44 +112,44 @@ function compilerFlags(compiler) { cl('StringPooling', { map: {'true': '/GF'} }); cl('EnableFiberSafeOptimizations', { map: {'true': '/GT'} }); cl('OmitFramePointers', { - map: {'false': '-', 'true': ''}, prefix: '/Oy' }) + map: {'false': '-', 'true': ''}, prefix: '/Oy' }); cl('EnableIntrinsicFunctions', { - map: {'false': '-', 'true': ''}, prefix: '/Oi' }) + map: {'false': '-', 'true': ''}, prefix: '/Oi' }); cl('FavorSizeOrSpeed', { - map: {'1': 't', '2': 's'}, prefix: '/O' }) + map: {'1': 't', '2': 's'}, prefix: '/O' }); cl('FloatingPointModel', { map: {'0': 'precise', '1': 'strict', '2': 'fast'}, - prefix: '/fp:', defvalue: '0' }) - cl('WholeProgramOptimization', { map: {'true': '/GL'} }) - cl('WarningLevel', { prefix: '/W' }) - cl('WarnAsError', { map: {'true': '/WX'} }) + prefix: '/fp:', defvalue: '0' }); + cl('WholeProgramOptimization', { map: {'true': '/GL'} }); + cl('WarningLevel', { prefix: '/W' }); + cl('WarnAsError', { map: {'true': '/WX'} }); cl('CallingConvention', { map: {'0': 'd', '1': 'r', '2': 'z', '3': 'v'}, - prefix: '/G' }) + prefix: '/G' }); cl('DebugInformationFormat', { - map: {'1': '7', '3': 'i', '4': 'I'}, prefix: '/Z' }) - cl('RuntimeTypeInfo', { map: {'true': '/GR', 'false': '/GR-'} }) + map: {'1': '7', '3': 'i', '4': 'I'}, prefix: '/Z' }); + cl('RuntimeTypeInfo', { map: {'true': '/GR', 'false': '/GR-'} }); cl('EnableFunctionLevelLinking', { - map: {'true': '/Gy', 'false': '/Gy-'} }) - cl('MinimalRebuild', { map: {'true': '/Gm'} }) - cl('BufferSecurityCheck', { map: {'true': '/GS', 'false': '/GS-'} }) + map: {'true': '/Gy', 'false': '/Gy-'} }); + cl('MinimalRebuild', { map: {'true': '/Gm'} }); + cl('BufferSecurityCheck', { map: {'true': '/GS', 'false': '/GS-'} }); cl('BasicRuntimeChecks', { - map: {'1': 's', '2': 'u', '3': '1'}, prefix: '/RTC' }) + map: {'1': 's', '2': 'u', '3': '1'}, prefix: '/RTC' }); cl('RuntimeLibrary', { - map: {'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix: '/M' }) - cl('ExceptionHandling', { map: {'1': 'sc','2': 'a'}, prefix: '/EH' }) - cl('DefaultCharIsUnsigned', { map: {'true': '/J'} }) + map: {'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix: '/M' }); + cl('ExceptionHandling', { map: {'1': 'sc','2': 'a'}, prefix: '/EH' }); + cl('DefaultCharIsUnsigned', { map: {'true': '/J'} }); cl('TreatWChar_tAsBuiltInType', { - map: {'false': '-', 'true': ''}, prefix: '/Zc:wchar_t' }) - cl('EnablePREfast', { map: {'true': '/analyze'} }) - cl('AdditionalOptions') + map: {'false': '-', 'true': ''}, prefix: '/Zc:wchar_t' }); + cl('EnablePREfast', { map: {'true': '/analyze'} }); + cl('AdditionalOptions'); cl('EnableEnhancedInstructionSet', { map: {'1': 'SSE', '2': 'SSE2', '3': 'AVX', '4': 'IA32', '5': 'AVX2'}, - prefix: '/arch:' }) + prefix: '/arch:' }); cl('ForcedIncludeFiles', { prefix: '/FI'}); // New flag required in 2013 to maintain previous PDB behavior. - if (true) //TODO: (vs_version.short_name in ('2013', '2013e', '2015')) - cflags.push('/FS'); + //TODO: if (vs_version.short_name in ('2013', '2013e', '2015')) + cflags.push('/FS'); // ninja handles parallelism by itself, don't have the compiler do it too. cflags = cflags.filter(f => !f.startsWith('/MP')); } @@ -159,30 +157,30 @@ function compilerFlags(compiler) { } function librarianFlags(librarian) { - let libflags = [] - if (librarian) { - let lib = SettingsWrapper(librarian, libflags); + let libflags = []; + if (librarian) { + let lib = settingsWrapper(librarian, libflags); //TODO: libflags = libflags.concat(GetAdditionalLibraryDirectories( // librarian, config, gyp_to_build_path)); - lib('LinkTimeCodeGeneration', { map: {'true': '/LTCG'} }); - lib('TargetMachine', { - map: {'1': 'X86', '17': 'X64', '3': 'ARM'}, prefix: '/MACHINE:' }); - lib('OutputFile', { prefix: '/OUT:', map: expandMSBuildMacros }); - lib('AdditionalOptions'); - } - return libflags; + lib('LinkTimeCodeGeneration', { map: {'true': '/LTCG'} }); + lib('TargetMachine', { + map: {'1': 'X86', '17': 'X64', '3': 'ARM'}, prefix: '/MACHINE:' }); + lib('OutputFile', { prefix: '/OUT:', map: expandMSBuildMacros }); + lib('AdditionalOptions'); + } + return libflags; } function linkerFlags(linker) { let ldflags = []; if (linker) { - let ld = SettingsWrapper(linker, ldflags); + let ld = settingsWrapper(linker, ldflags); ld('GenerateDebugInformation', { map: {'true': '/DEBUG'} }); ld('TargetMachine', { map: {'1': 'X86', '17': 'X64', '3': 'ARM'}, prefix: '/MACHINE:' }); //TODO: ldflags = ldflags.concat(GetAdditionalLibraryDirectories( // linker, config, gyp_to_build_path)); - ld('DelayLoadDLLs', { prefix: '/DELAYLOAD:' }) + ld('DelayLoadDLLs', { prefix: '/DELAYLOAD:' }); ld('TreatLinkerWarningAsErrors', { map: {'true': '', 'false': ':NO'}, prefix: '/WX' }); ld('OutputFile', { map: expandMSBuildMacros, prefix: '/OUT:' }); @@ -240,13 +238,16 @@ function linkerFlags(linker) { ld('AdditionalDependencies'); ld('ImageHasSafeExceptionHandlers', { map: {'false': ':NO', 'true': ''}, - prefix: '/SAFESEH', - /*TODO: defvalue: GetArch(config) === 'x86'? 'true' : undefined*/ }); + prefix: '/SAFESEH' + /*TODO: defvalue: GetArch(config) === 'x86'? 'true' : undefined*/ + }); // If the base address is not specifically controlled, // DYNAMICBASE should be on by default. - if (!ldflags.find(f => f.startsWith('/DYNAMICBASE') - || f.startsWith('/FIXED'))) ldflags.push('/DYNAMICBASE'); + if (!ldflags.find(f => f.startsWith('/DYNAMICBASE') || + f.startsWith('/FIXED'))) { + ldflags.push('/DYNAMICBASE'); + } // If the NXCOMPAT flag has not been specified, default to on. Despite the // documentation that says this only defaults to on when the subsystem is @@ -276,7 +277,7 @@ win.targetFlags = function targetFlags(target) { let ldflags = []; cflags = cflags.concat(compilerFlags(settings.VCCLCompilerTool)); - cflags = cflags.concat(disabled_warnings.map(w => '/wd' + w)) + cflags = cflags.concat(disabled_warnings.map(w => '/wd' + w)); if (target.type === 'static_library') { ldflags = ldflags.concat(librarianFlags(settings.VCLibrarianTool)); @@ -314,7 +315,7 @@ win.escapeDefine = function escapeDefine(arg) { // passed literally through escaping so they can be singled to just the // original %. Otherwise, trying to pass the literal representation that // looks like an environment variable to the shell (e.g. %PATH%) would fail. - arg = arg.replace(/%/g, '%%') + arg = arg.replace(/%/g, '%%'); // These commands are used in rsp files, so no escaping for the shell (via ^) // is necessary. diff --git a/lib/gyp/py.js b/lib/gyp/py.js index 5788689..dd99ec3 100644 --- a/lib/gyp/py.js +++ b/lib/gyp/py.js @@ -151,7 +151,7 @@ GYPJSON.prototype.parseString = function parseString() { } } else if (c === q) { break; - } else if (c === '\r' || c == '\n') { + } else if (c === '\r' || c === '\n') { throw new Error(`Unexpected newline in a string at ${this.pos()}`); } else { res += c; @@ -256,7 +256,7 @@ function parseJSON(contents) { const g = new GYPJSON(contents); return g.parse(contents); } -exports.parseJSON = parseJSON +exports.parseJSON = parseJSON; function checkedParseJSON(contents) { /* Return the eval of a gyp file. @@ -277,12 +277,12 @@ const MAX_PRIORITY = 4; // NOTE: This is only a small subset, but should be enough // TODO(indutny): consider expanding this, if needed const PRIORITY_RE = new RegExp( - `^(?:` + - `((?:not\\s+in|in|is not|is)(?=\\s|$)|==|!=|>=|<=|>|<)|` + // priority 1 - `(not)|` + // priority 2, XXX(indutny): it is a prefix!!! - `(and)|` + // priority 3 - `(or)` + // priority 4 - `)`); + '^(?:' + + '((?:not\\s+in|in|is not|is)(?=\\s|$)|==|!=|>=|<=|>|<)|' + // priority 1 + '(not)|' + // priority 2, XXX(indutny): it is a prefix!!! + '(and)|' + // priority 3 + '(or)' + // priority 4 + ')'); function Condition(str) { GYPJSON.call(this, str); @@ -300,7 +300,7 @@ Condition.prototype.parseOne = function parseOne(priority) { this.space(); // .split() - if (this.peek() == '.') { + if (this.peek() === '.') { seed = this.parseMethod(seed); this.space(); } diff --git a/lib/gyp/shlex.js b/lib/gyp/shlex.js index 0c1a48a..192e899 100644 --- a/lib/gyp/shlex.js +++ b/lib/gyp/shlex.js @@ -28,7 +28,7 @@ shlex.split = function split(str) { quotes = false; else quotes = c; - } else if (c === '\\' && quotes != '\'') { + } else if (c === '\\' && quotes !== '\'') { if (i + 1 >= str.length) throw new Error('Unmatched escape'); acc += str.slice(off, i); diff --git a/package.json b/package.json index c135316..3e116e7 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,16 @@ }, "main": "lib/gyp.js", "scripts": { - "test": "mocha --reporter=spec test/*-test.js" + "lint": "make lint", + "format": "make format", + "test": "mocha --reporter=spec test/*-test.js && npm run lint" }, "keywords": [], "author": "Fedor Indutny ", "license": "MIT", "devDependencies": { + "eslint": "^2.12.0", + "jshint": "^2.9.2", "mocha": "^2.5.3" }, "dependencies": { diff --git a/test/generator-ninja-writer-test.js b/test/generator-ninja-writer-test.js index 85cd349..b039385 100644 --- a/test/generator-ninja-writer-test.js +++ b/test/generator-ninja-writer-test.js @@ -1,4 +1,5 @@ 'use strict'; +/* global describe it */ const assert = require('assert'); diff --git a/test/platform-win-test.js b/test/platform-win-test.js index 05c7c0a..c211d47 100644 --- a/test/platform-win-test.js +++ b/test/platform-win-test.js @@ -1,4 +1,5 @@ 'use strict'; +/* global describe it */ const assert = require('assert'); @@ -12,27 +13,27 @@ describe('gyp.platform.win', () => { it('should remove prefix `-l`', () => { assert.deepEqual( - win.adjustLibraries(['-llib1.lib', 'lib2.lib']), - ['lib1.lib', 'lib2.lib']); + win.adjustLibraries([ '-llib1.lib', 'lib2.lib' ]), + [ 'lib1.lib', 'lib2.lib' ]); }); it('should append suffix `.lib`', () => { assert.deepEqual( - win.adjustLibraries(['-llib1', 'lib2.lib', 'lib3.Lib']), - ['lib1.lib', 'lib2.lib', 'lib3.Lib']); + win.adjustLibraries([ '-llib1', 'lib2.lib', 'lib3.Lib' ]), + [ 'lib1.lib', 'lib2.lib', 'lib3.Lib' ]); }); it('should remove prefix `-l` and append suffix `.lib`', () => { assert.deepEqual( - win.adjustLibraries(['lib1', '-llib2', '-llib3.lib', 'lib4.lib']), - ['lib1.lib', 'lib2.lib', 'lib3.lib', 'lib4.lib']); + win.adjustLibraries([ 'lib1', '-llib2', '-llib3.lib', 'lib4.lib' ]), + [ 'lib1.lib', 'lib2.lib', 'lib3.lib', 'lib4.lib' ]); }); it('should preserve quotes', () => { assert.deepEqual( - win.adjustLibraries(['"some path/lib1"', '-l"lib2"', - '-l"lib3.lib"', '"lib4.lib"']), - ['"some path/lib1.lib"', '"lib2.lib"', '"lib3.lib"', '"lib4.lib"']); + win.adjustLibraries([ '"some path/lib1"', '-l"lib2"', + '-l"lib3.lib"', '"lib4.lib"' ]), + [ '"some path/lib1.lib"', '"lib2.lib"', '"lib3.lib"', '"lib4.lib"' ]); }); }); @@ -40,10 +41,10 @@ describe('gyp.platform.win', () => { it('disable specific warnings', () => { const warnings = [1, 2, 3, 4]; assert.deepEqual(win.targetFlags( - { msvs_disabled_warnings: []}).cflags, []); + { msvs_disabled_warnings: [] }).cflags, []); assert.deepEqual(win.targetFlags( - { msvs_disabled_warnings: warnings}).cflags, - ['/wd1', '/wd2', '/wd3', '/wd4']); + { msvs_disabled_warnings: warnings }).cflags, + [ '/wd1', '/wd2', '/wd3', '/wd4' ]); }); it('compiler', () => { @@ -72,9 +73,9 @@ describe('gyp.platform.win', () => { DefaultCharIsUnsigned: true, TreatWChar_tAsBuiltInType: true, EnablePREfast: true, - AdditionalOptions: ['/XXX', '/YYY', '/MP'], // /MP should be removed + AdditionalOptions: [ '/XXX', '/YYY', '/MP' ], // /MP should be removed EnableEnhancedInstructionSet: 5, - ForcedIncludeFiles: ['file1.h', 'file2.h'], + ForcedIncludeFiles: [ 'file1.h', 'file2.h' ] }; const cflags = [ '/Od', @@ -115,7 +116,7 @@ describe('gyp.platform.win', () => { LinkTimeCodeGeneration: true, TargetMachine: 1, OutputFile: 'output.lib', - AdditionalOptions: ['/XXX', '/YYY'] + AdditionalOptions: [ '/XXX', '/YYY' ] }; const libflags = [ '/LTCG', @@ -131,16 +132,15 @@ describe('gyp.platform.win', () => { const linker = { GenerateDebugInformation: true, TargetMachine: 17, - DelayLoadDLLs: ['lib1.dll', 'lib2.dll'], + DelayLoadDLLs: [ 'lib1.dll', 'lib2.dll' ], TreatLinkerWarningAsErrors: false, OutputFile: 'output.dll', - GenerateDebugInformation: true, ProgramDatabaseFile: 'data.pdb', ProfileGuidedDatabase: 'data.pgd', GenerateMapFile: true, MapFileName: 'data.map', MapExports: true, - AdditionalOptions: ['/XXX', '/YYY'], + AdditionalOptions: [ '/XXX', '/YYY' ], MinimumRequiredVersion: 7, SubSystem: 2, StackReserveSize: 100, @@ -152,16 +152,16 @@ describe('gyp.platform.win', () => { RandomizedBaseAddress: 1, DataExecutionPrevention: 2, OptimizeReferences: 2, - ForceSymbolReferences: ['aa', 'zz'], + ForceSymbolReferences: [ 'aa', 'zz' ], EnableCOMDATFolding: 2, LinkTimeCodeGeneration: 4, - IgnoreDefaultLibraryNames: ['xxx.lib'], + IgnoreDefaultLibraryNames: [ 'xxx.lib' ], ResourceOnlyDLL: true, EntryPointSymbol: 'main', Profile: true, LargeAddressAware: 2, - AdditionalDependencies: ['my1.lib', 'my2.lib'], - ImageHasSafeExceptionHandlers: true, + AdditionalDependencies: [ 'my1.lib', 'my2.lib' ], + ImageHasSafeExceptionHandlers: true }; const ldflags = [ '/DEBUG', @@ -192,7 +192,7 @@ describe('gyp.platform.win', () => { '/PROFILE', '/LARGEADDRESSAWARE', 'my1.lib', 'my2.lib', - '/SAFESEH', + '/SAFESEH' ]; assert.deepEqual(win.targetFlags( { msvs_settings: { VCLinkerTool: linker }}).ldflags, ldflags); diff --git a/test/py-base-test.js b/test/py-base-test.js index d8b0bdc..5260b24 100644 --- a/test/py-base-test.js +++ b/test/py-base-test.js @@ -1,4 +1,5 @@ 'use strict'; +/* global describe it */ const assert = require('assert'); @@ -6,7 +7,7 @@ const gyp = require('../'); const Base = gyp.py.Base; describe('gyp.py.Base', () => { - describe('it should return proper pos', () => { + it('should return proper pos', () => { const b = new Base('123\n456\r\n987\r123'); b.off = 11; assert.equal(b.pos(), '3:2'); diff --git a/test/py-compile-condition-test.js b/test/py-compile-condition-test.js index 0ef02c1..e7d9b93 100644 --- a/test/py-compile-condition-test.js +++ b/test/py-compile-condition-test.js @@ -1,4 +1,5 @@ 'use strict'; +/* global describe it */ const assert = require('assert'); diff --git a/test/py-json-test.js b/test/py-json-test.js index e662391..acf10c2 100644 --- a/test/py-json-test.js +++ b/test/py-json-test.js @@ -1,4 +1,5 @@ 'use strict'; +/* global describe it */ const assert = require('assert'); diff --git a/test/py-parse-condition-test.js b/test/py-parse-condition-test.js index 96ce6b4..733f046 100644 --- a/test/py-parse-condition-test.js +++ b/test/py-parse-condition-test.js @@ -1,4 +1,5 @@ 'use strict'; +/* global describe it */ const assert = require('assert'); diff --git a/test/shlex-test.js b/test/shlex-test.js index f94a32d..6cb25de 100644 --- a/test/shlex-test.js +++ b/test/shlex-test.js @@ -1,4 +1,5 @@ 'use strict'; +/* global describe it */ const assert = require('assert'); @@ -12,26 +13,26 @@ describe('gyp.shlex', () => { it('should coalesce parts in single quotes', () => { assert.deepEqual(shlex.split('a pre\'b c\'post d'), [ - 'a', 'preb cpost', 'd' ]); + 'a', 'preb cpost', 'd' ]); }); it('should coalesce parts in double quotes', () => { assert.deepEqual(shlex.split('a pre"b c"post d'), [ - 'a', 'preb cpost', 'd' ]); + 'a', 'preb cpost', 'd' ]); }); it('should not escape `\\` in single quotes', () => { assert.deepEqual(shlex.split('a pre\'b\\n c\'post d'), [ - 'a', 'preb\\n cpost', 'd' ]); + 'a', 'preb\\n cpost', 'd' ]); }); it('should escape `\\` in double quotes', () => { assert.deepEqual(shlex.split('a pre\"b\\n c\"post d'), [ - 'a', 'preb\n cpost', 'd' ]); + 'a', 'preb\n cpost', 'd' ]); }); it('should escape `\\"` in double quotes', () => { assert.deepEqual(shlex.split('a pre\"b\\" c\"post d'), [ - 'a', 'preb" cpost', 'd' ]); + 'a', 'preb" cpost', 'd' ]); }); });