Add mozcontral options

This commit is contained in:
Yury Delendik 2012-05-08 10:23:55 -05:00
parent b390a3991a
commit 6aa161566e

102
make.js
View File

@ -228,7 +228,6 @@ var EXTENSION_WEB_FILES =
'web/viewer.js',
'web/viewer.html',
'external/webL10n/l10n.js',
'web/locale.properties',
'web/viewer-production.html'],
EXTENSION_BASE_VERSION = 'f0f0418a9c6637981fe1182b9212c2d592774c7d',
EXTENSION_VERSION_PREFIX = '0.3.',
@ -276,11 +275,10 @@ target.firefox = function() {
FIREFOX_EXTENSION_FILES_TO_COPY =
['*.js',
'*.rdf',
'*.svg',
'*.png',
'install.rdf.in',
'README.mozilla',
'components',
'../../LICENSE'];
'../../LICENSE'],
FIREFOX_EXTENSION_FILES =
['bootstrap.js',
'install.rdf',
@ -288,14 +286,7 @@ target.firefox = function() {
'icon64.png',
'components',
'content',
'LICENSE'];
FIREFOX_MC_EXTENSION_FILES =
['bootstrap.js',
'icon.png',
'icon64.png',
'components',
'content',
'LICENSE'];
'LICENSE'],
FIREFOX_EXTENSION_NAME = 'pdf.js.xpi',
FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';
@ -319,6 +310,7 @@ target.firefox = function() {
// Copy a standalone version of pdf.js inside the content directory
cp(BUILD_TARGET, FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
cp('-R', EXTENSION_WEB_FILES, FIREFOX_BUILD_CONTENT_DIR + '/web');
cp('web/locale.properties', FIREFOX_BUILD_CONTENT_DIR + '/web');
rm(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer-production.html');
// Copy over the firefox extension snippet so we can inline pdf.js in it
@ -346,13 +338,10 @@ target.firefox = function() {
// Update the build version number
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/install.rdf');
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/update.rdf');
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/install.rdf.in');
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/README.mozilla');
// Update localized metadata
var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc');
sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata, FIREFOX_BUILD_DIR + '/install.rdf');
sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata, FIREFOX_BUILD_DIR + '/install.rdf.in');
// Create the xpi
cd(FIREFOX_BUILD_DIR);
@ -366,9 +355,89 @@ target.firefox = function() {
exec('zip -r ' + FIREFOX_AMO_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));
echo('AMO extension created: ' + FIREFOX_AMO_EXTENSION_NAME);
cd(ROOT_DIR);
};
//
// make mozcentral
//
target.mozcentral = function() {
cd(ROOT_DIR);
echo();
echo('### Building mozilla-central extension');
var MOZCENTRAL_DIR = BUILD_DIR + '/mozcentral',
MOZCENTRAL_CONTENT_DIR = MOZCENTRAL_DIR + '/content/',
MOZCENTRAL_L10N_DIR = MOZCENTRAL_DIR + '/l10n/',
FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
FIREFOX_EXTENSION_FILES_TO_COPY =
['*.js',
'*.svg',
'*.png',
'install.rdf.in',
'README.mozilla',
'components',
'../../LICENSE'],
DEFAULT_LOCALE_FILES =
['l10n/en-US/viewer.properties',
'l10n/en-US/metadata.inc'],
FIREFOX_MC_EXTENSION_FILES =
['bootstrap.js',
'icon.png',
'icon64.png',
'components',
'content',
'LICENSE'];
target.production();
target.buildnumber();
cd(ROOT_DIR);
// Clear out everything in the firefox extension build directory
rm('-rf', MOZCENTRAL_DIR);
mkdir('-p', MOZCENTRAL_CONTENT_DIR);
mkdir('-p', MOZCENTRAL_L10N_DIR);
mkdir('-p', MOZCENTRAL_CONTENT_DIR + BUILD_DIR);
mkdir('-p', MOZCENTRAL_CONTENT_DIR + '/web');
// Copy extension files
cd('extensions/firefox');
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + MOZCENTRAL_DIR);
cd(ROOT_DIR);
// Copy a standalone version of pdf.js inside the content directory
cp(BUILD_TARGET, MOZCENTRAL_CONTENT_DIR + BUILD_DIR);
cp('-R', EXTENSION_WEB_FILES, MOZCENTRAL_CONTENT_DIR + '/web');
rm(MOZCENTRAL_CONTENT_DIR + '/web/viewer-production.html');
// Copy over the firefox extension snippet so we can inline pdf.js in it
cp('web/viewer-snippet-firefox-extension.html', MOZCENTRAL_CONTENT_DIR + '/web');
// Modify the viewer so it does all the extension-only stuff.
cd(MOZCENTRAL_CONTENT_DIR + '/web');
sed('-i', /.*PDFJSSCRIPT_INCLUDE_BUNDLE.*\n/, cat(ROOT_DIR + BUILD_TARGET), 'viewer-snippet-firefox-extension.html');
sed('-i', /.*PDFJSSCRIPT_REMOVE_CORE.*\n/g, '', 'viewer.html');
sed('-i', /.*PDFJSSCRIPT_REMOVE_FIREFOX_EXTENSION.*\n/g, '', 'viewer.html');
sed('-i', /.*PDFJSSCRIPT_INCLUDE_FIREFOX_EXTENSION.*\n/, cat('viewer-snippet-firefox-extension.html'), 'viewer.html');
cd(ROOT_DIR);
// We don't need pdf.js anymore since its inlined
rm('-Rf', MOZCENTRAL_CONTENT_DIR + BUILD_DIR);
rm(MOZCENTRAL_CONTENT_DIR + '/web/viewer-snippet-firefox-extension.html');
// Remove '.DS_Store' and other hidden files
find(MOZCENTRAL_DIR).forEach(function(file) {
if (file.match(/^\./))
rm('-f', file);
});
// Copy default localization files
cp(DEFAULT_LOCALE_FILES, MOZCENTRAL_L10N_DIR);
// Update the build version number
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, MOZCENTRAL_DIR + '/install.rdf.in');
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, MOZCENTRAL_DIR + '/README.mozilla');
// List all files for mozilla-central
cd(FIREFOX_BUILD_DIR);
cd(MOZCENTRAL_DIR);
var extensionFiles = '';
find(FIREFOX_MC_EXTENSION_FILES).forEach(function(file){
if (test('-f', file))
@ -408,6 +477,7 @@ target.chrome = function() {
// Copy a standalone version of pdf.js inside the content directory
cp(BUILD_TARGET, CHROME_BUILD_CONTENT_DIR + BUILD_DIR);
cp('-R', EXTENSION_WEB_FILES, CHROME_BUILD_CONTENT_DIR + '/web');
cp('web/locale.properties', CHROME_BUILD_CONTENT_DIR + '/web');
mv('-f', CHROME_BUILD_CONTENT_DIR + '/web/viewer-production.html',
CHROME_BUILD_CONTENT_DIR + '/web/viewer.html');
};