#!/usr/bin/env node require('./external/shelljs/make'); var ROOT_DIR = __dirname + '/', // absolute path to project's root BUILD_DIR = 'build/', BUILD_TARGET = BUILD_DIR + 'pdf.js', FIREFOX_BUILD_DIR = BUILD_DIR + '/firefox/', EXTENSION_SRC_DIR = 'extensions/', GH_PAGES_DIR = BUILD_DIR + 'gh-pages/', REPO = 'git@github.com:mozilla/pdf.js.git', PYTHON_BIN = 'python2.7'; // // make all // target.all = function() { // Don't do anything by default echo('Please specify a target. Available targets:'); for (t in target) if (t !== 'all') echo(' ' + t); }; /////////////////////////////////////////////////////////////////////////////////////////// // // Production stuff // // // make web // Generates the website for the project, by checking out the gh-pages branch underneath // the build directory, and then moving the various viewer files into place. // target.web = function() { target.production(); target.extension(); target.pagesrepo(); cd(ROOT_DIR); echo(); echo('### Creating web site'); cp(BUILD_TARGET, GH_PAGES_DIR + BUILD_TARGET); cp('-R', 'web/*', GH_PAGES_DIR + '/web'); cp(FIREFOX_BUILD_DIR + '/*.xpi', FIREFOX_BUILD_DIR + '/*.rdf', GH_PAGES_DIR + EXTENSION_SRC_DIR + 'firefox/'); cp(GH_PAGES_DIR + '/web/index.html.template', GH_PAGES_DIR + '/index.html'); mv('-f', GH_PAGES_DIR + '/web/viewer-production.html', GH_PAGES_DIR + '/web/viewer.html'); cd(GH_PAGES_DIR); exec('git add -A'); echo(); echo("Website built in " + GH_PAGES_DIR); echo("Don't forget to cd into " + GH_PAGES_DIR + " and issue 'git commit' to push changes."); }; // // make production // Creates production output (pdf.js, and corresponding changes to web/ files) // target.production = function() { target.bundle(); target.viewer(); }; // // make bundle // Bundles all source files into one wrapper 'pdf.js' file, in the given order. // target.bundle = function() { cd(ROOT_DIR); echo(); echo('### Bundling files into ' + BUILD_TARGET); // File order matters var SRC_FILES = ['core.js', 'util.js', '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', 'bidi.js']; if (!exists(BUILD_DIR)) mkdir(BUILD_DIR); cd('src'); var bundle = cat(SRC_FILES), bundleVersion = exec('git log --format="%h" -n 1', {silent: true}).output.replace('\n', ''); sed(/.*PDFJSSCRIPT_INCLUDE_ALL.*\n/, bundle, 'pdf.js') .to(ROOT_DIR + BUILD_TARGET); sed('-i', 'PDFJSSCRIPT_BUNDLE_VER', bundleVersion, ROOT_DIR + BUILD_TARGET); }; // // make viewer // Changes development