Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
232
gaia/apps/settings/build/build.js
Executable file
232
gaia/apps/settings/build/build.js
Executable file
|
|
@ -0,0 +1,232 @@
|
|||
'use strict';
|
||||
|
||||
/* jshint node: true */
|
||||
|
||||
var utils = require('utils');
|
||||
var jsmin = require('jsmin');
|
||||
var preprocessor = require('preprocessor');
|
||||
|
||||
var jsSuffix = /\.js$/;
|
||||
|
||||
function hasGitCommand() {
|
||||
return utils.getEnvPath().some(function(path) {
|
||||
try {
|
||||
var cmd = utils.getFile(path, 'git');
|
||||
return cmd.exists();
|
||||
} catch (e) {
|
||||
// path not found
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// FIXME: execute any command without shell does not work on build machine for
|
||||
// flame, so we need this workaround to fix this issue. please remove it if
|
||||
// bug 1044981 is fixed.
|
||||
function executeGitByShell(gitDirPath, commitFilePath) {
|
||||
var sh = new utils.Commander('sh');
|
||||
sh.initPath(utils.getEnvPath());
|
||||
|
||||
sh.run(['-c', 'git --git-dir=' + gitDirPath + ' log -1 ' +
|
||||
'--format="%H%n%ct" HEAD > ' + commitFilePath]);
|
||||
}
|
||||
|
||||
var SettingsAppBuilder = function() {
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.RESOURCES_PATH = 'resources';
|
||||
|
||||
SettingsAppBuilder.prototype.writeSupportsJSON = function(options) {
|
||||
var distDir = options.GAIA_DISTRIBUTION_DIR;
|
||||
|
||||
var file = utils.getFile(options.STAGE_APP_DIR, 'resources', 'support.json');
|
||||
var defaultContent = null;
|
||||
var content = utils.getDistributionFileContent('support',
|
||||
defaultContent, distDir);
|
||||
utils.writeContent(file, content);
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.writeDeviceFeaturesJSON = function(options) {
|
||||
var distDir = options.GAIA_DISTRIBUTION_DIR;
|
||||
|
||||
var file = utils.getFile(options.STAGE_APP_DIR, 'resources',
|
||||
'device-features.json');
|
||||
var defaultContent = {
|
||||
ambientLight: true,
|
||||
vibration: true,
|
||||
usbHotProtocolSwitch: false
|
||||
};
|
||||
var content = utils.getDistributionFileContent('device-features',
|
||||
defaultContent, distDir);
|
||||
utils.writeContent(file, content);
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.writeFindMyDeviceConfigJSON = function(options) {
|
||||
var distDir = options.GAIA_DISTRIBUTION_DIR;
|
||||
|
||||
var file = utils.getFile(options.STAGE_APP_DIR,
|
||||
'resources', 'findmydevice.json');
|
||||
var defaultContent = {
|
||||
api_url: 'https://find.firefox.com',
|
||||
api_version: '1',
|
||||
};
|
||||
|
||||
var content = utils.getDistributionFileContent('findmydevice',
|
||||
defaultContent, distDir);
|
||||
utils.writeContent(file, content);
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.writeEuRoamingJSON = function(options) {
|
||||
var distDir = options.GAIA_DISTRIBUTION_DIR;
|
||||
|
||||
var file = utils.getFile(options.STAGE_APP_DIR, 'resources',
|
||||
'eu-roaming.json');
|
||||
var defaultContent = {};
|
||||
var content = utils.getDistributionFileContent('eu-roaming',
|
||||
defaultContent, distDir);
|
||||
utils.writeContent(file, content);
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.executeRjs = function(options) {
|
||||
var appName = this.appName;
|
||||
var config = utils.getFile(options.APP_DIR, 'build',
|
||||
'settings.build.jslike');
|
||||
var rjsPath = utils.joinPath(options.GAIA_DIR, 'build', 'r.js');
|
||||
var requirejs;
|
||||
|
||||
if (utils.isNode()) {
|
||||
requirejs = require(rjsPath);
|
||||
} else {
|
||||
var sandbox = utils.createSandbox();
|
||||
sandbox.arguments = [];
|
||||
sandbox.requirejsAsLib = true;
|
||||
sandbox.print = function() {
|
||||
utils.log(appName, Array.prototype.join.call(arguments, ' '));
|
||||
};
|
||||
utils.runScriptInSandbox(rjsPath, sandbox);
|
||||
requirejs = sandbox.requirejs;
|
||||
}
|
||||
|
||||
// logLevel set 4 for silent, set 0 for all
|
||||
var log = 'logLevel=' + (options.VERBOSE === '1' ? '0' : '4');
|
||||
var optimize = 'optimize=none';
|
||||
var build = new Promise(function(resolve, reject) {
|
||||
requirejs.optimize([config.path, optimize, log], resolve, reject);
|
||||
});
|
||||
|
||||
return build
|
||||
.then(function() {
|
||||
utils.log(appName, 'require.js optimize done');
|
||||
})
|
||||
.catch(function(err) {
|
||||
utils.log(appName, 'require.js optimize failed');
|
||||
utils.log(appName, err);
|
||||
});
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.executeJsmin = function(options) {
|
||||
var appName = this.appName;
|
||||
if (options.GAIA_OPTIMIZE === '1') {
|
||||
utils.listFiles(options.STAGE_APP_DIR, utils.FILE_TYPE_FILE, true).forEach(
|
||||
function(filePath) {
|
||||
if (jsSuffix.test(filePath)) {
|
||||
try {
|
||||
var file = utils.getFile(filePath);
|
||||
var content = utils.getFileContent(file);
|
||||
utils.writeContent(file, jsmin(content).code);
|
||||
} catch(e) {
|
||||
utils.log(appName, 'Error minifying content: ' + filePath);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.writeGitCommit = function(options) {
|
||||
var appName = this.appName;
|
||||
var gitDir = utils.getFile(options.GAIA_DIR, '.git');
|
||||
var overrideCommitFile = utils.getFile(options.GAIA_DIR,
|
||||
'gaia_commit_override.txt');
|
||||
var commitFile = utils.getFile(options.STAGE_APP_DIR, 'resources');
|
||||
utils.ensureFolderExists(commitFile);
|
||||
commitFile = utils.getFile(commitFile.path, 'gaia_commit.txt');
|
||||
|
||||
if (overrideCommitFile.exists()) {
|
||||
utils.copyFileTo(overrideCommitFile, commitFile.parent.path,
|
||||
commitFile.leafName);
|
||||
} else if(gitDir.exists() && hasGitCommand()) {
|
||||
var git = new utils.Commander('git');
|
||||
var stderr, stdout;
|
||||
var args = [
|
||||
'--git-dir=' + gitDir.path,
|
||||
'log', '-1',
|
||||
'--format=%H%n%ct',
|
||||
'HEAD'];
|
||||
var cmdOptions = {
|
||||
stdout: function(data) {
|
||||
stdout = data;
|
||||
},
|
||||
stderr: function(data) {
|
||||
stderr = data;
|
||||
},
|
||||
done: function(data) {
|
||||
if (data.exitCode !== 0) {
|
||||
var errStr = 'Error writing git commit file!\n' + 'stderr: \n' +
|
||||
stderr + '\nstdout: ' + stdout;
|
||||
utils.log(appName, errStr);
|
||||
utils.log(appName, 'fallback to execute git by shell');
|
||||
// FIXME: see comment on executeGitByShell()
|
||||
executeGitByShell(gitDir.path, commitFile.path);
|
||||
} else {
|
||||
utils.log(appName, 'Writing git commit information ' +
|
||||
'to: ' + commitFile.path);
|
||||
utils.writeContent(commitFile, stdout);
|
||||
}
|
||||
}
|
||||
};
|
||||
git.initPath(utils.getEnvPath());
|
||||
git.runWithSubprocess(args, cmdOptions);
|
||||
} else {
|
||||
utils.writeContent(commitFile,
|
||||
'Unknown Git commit; build date shown here.\n' +
|
||||
parseInt(Date.now()/1000) + '\n');
|
||||
}
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.enableDataSync = function(options) {
|
||||
var fileList = {
|
||||
process:[
|
||||
['elements', 'root.html'],
|
||||
['index.html']
|
||||
],
|
||||
remove:[
|
||||
['elements', 'firefox_sync.html'],
|
||||
['js', 'panels', 'firefox_sync', 'firefox_sync.js'],
|
||||
['js', 'panels', 'firefox_sync', 'panel.js'],
|
||||
['js', 'modules', 'sync_manager_bridge.js'],
|
||||
['style', 'images', 'fxsync_error.png'],
|
||||
['style', 'images', 'fxsync_intro.png'],
|
||||
['test', 'unit', 'panels', 'firefox_sync', 'manager_bridge_test.js'],
|
||||
['test', 'unit', 'panels', 'firefox_sync', 'panel_test.js']
|
||||
]
|
||||
};
|
||||
preprocessor.execute(options, 'FIREFOX_SYNC', fileList);
|
||||
};
|
||||
|
||||
SettingsAppBuilder.prototype.execute = function(options) {
|
||||
this.appName = utils.basename(options.APP_DIR);
|
||||
this.writeGitCommit(options);
|
||||
this.writeDeviceFeaturesJSON(options);
|
||||
this.writeSupportsJSON(options);
|
||||
this.writeFindMyDeviceConfigJSON(options);
|
||||
this.writeEuRoamingJSON(options);
|
||||
|
||||
return this.executeRjs(options).then(function() {
|
||||
this.enableDataSync(options);
|
||||
this.executeJsmin(options);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
exports.execute = function(options) {
|
||||
return (new SettingsAppBuilder()).execute(options);
|
||||
};
|
||||
92
gaia/apps/settings/build/settings.build.jslike
Executable file
92
gaia/apps/settings/build/settings.build.jslike
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
{
|
||||
appDir: '..',
|
||||
baseUrl: 'js',
|
||||
mainConfigFile: '../js/config/require.js',
|
||||
dir: '../../../build_stage/settings',
|
||||
|
||||
// Set the path to "empty" to prevent the scripts defining global objects
|
||||
// from being merged or they are removed after the optimization process,
|
||||
// which makes the objects inaccessible by reference.
|
||||
// If the inquiries to the object are all performed by requirejs, we can
|
||||
// remove the path of the object from the following list.
|
||||
// organized in alphabet order
|
||||
paths: {
|
||||
'modules/defer': 'empty:',
|
||||
'modules/dialog_panel': 'empty:',
|
||||
'modules/navigator/mozApps': 'empty:',
|
||||
'modules/wifi_context': 'empty:',
|
||||
'modules/wifi_utils': 'empty:',
|
||||
'prim': 'empty:',
|
||||
'settings': 'empty:',
|
||||
'shared/addons/match_pattern': 'empty:',
|
||||
'shared/airplane_mode_helper': 'empty:',
|
||||
'shared/apn_helper': 'empty:',
|
||||
'shared/async_storage': 'empty:',
|
||||
'shared/device_storage/enumerate_all': 'empty:',
|
||||
'shared/homescreens/homescreen_settings': 'empty:',
|
||||
'shared/icc_helper': 'empty:',
|
||||
'shared/language_list': 'empty:',
|
||||
'shared/lazy_loader': 'empty:',
|
||||
'shared/manifest_helper': 'empty:',
|
||||
'shared/mobile_operator': 'empty:',
|
||||
'shared/omadrm/fl': 'empty:',
|
||||
'shared/passcode_helper': 'empty:',
|
||||
'shared/sanitizer': 'empty:',
|
||||
'shared/settings_helper': 'empty:',
|
||||
'shared/settings_listener': 'empty:',
|
||||
'shared/settings_url': 'empty:',
|
||||
'shared/simslot': 'empty:',
|
||||
'shared/simslot_manager': 'empty:',
|
||||
'shared/sim_settings_helper': 'empty:',
|
||||
'shared/stk_helper': 'empty:',
|
||||
'shared/toaster': 'empty:',
|
||||
'shared/wifi_helper': 'empty:',
|
||||
'shared/tz_select': 'empty:',
|
||||
'vendor/jszip': 'empty:'
|
||||
},
|
||||
|
||||
findNestedDependencies: true,
|
||||
|
||||
// Be sure to normalize all define() calls by extracting
|
||||
// dependencies so Function toString is not needed, and
|
||||
// lower capability devices like Tarako can optimize
|
||||
// memory by discarding function sources. This is
|
||||
// automatically done when an 'optimize' value other than
|
||||
// 'none' is used. This setting makes sure it happens for
|
||||
// builds where 'none' is used for 'optimize'.
|
||||
normalizeDirDefines: 'all',
|
||||
|
||||
// optimize is now passed via Makefile's GAIA_SETTINGS_MINIFY
|
||||
// default is none if not passed at all.
|
||||
// optimize: 'none',
|
||||
|
||||
// Just strip comments, no code compression or mangling.
|
||||
// Only active if optimize: 'uglify2'
|
||||
uglify2: {
|
||||
// Comment out the output section to get rid of line
|
||||
// returns and tabs spacing.
|
||||
output: {
|
||||
beautify: false
|
||||
},
|
||||
compress: true,
|
||||
mangle: true
|
||||
},
|
||||
|
||||
// Rewrite the waitSeconds directive so that we never time out
|
||||
// waiting for modules to load when DEBUG=1 is not set. See
|
||||
// js/config/require.js for more details.
|
||||
onBuildWrite: function(id, url, contents) {
|
||||
if (id === 'config/require') {
|
||||
return contents.replace(/waitSeconds:\s*\d+/, 'waitSeconds: 0');
|
||||
} else {
|
||||
return contents;
|
||||
}
|
||||
},
|
||||
|
||||
fileExclusionRegExp: /^\.|^test$|^build$/,
|
||||
|
||||
// Keeping build dir since Makefile cleans it up and
|
||||
// preps build dir with the shared directory
|
||||
keepBuildDir: true,
|
||||
removeCombined: true
|
||||
}
|
||||
Loading…
Reference in a new issue