Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1131499 - merge pull request #28250 from RickyChien:clean-stage-a…
Browse files Browse the repository at this point in the history
…pp-nodejs to mozilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed Feb 24, 2015
2 parents 2fcc32b + 9ae09a6 commit 9461585
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
4 changes: 0 additions & 4 deletions Makefile
Expand Up @@ -72,11 +72,7 @@ ifdef LOCALES_FILE
REBUILD=1
endif

# Switching XPCShell/Node.js build runner
BUILD_RUNNER=run-js-command
ifeq ($(RUN_ON_NODE), 1)
BUILD_RUNNER=run-node-command
endif

-include local.mk

Expand Down
4 changes: 1 addition & 3 deletions build/clean-stage-app.js
@@ -1,8 +1,6 @@
'use strict';

/* global require, exports */

var utils = require('utils');
var utils = require('./utils');

function remove(stageDir, appName) {
var stageAppDir = utils.getFile(stageDir, appName);
Expand Down
4 changes: 1 addition & 3 deletions build/common.mk
Expand Up @@ -24,7 +24,5 @@ define run-js-command
endef

define run-node-command
echo "run-node-command $1";
node --harmony -e \
"require('./build/$(strip $1).js').execute($(BUILD_CONFIG))"
node --harmony -e "require('./build/$(strip $1).js').execute($(BUILD_CONFIG))"
endef
6 changes: 4 additions & 2 deletions build/pre-app.js
@@ -1,9 +1,10 @@
'use strict';

/* global require, exports */
var utils = require('utils');
var nodeHelper = new utils.NodeHelper();

function execute(options) {
require('./clean-stage-app').execute(options);
nodeHelper.require('clean-stage-app', options);

require('./svoperapps').execute(options);

Expand All @@ -29,4 +30,5 @@ function execute(options) {
// Copy common files such as webapps.json
require('./copy-common-files').execute(options);
}

exports.execute = execute;
6 changes: 2 additions & 4 deletions build/utils-node.js
Expand Up @@ -10,8 +10,6 @@
* which contains the complete functions used in 'utils.js'
*/

/* jshint node: true */

var utils = require('./utils.js');
var path = require('path');
var childProcess = require('child_process');
Expand Down Expand Up @@ -69,10 +67,10 @@ module.exports = {
}
return {
exists: function() {
return fs.accessSync(src);
return fs.existsSync(src);
},
remove: function() {
fs.remove(src);
fs.removeSync(src);
},
isDirectory: function() {
return !!fileStat && fileStat.isDirectory();
Expand Down
35 changes: 21 additions & 14 deletions build/utils-xpc.js
@@ -1,7 +1,7 @@
'use strict';

/* global require, Services, dump, FileUtils, exports, OS, Promise, Reflect */
/* jshint -W079, -W118 */
/* global Services, dump, FileUtils, OS */
/* jshint -W118 */

const { Cc, Ci, Cr, Cu, CC } = require('chrome');

Expand Down Expand Up @@ -940,7 +940,6 @@ function Commander(cmd) {
var process = Cc['@mozilla.org/process/util;1']
.createInstance(Ci.nsIProcess);
try {
log('cmd', command + ' ' + args.join(' '));
process.init(_file);
process.run(true, args, args.length);
callback && callback(process.exitValue);
Expand Down Expand Up @@ -1241,15 +1240,24 @@ var scriptLoader = {
}
};

var requireNode = function() {
var node = new Commander('node');
node.initPath(getEnvPath());

this.run = function(path) {
node.run(['--harmony', '-e', 'require("./build/' + path + '").execute(' +
getEnv('BUILD_CONFIG') + ')']);
};
};
/**
* Run specific build task on Node.js if RUN_ON_NODE is on, otherwise we go back
* to XPCShell.
*/
function NodeHelper(path) {
if (getEnv('RUN_ON_NODE') === '1') {
var node = new Commander('node');
node.initPath(getEnvPath());
this.require = function(path, options) {
node.run(['--harmony', '-e', 'require("./build/' + path + '").execute(' +
JSON.stringify(options) + ')']);
};
} else {
this.require = function(path, options) {
require(path).execute(options);
};
}
}

exports.Q = Promise;
exports.ls = ls;
Expand Down Expand Up @@ -1277,8 +1285,6 @@ exports.generateUUID = generateUUID;
exports.copyRec = copyRec;
exports.createZip = createZip;
exports.scriptParser = Reflect.parse;
exports.requireNode = requireNode;
// ===== the following functions support node.js compitable interface.
exports.deleteFile = deleteFile;
exports.listFiles = listFiles;
exports.fileExists = fileExists;
Expand Down Expand Up @@ -1311,3 +1317,4 @@ exports.getCompression = getCompression;
exports.existsInAppDirs = existsInAppDirs;
exports.removeFiles = removeFiles;
exports.scriptLoader = scriptLoader;
exports.NodeHelper = NodeHelper;
6 changes: 3 additions & 3 deletions build/utils.js
@@ -1,10 +1,10 @@
'use strict';

/**
* This file exports all 'utils' functions, which indeed exports the
* implementations inside the 'utils-node' and 'utils-xpc' files.
*/

'use strict';
/* global exports, require, process*/
const FILE_TYPE_FILE = 0;
const FILE_TYPE_DIRECTORY = 1;

Expand Down Expand Up @@ -361,4 +361,4 @@ exports.getAppNameRegex = getAppNameRegex;
exports.serializeDocument = serializeDocument;
exports.cloneJSON = cloneJSON;
exports.jsComparator = jsComparator;
exports.requireNode = utils.requireNode;
exports.NodeHelper = utils.NodeHelper;

0 comments on commit 9461585

Please sign in to comment.