This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22774 from yurenju/app-makefile-2
Bug 1029385 - Rewrite app-makefile rule in javascript
- Loading branch information
Showing
25 changed files
with
175 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
/* global exports, require */ | ||
|
||
var utils = require('utils'); | ||
|
||
exports.execute = function(options) { | ||
var appRegExp; | ||
try { | ||
appRegExp = utils.getAppNameRegex(options.BUILD_APP_NAME); | ||
} catch (e) { | ||
utils.log('utils', 'Using an invalid regular expression for APP ' + | ||
'environment variable, APP=' + options.BUILD_APP_NAME); | ||
throw e; | ||
} | ||
|
||
options.GAIA_APPDIRS.split(' ').forEach(function(appDir) { | ||
let appDirFile = utils.getFile(appDir); | ||
|
||
if (appRegExp.test(appDirFile.leafName)) { | ||
let appOptions = utils.cloneJSON(options); | ||
let stageAppDir = utils.getFile(options.STAGE_DIR, appDirFile.leafName); | ||
|
||
appOptions.APP_DIR = appDirFile.path; | ||
appOptions.STAGE_APP_DIR = stageAppDir.path; | ||
|
||
let buildFile = utils.getFile(appDir, 'build', 'build.js'); | ||
if (buildFile.exists()) { | ||
utils.log('app', 'building ' + appDirFile.leafName + ' app...'); | ||
require(appDirFile.leafName + '/build').execute(appOptions); | ||
} else { | ||
utils.copyToStage(appOptions); | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict'; | ||
|
||
var assert = require('chai').assert; | ||
var proxyquire = require('proxyquire'); | ||
var mockUtils = require('./mock_utils.js'); | ||
|
||
suite('app.js', function() { | ||
var app; | ||
var files = []; | ||
var copied = false; | ||
var existed = false; | ||
var stageDir = '/path/to/build_stage'; | ||
var applist = ['app1', 'app2', 'app3']; | ||
var options = { | ||
GAIA_APPDIRS: '/path/to/app1 /path/to/app2 /path/to/app3', | ||
STAGE_DIR: stageDir | ||
}; | ||
|
||
setup(function() { | ||
var stubs = { | ||
'utils': mockUtils | ||
}; | ||
app = proxyquire.noCallThru().load('../../app', stubs); | ||
|
||
mockUtils.getFile = function() { | ||
var path = Array.prototype.slice.call(arguments, 0).join('/'); | ||
var file = { | ||
path: path, | ||
leafName: path.split('/').pop(), | ||
exists: function() { return existed; } | ||
}; | ||
files.push(file); | ||
return file; | ||
}; | ||
|
||
mockUtils.copyToStage = function(options) { | ||
copied = true; | ||
}; | ||
}); | ||
|
||
test('BUILD_APP_NAME = *', function() { | ||
options.BUILD_APP_NAME = '*'; | ||
app.execute(options); | ||
|
||
applist.forEach(function(appName, i) { | ||
var baseIdx = i * applist.length; | ||
assert.equal(files[baseIdx].path, '/path/to/' + appName, | ||
'1st file which access in app.js should be app absolute dir'); | ||
assert.equal(files[baseIdx + 1].path, stageDir + '/' + appName, | ||
'2nd file which access in app.js should be app dir in build_stage'); | ||
assert.equal(files[baseIdx + 2].path, | ||
'/path/to/' + appName + '/build/build.js', | ||
'3rd file which access in app.js should be build script in app dir'); | ||
}); | ||
}); | ||
|
||
test('BUILD_APP_NAME = app1', function() { | ||
var appName = 'app1'; | ||
options.BUILD_APP_NAME = appName; | ||
app.execute(options); | ||
assert.equal(files[0].path, '/path/to/' + appName, | ||
'1st file which access in app.js should be app absolute dir'); | ||
assert.equal(files[1].path, stageDir + '/' + appName, | ||
'2nd file which access in app.js should be app dir in build_stage'); | ||
assert.equal(files[2].path, | ||
'/path/to/' + appName + '/build/build.js', | ||
'3rd file which access in app.js should be build script in app dir'); | ||
}); | ||
|
||
teardown(function() { | ||
files = []; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.