Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 1513 lines (1283 sloc) 44.012 kb
0e948f1 Kalervo Kujala Add mode setting and strict to make.js
kkujala authored
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
3 /* Copyright 2012 Mozilla Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
c4eab85 Jon Buckley Issue #2008 - Fix lint errors for make.js
jbuck authored
17 /* jshint node:true */
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
18 /* globals cat, cd, cp, echo, env, exec, exit, find, ls, mkdir, mv, process, rm,
19 sed, target, test */
0e948f1 Kalervo Kujala Add mode setting and strict to make.js
kkujala authored
20
21 'use strict';
22
f6ba384 Artur Adib Using ShellJS
arturadib authored
23 require('./external/shelljs/make');
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
24 var builder = require('./external/builder/builder.js');
2ffd3ae Kalervo Kujala Create crlfchecker module and use it in make.js.
kkujala authored
25 var crlfchecker = require('./external/crlfchecker/crlfchecker.js');
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
26 var path = require('path');
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
27 var fs = require('fs');
28
29 var CONFIG_FILE = 'pdfjs.config';
30 var config = JSON.parse(fs.readFileSync(CONFIG_FILE));
31
32 // Defined by buildnumber target.
33 var BUILD_NUMBER,
34 VERSION;
f6ba384 Artur Adib Using ShellJS
arturadib authored
35
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
36 var ROOT_DIR = __dirname + '/', // absolute path to project's root
f6ba384 Artur Adib Using ShellJS
arturadib authored
37 BUILD_DIR = 'build/',
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
38 SRC_DIR = 'src/',
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
39 BUILD_TARGET = BUILD_DIR + 'pdf.js',
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
40 BUILD_WORKER_TARGET = BUILD_DIR + 'pdf.worker.js',
41 BUILD_TARGETS = [BUILD_TARGET, BUILD_WORKER_TARGET],
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
42 FIREFOX_BUILD_DIR = BUILD_DIR + '/firefox/',
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
43 CHROME_BUILD_DIR = BUILD_DIR + '/chromium/',
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
44 B2G_BUILD_DIR = BUILD_DIR + '/b2g/',
2ca2c38 Yury Delendik Creates make.js code to build jsdoc.
yurydelendik authored
45 JSDOC_DIR = BUILD_DIR + 'jsdoc',
f6ba384 Artur Adib Using ShellJS
arturadib authored
46 EXTENSION_SRC_DIR = 'extensions/',
1cda4c7 Yury Delendik Loading PDF.js extension into e10s windows
yurydelendik authored
47 FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
48 LOCALE_SRC_DIR = 'l10n/',
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
49 GH_PAGES_DIR = BUILD_DIR + 'gh-pages/',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
50 GENERIC_DIR = BUILD_DIR + 'generic/',
2b298a7 Yury Delendik Adds make minified command
yurydelendik authored
51 MINIFIED_DIR = BUILD_DIR + 'minified/',
b16a406 Yury Delendik Packages PDFViewer as a UI component.
yurydelendik authored
52 SINGLE_FILE_DIR = BUILD_DIR + 'singlefile/',
53 COMPONENTS_DIR = BUILD_DIR + 'components/',
f6ba384 Artur Adib Using ShellJS
arturadib authored
54 REPO = 'git@github.com:mozilla/pdf.js.git',
4bee4c6 Brendan Dahl Use different id's for moz central and extension.
brendandahl authored
55 MOZCENTRAL_PREF_PREFIX = 'pdfjs',
56 FIREFOX_PREF_PREFIX = 'extensions.uriloader@pdf.js',
57 MOZCENTRAL_STREAM_CONVERTER_ID = 'd0c5195d-e798-49d4-b1d3-9324328b2291',
58 FIREFOX_STREAM_CONVERTER_ID = '6457a96b-2d68-439a-bcfa-44465fbcdbb1';
f6ba384 Artur Adib Using ShellJS
arturadib authored
59
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
60 var DEFINES = {
61 PRODUCTION: true,
62 // The main build targets:
63 GENERIC: false,
64 FIREFOX: false,
65 MOZCENTRAL: false,
66 B2G: false,
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
67 CHROME: false,
2b298a7 Yury Delendik Adds make minified command
yurydelendik authored
68 MINIFIED: false,
b16a406 Yury Delendik Packages PDFViewer as a UI component.
yurydelendik authored
69 SINGLE_FILE: false,
70 COMPONENTS: false
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
71 };
72
f6ba384 Artur Adib Using ShellJS
arturadib authored
73 //
74 // make all
75 //
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
76 target.all = function() {
f6ba384 Artur Adib Using ShellJS
arturadib authored
77 // Don't do anything by default
78 echo('Please specify a target. Available targets:');
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
79 for (var t in target) {
80 if (t !== 'all') {
81 echo(' ' + t);
82 }
83 }
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
84 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
85
86
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
87 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
88 //
89 // Production stuff
90 //
91
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
92 // Files that need to be included in every build.
2c1eae5 Brendan Dahl Remove trailing whitespace.
brendandahl authored
93 var COMMON_WEB_FILES =
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
94 ['web/images',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
95 'web/debugger.js'],
96 COMMON_WEB_FILES_PREPROCESS =
97 ['web/viewer.js',
1cda4c7 Yury Delendik Loading PDF.js extension into e10s windows
yurydelendik authored
98 'web/viewer.html'],
99 COMMON_FIREFOX_FILES_PREPROCESS =
100 [FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm',
101 FIREFOX_CONTENT_DIR + 'PdfjsContentUtils.jsm',
102 FIREFOX_CONTENT_DIR + 'PdfjsChromeUtils.jsm',
103 FIREFOX_CONTENT_DIR + 'PdfRedirector.jsm'];
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
104 //
105 // make generic
106 // Builds the generic production viewer that should be compatible with most
107 // modern HTML5 browsers.
108 //
109 target.generic = function() {
e1a50ed Mack Duan Fix node make extension for building chrome
mduan authored
110 target.bundle({});
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
111 target.locale();
112
113 cd(ROOT_DIR);
114 echo();
115 echo('### Creating generic viewer');
116
117 rm('-rf', GENERIC_DIR);
118 mkdir('-p', GENERIC_DIR);
119 mkdir('-p', GENERIC_DIR + BUILD_DIR);
120 mkdir('-p', GENERIC_DIR + '/web');
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
121 mkdir('-p', GENERIC_DIR + '/web/cmaps');
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
122
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
123 var defines = builder.merge(DEFINES, {GENERIC: true});
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
124
125 var setup = {
126 defines: defines,
127 copy: [
128 [COMMON_WEB_FILES, GENERIC_DIR + '/web'],
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
129 ['LICENSE', GENERIC_DIR],
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
130 ['external/webL10n/l10n.js', GENERIC_DIR + '/web'],
131 ['web/compatibility.js', GENERIC_DIR + '/web'],
132 ['web/compressed.tracemonkey-pldi-09.pdf', GENERIC_DIR + '/web'],
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
133 ['external/bcmaps/*', GENERIC_DIR + '/web/cmaps/'],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
134 ['web/locale', GENERIC_DIR + '/web']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
135 ],
136 preprocess: [
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
137 [BUILD_TARGETS, GENERIC_DIR + BUILD_DIR],
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
138 [COMMON_WEB_FILES_PREPROCESS, GENERIC_DIR + '/web']
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
139 ],
140 preprocessCSS: [
141 ['generic', 'web/viewer.css',
142 GENERIC_DIR + '/web/viewer.css']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
143 ]
144 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
145 builder.build(setup);
83b6eae Vivin Paliath pr #3356
vivin authored
146
147 cleanupJSSource(GENERIC_DIR + '/web/viewer.js');
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
148 cleanupCSSSource(GENERIC_DIR + '/web/viewer.css');
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
149 };
150
b16a406 Yury Delendik Packages PDFViewer as a UI component.
yurydelendik authored
151 target.components = function() {
152 cd(ROOT_DIR);
153 echo();
154 echo('### Creating generic components');
155
156 rm('-rf', COMPONENTS_DIR);
157 mkdir('-p', COMPONENTS_DIR);
158 mkdir('-p', COMPONENTS_DIR + 'images');
159
160 var defines = builder.merge(DEFINES, {COMPONENTS: true});
161
162 var COMPONENTS_IMAGES = [
163 'web/images/annotation-*.svg',
164 'web/images/loading-icon.gif',
165 'web/images/shadow.png',
166 'web/images/texture.png',
167 ];
168
169 var setup = {
170 defines: defines,
171 copy: [
172 [COMPONENTS_IMAGES, COMPONENTS_DIR + 'images'],
173 ['web/compatibility.js', COMPONENTS_DIR],
174 ],
175 preprocess: [
176 ['web/pdf_viewer.component.js', COMPONENTS_DIR + 'pdf_viewer.js'],
177 ],
178 preprocessCSS: [
179 ['components', 'web/pdf_viewer.css', COMPONENTS_DIR + 'pdf_viewer.css'],
180 ]
181 };
182 builder.build(setup);
183
184 cleanupJSSource(COMPONENTS_DIR + 'pdf_viewer.js');
185 cleanupCSSSource(COMPONENTS_DIR + 'pdf_viewer.css');
186 };
187
2ca2c38 Yury Delendik Creates make.js code to build jsdoc.
yurydelendik authored
188 target.jsdoc = function() {
189 echo();
190 echo('### Generating jsdoc');
191
192 var JSDOC_FILES = [
193 'src/doc_helper.js',
194 'src/display/api.js',
195 'src/shared/util.js'
196 ];
197
198 if (test('-d', JSDOC_DIR)) {
199 rm('-rf', JSDOC_DIR);
200 }
201
202 mkdir('-p',JSDOC_DIR);
203
204 exec('"node_modules/.bin/jsdoc" -d "' + JSDOC_DIR + '" ' +
205 JSDOC_FILES.join(' '));
206
207 echo();
208 };
209
f6ba384 Artur Adib Using ShellJS
arturadib authored
210 //
211 // make web
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
212 // Generates the website for the project, by checking out the gh-pages branch
213 // underneath the build directory, and then moving the various viewer files
214 // into place.
f6ba384 Artur Adib Using ShellJS
arturadib authored
215 //
216 target.web = function() {
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
217 target.generic();
f6ba384 Artur Adib Using ShellJS
arturadib authored
218 target.extension();
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
219 target.b2g();
2ca2c38 Yury Delendik Creates make.js code to build jsdoc.
yurydelendik authored
220 target.jsdoc();
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
221
f6ba384 Artur Adib Using ShellJS
arturadib authored
222 echo();
223 echo('### Creating web site');
224
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
225 if (test('-d', GH_PAGES_DIR)) {
790f608 Artur Adib remove target.pagesrepo, commit here (not bot)
arturadib authored
226 rm('-rf', GH_PAGES_DIR);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
227 }
790f608 Artur Adib remove target.pagesrepo, commit here (not bot)
arturadib authored
228
229 mkdir('-p', GH_PAGES_DIR + '/web');
230 mkdir('-p', GH_PAGES_DIR + '/web/images');
231 mkdir('-p', GH_PAGES_DIR + BUILD_DIR);
232 mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/firefox');
79c57dc Yury Delendik Fixes 'make web' after chromium directory remaning
yurydelendik authored
233 mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/chromium');
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
234 mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/b2g');
2ca2c38 Yury Delendik Creates make.js code to build jsdoc.
yurydelendik authored
235 mkdir('-p', GH_PAGES_DIR + '/api/draft/');
de844a8 Yury Delendik Removes examples from jsbin.com
yurydelendik authored
236 mkdir('-p', GH_PAGES_DIR + '/examples/');
790f608 Artur Adib remove target.pagesrepo, commit here (not bot)
arturadib authored
237
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
238 cp('-R', GENERIC_DIR + '/*', GH_PAGES_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
239 cp(FIREFOX_BUILD_DIR + '/*.xpi', FIREFOX_BUILD_DIR + '/*.rdf',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
240 GH_PAGES_DIR + EXTENSION_SRC_DIR + 'firefox/');
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
241 cp(CHROME_BUILD_DIR + '/*.crx', FIREFOX_BUILD_DIR + '/*.rdf',
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
242 GH_PAGES_DIR + EXTENSION_SRC_DIR + 'chromium/');
10f37f7 Yury Delendik PDF.js features testing
yurydelendik authored
243 cp('-R', 'test/features', GH_PAGES_DIR);
de844a8 Yury Delendik Removes examples from jsbin.com
yurydelendik authored
244 cp('-R', 'examples/learning', GH_PAGES_DIR + '/examples/');
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
245 cp('-R', B2G_BUILD_DIR, GH_PAGES_DIR + EXTENSION_SRC_DIR + 'b2g/');
2ca2c38 Yury Delendik Creates make.js code to build jsdoc.
yurydelendik authored
246 cp('-R', JSDOC_DIR + '/*', GH_PAGES_DIR + '/api/draft/');
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
247
cffe0fd Yury Delendik Require wintersmith when needed
yurydelendik authored
248 var wintersmith = require('wintersmith');
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
249 var env = wintersmith('docs/config.json');
250 env.build(GH_PAGES_DIR, function (error) {
251 if (error) {
252 throw error;
253 }
254 sed('-i', /STABLE_VERSION/g, config.stableVersion,
255 GH_PAGES_DIR + '/getting_started/index.html');
256 sed('-i', /BETA_VERSION/g, config.betaVersion,
257 GH_PAGES_DIR + '/getting_started/index.html');
258 echo('Done building with wintersmith.');
259
260 cd(GH_PAGES_DIR);
261 exec('git init');
262 exec('git remote add origin ' + REPO);
263 exec('git add -A');
264 exec('git commit -am "gh-pages site created via make.js script"');
265 exec('git branch -m gh-pages');
266
267 echo();
268 echo('Website built in ' + GH_PAGES_DIR);
269 });
270 };
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
271
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
272 target.dist = function() {
273 target.generic();
2704119 Yury Delendik Builds distribution package for npm and bower.
yurydelendik authored
274 target.singlefile();
b16a406 Yury Delendik Packages PDFViewer as a UI component.
yurydelendik authored
275 target.components();
2704119 Yury Delendik Builds distribution package for npm and bower.
yurydelendik authored
276
277 var DIST_DIR = BUILD_DIR + 'dist/';
278 var DIST_REPO_URL = 'https://github.com/mozilla/pdfjs-dist';
279
280 cd(ROOT_DIR);
281
282 echo();
283 echo('### Cloning baseline distribution');
284
285 rm('-rf', DIST_DIR);
286 mkdir('-p', DIST_DIR);
287 exec('git clone --depth 1 ' + DIST_REPO_URL + ' ' + DIST_DIR);
288
289 echo();
290 echo('### Overwriting all files');
291 rm('-rf', DIST_DIR + '*');
292
10f702f Yury Delendik Adds readme file for the pdfjs-dist repo.
yurydelendik authored
293 cp('-R', ROOT_DIR + 'external/dist/*', DIST_DIR);
2704119 Yury Delendik Builds distribution package for npm and bower.
yurydelendik authored
294 cp('-R', GENERIC_DIR + 'LICENSE', DIST_DIR);
295 cp('-R', GENERIC_DIR + 'web/cmaps', DIST_DIR);
296 mkdir('-p', DIST_DIR + 'build/');
297 cp('-R', [
298 GENERIC_DIR + 'build/pdf.js',
299 GENERIC_DIR + 'build/pdf.worker.js',
300 SINGLE_FILE_DIR + 'build/pdf.combined.js',
301 ], DIST_DIR + 'build/');
302
303 mkdir('-p', DIST_DIR + 'web/');
304 cp('-R', [
b16a406 Yury Delendik Packages PDFViewer as a UI component.
yurydelendik authored
305 COMPONENTS_DIR + '*',
2704119 Yury Delendik Builds distribution package for npm and bower.
yurydelendik authored
306 ], DIST_DIR + 'web/');
307
308 echo();
309 echo('### Rebuilding manifests');
310
311 var DIST_NAME = 'pdfjs-dist';
312 var DIST_DESCRIPTION = 'Generic build of Mozilla\'s PDF.js library.';
313 var DIST_KEYWORDS = ['Mozilla', 'pdf', 'pdf.js'];
314 var DIST_HOMEPAGE = 'http://mozilla.github.io/pdf.js/';
315 var DIST_BUGS_URL = 'https://github.com/mozilla/pdf.js/issues';
316 var DIST_LICENSE = 'Apache-2.0';
317 var npmManifest = {
318 name: DIST_NAME,
319 version: VERSION,
320 description: DIST_DESCRIPTION,
321 keywords: DIST_KEYWORDS,
322 homepage: DIST_HOMEPAGE,
323 bugs: DIST_BUGS_URL,
324 license: DIST_LICENSE,
325 repository: {
326 type: 'git',
327 url: DIST_REPO_URL
328 },
329 };
330 fs.writeFileSync(DIST_DIR + 'package.json',
331 JSON.stringify(npmManifest, null, 2));
332 var bowerManifest = {
333 name: DIST_NAME,
334 version: VERSION,
335 main: [
336 'build/pdf.js',
337 'build/pdf.worker.js',
338 ],
339 ignore: [],
340 keywords: DIST_KEYWORDS,
341 };
342 fs.writeFileSync(DIST_DIR + 'bower.json',
343 JSON.stringify(bowerManifest, null, 2));
344
345 echo();
346 echo('### Commiting changes');
347
348 cd(DIST_DIR);
349 var message = 'PDF.js version ' + VERSION;
350 exec('git add *');
351 exec('git commit -am \"' + message + '\"');
352 exec('git tag -a v' + VERSION + ' -m \"' + message + '\"');
353
354 cd(ROOT_DIR);
355
356 echo();
357 echo('Done. Push with');
358 echo(' cd ' + DIST_DIR + '; git push --tags ' + DIST_REPO_URL + ' master');
359 echo();
360 };
361
362 target.publish = function() {
363 target.generic();
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
364 config.stableVersion = config.betaVersion;
365 config.betaVersion = VERSION;
366 fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
367 cd(GENERIC_DIR);
368 var distFilename = 'pdfjs-' + VERSION + '-dist.zip';
369 exec('zip -r ' + ROOT_DIR + BUILD_DIR + distFilename + ' *');
370 echo('Built distribution file: ' + distFilename);
371 cd(ROOT_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
372 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
373
374 //
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
375 // make locale
376 // Creates localized resources for the viewer and extension.
377 //
378 target.locale = function() {
379 var METADATA_OUTPUT = 'extensions/firefox/metadata.inc';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
380 var CHROME_MANIFEST_OUTPUT = 'extensions/firefox/chrome.manifest.inc';
381 var EXTENSION_LOCALE_OUTPUT = 'extensions/firefox/locale';
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
382 var VIEWER_LOCALE_OUTPUT = 'web/locale/';
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
383
384 cd(ROOT_DIR);
385 echo();
386 echo('### Building localization files');
387
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
388 rm('-rf', EXTENSION_LOCALE_OUTPUT);
389 mkdir('-p', EXTENSION_LOCALE_OUTPUT);
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
390 rm('-rf', VIEWER_LOCALE_OUTPUT);
391 mkdir('-p', VIEWER_LOCALE_OUTPUT);
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
392
393 var subfolders = ls(LOCALE_SRC_DIR);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
394 subfolders.sort();
395 var metadataContent = '';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
396 var chromeManifestContent = '';
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
397 var viewerOutput = '';
398 for (var i = 0; i < subfolders.length; i++) {
399 var locale = subfolders[i];
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
400 var path = LOCALE_SRC_DIR + locale;
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
401 if (!test('-d', path)) {
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
402 continue;
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
403 }
c6f0094 Tim van der Meij Implements importl10n command
timvandermeij authored
404 if (!/^[a-z][a-z]([a-z])?(-[A-Z][A-Z])?$/.test(locale)) {
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
405 echo('Skipping invalid locale: ' + locale);
406 continue;
407 }
408
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
409 mkdir('-p', EXTENSION_LOCALE_OUTPUT + '/' + locale);
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
410 mkdir('-p', VIEWER_LOCALE_OUTPUT + '/' + locale);
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
411 chromeManifestContent += 'locale pdf.js ' + locale + ' locale/' +
412 locale + '/\n';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
413
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
414 if (test('-f', path + '/viewer.properties')) {
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
415 viewerOutput += '[' + locale + ']\n' +
416 '@import url(' + locale + '/viewer.properties)\n\n';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
417 cp(path + '/viewer.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
418 cp(path + '/viewer.properties', VIEWER_LOCALE_OUTPUT + '/' + locale);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
419 }
420
080c3e7 Brendan Dahl Merge upstream. Use new l10n.
brendandahl authored
421 if (test('-f', path + '/chrome.properties')) {
422 cp(path + '/chrome.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
423 }
424
425 if (test('-f', path + '/metadata.inc')) {
426 var metadata = cat(path + '/metadata.inc');
427 metadataContent += metadata;
428 }
429 }
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
430 viewerOutput.to(VIEWER_LOCALE_OUTPUT + 'locale.properties');
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
431 metadataContent.to(METADATA_OUTPUT);
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
432 chromeManifestContent.to(CHROME_MANIFEST_OUTPUT);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
433 };
434
435 //
69efd9c Yury Delendik CMaps binary packing
yurydelendik authored
436 // make cmaps
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
437 // Compresses cmap files. Ensure that Adobe cmap download and uncompressed at
438 // ./external/cmaps location.
69efd9c Yury Delendik CMaps binary packing
yurydelendik authored
439 //
440 target.cmaps = function (args) {
441 var CMAP_INPUT = 'external/cmaps';
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
442 var VIEWER_CMAP_OUTPUT = 'external/bcmaps';
443
69efd9c Yury Delendik CMaps binary packing
yurydelendik authored
444 cd(ROOT_DIR);
445 echo();
446 echo('### Building cmaps');
447
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
448 // testing a file that usually present
449 if (!test('-f', CMAP_INPUT + '/UniJIS-UCS2-H')) {
450 echo('./external/cmaps has no cmap files, please download them from:');
451 echo(' http://sourceforge.net/adobe/cmap/wiki/Home/');
452 exit(1);
453 }
454
455 rm(VIEWER_CMAP_OUTPUT + '*.bcmap');
69efd9c Yury Delendik CMaps binary packing
yurydelendik authored
456
457 var compressCmaps =
458 require('./external/cmapscompress/compress.js').compressCmaps;
459 compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
460 };
461
462 //
f6ba384 Artur Adib Using ShellJS
arturadib authored
463 // make bundle
464 // Bundles all source files into one wrapper 'pdf.js' file, in the given order.
465 //
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
466 target.bundle = function(args) {
467 args = args || {};
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
468 var defines = args.defines || DEFINES;
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
469 var excludes = args.excludes || [];
470
7b70710 Yury Delendik Traces pdf.js version
yurydelendik authored
471 target.buildnumber();
472
f6ba384 Artur Adib Using ShellJS
arturadib authored
473 cd(ROOT_DIR);
474 echo();
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
475 echo('### Bundling files into ' + BUILD_TARGET);
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
476 var reg = /\n\/\* -\*- Mode(.|\n)*?Mozilla Foundation(.|\n)*?'use strict';/g;
f6ba384 Artur Adib Using ShellJS
arturadib authored
477
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
478 function bundle(filename, dir, SRC_FILES, EXT_SRC_FILES) {
479 for (var i = 0, length = excludes.length; i < length; ++i) {
480 var exclude = excludes[i];
481 var index = SRC_FILES.indexOf(exclude);
482 if (index >= 0) {
483 SRC_FILES.splice(index, 1);
484 }
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
485 }
486
73e23bb Tim van der Meij Fixes lint warning W004 in make.js
timvandermeij authored
487 var bundleContent = cat(SRC_FILES),
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
488 bundleVersion = VERSION,
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
489 bundleBuild = exec('git log --format="%h" -n 1',
490 {silent: true}).output.replace('\n', '');
491
492 crlfchecker.checkIfCrlfIsPresent(SRC_FILES);
493
494 // Strip out all the vim/license headers.
73e23bb Tim van der Meij Fixes lint warning W004 in make.js
timvandermeij authored
495 bundleContent = bundleContent.replace(reg, '');
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
496
497 // Append external files last since we don't want to modify them.
73e23bb Tim van der Meij Fixes lint warning W004 in make.js
timvandermeij authored
498 bundleContent += cat(EXT_SRC_FILES);
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
499
500 // This just preprocesses the empty pdf.js file, we don't actually want to
501 // preprocess everything yet since other build targets use this file.
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
502 builder.preprocess(filename, dir, builder.merge(defines,
73e23bb Tim van der Meij Fixes lint warning W004 in make.js
timvandermeij authored
503 {BUNDLE: bundleContent,
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
504 BUNDLE_VERSION: bundleVersion,
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
505 BUNDLE_BUILD: bundleBuild}));
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
506 }
76d877e Brendan Dahl Strip out license for bundled version.
brendandahl authored
507
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
508 if (!test('-d', BUILD_DIR)) {
f6ba384 Artur Adib Using ShellJS
arturadib authored
509 mkdir(BUILD_DIR);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
510 }
f6ba384 Artur Adib Using ShellJS
arturadib authored
511
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
512 var SHARED_SRC_FILES = [
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
513 'shared/util.js',
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
514 ];
515
516 var MAIN_SRC_FILES = SHARED_SRC_FILES.concat([
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
517 'display/api.js',
518 'display/metadata.js',
519 'display/canvas.js',
f57c693 Yury Delendik Implements WebGL support
yurydelendik authored
520 'display/webgl.js',
bf432a3 Yury Delendik Refactors shared/pattern.js into core/ and display/
yurydelendik authored
521 'display/pattern_helper.js',
bdeca30 Yury Delendik Splits shared/annotation.js into core/ and display/
yurydelendik authored
522 'display/font_loader.js',
523 'display/annotation_helper.js',
0f862e7 Yury Delendik Adds svg.js to the generic and singlefile builds
yurydelendik authored
524 'display/svg.js'
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
525 ]);
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
526
5a49d2e Christian Krebs Create the WORKER_SRC_FILES and EXT_SRC_FILES lists in make automaticall...
chriskr authored
527 var srcFiles = builder.getWorkerSrcFiles('src/worker_loader.js');
528 var WORKER_SRC_FILES = srcFiles.srcFiles;
b13798f Kalervo Kujala Add carriage return checks to make.js.
kkujala authored
529
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
530 if (!defines.SINGLE_FILE) {
531 // We want shared_src_files in both pdf.js and pdf.worker.js
532 // unless it's being built in singlefile mode.
533 WORKER_SRC_FILES = SHARED_SRC_FILES.concat(WORKER_SRC_FILES);
04e2235 Greg Jordan Fix singlefile build target
gjuggler authored
534 } else {
535 // In singlefile mode, all of the src files will be bundled into
536 // the main pdf.js outuput.
537 MAIN_SRC_FILES = MAIN_SRC_FILES.concat(WORKER_SRC_FILES);
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
538 }
539
5a49d2e Christian Krebs Create the WORKER_SRC_FILES and EXT_SRC_FILES lists in make automaticall...
chriskr authored
540 var EXT_SRC_FILES = srcFiles.externalSrcFiles;
76d877e Brendan Dahl Strip out license for bundled version.
brendandahl authored
541
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
542 cd(SRC_DIR);
76d877e Brendan Dahl Strip out license for bundled version.
brendandahl authored
543
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
544 bundle('pdf.js', ROOT_DIR + BUILD_TARGET, MAIN_SRC_FILES, []);
545 var srcCopy = ROOT_DIR + BUILD_DIR + 'pdf.worker.js.temp';
546 cp('pdf.js', srcCopy);
547 bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, WORKER_SRC_FILES,
548 EXT_SRC_FILES);
549 rm(srcCopy);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
550 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
551
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
552 //
553 // make singlefile
554 // Concatenates pdf.js and pdf.worker.js into one big pdf.combined.js, and
555 // flags the script loader to not attempt to load the separate worker JS file.
556 //
557 target.singlefile = function() {
558 cd(ROOT_DIR);
559 echo();
560 echo('### Creating singlefile build');
561
562 var SINGLE_FILE_TARGET = BUILD_DIR + 'pdf.combined.js';
563
564 var defines = builder.merge(DEFINES, {SINGLE_FILE: true});
565 target.bundle({defines: defines});
566
567 cd(ROOT_DIR);
568
569 rm('-rf', SINGLE_FILE_DIR);
570 mkdir('-p', SINGLE_FILE_DIR);
571 mkdir('-p', SINGLE_FILE_DIR + BUILD_DIR);
572
573 var setup = {
574 defines: defines,
575 copy: [],
576 preprocess: [
577 [BUILD_TARGETS, SINGLE_FILE_DIR + BUILD_DIR]
578 ]
579 };
580 builder.build(setup);
581
582 cd(SINGLE_FILE_DIR);
583
584 echo();
04e2235 Greg Jordan Fix singlefile build target
gjuggler authored
585 echo('### Moving pdf.js to pdf.combined.js');
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
586 var pdfJs = cat(BUILD_TARGET);
587 pdfJs.to(SINGLE_FILE_TARGET);
588
589 rm(BUILD_TARGET);
590 rm(BUILD_WORKER_TARGET);
591
592 };
593
83b6eae Vivin Paliath pr #3356
vivin authored
594 function cleanupJSSource(file) {
595 var content = cat(file);
596
597 // Strip out all the vim/license headers.
598 var reg = /\n\/\* -\*- Mode(.|\n)*?Mozilla Foundation(.|\n)*?'use strict';/g;
599 content = content.replace(reg, '');
f6ba384 Artur Adib Using ShellJS
arturadib authored
600
83b6eae Vivin Paliath pr #3356
vivin authored
601 content.to(file);
602 }
f6ba384 Artur Adib Using ShellJS
arturadib authored
603
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
604 function cleanupCSSSource(file) {
605 var content = cat(file);
606
607 // Strip out all license headers in the middle.
608 var reg = /\n\/\* Copyright(.|\n)*?Mozilla Foundation(.|\n)*?\*\//g;
609 content = content.replace(reg, '');
610
611 content.to(file);
612 }
613
2b298a7 Yury Delendik Adds make minified command
yurydelendik authored
614 //
615 // make minified
616 // Builds the minified production viewer that should be compatible with most
617 // modern HTML5 browsers. Requires Google Closure Compiler.
618 //
619 target.minified = function() {
620 var compilerPath = process.env['CLOSURE_COMPILER'];
621 if (!compilerPath) {
622 echo('### Closure Compiler is not set. Specify CLOSURE_COMPILER variable');
623 exit(1);
624 }
625
626 target.bundle({});
627 target.locale();
628
629 cd(ROOT_DIR);
630 echo();
631 echo('### Creating minified viewer');
632
633 rm('-rf', MINIFIED_DIR);
634 mkdir('-p', MINIFIED_DIR);
635 mkdir('-p', MINIFIED_DIR + BUILD_DIR);
636 mkdir('-p', MINIFIED_DIR + '/web');
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
637 mkdir('-p', MINIFIED_DIR + '/web/cmaps');
2b298a7 Yury Delendik Adds make minified command
yurydelendik authored
638
639 var defines = builder.merge(DEFINES, {GENERIC: true, MINIFIED: true});
640
641 var setup = {
642 defines: defines,
643 copy: [
644 [COMMON_WEB_FILES, MINIFIED_DIR + '/web'],
645 ['web/compressed.tracemonkey-pldi-09.pdf', MINIFIED_DIR + '/web'],
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
646 ['external/bcmaps/*', MINIFIED_DIR + '/web/cmaps'],
2b298a7 Yury Delendik Adds make minified command
yurydelendik authored
647 ['web/locale', MINIFIED_DIR + '/web']
648 ],
649 preprocess: [
650 [BUILD_TARGETS, MINIFIED_DIR + BUILD_DIR],
651 [COMMON_WEB_FILES_PREPROCESS, MINIFIED_DIR + '/web']
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
652 ],
653 preprocessCSS: [
654 ['minified', 'web/viewer.css',
655 MINIFIED_DIR + '/web/viewer.css']
2b298a7 Yury Delendik Adds make minified command
yurydelendik authored
656 ]
657 };
658 builder.build(setup);
659
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
660 cleanupCSSSource(MINIFIED_DIR + '/web/viewer.css');
661
2b298a7 Yury Delendik Adds make minified command
yurydelendik authored
662 var viewerFiles = [
663 'web/compatibility.js',
664 'external/webL10n/l10n.js',
665 MINIFIED_DIR + BUILD_DIR + 'pdf.js',
666 MINIFIED_DIR + '/web/viewer.js'
667 ];
668 var cmdPrefix = 'java -jar \"' + compilerPath + '\" ' +
669 '--language_in ECMASCRIPT5 ' +
670 '--warning_level QUIET ' +
671 '--compilation_level SIMPLE_OPTIMIZATIONS ';
672
673 echo();
674 echo('### Minifying js files');
675
676 exec(cmdPrefix + viewerFiles.map(function(s) {
677 return '--js \"' + s + '\"';
678 }).join(' ') +
679 ' --js_output_file \"' + MINIFIED_DIR + '/web/pdf.viewer.js\"');
680 exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.js' + '\" ' +
681 '--js_output_file \"' + MINIFIED_DIR + '/build/pdf.min.js' + '\"');
682 exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.worker.js' + '\" ' +
683 '--js_output_file \"' + MINIFIED_DIR + '/build/pdf.worker.min.js' + '\"');
684
685 echo();
686 echo('### Cleaning js files');
687
688 rm(MINIFIED_DIR + '/web/viewer.js');
689 rm(MINIFIED_DIR + '/web/debugger.js');
690 rm(MINIFIED_DIR + '/build/pdf.js');
691 rm(MINIFIED_DIR + '/build/pdf.worker.js');
692 mv(MINIFIED_DIR + '/build/pdf.min.js',
693 MINIFIED_DIR + '/build/pdf.js');
694 mv(MINIFIED_DIR + '/build/pdf.worker.min.js',
695 MINIFIED_DIR + '/build/pdf.worker.js');
696 };
697
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
698 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
699 //
700 // Extension stuff
701 //
702
703 //
704 // make extension
705 //
706 target.extension = function() {
707 cd(ROOT_DIR);
708 echo();
709 echo('### Building extensions');
710
085723a Yury Delendik make the locale stuff a precondition for make extension
yurydelendik authored
711 target.locale();
f6ba384 Artur Adib Using ShellJS
arturadib authored
712 target.firefox();
8dc41e7 Andreas Bovens adjusted some more chrome references in make.js and README.js as per @yu...
andreasbovens authored
713 target.chromium();
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
714 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
715
716 target.buildnumber = function() {
717 cd(ROOT_DIR);
718 echo();
719 echo('### Getting extension build number');
720
332ae4c Brendan Dahl Change to the Apache v2 license.
brendandahl authored
721 var lines = exec('git log --format=oneline ' +
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
722 config.baseVersion + '..', {silent: true}).output;
f6ba384 Artur Adib Using ShellJS
arturadib authored
723 // Build number is the number of commits since base version
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
724 BUILD_NUMBER = lines ? lines.match(/\n/g).length : 0;
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
725
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
726 echo('Extension build number: ' + BUILD_NUMBER);
6abbc28 notmasteryet Changing make.js
notmasteryet authored
727
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
728 VERSION = config.versionPrefix + BUILD_NUMBER;
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
729 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
730
731 //
732 // make firefox
733 //
734 target.firefox = function() {
735 cd(ROOT_DIR);
736 echo();
737 echo('### Building Firefox extension');
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
738 var defines = builder.merge(DEFINES, {FIREFOX: true});
f6ba384 Artur Adib Using ShellJS
arturadib authored
739
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
740 var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
741 FIREFOX_EXTENSION_DIR = 'extensions/firefox/',
f6ba384 Artur Adib Using ShellJS
arturadib authored
742 FIREFOX_EXTENSION_FILES_TO_COPY =
743 ['*.js',
744 '*.rdf',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
745 '*.svg',
cd1fd17 Brendan Dahl Add icon for extension.
brendandahl authored
746 '*.png',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
747 '*.manifest',
748 'locale',
1cda4c7 Yury Delendik Loading PDF.js extension into e10s windows
yurydelendik authored
749 'chrome',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
750 '../../LICENSE'],
f6ba384 Artur Adib Using ShellJS
arturadib authored
751 FIREFOX_EXTENSION_FILES =
6abbc28 notmasteryet Changing make.js
notmasteryet authored
752 ['bootstrap.js',
f6ba384 Artur Adib Using ShellJS
arturadib authored
753 'install.rdf',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
754 'chrome.manifest',
cd1fd17 Brendan Dahl Add icon for extension.
brendandahl authored
755 'icon.png',
756 'icon64.png',
6abbc28 notmasteryet Changing make.js
notmasteryet authored
757 'content',
1cda4c7 Yury Delendik Loading PDF.js extension into e10s windows
yurydelendik authored
758 'chrome',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
759 'locale',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
760 'LICENSE'],
f6ba384 Artur Adib Using ShellJS
arturadib authored
761 FIREFOX_EXTENSION_NAME = 'pdf.js.xpi',
762 FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';
763
085723a Yury Delendik make the locale stuff a precondition for make extension
yurydelendik authored
764 target.locale();
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
765 target.bundle({ excludes: ['core/network.js'], defines: defines });
f6ba384 Artur Adib Using ShellJS
arturadib authored
766 cd(ROOT_DIR);
767
768 // Clear out everything in the firefox extension build directory
769 rm('-rf', FIREFOX_BUILD_DIR);
770 mkdir('-p', FIREFOX_BUILD_CONTENT_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
771 mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
772 mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web');
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
773 mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web/cmaps');
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
774
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
775 cp(FIREFOX_CONTENT_DIR + 'PdfJs-stub.jsm',
776 FIREFOX_BUILD_CONTENT_DIR + 'PdfJs.jsm');
1bb7a7e Yury Delendik Adds stub PdfJs.jsm for FF15
yurydelendik authored
777
ba23a9e Yury Delendik Adds initial telemetry probes
yurydelendik authored
778 cp(FIREFOX_CONTENT_DIR + 'PdfJsTelemetry-addon.jsm',
779 FIREFOX_BUILD_CONTENT_DIR + 'PdfJsTelemetry.jsm');
780
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
781 // Copy extension files
6046c55 Kalervo Kujala Fix few jslint warnings in make.js.
kkujala authored
782 cd(FIREFOX_EXTENSION_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
783 cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + FIREFOX_BUILD_DIR);
f6ba384 Artur Adib Using ShellJS
arturadib authored
784 cd(ROOT_DIR);
785
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
786 var setup = {
787 defines: defines,
788 copy: [
789 [COMMON_WEB_FILES, FIREFOX_BUILD_CONTENT_DIR + '/web'],
d95f786 Yury Delendik Adds compatibility.js to the Firefox extension
yurydelendik authored
790 ['web/compatibility.js', FIREFOX_BUILD_CONTENT_DIR + '/web'],
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
791 ['external/bcmaps/*', FIREFOX_BUILD_CONTENT_DIR + '/web/cmaps'],
6046c55 Kalervo Kujala Fix few jslint warnings in make.js.
kkujala authored
792 [FIREFOX_EXTENSION_DIR + 'tools/l10n.js',
f6cfab0 Jonas Jenwald [Firefox] Stop importing default_preferences.js as a module and include ...
Snuffleupagus authored
793 FIREFOX_BUILD_CONTENT_DIR + '/web']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
794 ],
795 preprocess: [
babd8df Brendan Dahl Un-inline pdf.js for the extension/mozcentral and remove fetch pdf by co...
brendandahl authored
796 [COMMON_WEB_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR + '/web'],
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
797 [BUILD_TARGETS, FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR],
1cda4c7 Yury Delendik Loading PDF.js extension into e10s windows
yurydelendik authored
798 [COMMON_FIREFOX_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR],
f6cfab0 Jonas Jenwald [Firefox] Stop importing default_preferences.js as a module and include ...
Snuffleupagus authored
799 [SRC_DIR + 'core/network.js', FIREFOX_BUILD_CONTENT_DIR],
800 [FIREFOX_EXTENSION_DIR + 'bootstrap.js', FIREFOX_BUILD_DIR]
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
801 ],
802 preprocessCSS: [
803 ['firefox', 'web/viewer.css',
804 FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.css']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
805 ]
806 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
807 builder.build(setup);
f6ba384 Artur Adib Using ShellJS
arturadib authored
808
83b6eae Vivin Paliath pr #3356
vivin authored
809 cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.js');
f6cfab0 Jonas Jenwald [Firefox] Stop importing default_preferences.js as a module and include ...
Snuffleupagus authored
810 cleanupJSSource(FIREFOX_BUILD_DIR + 'bootstrap.js');
6c9aa6d Jonas Jenwald For |make firefox/mozcentral| builds, add cleanupJSSource to remove dupl...
Snuffleupagus authored
811 cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm');
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
812 cleanupCSSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.css');
83b6eae Vivin Paliath pr #3356
vivin authored
813
c3bdf1e Artur Adib adding new find() commands
arturadib authored
814 // Remove '.DS_Store' and other hidden files
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
815 find(FIREFOX_BUILD_DIR).forEach(function(file) {
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
816 if (file.match(/^\./)) {
c3bdf1e Artur Adib adding new find() commands
arturadib authored
817 rm('-f', file);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
818 }
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
819 });
f6ba384 Artur Adib Using ShellJS
arturadib authored
820
821 // Update the build version number
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
822 sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
823 FIREFOX_BUILD_DIR + '/install.rdf');
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
824 sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
825 FIREFOX_BUILD_DIR + '/update.rdf');
826
827 sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
828 FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
829 sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
830 FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
831 sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false',
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
832 FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
3ac9bd0 Jonas Jenwald Fix setPreferences regression from the e10s patch (PR 5115)
Snuffleupagus authored
833 sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX,
834 FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm');
4bee4c6 Brendan Dahl Use different id's for moz central and extension.
brendandahl authored
835
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
836 // Update localized metadata
837 var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
838 sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata,
839 FIREFOX_BUILD_DIR + '/install.rdf');
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
840 var chromeManifest = cat(EXTENSION_SRC_DIR + '/firefox/chrome.manifest.inc');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
841 sed('-i', /.*PDFJS_SUPPORTED_LOCALES.*\n/, chromeManifest,
842 FIREFOX_BUILD_DIR + '/chrome.manifest');
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
843
f6ba384 Artur Adib Using ShellJS
arturadib authored
844 // Create the xpi
845 cd(FIREFOX_BUILD_DIR);
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
846 exec('zip -r ' + FIREFOX_EXTENSION_NAME + ' ' +
847 FIREFOX_EXTENSION_FILES.join(' '));
f6ba384 Artur Adib Using ShellJS
arturadib authored
848 echo('extension created: ' + FIREFOX_EXTENSION_NAME);
849 cd(ROOT_DIR);
850
851 // Build the amo extension too (remove the updateUrl)
852 cd(FIREFOX_BUILD_DIR);
853 sed('-i', /.*updateURL.*\n/, '', 'install.rdf');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
854 exec('zip -r ' + FIREFOX_AMO_EXTENSION_NAME + ' ' +
855 FIREFOX_EXTENSION_FILES.join(' '));
f6ba384 Artur Adib Using ShellJS
arturadib authored
856 echo('AMO extension created: ' + FIREFOX_AMO_EXTENSION_NAME);
857 cd(ROOT_DIR);
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
858 };
859
860 //
861 // make mozcentral
862 //
863 target.mozcentral = function() {
864 cd(ROOT_DIR);
865 echo();
866 echo('### Building mozilla-central extension');
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
867 var defines = builder.merge(DEFINES, {MOZCENTRAL: true});
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
868
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
869 var MOZCENTRAL_DIR = BUILD_DIR + 'mozcentral/',
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
870 MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + 'browser/extensions/pdfjs/',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
871 MOZCENTRAL_CONTENT_DIR = MOZCENTRAL_EXTENSION_DIR + 'content/',
872 MOZCENTRAL_L10N_DIR = MOZCENTRAL_DIR + 'browser/locales/en-US/pdfviewer/',
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
873 MOZCENTRAL_TEST_DIR = MOZCENTRAL_EXTENSION_DIR + 'test/',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
874 FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
875 FIREFOX_EXTENSION_FILES_TO_COPY =
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
876 ['*.svg',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
877 '*.png',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
878 '*.manifest',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
879 'README.mozilla',
880 '../../LICENSE'],
881 DEFAULT_LOCALE_FILES =
03032d2 Brendan Dahl Add chrome.properties for moz central build.
brendandahl authored
882 [LOCALE_SRC_DIR + 'en-US/viewer.properties',
2684c79 Tim van der Meij Cleaning up files in extension
timvandermeij authored
883 LOCALE_SRC_DIR + 'en-US/chrome.properties'],
884 FIREFOX_MC_EXCLUDED_FILES =
885 ['icon.png',
886 'icon64.png'];
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
887
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
888 target.bundle({ excludes: ['core/network.js'], defines: defines });
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
889 cd(ROOT_DIR);
890
891 // Clear out everything in the firefox extension build directory
892 rm('-rf', MOZCENTRAL_DIR);
893 mkdir('-p', MOZCENTRAL_CONTENT_DIR);
894 mkdir('-p', MOZCENTRAL_L10N_DIR);
895 mkdir('-p', MOZCENTRAL_CONTENT_DIR + BUILD_DIR);
896 mkdir('-p', MOZCENTRAL_CONTENT_DIR + '/web');
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
897 mkdir('-p', MOZCENTRAL_CONTENT_DIR + '/web/cmaps');
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
898
ba23a9e Yury Delendik Adds initial telemetry probes
yurydelendik authored
899 cp(FIREFOX_CONTENT_DIR + 'PdfJsTelemetry.jsm', MOZCENTRAL_CONTENT_DIR);
3d7f01d Brendan Dahl Add global pref to enable/disable. Control pdf.js in application prefer...
brendandahl authored
900
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
901 // Copy extension files
902 cd('extensions/firefox');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
903 cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY,
904 ROOT_DIR + MOZCENTRAL_EXTENSION_DIR);
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
905 mv('-f', ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome-mozcentral.manifest',
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
906 ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome.manifest');
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
907 cd(ROOT_DIR);
908
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
909 var setup = {
910 defines: defines,
911 copy: [
912 [COMMON_WEB_FILES, MOZCENTRAL_CONTENT_DIR + '/web'],
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
913 ['external/bcmaps/*', MOZCENTRAL_CONTENT_DIR + '/web/cmaps'],
f6cfab0 Jonas Jenwald [Firefox] Stop importing default_preferences.js as a module and include ...
Snuffleupagus authored
914 ['extensions/firefox/tools/l10n.js', MOZCENTRAL_CONTENT_DIR + '/web']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
915 ],
916 preprocess: [
babd8df Brendan Dahl Un-inline pdf.js for the extension/mozcentral and remove fetch pdf by co...
brendandahl authored
917 [COMMON_WEB_FILES_PREPROCESS, MOZCENTRAL_CONTENT_DIR + '/web'],
e77e5c4 Yury Delendik Copies pdfjschildbootstrap.js for MOZCENTRAL
yurydelendik authored
918 [FIREFOX_CONTENT_DIR + 'pdfjschildbootstrap.js', MOZCENTRAL_CONTENT_DIR],
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
919 [BUILD_TARGETS, MOZCENTRAL_CONTENT_DIR + BUILD_DIR],
f6cfab0 Jonas Jenwald [Firefox] Stop importing default_preferences.js as a module and include ...
Snuffleupagus authored
920 [SRC_DIR + 'core/network.js', MOZCENTRAL_CONTENT_DIR],
1cda4c7 Yury Delendik Loading PDF.js extension into e10s windows
yurydelendik authored
921 [COMMON_FIREFOX_FILES_PREPROCESS, MOZCENTRAL_CONTENT_DIR],
f6cfab0 Jonas Jenwald [Firefox] Stop importing default_preferences.js as a module and include ...
Snuffleupagus authored
922 [FIREFOX_CONTENT_DIR + 'PdfJs.jsm', MOZCENTRAL_CONTENT_DIR]
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
923 ],
924 preprocessCSS: [
894c82c Yury Delendik Removes -moz-box-sizing usage
yurydelendik authored
925 ['mozcentral',
926 'web/viewer.css',
927 MOZCENTRAL_CONTENT_DIR + '/web/viewer.css']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
928 ]
929 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
930 builder.build(setup);
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
931
83b6eae Vivin Paliath pr #3356
vivin authored
932 cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.js');
f6cfab0 Jonas Jenwald [Firefox] Stop importing default_preferences.js as a module and include ...
Snuffleupagus authored
933 cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfJs.jsm');
6c9aa6d Jonas Jenwald For |make firefox/mozcentral| builds, add cleanupJSSource to remove dupl...
Snuffleupagus authored
934 cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfjsChromeUtils.jsm');
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
935 cleanupCSSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.css');
83b6eae Vivin Paliath pr #3356
vivin authored
936
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
937 // Remove '.DS_Store' and other hidden files
938 find(MOZCENTRAL_DIR).forEach(function(file) {
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
939 if (file.match(/^\./)) {
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
940 rm('-f', file);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
941 }
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
942 });
943
2684c79 Tim van der Meij Cleaning up files in extension
timvandermeij authored
944 // Remove excluded files
945 cd(MOZCENTRAL_EXTENSION_DIR);
946 FIREFOX_MC_EXCLUDED_FILES.forEach(function(file) {
947 if (test('-f', file)) {
948 rm('-r', file);
949 }
950 });
951 cd(ROOT_DIR);
952
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
953 // Copy default localization files
954 cp(DEFAULT_LOCALE_FILES, MOZCENTRAL_L10N_DIR);
955
956 // Update the build version number
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
957 sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
958 MOZCENTRAL_EXTENSION_DIR + 'README.mozilla');
6abbc28 notmasteryet Changing make.js
notmasteryet authored
959
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
960 sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
961 MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
962 sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
963 MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
964 sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true',
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
965 MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
3ac9bd0 Jonas Jenwald Fix setPreferences regression from the e10s patch (PR 5115)
Snuffleupagus authored
966 sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX,
967 MOZCENTRAL_CONTENT_DIR + 'PdfjsChromeUtils.jsm');
4bee4c6 Brendan Dahl Use different id's for moz central and extension.
brendandahl authored
968
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
969 // Copy test files
970 mkdir('-p', MOZCENTRAL_TEST_DIR);
971 cp('-Rf', 'test/mozcentral/*', MOZCENTRAL_TEST_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
972 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
973
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
974 target.b2g = function() {
fd4e40c Brendan Dahl New GUI for B2G viewer.
brendandahl authored
975 target.locale();
7b70710 Yury Delendik Traces pdf.js version
yurydelendik authored
976
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
977 echo();
978 echo('### Building B2G (Firefox OS App)');
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
979 var B2G_BUILD_CONTENT_DIR = B2G_BUILD_DIR + '/content/';
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
980 var defines = builder.merge(DEFINES, { B2G: true });
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
981 target.bundle({ defines: defines });
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
982
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
983 // Clear out everything in the b2g build directory
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
984 cd(ROOT_DIR);
985 rm('-Rf', B2G_BUILD_DIR);
986 mkdir('-p', B2G_BUILD_CONTENT_DIR);
987 mkdir('-p', B2G_BUILD_CONTENT_DIR + BUILD_DIR);
988 mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web');
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
989 mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web/cmaps');
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
990
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
991 var setup = {
992 defines: defines,
993 copy: [
fd4e40c Brendan Dahl New GUI for B2G viewer.
brendandahl authored
994 ['extensions/b2g/images', B2G_BUILD_CONTENT_DIR + '/web'],
995 ['extensions/b2g/viewer.html', B2G_BUILD_CONTENT_DIR + '/web'],
996 ['extensions/b2g/viewer.css', B2G_BUILD_CONTENT_DIR + '/web'],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
997 ['web/locale', B2G_BUILD_CONTENT_DIR + '/web'],
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
998 ['external/bcmaps/*', B2G_BUILD_CONTENT_DIR + '/web/cmaps'],
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
999 ['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web']
1000 ],
1001 preprocess: [
fd4e40c Brendan Dahl New GUI for B2G viewer.
brendandahl authored
1002 ['web/viewer.js', B2G_BUILD_CONTENT_DIR + '/web'],
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
1003 [BUILD_TARGETS, B2G_BUILD_CONTENT_DIR + BUILD_DIR]
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
1004 ]
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
1005 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
1006 builder.build(setup);
83b6eae Vivin Paliath pr #3356
vivin authored
1007
1008 cleanupJSSource(B2G_BUILD_CONTENT_DIR + '/web/viewer.js');
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
1009 };
1010
f6ba384 Artur Adib Using ShellJS
arturadib authored
1011 //
1012 // make chrome
1013 //
8dc41e7 Andreas Bovens adjusted some more chrome references in make.js and README.js as per @yu...
andreasbovens authored
1014 target.chromium = function() {
69efd9c Yury Delendik CMaps binary packing
yurydelendik authored
1015 target.locale();
1016
f6ba384 Artur Adib Using ShellJS
arturadib authored
1017 cd(ROOT_DIR);
1018 echo();
8dc41e7 Andreas Bovens adjusted some more chrome references in make.js and README.js as per @yu...
andreasbovens authored
1019 echo('### Building Chromium extension');
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
1020 var defines = builder.merge(DEFINES, {CHROME: true});
f6ba384 Artur Adib Using ShellJS
arturadib authored
1021
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
1022 var CHROME_BUILD_DIR = BUILD_DIR + '/chromium/',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
1023 CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/';
f6ba384 Artur Adib Using ShellJS
arturadib authored
1024
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
1025 target.bundle({ defines: defines });
f6ba384 Artur Adib Using ShellJS
arturadib authored
1026 cd(ROOT_DIR);
1027
1028 // Clear out everything in the chrome extension build directory
1029 rm('-Rf', CHROME_BUILD_DIR);
1030 mkdir('-p', CHROME_BUILD_CONTENT_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1031 mkdir('-p', CHROME_BUILD_CONTENT_DIR + BUILD_DIR);
1032 mkdir('-p', CHROME_BUILD_CONTENT_DIR + '/web');
f6ba384 Artur Adib Using ShellJS
arturadib authored
1033
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
1034 var setup = {
1035 defines: defines,
1036 copy: [
1037 [COMMON_WEB_FILES, CHROME_BUILD_CONTENT_DIR + '/web'],
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
1038 [['extensions/chromium/*.json',
1039 'extensions/chromium/*.html',
1040 'extensions/chromium/*.js',
1041 'extensions/chromium/*.css',
1042 'extensions/chromium/icon*.png',],
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1043 CHROME_BUILD_DIR],
1055350 Rob Wu Chrome extension: Isolate pageAction logic
Rob--W authored
1044 ['extensions/chromium/pageAction/*.*', CHROME_BUILD_DIR + '/pageAction'],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
1045 ['external/webL10n/l10n.js', CHROME_BUILD_CONTENT_DIR + '/web'],
1d8f6cf Yury Delendik Updates make.js for cmaps and make binary cmaps by default
yurydelendik authored
1046 ['external/bcmaps/*', CHROME_BUILD_CONTENT_DIR + '/web/cmaps'],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
1047 ['web/locale', CHROME_BUILD_CONTENT_DIR + '/web']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
1048 ],
1049 preprocess: [
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
1050 [BUILD_TARGETS, CHROME_BUILD_CONTENT_DIR + BUILD_DIR],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
1051 [COMMON_WEB_FILES_PREPROCESS, CHROME_BUILD_CONTENT_DIR + '/web']
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
1052 ],
1053 preprocessCSS: [
1054 ['chrome', 'web/viewer.css',
1055 CHROME_BUILD_CONTENT_DIR + '/web/viewer.css']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
1056 ]
1057 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
1058 builder.build(setup);
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
1059
83b6eae Vivin Paliath pr #3356
vivin authored
1060 cleanupJSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.js');
5b93cc1 Yury Delendik Adds css import preprocessing
yurydelendik authored
1061 cleanupCSSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.css');
83b6eae Vivin Paliath pr #3356
vivin authored
1062
6ca9245 moderation Changes to allowed versioned building of Chrome extension that meets new
moderation authored
1063 // Update the build version number
3ce622a Brendan Dahl Redo and add more documentation to gh-pages.
brendandahl authored
1064 sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
6ca9245 moderation Changes to allowed versioned building of Chrome extension that meets new
moderation authored
1065 CHROME_BUILD_DIR + '/manifest.json');
1066
e181a3c Rob Wu Highly improved Chrome extension
Rob--W authored
1067 // Allow PDF.js resources to be loaded by adding the files to
1068 // the "web_accessible_resources" section.
1069 var file_list = ls('-RA', CHROME_BUILD_CONTENT_DIR);
1070 var public_chrome_files = file_list.reduce(function(war, file) {
1071 // Exclude directories (naive: Exclude paths without dot)
1072 if (file.indexOf('.') !== -1) {
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1073 // Only add a comma after the first file
1074 if (war) {
1075 war += ',\n';
1076 }
1077 war += JSON.stringify('content/' + file);
e181a3c Rob Wu Highly improved Chrome extension
Rob--W authored
1078 }
1079 return war;
1080 }, '');
1081 sed('-i', /"content\/\*"/, public_chrome_files,
1082 CHROME_BUILD_DIR + '/manifest.json');
1083
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
1084 // Bundle the files to a Chrome extension file .crx if path to key is set
1085 var pem = env['PDFJS_CHROME_KEY'];
1086 if (!pem) {
1087 return;
1088 }
1089
1090 echo();
1091 echo('### Bundling .crx extension into ' + CHROME_BUILD_DIR);
1092
1093 if (!test('-f', pem)) {
1094 echo('Incorrect PDFJS_CHROME_KEY path');
1095 exit(1);
1096 }
1097
1098 var browserManifest = env['PDF_BROWSERS'] ||
1099 'test/resources/browser_manifests/browser_manifest.json';
1100
1101 if (!test('-f', browserManifest)) {
1102 echo('Browser manifest file ' + browserManifest + ' does not exist.');
1103 echo('Try copying one of the examples in test/resources/browser_manifests');
1104 exit(1);
1105 }
1106
c4eab85 Jon Buckley Issue #2008 - Fix lint errors for make.js
jbuck authored
1107 var manifest;
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
1108 try {
c4eab85 Jon Buckley Issue #2008 - Fix lint errors for make.js
jbuck authored
1109 manifest = JSON.parse(cat(browserManifest));
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
1110 } catch (e) {
1111 echo('Malformed browser manifest file');
1112 echo(e.message);
1113 exit(1);
1114 }
1115
1116 var executable;
1117 manifest.forEach(function(browser) {
1118 if (browser.name === 'chrome') {
1119 executable = browser.path;
1120 }
1121 });
1122
1123 // If there was no chrome entry in the browser manifest, exit
c2cfa99 Yury Delendik Fixing new make.js lint errors
yurydelendik authored
1124 if (!executable) {
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
1125 echo('There was no \'chrome\' entry in the browser manifest');
1126 exit(1);
1127 }
1128
1129 // If we're on a Darwin (Mac) OS, then let's check for an .app path
1130 if (process.platform === 'darwin' && executable.indexOf('.app') !== -1) {
df32b43 Artur Adib Update make.js
arturadib authored
1131 executable = executable + '/Contents/MacOS/Google Chrome';
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
1132 }
1133
1134 // If the chrome executable doesn't exist
c2cfa99 Yury Delendik Fixing new make.js lint errors
yurydelendik authored
1135 if (!test('-f', executable)) {
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
1136 echo('Incorrect executable path to chrome');
1137 exit(1);
1138 }
1139
1140 // Let chrome pack the extension for us
1141 exec('"' + executable + '"' +
1142 ' --no-message-box' +
1143 ' "--pack-extension=' + ROOT_DIR + CHROME_BUILD_DIR + '"' +
1144 ' "--pack-extension-key=' + pem + '"');
1145
1146 // Rename to pdf.js.crx
1147 mv(BUILD_DIR + 'chrome.crx', CHROME_BUILD_DIR + 'pdf.js.crx');
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1148 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
1149
1150
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
1151 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
1152 //
1153 // Test stuff
1154 //
1155
1156 //
1157 // make test
1158 //
1159 target.test = function() {
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
1160 target.unittest({}, function() {
1161 target.browsertest();
1162 });
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1163 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
1164
1165 //
89ceead Artur Adib make bottest
arturadib authored
1166 // make bottest
1167 // (Special tests for the Github bot)
1168 //
1169 target.bottest = function() {
eea1d90 Brendan Dahl Fix bottest.
brendandahl authored
1170 target.unittest({}, function() {
5afec33 Yury Delendik Adds ttx test harness
yurydelendik authored
1171 target.fonttest({}, function() {
1172 target.browsertest({noreftest: true});
1173 });
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
1174 });
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1175 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
1176
1177 //
1178 // make browsertest
1179 //
89ceead Artur Adib make bottest
arturadib authored
1180 target.browsertest = function(options) {
f6ba384 Artur Adib Using ShellJS
arturadib authored
1181 cd(ROOT_DIR);
1182 echo();
1183 echo('### Running browser tests');
1184
1185 var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1186 PDF_BROWSERS = env['PDF_BROWSERS'] ||
1187 'resources/browser_manifests/browser_manifest.json';
f6ba384 Artur Adib Using ShellJS
arturadib authored
1188
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
1189 if (!test('-f', 'test/' + PDF_BROWSERS)) {
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1190 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1191 echo('Copy one of the examples in test/resources/browser_manifests/');
f6ba384 Artur Adib Using ShellJS
arturadib authored
1192 exit(1);
1193 }
1194
3740bed Artur Adib minor fixes
arturadib authored
1195 var reftest = (options && options.noreftest) ? '' : '--reftest';
89ceead Artur Adib make bottest
arturadib authored
1196
f6ba384 Artur Adib Using ShellJS
arturadib authored
1197 cd('test');
0fe0bb1 Yury Delendik Removes test.py
yurydelendik authored
1198 exec('node test.js ' + reftest + ' --browserManifestFile=' +
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1199 PDF_BROWSERS + ' --manifestFile=' + PDF_TEST, {async: true});
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1200 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
1201
1202 //
1203 // make unittest
1204 //
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
1205 target.unittest = function(options, callback) {
f6ba384 Artur Adib Using ShellJS
arturadib authored
1206 cd(ROOT_DIR);
1207 echo();
1208 echo('### Running unit tests');
1209
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1210 var PDF_BROWSERS = env['PDF_BROWSERS'] ||
1211 'resources/browser_manifests/browser_manifest.json';
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
1212
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
1213 if (!test('-f', 'test/' + PDF_BROWSERS)) {
1214 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1215 echo('Copy one of the examples in test/resources/browser_manifests/');
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
1216 exit(1);
1217 }
1218 callback = callback || function() {};
1219 cd('test');
0fe0bb1 Yury Delendik Removes test.py
yurydelendik authored
1220 exec('node test.js --unitTest --browserManifestFile=' +
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1221 PDF_BROWSERS, {async: true}, callback);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1222 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
1223
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
1224 //
5afec33 Yury Delendik Adds ttx test harness
yurydelendik authored
1225 // make fonttest
1226 //
1227 target.fonttest = function(options, callback) {
1228 cd(ROOT_DIR);
1229 echo();
1230 echo('### Running font tests');
1231
1232 var PDF_BROWSERS = env['PDF_BROWSERS'] ||
1233 'resources/browser_manifests/browser_manifest.json';
1234
1235 if (!test('-f', 'test/' + PDF_BROWSERS)) {
1236 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
1237 echo('Copy one of the examples in test/resources/browser_manifests/');
1238 exit(1);
1239 }
1240 callback = callback || function() {};
1241 cd('test');
0fe0bb1 Yury Delendik Removes test.py
yurydelendik authored
1242 exec('node test.js --fontTest --browserManifestFile=' +
5afec33 Yury Delendik Adds ttx test harness
yurydelendik authored
1243 PDF_BROWSERS, {async: true}, callback);
1244 };
1245
1246 //
3740bed Artur Adib minor fixes
arturadib authored
1247 // make botmakeref
1248 //
1249 target.botmakeref = function() {
1250 cd(ROOT_DIR);
1251 echo();
1252 echo('### Creating reference images');
1253
1254 var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1255 PDF_BROWSERS = env['PDF_BROWSERS'] ||
1256 'resources/browser_manifests/browser_manifest.json';
3740bed Artur Adib minor fixes
arturadib authored
1257
1258 if (!test('-f', 'test/' + PDF_BROWSERS)) {
1259 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1260 echo('Copy one of the examples in test/resources/browser_manifests/');
3740bed Artur Adib minor fixes
arturadib authored
1261 exit(1);
1262 }
1263
1264 cd('test');
0fe0bb1 Yury Delendik Removes test.py
yurydelendik authored
1265 exec('node test.js --masterMode --noPrompts ' +
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
1266 '--browserManifestFile=' + PDF_BROWSERS, {async: true});
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
1267 };
1268
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1269 ////////////////////////////////////////////////////////////////////////////////
1270 //
1271 // Baseline operation
1272 //
1273 target.baseline = function() {
1274 cd(ROOT_DIR);
1275
1276 echo();
1277 echo('### Creating baseline environment');
1278
1279 var baselineCommit = env['BASELINE'];
1280 if (!baselineCommit) {
1281 echo('Baseline commit is not provided. Please specify BASELINE variable');
1282 exit(1);
1283 }
1284
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1285 if (!test('-d', BUILD_DIR)) {
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1286 mkdir(BUILD_DIR);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1287 }
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1288
1289 var BASELINE_DIR = BUILD_DIR + 'baseline';
1290 if (test('-d', BASELINE_DIR)) {
1291 cd(BASELINE_DIR);
1292 exec('git fetch origin');
1293 } else {
1294 cd(BUILD_DIR);
1295 exec('git clone .. baseline');
1296 cd(ROOT_DIR + BASELINE_DIR);
1297 }
1298 exec('git checkout ' + baselineCommit);
1299 };
1300
1301 target.mozcentralbaseline = function() {
1302 target.baseline();
1303
1304 cd(ROOT_DIR);
1305
1306 echo();
1307 echo('### Creating mozcentral baseline environment');
1308
1309 var BASELINE_DIR = BUILD_DIR + 'baseline';
1310 var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1311 if (test('-d', MOZCENTRAL_BASELINE_DIR)) {
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1312 rm('-rf', MOZCENTRAL_BASELINE_DIR);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1313 }
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1314
1315 cd(BASELINE_DIR);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1316 if (test('-d', 'build')) {
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1317 rm('-rf', 'build');
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1318 }
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1319 exec('node make mozcentral');
1320
1321 cd(ROOT_DIR);
1322 mkdir(MOZCENTRAL_BASELINE_DIR);
1323 cp('-Rf', BASELINE_DIR + '/build/mozcentral/*', MOZCENTRAL_BASELINE_DIR);
1324 // fixing baseline
1325 if (test('-f', MOZCENTRAL_BASELINE_DIR +
1326 '/browser/extensions/pdfjs/PdfStreamConverter.js')) {
1327 rm(MOZCENTRAL_BASELINE_DIR +
1328 '/browser/extensions/pdfjs/PdfStreamConverter.js');
1329 }
1330
1331 cd(MOZCENTRAL_BASELINE_DIR);
1332 exec('git init');
1333 exec('git add .');
1334 exec('git commit -m "mozcentral baseline"');
1335 };
1336
1337 target.mozcentraldiff = function() {
1338 target.mozcentral();
1339
1340 cd(ROOT_DIR);
1341
1342 echo();
1343 echo('### Creating mozcentral diff');
1344
1345 var MOZCENTRAL_DIFF = BUILD_DIR + 'mozcentral.diff';
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1346 if (test('-f', MOZCENTRAL_DIFF)) {
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1347 rm(MOZCENTRAL_DIFF);
855b969 Jonas Jenwald Fix coding style in make.js
Snuffleupagus authored
1348 }
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1349
1350 var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
1351 if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
1352 echo('mozcentral baseline was not found');
1353 echo('Please build one using "node make mozcentralbaseline"');
1354 exit(1);
1355 }
1356 cd(MOZCENTRAL_BASELINE_DIR);
1357 exec('git reset --hard');
1358 cd(ROOT_DIR); rm('-rf', MOZCENTRAL_BASELINE_DIR + '/*'); // trying to be safe
1359 cd(MOZCENTRAL_BASELINE_DIR);
1360 cp('-Rf', '../mozcentral/*', '.');
1361 exec('git add -A');
1362 exec('git diff --binary --cached --unified=8', {silent: true}).output.
1363 to('../mozcentral.diff');
1364
1365 echo('Result diff can be found at ' + MOZCENTRAL_DIFF);
1366 };
1367
1368 target.mozcentralcheck = function() {
1369 cd(ROOT_DIR);
1370
1371 echo();
1372 echo('### Checking mozcentral changes');
1373
1374 var mcPath = env['MC_PATH'];
1375 if (!mcPath) {
1376 echo('mozilla-central path is not provided.');
1377 echo('Please specify MC_PATH variable');
1378 exit(1);
1379 }
c29faaa Tim van der Meij Use strict equalities in make.js, external/* and extensions/*
timvandermeij authored
1380 if ((mcPath[0] !== '/' && mcPath[0] !== '~' && mcPath[1] !== ':') ||
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
1381 !test('-d', mcPath)) {
1382 echo('mozilla-central path is not in absolute form or does not exist.');
1383 exit(1);
1384 }
1385
1386 var MOZCENTRAL_DIFF = BUILD_DIR + 'mozcentral_changes.diff';
1387 if (test('-f', MOZCENTRAL_DIFF)) {
1388 rm(MOZCENTRAL_DIFF);
1389 }
1390
1391 var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
1392 if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
1393 echo('mozcentral baseline was not found');
1394 echo('Please build one using "node make mozcentralbaseline"');
1395 exit(1);
1396 }
1397 cd(MOZCENTRAL_BASELINE_DIR);
1398 exec('git reset --hard');
1399 cd(ROOT_DIR); rm('-rf', MOZCENTRAL_BASELINE_DIR + '/*'); // trying to be safe
1400 cd(MOZCENTRAL_BASELINE_DIR);
1401 mkdir('browser');
1402 cd('browser');
1403 mkdir('-p', 'extensions/pdfjs');
1404 cp('-Rf', mcPath + '/browser/extensions/pdfjs/*', 'extensions/pdfjs');
1405 mkdir('-p', 'locales/en-US/pdfviewer');
1406 cp('-Rf', mcPath + '/browser/locales/en-US/pdfviewer/*',
1407 'locales/en-US/pdfviewer');
1408 // Remove '.DS_Store' and other hidden files
1409 find('.').forEach(function(file) {
1410 if (file.match(/^\.\w|~$/)) {
1411 rm('-f', file);
1412 }
1413 });
1414
1415 cd('..');
1416 exec('git add -A');
1417 var diff = exec('git diff --binary --cached --unified=8',
1418 {silent: true}).output;
1419
1420 if (diff) {
1421 echo('There were changes found at mozilla-central.');
1422 diff.to('../mozcentral_changes.diff');
1423 echo('Result diff can be found at ' + MOZCENTRAL_DIFF);
1424 exit(1);
1425 }
1426
1427 echo('Success: there are no changes at mozilla-central');
1428 };
1429
f6ba384 Artur Adib Using ShellJS
arturadib authored
1430
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
1431 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
1432 //
1433 // Other
1434 //
1435
1436 //
1437 // make server
1438 //
1439 target.server = function() {
1440 cd(ROOT_DIR);
1441 echo();
1442 echo('### Starting local server');
1443
4df24f4 Yury Delendik Replaces pythons web server
yurydelendik authored
1444 var WebServer = require('./test/webserver.js').WebServer;
1445 var server = new WebServer();
1446 server.port = 8888;
1447 server.start();
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1448 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
1449
1450 //
1451 // make lint
1452 //
1453 target.lint = function() {
1454 cd(ROOT_DIR);
1455 echo();
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
1456 echo('### Linting JS files');
19dbeaa Jon Buckley Issue #2008 - Add jshint
jbuck authored
1457
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
1458 var jshintPath = path.normalize('./node_modules/.bin/jshint');
1459 if (!test('-f', jshintPath)) {
1460 echo('jshint is not installed -- installing...');
2c82e72 Mitar Updated to current latest stable version of jshint.
mitar authored
1461 exec('npm install jshint@2.4.x'); // TODO read version from package.json
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
1462 }
1463
fcebe57 Yury Delendik Introduces .jshintignore
yurydelendik authored
1464 var exitCode = exec('"' + jshintPath + '" .').code;
1d066b7 Tim van der Meij Removes custom test/reporter.js from the lint process
timvandermeij authored
1465 if (exitCode === 0) {
1466 echo('files checked, no errors found');
1467 }
19dbeaa Jon Buckley Issue #2008 - Add jshint
jbuck authored
1468 };
1469
1470 //
f6ba384 Artur Adib Using ShellJS
arturadib authored
1471 // make clean
1472 //
1473 target.clean = function() {
1474 cd(ROOT_DIR);
1475 echo();
1476 echo('### Cleaning up project builds');
1477
1478 rm('-rf', BUILD_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1479 };
b13798f Kalervo Kujala Add carriage return checks to make.js.
kkujala authored
1480
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1481 //
1482 // make makefile
1483 //
1484 target.makefile = function() {
1485 var makefileContent = 'help:\n\tnode make\n\n';
dc451b0 Yury Delendik Adds .PHONY to Makefile
yurydelendik authored
1486 var targetsNames = [];
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1487 for (var i in target) {
1488 makefileContent += i + ':\n\tnode make ' + i + '\n\n';
dc451b0 Yury Delendik Adds .PHONY to Makefile
yurydelendik authored
1489 targetsNames.push(i);
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1490 }
dc451b0 Yury Delendik Adds .PHONY to Makefile
yurydelendik authored
1491 makefileContent += '.PHONY: ' + targetsNames.join(' ') + '\n';
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1492 makefileContent.to('Makefile');
1493 };
c6f0094 Tim van der Meij Implements importl10n command
timvandermeij authored
1494
1495 //
1496 //make importl10n
1497 //
1498 target.importl10n = function() {
1499 var locales = require('./external/importL10n/locales.js');
1500 var LOCAL_L10N_DIR = 'l10n';
1501
1502 cd(ROOT_DIR);
1503 echo();
1504 echo('### Importing translations from mozilla-aurora');
1505
1506 if (!test('-d', LOCAL_L10N_DIR)) {
1507 mkdir(LOCAL_L10N_DIR);
1508 }
1509 cd(LOCAL_L10N_DIR);
1510
1511 locales.downloadL10n();
1512 };
Something went wrong with that request. Please try again.