2012-03-04 04:01:31 +09:00
|
|
|
#!/usr/bin/env node
|
|
|
|
require('./external/shelljs/make');
|
2012-07-28 07:19:43 +09:00
|
|
|
var fs = require('fs');
|
2012-08-02 03:29:13 +09:00
|
|
|
var path = require('path');
|
2012-07-28 07:19:43 +09:00
|
|
|
var vm = require('vm');
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-03-05 11:26:57 +09:00
|
|
|
var ROOT_DIR = __dirname + '/', // absolute path to project's root
|
2012-03-04 04:01:31 +09:00
|
|
|
BUILD_DIR = 'build/',
|
2012-03-05 11:26:57 +09:00
|
|
|
BUILD_TARGET = BUILD_DIR + 'pdf.js',
|
|
|
|
FIREFOX_BUILD_DIR = BUILD_DIR + '/firefox/',
|
2012-03-04 04:01:31 +09:00
|
|
|
EXTENSION_SRC_DIR = 'extensions/',
|
2012-05-12 04:39:11 +09:00
|
|
|
LOCALE_SRC_DIR = 'l10n/',
|
2012-03-05 11:26:57 +09:00
|
|
|
GH_PAGES_DIR = BUILD_DIR + 'gh-pages/',
|
2012-08-02 03:29:13 +09:00
|
|
|
GENERIC_DIR = BUILD_DIR + 'generic/',
|
2012-03-04 04:01:31 +09:00
|
|
|
REPO = 'git@github.com:mozilla/pdf.js.git',
|
2012-05-24 07:57:14 +09:00
|
|
|
PYTHON_BIN = 'python2.7',
|
|
|
|
MOZCENTRAL_PREF_PREFIX = 'pdfjs',
|
|
|
|
FIREFOX_PREF_PREFIX = 'extensions.uriloader@pdf.js',
|
|
|
|
MOZCENTRAL_STREAM_CONVERTER_ID = 'd0c5195d-e798-49d4-b1d3-9324328b2291',
|
|
|
|
FIREFOX_STREAM_CONVERTER_ID = '6457a96b-2d68-439a-bcfa-44465fbcdbb1';
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
var DEFINES = {
|
|
|
|
PRODUCTION: true,
|
|
|
|
// The main build targets:
|
|
|
|
GENERIC: false,
|
|
|
|
FIREFOX: false,
|
|
|
|
MOZCENTRAL: false,
|
|
|
|
B2G: false,
|
|
|
|
CHROME: false
|
|
|
|
};
|
|
|
|
|
|
|
|
function extendDefines(obj) {
|
|
|
|
var ret = {};
|
|
|
|
for (var key in DEFINES)
|
|
|
|
ret[key] = DEFINES[key];
|
|
|
|
for (key in obj)
|
|
|
|
ret[key] = obj[key];
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
var BuildHelper = {
|
|
|
|
/**
|
|
|
|
* A simple preprocessor that is based on the firefox preprocessor
|
|
|
|
* see (https://developer.mozilla.org/en/Build/Text_Preprocessor). The main
|
|
|
|
* difference is that this supports a subset of the commands and it supports
|
|
|
|
* preproccesor commands in html style comments.
|
|
|
|
* Currently Supported commands:
|
|
|
|
* - if
|
|
|
|
* - else
|
|
|
|
* - endif
|
|
|
|
* - include
|
|
|
|
* - expand
|
|
|
|
*/
|
|
|
|
preprocess: function preprocess(inFilename, outFilename, defines) {
|
|
|
|
// TODO make this really read line by line.
|
|
|
|
var lines = fs.readFileSync(inFilename).toString().split('\n');
|
|
|
|
var totalLines = lines.length;
|
|
|
|
var out = '';
|
|
|
|
var i = 0;
|
|
|
|
function readLine() {
|
|
|
|
if (i < totalLines) {
|
|
|
|
return lines[i++];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
var writeLine = typeof outFilename === 'function' ? outFilename : function(line) {
|
|
|
|
out += line + '\n';
|
|
|
|
}
|
|
|
|
function include(file) {
|
|
|
|
var realPath = fs.realpathSync(inFilename);
|
|
|
|
var dir = path.dirname(realPath);
|
|
|
|
preprocess(path.join(dir, file), writeLine, defines);
|
|
|
|
}
|
|
|
|
function expand(line) {
|
|
|
|
line = line.replace(/__[\w]+__/g, function(variable) {
|
|
|
|
variable = variable.substring(2, variable.length - 2);
|
|
|
|
if (variable in defines) {
|
|
|
|
return defines[variable];
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
});
|
|
|
|
writeLine(line);
|
2012-07-28 07:19:43 +09:00
|
|
|
}
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
var s, state = 0, stack = [];
|
|
|
|
var control = /^(?:\/\/|<!--)\s*#(if|else|endif|expand|include)(?:\s+(.*?)(?:-->)?$)?/;
|
|
|
|
var lineNumber = 0;
|
|
|
|
while ((s = readLine()) !== null) {
|
|
|
|
++lineNumber;
|
|
|
|
var m = control.exec(s);
|
|
|
|
if (m) {
|
|
|
|
switch (m[1]) {
|
|
|
|
case 'if':
|
|
|
|
stack.push(state);
|
|
|
|
try {
|
|
|
|
state = vm.runInNewContext(m[2], defines) ? 3 : 1;
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Could not evalute line \'' + m[2] + '\' at ' +
|
|
|
|
fs.realpathSync(inFilename) + ':' + lineNumber);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'else':
|
|
|
|
state = state === 1 ? 3 : 2;
|
|
|
|
break;
|
|
|
|
case 'endif':
|
|
|
|
state = stack.pop();
|
|
|
|
break;
|
|
|
|
case 'expand':
|
|
|
|
if (state === 0 || state === 3)
|
|
|
|
expand(m[2]);
|
|
|
|
break;
|
|
|
|
case 'include':
|
|
|
|
if (state === 0 || state === 3)
|
|
|
|
include(m[2]);
|
|
|
|
break;
|
|
|
|
}
|
2012-07-28 07:19:43 +09:00
|
|
|
} else {
|
2012-08-02 03:29:13 +09:00
|
|
|
if (state === 0) {
|
|
|
|
writeLine(s);
|
|
|
|
} else if(state === 3) {
|
|
|
|
writeLine(s.replace(/^\/\/|^<!--|-->/g, " "));
|
|
|
|
}
|
2012-07-28 07:19:43 +09:00
|
|
|
}
|
|
|
|
}
|
2012-08-02 03:29:13 +09:00
|
|
|
if (state !== 0 || stack.length !== 0)
|
|
|
|
throw new Error('Missing endif in preprocessor.');
|
|
|
|
if (typeof outFilename !== 'function')
|
|
|
|
fs.writeFileSync(outFilename, out);
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Simplifies common build steps.
|
|
|
|
* @param setup
|
|
|
|
* .defines defines for preprocessors
|
|
|
|
* .copy array of arrays of source and destination pairs of files to copy
|
|
|
|
* .preprocess array of arrays of source and destination pairs of files
|
|
|
|
* run through preprocessor
|
|
|
|
*/
|
|
|
|
build: function build(setup) {
|
|
|
|
var defines = setup.defines;
|
|
|
|
|
|
|
|
setup.copy.forEach(function(option) {
|
|
|
|
var source = option[0];
|
|
|
|
var destination = option[1];
|
|
|
|
cp('-R', source, destination);
|
|
|
|
});
|
|
|
|
|
|
|
|
setup.preprocess.forEach(function(option) {
|
|
|
|
var sources = option[0];
|
|
|
|
var destination = option[1];
|
|
|
|
|
|
|
|
sources = ls('-R', sources);
|
|
|
|
sources.forEach(function(source) {
|
|
|
|
// ??? Warn if the source is wildcard and dest is file?
|
|
|
|
var destWithFolder = destination;
|
|
|
|
if (test('-d', destination))
|
|
|
|
destWithFolder += '/' + path.basename(source);
|
|
|
|
BuildHelper.preprocess(source, destWithFolder, defines);
|
|
|
|
});
|
|
|
|
});
|
2012-07-28 07:19:43 +09:00
|
|
|
}
|
2012-08-02 03:29:13 +09:00
|
|
|
};
|
2012-07-28 07:19:43 +09:00
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
//
|
|
|
|
// make all
|
|
|
|
//
|
2012-03-05 11:26:57 +09:00
|
|
|
target.all = function() {
|
2012-03-04 04:01:31 +09:00
|
|
|
// Don't do anything by default
|
|
|
|
echo('Please specify a target. Available targets:');
|
|
|
|
for (t in target)
|
|
|
|
if (t !== 'all') echo(' ' + t);
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Production stuff
|
|
|
|
//
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
// Files that need to be included in every build.
|
|
|
|
var COMMON_WEB_FILES =
|
|
|
|
['web/viewer.css',
|
|
|
|
'web/images',
|
|
|
|
'web/debugger.js'],
|
|
|
|
COMMON_WEB_FILES_PREPROCESS =
|
|
|
|
['web/viewer.js',
|
|
|
|
'web/viewer.html'];
|
|
|
|
|
|
|
|
//
|
|
|
|
// make generic
|
|
|
|
// Builds the generic production viewer that should be compatible with most
|
|
|
|
// modern HTML5 browsers.
|
|
|
|
//
|
|
|
|
target.generic = function() {
|
|
|
|
target.bundle();
|
|
|
|
target.locale();
|
|
|
|
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Creating generic viewer');
|
|
|
|
|
|
|
|
rm('-rf', GENERIC_DIR);
|
|
|
|
mkdir('-p', GENERIC_DIR);
|
|
|
|
mkdir('-p', GENERIC_DIR + BUILD_DIR);
|
|
|
|
mkdir('-p', GENERIC_DIR + '/web');
|
|
|
|
|
|
|
|
var defines = extendDefines({GENERIC: true});
|
|
|
|
|
|
|
|
var setup = {
|
|
|
|
defines: defines,
|
|
|
|
copy: [
|
|
|
|
[COMMON_WEB_FILES, GENERIC_DIR + '/web'],
|
|
|
|
['external/webL10n/l10n.js', GENERIC_DIR + '/web'],
|
|
|
|
['web/compatibility.js', GENERIC_DIR + '/web'],
|
|
|
|
['web/compressed.tracemonkey-pldi-09.pdf', GENERIC_DIR + '/web'],
|
|
|
|
['web/locale.properties', GENERIC_DIR + '/web']
|
|
|
|
],
|
|
|
|
preprocess: [
|
|
|
|
[BUILD_TARGET, GENERIC_DIR + BUILD_TARGET],
|
|
|
|
[COMMON_WEB_FILES_PREPROCESS, GENERIC_DIR + '/web']
|
|
|
|
]
|
|
|
|
};
|
|
|
|
BuildHelper.build(setup);
|
|
|
|
};
|
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
//
|
|
|
|
// make web
|
2012-03-05 11:26:57 +09:00
|
|
|
// Generates the website for the project, by checking out the gh-pages branch underneath
|
2012-03-04 04:01:31 +09:00
|
|
|
// the build directory, and then moving the various viewer files into place.
|
|
|
|
//
|
|
|
|
target.web = function() {
|
2012-08-02 03:29:13 +09:00
|
|
|
target.generic();
|
2012-03-04 04:01:31 +09:00
|
|
|
target.extension();
|
|
|
|
target.pagesrepo();
|
2012-03-05 11:26:57 +09:00
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Creating web site');
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
cp('-R', GENERIC_DIR + '/*', GH_PAGES_DIR);
|
2012-03-05 11:26:57 +09:00
|
|
|
cp(FIREFOX_BUILD_DIR + '/*.xpi', FIREFOX_BUILD_DIR + '/*.rdf',
|
2012-08-02 03:29:13 +09:00
|
|
|
GH_PAGES_DIR + EXTENSION_SRC_DIR + 'firefox/');
|
|
|
|
cp('web/index.html.template', GH_PAGES_DIR + '/index.html');
|
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
cd(GH_PAGES_DIR);
|
|
|
|
exec('git add -A');
|
2012-03-05 11:26:57 +09:00
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
echo();
|
2012-03-05 11:26:57 +09:00
|
|
|
echo("Website built in " + GH_PAGES_DIR);
|
|
|
|
echo("Don't forget to cd into " + GH_PAGES_DIR +
|
2012-08-02 03:29:13 +09:00
|
|
|
" and issue 'git commit' to push changes.");
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-05-02 22:51:52 +09:00
|
|
|
//
|
|
|
|
// make locale
|
|
|
|
// Creates localized resources for the viewer and extension.
|
|
|
|
//
|
|
|
|
target.locale = function() {
|
|
|
|
var METADATA_OUTPUT = 'extensions/firefox/metadata.inc';
|
2012-05-12 04:39:11 +09:00
|
|
|
var CHROME_MANIFEST_OUTPUT = 'extensions/firefox/chrome.manifest.inc';
|
|
|
|
var EXTENSION_LOCALE_OUTPUT = 'extensions/firefox/locale';
|
2012-05-02 22:51:52 +09:00
|
|
|
var VIEWER_OUTPUT = 'web/locale.properties';
|
|
|
|
var DEFAULT_LOCALE = 'en-US';
|
|
|
|
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Building localization files');
|
|
|
|
|
2012-05-12 04:39:11 +09:00
|
|
|
rm('-rf', EXTENSION_LOCALE_OUTPUT);
|
|
|
|
mkdir('-p', EXTENSION_LOCALE_OUTPUT);
|
|
|
|
|
|
|
|
var subfolders = ls(LOCALE_SRC_DIR);
|
2012-05-02 22:51:52 +09:00
|
|
|
subfolders.sort();
|
|
|
|
var metadataContent = '';
|
2012-05-12 04:39:11 +09:00
|
|
|
var chromeManifestContent = '';
|
2012-05-02 22:51:52 +09:00
|
|
|
var viewerOutput = '';
|
|
|
|
for (var i = 0; i < subfolders.length; i++) {
|
|
|
|
var locale = subfolders[i];
|
2012-05-12 04:39:11 +09:00
|
|
|
var path = LOCALE_SRC_DIR + locale;
|
2012-05-02 22:51:52 +09:00
|
|
|
if (!test('-d', path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!/^[a-z][a-z](-[A-Z][A-Z])?$/.test(locale)) {
|
|
|
|
echo('Skipping invalid locale: ' + locale);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-05-12 04:39:11 +09:00
|
|
|
mkdir('-p', EXTENSION_LOCALE_OUTPUT + '/' + locale);
|
2012-05-12 07:35:43 +09:00
|
|
|
chromeManifestContent += 'locale pdf.js ' + locale + ' locale/' + locale + '/\n';
|
2012-05-12 04:39:11 +09:00
|
|
|
|
2012-05-02 22:51:52 +09:00
|
|
|
if (test('-f', path + '/viewer.properties')) {
|
|
|
|
var properties = cat(path + '/viewer.properties');
|
2012-05-12 04:39:11 +09:00
|
|
|
viewerOutput += '[' + locale + ']\n' + properties + '\n';
|
|
|
|
cp(path + '/viewer.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
|
2012-05-02 22:51:52 +09:00
|
|
|
}
|
|
|
|
|
2012-05-16 02:33:01 +09:00
|
|
|
if (test('-f', path + '/chrome.properties')) {
|
|
|
|
cp(path + '/chrome.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
|
2012-05-02 22:51:52 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test('-f', path + '/metadata.inc')) {
|
|
|
|
var metadata = cat(path + '/metadata.inc');
|
|
|
|
metadataContent += metadata;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
viewerOutput.to(VIEWER_OUTPUT);
|
|
|
|
metadataContent.to(METADATA_OUTPUT);
|
2012-05-12 04:39:11 +09:00
|
|
|
chromeManifestContent.to(CHROME_MANIFEST_OUTPUT);
|
2012-05-02 22:51:52 +09:00
|
|
|
};
|
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
//
|
|
|
|
// make bundle
|
|
|
|
// Bundles all source files into one wrapper 'pdf.js' file, in the given order.
|
|
|
|
//
|
|
|
|
target.bundle = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
2012-03-05 11:26:57 +09:00
|
|
|
echo('### Bundling files into ' + BUILD_TARGET);
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
// File order matters
|
2012-03-05 11:26:57 +09:00
|
|
|
var SRC_FILES =
|
2012-03-04 04:01:31 +09:00
|
|
|
['core.js',
|
|
|
|
'util.js',
|
2012-04-13 06:02:47 +09:00
|
|
|
'api.js',
|
2012-03-04 04:01:31 +09:00
|
|
|
'canvas.js',
|
|
|
|
'obj.js',
|
|
|
|
'function.js',
|
|
|
|
'charsets.js',
|
|
|
|
'cidmaps.js',
|
|
|
|
'colorspace.js',
|
|
|
|
'crypto.js',
|
|
|
|
'evaluator.js',
|
|
|
|
'fonts.js',
|
|
|
|
'glyphlist.js',
|
|
|
|
'image.js',
|
|
|
|
'metrics.js',
|
|
|
|
'parser.js',
|
|
|
|
'pattern.js',
|
|
|
|
'stream.js',
|
|
|
|
'worker.js',
|
|
|
|
'../external/jpgjs/jpg.js',
|
|
|
|
'jpx.js',
|
2012-06-22 20:41:28 +09:00
|
|
|
'jbig2.js',
|
2012-03-25 03:59:51 +09:00
|
|
|
'bidi.js',
|
2012-03-27 06:53:51 +09:00
|
|
|
'metadata.js'];
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-03-27 05:33:00 +09:00
|
|
|
if (!test('-d', BUILD_DIR))
|
2012-03-04 04:01:31 +09:00
|
|
|
mkdir(BUILD_DIR);
|
|
|
|
|
|
|
|
cd('src');
|
|
|
|
var bundle = cat(SRC_FILES),
|
2012-03-05 11:26:57 +09:00
|
|
|
bundleVersion = exec('git log --format="%h" -n 1',
|
|
|
|
{silent: true}).output.replace('\n', '');
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
// This just preprocesses the empty pdf.js file, we don't actually want to
|
|
|
|
// preprocess everything yet since other build targets use this file.
|
|
|
|
BuildHelper.preprocess('pdf.js', ROOT_DIR + BUILD_TARGET,
|
|
|
|
{BUNDLE: bundle, BUNDLE_VERSION: bundleVersion});
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// make pagesrepo
|
|
|
|
//
|
2012-03-05 11:26:57 +09:00
|
|
|
// This target clones the gh-pages repo into the build directory. It deletes the current contents
|
2012-03-04 04:01:31 +09:00
|
|
|
// of the repo, since we overwrite everything with data from the master repo. The 'make web' target
|
|
|
|
// then uses 'git add -A' to track additions, modifications, moves, and deletions.
|
|
|
|
target.pagesrepo = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Creating fresh clone of gh-pages');
|
|
|
|
|
2012-03-27 05:33:00 +09:00
|
|
|
if (!test('-d', BUILD_DIR))
|
2012-03-04 04:01:31 +09:00
|
|
|
mkdir(BUILD_DIR);
|
|
|
|
|
2012-03-27 05:33:00 +09:00
|
|
|
if (!test('-d', GH_PAGES_DIR)) {
|
2012-03-04 04:01:31 +09:00
|
|
|
echo();
|
|
|
|
echo('Cloning project repo...');
|
|
|
|
echo('(This operation can take a while, depending on network conditions)');
|
2012-03-15 08:40:01 +09:00
|
|
|
exec('git clone -b gh-pages --depth=1 ' + REPO + ' ' + GH_PAGES_DIR,
|
2012-03-05 11:26:57 +09:00
|
|
|
{silent: true});
|
2012-03-04 04:01:31 +09:00
|
|
|
echo('Done.');
|
|
|
|
}
|
|
|
|
|
2012-03-05 11:26:57 +09:00
|
|
|
rm('-rf', GH_PAGES_DIR + '/*');
|
|
|
|
mkdir('-p', GH_PAGES_DIR + '/web');
|
|
|
|
mkdir('-p', GH_PAGES_DIR + '/web/images');
|
|
|
|
mkdir('-p', GH_PAGES_DIR + BUILD_DIR);
|
|
|
|
mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/firefox');
|
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Extension stuff
|
|
|
|
//
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
var EXTENSION_BASE_VERSION = 'f0f0418a9c6637981fe1182b9212c2d592774c7d',
|
2012-04-17 03:14:41 +09:00
|
|
|
EXTENSION_VERSION_PREFIX = '0.3.',
|
2012-03-14 10:31:53 +09:00
|
|
|
EXTENSION_BUILD_NUMBER,
|
|
|
|
EXTENSION_VERSION;
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
//
|
|
|
|
// make extension
|
|
|
|
//
|
|
|
|
target.extension = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Building extensions');
|
|
|
|
|
2012-05-12 08:12:48 +09:00
|
|
|
target.locale();
|
2012-03-04 04:01:31 +09:00
|
|
|
target.firefox();
|
|
|
|
target.chrome();
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
target.buildnumber = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Getting extension build number');
|
|
|
|
|
|
|
|
// Build number is the number of commits since base version
|
2012-03-05 11:26:57 +09:00
|
|
|
EXTENSION_BUILD_NUMBER = exec('git log --format=oneline ' +
|
|
|
|
EXTENSION_BASE_VERSION + '..', {silent: true})
|
2012-03-04 04:01:31 +09:00
|
|
|
.output.match(/\n/g).length; // get # of lines in git output
|
2012-03-05 11:26:57 +09:00
|
|
|
|
|
|
|
echo('Extension build number: ' + EXTENSION_BUILD_NUMBER);
|
2012-03-14 10:31:53 +09:00
|
|
|
|
|
|
|
EXTENSION_VERSION = EXTENSION_VERSION_PREFIX + EXTENSION_BUILD_NUMBER;
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
//
|
|
|
|
// make firefox
|
|
|
|
//
|
|
|
|
target.firefox = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Building Firefox extension');
|
2012-08-02 03:29:13 +09:00
|
|
|
var defines = extendDefines({FIREFOX: true});
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-03-05 11:26:57 +09:00
|
|
|
var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/',
|
2012-08-02 03:29:13 +09:00
|
|
|
FIREFOX_EXTENSION_DIR = 'extensions/firefox/',
|
2012-03-05 11:26:57 +09:00
|
|
|
FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
|
2012-03-04 04:01:31 +09:00
|
|
|
FIREFOX_EXTENSION_FILES_TO_COPY =
|
|
|
|
['*.js',
|
|
|
|
'*.rdf',
|
2012-05-09 00:23:55 +09:00
|
|
|
'*.svg',
|
2012-03-21 07:25:02 +09:00
|
|
|
'*.png',
|
2012-05-12 04:39:11 +09:00
|
|
|
'*.manifest',
|
2012-03-14 10:31:53 +09:00
|
|
|
'components',
|
2012-05-12 04:39:11 +09:00
|
|
|
'locale',
|
2012-05-09 00:23:55 +09:00
|
|
|
'../../LICENSE'],
|
2012-03-04 04:01:31 +09:00
|
|
|
FIREFOX_EXTENSION_FILES =
|
2012-03-14 10:31:53 +09:00
|
|
|
['bootstrap.js',
|
2012-03-04 04:01:31 +09:00
|
|
|
'install.rdf',
|
2012-05-12 04:39:11 +09:00
|
|
|
'chrome.manifest',
|
2012-03-21 07:25:02 +09:00
|
|
|
'icon.png',
|
|
|
|
'icon64.png',
|
2012-03-04 04:01:31 +09:00
|
|
|
'components',
|
2012-03-14 10:31:53 +09:00
|
|
|
'content',
|
2012-05-12 04:39:11 +09:00
|
|
|
'locale',
|
2012-05-09 00:23:55 +09:00
|
|
|
'LICENSE'],
|
2012-03-04 04:01:31 +09:00
|
|
|
FIREFOX_EXTENSION_NAME = 'pdf.js.xpi',
|
|
|
|
FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';
|
|
|
|
|
2012-05-12 08:12:48 +09:00
|
|
|
target.locale();
|
2012-08-02 03:29:13 +09:00
|
|
|
target.bundle();
|
2012-03-04 04:01:31 +09:00
|
|
|
target.buildnumber();
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
|
|
|
|
// Clear out everything in the firefox extension build directory
|
|
|
|
rm('-rf', FIREFOX_BUILD_DIR);
|
|
|
|
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR);
|
2012-03-05 11:26:57 +09:00
|
|
|
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
|
|
|
|
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web');
|
|
|
|
|
|
|
|
// Copy extension files
|
2012-03-04 04:01:31 +09:00
|
|
|
cd('extensions/firefox');
|
2012-03-05 11:26:57 +09:00
|
|
|
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + FIREFOX_BUILD_DIR);
|
2012-03-04 04:01:31 +09:00
|
|
|
cd(ROOT_DIR);
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
var setup = {
|
|
|
|
defines: defines,
|
|
|
|
copy: [
|
|
|
|
[COMMON_WEB_FILES, FIREFOX_BUILD_CONTENT_DIR + '/web'],
|
|
|
|
['extensions/firefox/tools/l10n.js', FIREFOX_BUILD_CONTENT_DIR + '/web']
|
|
|
|
],
|
|
|
|
preprocess: [
|
|
|
|
[COMMON_WEB_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR + '/web']
|
|
|
|
]
|
|
|
|
};
|
|
|
|
BuildHelper.build(setup);
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-03-15 06:50:49 +09:00
|
|
|
// Remove '.DS_Store' and other hidden files
|
2012-03-27 05:33:00 +09:00
|
|
|
find(FIREFOX_BUILD_DIR).forEach(function(file) {
|
2012-03-15 06:50:49 +09:00
|
|
|
if (file.match(/^\./))
|
|
|
|
rm('-f', file);
|
2012-03-27 05:33:00 +09:00
|
|
|
});
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
// Update the build version number
|
2012-03-14 10:31:53 +09:00
|
|
|
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/install.rdf');
|
|
|
|
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/update.rdf');
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-05-24 07:57:14 +09:00
|
|
|
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID, FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
|
|
|
|
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX, FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
|
2012-06-01 03:16:06 +09:00
|
|
|
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false', FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
|
2012-05-24 07:57:14 +09:00
|
|
|
|
2012-05-02 22:51:52 +09:00
|
|
|
// Update localized metadata
|
|
|
|
var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc');
|
|
|
|
sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata, FIREFOX_BUILD_DIR + '/install.rdf');
|
2012-05-12 04:39:11 +09:00
|
|
|
var chromeManifest = cat(EXTENSION_SRC_DIR + '/firefox/chrome.manifest.inc');
|
|
|
|
sed('-i', /.*PDFJS_SUPPORTED_LOCALES.*\n/, chromeManifest, FIREFOX_BUILD_DIR + '/chrome.manifest');
|
2012-05-02 22:51:52 +09:00
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
// Create the xpi
|
|
|
|
cd(FIREFOX_BUILD_DIR);
|
2012-03-05 11:26:57 +09:00
|
|
|
exec('zip -r ' + FIREFOX_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));
|
2012-03-04 04:01:31 +09:00
|
|
|
echo('extension created: ' + FIREFOX_EXTENSION_NAME);
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
|
|
|
|
// Build the amo extension too (remove the updateUrl)
|
|
|
|
cd(FIREFOX_BUILD_DIR);
|
|
|
|
sed('-i', /.*updateURL.*\n/, '', 'install.rdf');
|
2012-03-05 11:26:57 +09:00
|
|
|
exec('zip -r ' + FIREFOX_AMO_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));
|
2012-03-04 04:01:31 +09:00
|
|
|
echo('AMO extension created: ' + FIREFOX_AMO_EXTENSION_NAME);
|
|
|
|
cd(ROOT_DIR);
|
2012-05-09 00:23:55 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// make mozcentral
|
|
|
|
//
|
|
|
|
target.mozcentral = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Building mozilla-central extension');
|
2012-08-02 03:29:13 +09:00
|
|
|
var defines = extendDefines({MOZCENTRAL: true});
|
2012-05-09 00:23:55 +09:00
|
|
|
|
2012-05-12 04:39:11 +09:00
|
|
|
var MOZCENTRAL_DIR = BUILD_DIR + 'mozcentral/',
|
2012-05-23 07:56:12 +09:00
|
|
|
MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + 'browser/extensions/pdfjs/',
|
2012-05-12 04:39:11 +09:00
|
|
|
MOZCENTRAL_CONTENT_DIR = MOZCENTRAL_EXTENSION_DIR + 'content/',
|
|
|
|
MOZCENTRAL_L10N_DIR = MOZCENTRAL_DIR + 'browser/locales/en-US/pdfviewer/',
|
2012-05-23 07:56:12 +09:00
|
|
|
MOZCENTRAL_TEST_DIR = MOZCENTRAL_EXTENSION_DIR + 'test/',
|
2012-05-09 00:23:55 +09:00
|
|
|
FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
|
|
|
|
FIREFOX_EXTENSION_FILES_TO_COPY =
|
2012-05-24 07:57:14 +09:00
|
|
|
['components/*.js',
|
2012-05-09 00:23:55 +09:00
|
|
|
'*.svg',
|
|
|
|
'*.png',
|
2012-05-12 04:39:11 +09:00
|
|
|
'*.manifest',
|
2012-05-09 00:23:55 +09:00
|
|
|
'README.mozilla',
|
|
|
|
'components',
|
|
|
|
'../../LICENSE'],
|
|
|
|
DEFAULT_LOCALE_FILES =
|
2012-05-16 03:38:38 +09:00
|
|
|
[LOCALE_SRC_DIR + 'en-US/viewer.properties',
|
|
|
|
LOCALE_SRC_DIR + 'en-US/chrome.properties'],
|
2012-05-09 00:23:55 +09:00
|
|
|
FIREFOX_MC_EXTENSION_FILES =
|
2012-05-24 07:57:14 +09:00
|
|
|
['chrome.manifest',
|
2012-05-09 00:23:55 +09:00
|
|
|
'components',
|
|
|
|
'content',
|
|
|
|
'LICENSE'];
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
target.bundle();
|
2012-05-09 00:23:55 +09:00
|
|
|
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');
|
|
|
|
|
2012-06-01 03:16:06 +09:00
|
|
|
cp(FIREFOX_CONTENT_DIR + 'PdfJs.jsm', MOZCENTRAL_CONTENT_DIR)
|
|
|
|
|
2012-05-09 00:23:55 +09:00
|
|
|
// Copy extension files
|
|
|
|
cd('extensions/firefox');
|
2012-05-12 04:39:11 +09:00
|
|
|
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + MOZCENTRAL_EXTENSION_DIR);
|
2012-05-23 07:56:12 +09:00
|
|
|
mv('-f', ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome-mozcentral.manifest',
|
|
|
|
ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome.manifest')
|
2012-05-09 00:23:55 +09:00
|
|
|
cd(ROOT_DIR);
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
var setup = {
|
|
|
|
defines: defines,
|
|
|
|
copy: [
|
|
|
|
[COMMON_WEB_FILES, MOZCENTRAL_CONTENT_DIR + '/web'],
|
|
|
|
['extensions/firefox/tools/l10n.js', MOZCENTRAL_CONTENT_DIR + '/web']
|
|
|
|
],
|
|
|
|
preprocess: [
|
|
|
|
[COMMON_WEB_FILES_PREPROCESS, MOZCENTRAL_CONTENT_DIR + '/web']
|
|
|
|
]
|
|
|
|
};
|
|
|
|
BuildHelper.build(setup);
|
2012-05-09 00:23:55 +09:00
|
|
|
|
|
|
|
// 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
|
2012-05-12 04:39:11 +09:00
|
|
|
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, MOZCENTRAL_EXTENSION_DIR + 'README.mozilla');
|
2012-03-14 10:31:53 +09:00
|
|
|
|
2012-05-24 07:57:14 +09:00
|
|
|
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID, MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
|
|
|
|
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX, MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
|
2012-06-01 03:16:06 +09:00
|
|
|
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true', MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
|
2012-05-24 07:57:14 +09:00
|
|
|
|
2012-03-15 06:50:49 +09:00
|
|
|
// List all files for mozilla-central
|
2012-05-12 04:39:11 +09:00
|
|
|
cd(MOZCENTRAL_EXTENSION_DIR);
|
2012-03-15 06:50:49 +09:00
|
|
|
var extensionFiles = '';
|
2012-03-27 05:33:00 +09:00
|
|
|
find(FIREFOX_MC_EXTENSION_FILES).forEach(function(file){
|
2012-03-15 06:50:49 +09:00
|
|
|
if (test('-f', file))
|
|
|
|
extensionFiles += file+'\n';
|
2012-03-27 05:33:00 +09:00
|
|
|
});
|
2012-03-15 06:50:49 +09:00
|
|
|
extensionFiles.to('extension-files');
|
2012-05-23 07:56:12 +09:00
|
|
|
cd(ROOT_DIR);
|
|
|
|
|
|
|
|
// Copy test files
|
|
|
|
mkdir('-p', MOZCENTRAL_TEST_DIR);
|
|
|
|
cp('-Rf', 'test/mozcentral/*', MOZCENTRAL_TEST_DIR);
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-07-28 07:19:43 +09:00
|
|
|
target.b2g = function() {
|
|
|
|
echo();
|
|
|
|
echo('### Building B2G (Firefox OS App)');
|
|
|
|
var B2G_BUILD_DIR = BUILD_DIR + '/b2g/',
|
|
|
|
B2G_BUILD_CONTENT_DIR = B2G_BUILD_DIR + '/content/';
|
2012-08-02 03:29:13 +09:00
|
|
|
var defines = extendDefines({ B2G: true });
|
|
|
|
target.bundle();
|
2012-07-28 07:19:43 +09:00
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
// Clear out everything in the b2g build directory
|
2012-07-28 07:19:43 +09:00
|
|
|
cd(ROOT_DIR);
|
|
|
|
rm('-Rf', B2G_BUILD_DIR);
|
|
|
|
mkdir('-p', B2G_BUILD_CONTENT_DIR);
|
|
|
|
mkdir('-p', B2G_BUILD_CONTENT_DIR + BUILD_DIR);
|
|
|
|
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web');
|
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
var setup = {
|
|
|
|
defines: defines,
|
|
|
|
copy: [
|
|
|
|
[COMMON_WEB_FILES, B2G_BUILD_CONTENT_DIR + '/web'],
|
|
|
|
['web/locale.properties', B2G_BUILD_CONTENT_DIR + '/web'],
|
|
|
|
['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web']
|
|
|
|
],
|
|
|
|
preprocess: [
|
|
|
|
[COMMON_WEB_FILES_PREPROCESS, B2G_BUILD_CONTENT_DIR + '/web'],
|
|
|
|
[BUILD_TARGET, B2G_BUILD_CONTENT_DIR + BUILD_TARGET]
|
|
|
|
]
|
2012-07-28 07:19:43 +09:00
|
|
|
};
|
2012-08-02 03:29:13 +09:00
|
|
|
BuildHelper.build(setup);
|
2012-07-28 07:19:43 +09:00
|
|
|
};
|
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
//
|
|
|
|
// make chrome
|
|
|
|
//
|
|
|
|
target.chrome = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Building Chrome extension');
|
2012-08-02 03:29:13 +09:00
|
|
|
var defines = extendDefines({CHROME: true});
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-03-05 11:26:57 +09:00
|
|
|
var CHROME_BUILD_DIR = BUILD_DIR + '/chrome/',
|
2012-08-02 03:29:13 +09:00
|
|
|
CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/';
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
target.bundle();
|
2012-03-04 04:01:31 +09:00
|
|
|
target.buildnumber();
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
|
|
|
|
// Clear out everything in the chrome extension build directory
|
|
|
|
rm('-Rf', CHROME_BUILD_DIR);
|
|
|
|
mkdir('-p', CHROME_BUILD_CONTENT_DIR);
|
2012-03-05 11:26:57 +09:00
|
|
|
mkdir('-p', CHROME_BUILD_CONTENT_DIR + BUILD_DIR);
|
|
|
|
mkdir('-p', CHROME_BUILD_CONTENT_DIR + '/web');
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-08-02 03:29:13 +09:00
|
|
|
var setup = {
|
|
|
|
defines: defines,
|
|
|
|
copy: [
|
|
|
|
[COMMON_WEB_FILES, CHROME_BUILD_CONTENT_DIR + '/web'],
|
|
|
|
[['extensions/chrome/*.json', 'extensions/chrome/*.html'], CHROME_BUILD_DIR],
|
|
|
|
[BUILD_TARGET, CHROME_BUILD_CONTENT_DIR + BUILD_TARGET],
|
|
|
|
['external/webL10n/l10n.js', CHROME_BUILD_CONTENT_DIR + '/web']
|
|
|
|
],
|
|
|
|
preprocess: [
|
|
|
|
[COMMON_WEB_FILES_PREPROCESS, CHROME_BUILD_CONTENT_DIR + '/web'],
|
|
|
|
['web/locale.properties', CHROME_BUILD_CONTENT_DIR + '/web']
|
|
|
|
]
|
|
|
|
};
|
|
|
|
BuildHelper.build(setup);
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Test stuff
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// make test
|
|
|
|
//
|
|
|
|
target.test = function() {
|
2012-04-20 04:32:24 +09:00
|
|
|
target.unittest({}, function() {
|
|
|
|
target.browsertest();
|
|
|
|
});
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-03-29 06:06:41 +09:00
|
|
|
//
|
|
|
|
// make bottest
|
|
|
|
// (Special tests for the Github bot)
|
|
|
|
//
|
|
|
|
target.bottest = function() {
|
2012-04-20 04:54:53 +09:00
|
|
|
target.unittest({}, function() {
|
|
|
|
target.browsertest({noreftest: true});
|
2012-04-20 04:32:24 +09:00
|
|
|
});
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
//
|
|
|
|
// make browsertest
|
|
|
|
//
|
2012-03-29 06:06:41 +09:00
|
|
|
target.browsertest = function(options) {
|
2012-03-04 04:01:31 +09:00
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Running browser tests');
|
|
|
|
|
|
|
|
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
|
|
|
|
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
|
|
|
|
|
2012-03-27 05:33:00 +09:00
|
|
|
if (!test('-f', 'test/' + PDF_BROWSERS)) {
|
2012-03-05 11:26:57 +09:00
|
|
|
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
|
2012-03-04 04:01:31 +09:00
|
|
|
echo('Try copying one of the examples in test/resources/browser_manifests/');
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-03-30 04:04:12 +09:00
|
|
|
var reftest = (options && options.noreftest) ? '' : '--reftest';
|
2012-03-29 06:06:41 +09:00
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
cd('test');
|
2012-03-29 06:06:41 +09:00
|
|
|
exec(PYTHON_BIN + ' -u test.py '+reftest+' --browserManifestFile=' + PDF_BROWSERS +
|
2012-03-05 11:26:57 +09:00
|
|
|
' --manifestFile=' + PDF_TEST, {async: true});
|
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
//
|
|
|
|
// make unittest
|
|
|
|
//
|
2012-04-20 04:32:24 +09:00
|
|
|
target.unittest = function(options, callback) {
|
2012-03-04 04:01:31 +09:00
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Running unit tests');
|
|
|
|
|
2012-04-20 04:32:24 +09:00
|
|
|
var PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
|
2012-03-27 05:33:00 +09:00
|
|
|
|
2012-04-20 04:32:24 +09:00
|
|
|
if (!test('-f', 'test/' + PDF_BROWSERS)) {
|
|
|
|
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
|
|
|
|
echo('Try copying one of the examples in test/resources/browser_manifests/');
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
callback = callback || function() {};
|
|
|
|
cd('test');
|
|
|
|
exec(PYTHON_BIN + ' -u test.py --unitTest --browserManifestFile=' + PDF_BROWSERS,
|
|
|
|
{async: true}, callback);
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
2012-03-30 04:04:12 +09:00
|
|
|
//
|
|
|
|
// make botmakeref
|
|
|
|
//
|
|
|
|
target.botmakeref = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Creating reference images');
|
|
|
|
|
|
|
|
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
|
|
|
|
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
|
|
|
|
|
|
|
|
if (!test('-f', 'test/' + PDF_BROWSERS)) {
|
|
|
|
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
|
|
|
|
echo('Try copying one of the examples in test/resources/browser_manifests/');
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-03-27 05:33:00 +09:00
|
|
|
cd('test');
|
|
|
|
exec(PYTHON_BIN + ' -u test.py --masterMode --noPrompts --browserManifestFile=' + PDF_BROWSERS,
|
|
|
|
{async: true});
|
|
|
|
};
|
|
|
|
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Other
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// make server
|
|
|
|
//
|
|
|
|
target.server = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Starting local server');
|
|
|
|
|
|
|
|
cd('test');
|
2012-03-05 11:26:57 +09:00
|
|
|
exec(PYTHON_BIN + ' -u test.py --port=8888', {async: true});
|
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
//
|
|
|
|
// make lint
|
|
|
|
//
|
|
|
|
target.lint = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Linting JS files (this can take a while!)');
|
|
|
|
|
|
|
|
var LINT_FILES = 'src/*.js \
|
|
|
|
web/*.js \
|
|
|
|
test/*.js \
|
|
|
|
test/unit/*.js \
|
|
|
|
extensions/firefox/*.js \
|
|
|
|
extensions/firefox/components/*.js \
|
|
|
|
extensions/chrome/*.js';
|
|
|
|
|
2012-03-05 11:26:57 +09:00
|
|
|
exec('gjslint --nojsdoc ' + LINT_FILES);
|
|
|
|
};
|
2012-03-04 04:01:31 +09:00
|
|
|
|
|
|
|
//
|
|
|
|
// make clean
|
|
|
|
//
|
|
|
|
target.clean = function() {
|
|
|
|
cd(ROOT_DIR);
|
|
|
|
echo();
|
|
|
|
echo('### Cleaning up project builds');
|
|
|
|
|
|
|
|
rm('-rf', BUILD_DIR);
|
2012-03-05 11:26:57 +09:00
|
|
|
};
|