Use config file.

This commit is contained in:
Brendan Dahl 2014-04-09 14:47:52 -07:00
parent 1ceac04351
commit c73d091e9c
2 changed files with 28 additions and 19 deletions

41
make.js
View File

@ -25,9 +25,14 @@ var builder = require('./external/builder/builder.js');
var crlfchecker = require('./external/crlfchecker/crlfchecker.js');
var wintersmith = require('wintersmith');
var path = require('path');
var fs = require('fs');
var BETA_VERSION = '0.8.1114'; // Current version in Firefox Nightly.
var STABLE_VERSION = '0.8.1181'; // Current version in Firefox Aurora.
var CONFIG_FILE = 'pdfjs.config';
var config = JSON.parse(fs.readFileSync(CONFIG_FILE));
// Defined by buildnumber target.
var BUILD_NUMBER,
VERSION;
var ROOT_DIR = __dirname + '/', // absolute path to project's root
BUILD_DIR = 'build/',
@ -168,9 +173,9 @@ target.web = function() {
if (error) {
throw error;
}
sed('-i', /STABLE_VERSION/g, STABLE_VERSION,
sed('-i', /STABLE_VERSION/g, config.stableVersion,
GH_PAGES_DIR + '/getting_started/index.html');
sed('-i', /BETA_VERSION/g, BETA_VERSION,
sed('-i', /BETA_VERSION/g, config.betaVersion,
GH_PAGES_DIR + '/getting_started/index.html');
echo('Done building with wintersmith.');
@ -188,8 +193,11 @@ target.web = function() {
target.dist = function() {
target.generic();
config.stableVersion = config.betaVersion;
config.betaVersion = VERSION;
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
cd(GENERIC_DIR);
var distFilename = 'pdfjs-' + EXTENSION_VERSION + '-dist.zip';
var distFilename = 'pdfjs-' + VERSION + '-dist.zip';
exec('zip -r ' + ROOT_DIR + BUILD_DIR + distFilename + ' *');
echo('Built distrobution file: ' + distFilename);
cd(ROOT_DIR);
@ -309,7 +317,7 @@ target.bundle = function(args) {
}
var bundle = cat(SRC_FILES),
bundleVersion = EXTENSION_VERSION,
bundleVersion = VERSION,
bundleBuild = exec('git log --format="%h" -n 1',
{silent: true}).output.replace('\n', '');
@ -537,11 +545,6 @@ target.minified = function() {
// Extension stuff
//
var EXTENSION_BASE_VERSION = '0ac55ac879d1c0eea9c0d155d5bbd9b11560f631',
EXTENSION_VERSION_PREFIX = '0.8.',
EXTENSION_BUILD_NUMBER,
EXTENSION_VERSION;
//
// make extension
//
@ -561,13 +564,13 @@ target.buildnumber = function() {
echo('### Getting extension build number');
var lines = exec('git log --format=oneline ' +
EXTENSION_BASE_VERSION + '..', {silent: true}).output;
config.baseVersion + '..', {silent: true}).output;
// Build number is the number of commits since base version
EXTENSION_BUILD_NUMBER = lines ? lines.match(/\n/g).length : 0;
BUILD_NUMBER = lines ? lines.match(/\n/g).length : 0;
echo('Extension build number: ' + EXTENSION_BUILD_NUMBER);
echo('Extension build number: ' + BUILD_NUMBER);
EXTENSION_VERSION = EXTENSION_VERSION_PREFIX + EXTENSION_BUILD_NUMBER;
VERSION = config.versionPrefix + BUILD_NUMBER;
};
//
@ -662,9 +665,9 @@ target.firefox = function() {
});
// Update the build version number
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
FIREFOX_BUILD_DIR + '/install.rdf');
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
FIREFOX_BUILD_DIR + '/update.rdf');
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID,
@ -795,7 +798,7 @@ target.mozcentral = function() {
cp(DEFAULT_LOCALE_FILES, MOZCENTRAL_L10N_DIR);
// Update the build version number
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
MOZCENTRAL_EXTENSION_DIR + 'README.mozilla');
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID,
@ -895,7 +898,7 @@ target.chromium = function() {
cleanupJSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.js');
// Update the build version number
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
CHROME_BUILD_DIR + '/manifest.json');
// Allow PDF.js resources to be loaded by adding the files to

6
pdfjs.config Normal file
View File

@ -0,0 +1,6 @@
{
"betaVersion": "0.8.1114",
"stableVersion": "0.8.1181",
"baseVersion": "0ac55ac879d1c0eea9c0d155d5bbd9b11560f631",
"versionPrefix": "0.8."
}