From c73d091e9cd3f8706673f55b8ac5da1a4869080e Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 9 Apr 2014 14:47:52 -0700 Subject: [PATCH] Use config file. --- make.js | 41 ++++++++++++++++++++++------------------- pdfjs.config | 6 ++++++ 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 pdfjs.config diff --git a/make.js b/make.js index 0b8f2351f..3ba0da144 100644 --- a/make.js +++ b/make.js @@ -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 diff --git a/pdfjs.config b/pdfjs.config new file mode 100644 index 000000000..52c0f970f --- /dev/null +++ b/pdfjs.config @@ -0,0 +1,6 @@ +{ + "betaVersion": "0.8.1114", + "stableVersion": "0.8.1181", + "baseVersion": "0ac55ac879d1c0eea9c0d155d5bbd9b11560f631", + "versionPrefix": "0.8." +} \ No newline at end of file