Skip to content

Commit

Permalink
Updates make.js for cmaps and make binary cmaps by default
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed Mar 17, 2014
1 parent 734d6f3 commit 1d8f6cf
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion external/cmapscompress/parse.js
Expand Up @@ -23,7 +23,7 @@ exports.parseAdobeCMap = function (content) {
var result = {
type: 1,
wmode: 0,
comment: 'Copyright 1990-2009 Adobe Systems Incorporated.\nAll rights reserved.\nhttp://sourceforge.net/adobe/cmap/wiki/License/',
comment: 'Copyright 1990-2009 Adobe Systems Incorporated.\nAll rights reserved.\nSee ./LICENSE',
usecmap: null,
body: []
};
Expand Down
43 changes: 23 additions & 20 deletions make.js
Expand Up @@ -90,7 +90,6 @@ var COMMON_WEB_FILES =
target.generic = function() {
target.bundle({});
target.locale();
target.cmaps();

cd(ROOT_DIR);
echo();
Expand All @@ -100,6 +99,7 @@ target.generic = function() {
mkdir('-p', GENERIC_DIR);
mkdir('-p', GENERIC_DIR + BUILD_DIR);
mkdir('-p', GENERIC_DIR + '/web');
mkdir('-p', GENERIC_DIR + '/web/cmaps');

var defines = builder.merge(DEFINES, {GENERIC: true});

Expand All @@ -111,7 +111,7 @@ target.generic = function() {
['web/viewer.css', GENERIC_DIR + '/web'],
['web/compatibility.js', GENERIC_DIR + '/web'],
['web/compressed.tracemonkey-pldi-09.pdf', GENERIC_DIR + '/web'],
['web/cmaps', GENERIC_DIR + '/web'],
['external/bcmaps/*', GENERIC_DIR + '/web/cmaps/'],
['web/locale', GENERIC_DIR + '/web']
],
preprocess: [
Expand Down Expand Up @@ -231,17 +231,25 @@ target.locale = function() {

//
// make cmaps
// Compresses cmap files
// Compresses cmap files. Ensure that Adobe cmap download and uncompressed at
// ./external/cmaps location.
//
target.cmaps = function (args) {
var CMAP_INPUT = 'external/cmaps';
var VIEWER_CMAP_OUTPUT = 'web/cmaps';
var VIEWER_CMAP_OUTPUT = 'external/bcmaps';

cd(ROOT_DIR);
echo();
echo('### Building cmaps');

rm('-rf', VIEWER_CMAP_OUTPUT);
mkdir('-p', VIEWER_CMAP_OUTPUT);
// testing a file that usually present
if (!test('-f', CMAP_INPUT + '/UniJIS-UCS2-H')) {
echo('./external/cmaps has no cmap files, please download them from:');
echo(' http://sourceforge.net/adobe/cmap/wiki/Home/');
exit(1);
}

rm(VIEWER_CMAP_OUTPUT + '*.bcmap');

var compressCmaps =
require('./external/cmapscompress/compress.js').compressCmaps;
Expand Down Expand Up @@ -430,7 +438,6 @@ target.minified = function() {

target.bundle({});
target.locale();
target.cmaps();

cd(ROOT_DIR);
echo();
Expand All @@ -440,6 +447,7 @@ target.minified = function() {
mkdir('-p', MINIFIED_DIR);
mkdir('-p', MINIFIED_DIR + BUILD_DIR);
mkdir('-p', MINIFIED_DIR + '/web');
mkdir('-p', MINIFIED_DIR + '/web/cmaps');

var defines = builder.merge(DEFINES, {GENERIC: true, MINIFIED: true});

Expand All @@ -449,7 +457,7 @@ target.minified = function() {
[COMMON_WEB_FILES, MINIFIED_DIR + '/web'],
['web/viewer.css', MINIFIED_DIR + '/web'],
['web/compressed.tracemonkey-pldi-09.pdf', MINIFIED_DIR + '/web'],
['web/cmaps', MINIFIED_DIR + '/web'],
['external/bcmaps/*', MINIFIED_DIR + '/web/cmaps'],
['web/locale', MINIFIED_DIR + '/web']
],
preprocess: [
Expand Down Expand Up @@ -514,7 +522,6 @@ target.extension = function() {
echo('### Building extensions');

target.locale();
target.cmaps();
target.firefox();
target.chromium();
};
Expand Down Expand Up @@ -567,7 +574,6 @@ target.firefox = function() {
FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';

target.locale();
target.cmaps();
target.bundle({ excludes: ['core/network.js'], defines: defines });
cd(ROOT_DIR);

Expand All @@ -576,6 +582,7 @@ target.firefox = function() {
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR);
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web');
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web/cmaps');

cp(FIREFOX_CONTENT_DIR + 'PdfJs-stub.jsm',
FIREFOX_BUILD_CONTENT_DIR + 'PdfJs.jsm');
Expand All @@ -598,7 +605,7 @@ target.firefox = function() {
defines: defines,
copy: [
[COMMON_WEB_FILES, FIREFOX_BUILD_CONTENT_DIR + '/web'],
['web/cmaps/', FIREFOX_BUILD_CONTENT_DIR + '/web/cmaps'],
['external/bcmaps/*', FIREFOX_BUILD_CONTENT_DIR + '/web/cmaps'],
[FIREFOX_EXTENSION_DIR + 'tools/l10n.js',
FIREFOX_BUILD_CONTENT_DIR + '/web'],
['web/default_preferences.js', FIREFOX_BUILD_CONTENT_DIR]
Expand Down Expand Up @@ -697,6 +704,7 @@ target.mozcentral = function() {
mkdir('-p', MOZCENTRAL_L10N_DIR);
mkdir('-p', MOZCENTRAL_CONTENT_DIR + BUILD_DIR);
mkdir('-p', MOZCENTRAL_CONTENT_DIR + '/web');
mkdir('-p', MOZCENTRAL_CONTENT_DIR + '/web/cmaps');

cp(FIREFOX_CONTENT_DIR + 'PdfJs.jsm', MOZCENTRAL_CONTENT_DIR);
cp(FIREFOX_CONTENT_DIR + 'PdfJsTelemetry.jsm', MOZCENTRAL_CONTENT_DIR);
Expand All @@ -715,7 +723,7 @@ target.mozcentral = function() {
defines: defines,
copy: [
[COMMON_WEB_FILES, MOZCENTRAL_CONTENT_DIR + '/web'],
['web/cmaps/', MOZCENTRAL_CONTENT_DIR + '/web/cmaps'],
['external/bcmaps/*', MOZCENTRAL_CONTENT_DIR + '/web/cmaps'],
['extensions/firefox/tools/l10n.js', MOZCENTRAL_CONTENT_DIR + '/web'],
['web/default_preferences.js', MOZCENTRAL_CONTENT_DIR]
],
Expand Down Expand Up @@ -770,7 +778,6 @@ target.mozcentral = function() {

target.b2g = function() {
target.locale();
target.cmaps();

echo();
echo('### Building B2G (Firefox OS App)');
Expand All @@ -784,15 +791,16 @@ target.b2g = function() {
mkdir('-p', B2G_BUILD_CONTENT_DIR);
mkdir('-p', B2G_BUILD_CONTENT_DIR + BUILD_DIR);
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web');
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web/cmaps');

var setup = {
defines: defines,
copy: [
['extensions/b2g/images', B2G_BUILD_CONTENT_DIR + '/web'],
['extensions/b2g/viewer.html', B2G_BUILD_CONTENT_DIR + '/web'],
['extensions/b2g/viewer.css', B2G_BUILD_CONTENT_DIR + '/web'],
['web/cmaps/', B2G_BUILD_CONTENT_DIR + '/web/cmaps'],
['web/locale', B2G_BUILD_CONTENT_DIR + '/web'],
['external/bcmaps/*', B2G_BUILD_CONTENT_DIR + '/web/cmaps'],
['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web']
],
preprocess: [
Expand All @@ -810,7 +818,6 @@ target.b2g = function() {
//
target.chromium = function() {
target.locale();
target.cmaps();

cd(ROOT_DIR);
echo();
Expand Down Expand Up @@ -841,7 +848,7 @@ target.chromium = function() {
CHROME_BUILD_DIR],
['external/webL10n/l10n.js', CHROME_BUILD_CONTENT_DIR + '/web'],
['web/viewer.css', CHROME_BUILD_CONTENT_DIR + '/web'],
['web/cmaps/', CHROME_BUILD_CONTENT_DIR + '/web/cmaps'],
['external/bcmaps/*', CHROME_BUILD_CONTENT_DIR + '/web/cmaps'],
['web/locale', CHROME_BUILD_CONTENT_DIR + '/web']
],
preprocess: [
Expand Down Expand Up @@ -959,8 +966,6 @@ target.test = function() {
// (Special tests for the Github bot)
//
target.bottest = function() {
target.cmaps();

target.unittest({}, function() {
target.fonttest({}, function() {
target.browsertest({noreftest: true});
Expand Down Expand Up @@ -1041,8 +1046,6 @@ target.fonttest = function(options, callback) {
// make botmakeref
//
target.botmakeref = function() {
target.cmaps();

cd(ROOT_DIR);
echo();
echo('### Creating reference images');
Expand Down
2 changes: 1 addition & 1 deletion test/driver.js
Expand Up @@ -28,7 +28,7 @@
// "firefox-bin: Fatal IO error 12 (Cannot allocate memory) on X server :1."
// PDFJS.disableWorker = true;
PDFJS.enableStats = true;
PDFJS.cMapUrl = '../web/cmaps/';
PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.cMapPacked = true;

var appPath, masterMode, browser, canvas, dummyCanvas, currentTaskIdx,
Expand Down
11 changes: 10 additions & 1 deletion web/viewer.js
Expand Up @@ -63,7 +63,8 @@ PDFJS.imageResourcesPath = './images/';
//PDFJS.workerSrc = '../build/pdf.worker.js';
//#endif
//#if !PRODUCTION
PDFJS.cMapUrl = '../external/cmaps/';
PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.cMapPacked = true;
//#else
//PDFJS.cMapUrl = '../web/cmaps/';
//PDFJS.cMapPacked = true;
Expand Down Expand Up @@ -1688,6 +1689,14 @@ function webViewerLoad(evt) {
(hashParams['ignoreCurrentPositionOnZoom'] === 'true');
}

//#if !PRODUCTION
if ('disableBcmaps' in hashParams && hashParams['disableBcmaps']) {
PDFJS.cMapUrl = '../external/cmaps/';
PDFJS.cMapPacked = false;
}
//#endif


//#if !(FIREFOX || MOZCENTRAL)
var locale = PDFJS.locale || navigator.language;
if ('locale' in hashParams) {
Expand Down

0 comments on commit 1d8f6cf

Please sign in to comment.