Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 1180 lines (998 sloc) 34.468 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');
f6ba384 Artur Adib Using ShellJS
arturadib authored
27
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
28 var ROOT_DIR = __dirname + '/', // absolute path to project's root
f6ba384 Artur Adib Using ShellJS
arturadib authored
29 BUILD_DIR = 'build/',
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
30 SRC_DIR = 'src/',
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
31 BUILD_TARGET = BUILD_DIR + 'pdf.js',
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
32 BUILD_WORKER_TARGET = BUILD_DIR + 'pdf.worker.js',
33 BUILD_TARGETS = [BUILD_TARGET, BUILD_WORKER_TARGET],
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
34 FIREFOX_BUILD_DIR = BUILD_DIR + '/firefox/',
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
35 CHROME_BUILD_DIR = BUILD_DIR + '/chromium/',
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
36 B2G_BUILD_DIR = BUILD_DIR + '/b2g/',
f6ba384 Artur Adib Using ShellJS
arturadib authored
37 EXTENSION_SRC_DIR = 'extensions/',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
38 LOCALE_SRC_DIR = 'l10n/',
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
39 GH_PAGES_DIR = BUILD_DIR + 'gh-pages/',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
40 GENERIC_DIR = BUILD_DIR + 'generic/',
f6ba384 Artur Adib Using ShellJS
arturadib authored
41 REPO = 'git@github.com:mozilla/pdf.js.git',
4bee4c6 Brendan Dahl Use different id's for moz central and extension.
brendandahl authored
42 PYTHON_BIN = 'python2.7',
43 MOZCENTRAL_PREF_PREFIX = 'pdfjs',
44 FIREFOX_PREF_PREFIX = 'extensions.uriloader@pdf.js',
45 MOZCENTRAL_STREAM_CONVERTER_ID = 'd0c5195d-e798-49d4-b1d3-9324328b2291',
46 FIREFOX_STREAM_CONVERTER_ID = '6457a96b-2d68-439a-bcfa-44465fbcdbb1';
f6ba384 Artur Adib Using ShellJS
arturadib authored
47
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
48 var DEFINES = {
49 PRODUCTION: true,
50 // The main build targets:
51 GENERIC: false,
52 FIREFOX: false,
53 MOZCENTRAL: false,
54 B2G: false,
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
55 CHROME: false,
56 SINGLE_FILE: false
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
57 };
58
f6ba384 Artur Adib Using ShellJS
arturadib authored
59 //
60 // make all
61 //
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
62 target.all = function() {
f6ba384 Artur Adib Using ShellJS
arturadib authored
63 // Don't do anything by default
64 echo('Please specify a target. Available targets:');
c4eab85 Jon Buckley Issue #2008 - Fix lint errors for make.js
jbuck authored
65 for (var t in target)
f6ba384 Artur Adib Using ShellJS
arturadib authored
66 if (t !== 'all') echo(' ' + t);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
67 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
68
69
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
70 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
71 //
72 // Production stuff
73 //
74
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
75 // Files that need to be included in every build.
2c1eae5 Brendan Dahl Remove trailing whitespace.
brendandahl authored
76 var COMMON_WEB_FILES =
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
77 ['web/images',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
78 'web/debugger.js'],
79 COMMON_WEB_FILES_PREPROCESS =
80 ['web/viewer.js',
81 'web/viewer.html'];
82
83 //
84 // make generic
85 // Builds the generic production viewer that should be compatible with most
86 // modern HTML5 browsers.
87 //
88 target.generic = function() {
e1a50ed Mack Duan Fix node make extension for building chrome
mduan authored
89 target.bundle({});
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
90 target.locale();
91
92 cd(ROOT_DIR);
93 echo();
94 echo('### Creating generic viewer');
95
96 rm('-rf', GENERIC_DIR);
97 mkdir('-p', GENERIC_DIR);
98 mkdir('-p', GENERIC_DIR + BUILD_DIR);
99 mkdir('-p', GENERIC_DIR + '/web');
100
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
101 var defines = builder.merge(DEFINES, {GENERIC: true});
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
102
103 var setup = {
104 defines: defines,
105 copy: [
106 [COMMON_WEB_FILES, GENERIC_DIR + '/web'],
107 ['external/webL10n/l10n.js', GENERIC_DIR + '/web'],
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
108 ['web/viewer.css', GENERIC_DIR + '/web'],
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
109 ['web/compatibility.js', GENERIC_DIR + '/web'],
110 ['web/compressed.tracemonkey-pldi-09.pdf', GENERIC_DIR + '/web'],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
111 ['web/locale', GENERIC_DIR + '/web']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
112 ],
113 preprocess: [
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
114 [BUILD_TARGETS, GENERIC_DIR + BUILD_DIR],
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
115 [COMMON_WEB_FILES_PREPROCESS, GENERIC_DIR + '/web']
116 ]
117 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
118 builder.build(setup);
83b6eae Vivin Paliath pr #3356
vivin authored
119
120 cleanupJSSource(GENERIC_DIR + '/web/viewer.js');
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
121 };
122
f6ba384 Artur Adib Using ShellJS
arturadib authored
123 //
124 // make web
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
125 // Generates the website for the project, by checking out the gh-pages branch
126 // underneath the build directory, and then moving the various viewer files
127 // into place.
f6ba384 Artur Adib Using ShellJS
arturadib authored
128 //
129 target.web = function() {
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
130 target.generic();
f6ba384 Artur Adib Using ShellJS
arturadib authored
131 target.extension();
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
132 target.b2g();
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
133
f6ba384 Artur Adib Using ShellJS
arturadib authored
134 echo();
135 echo('### Creating web site');
136
790f608 Artur Adib remove target.pagesrepo, commit here (not bot)
arturadib authored
137 if (test('-d', GH_PAGES_DIR))
138 rm('-rf', GH_PAGES_DIR);
139
140 mkdir('-p', GH_PAGES_DIR + '/web');
141 mkdir('-p', GH_PAGES_DIR + '/web/images');
142 mkdir('-p', GH_PAGES_DIR + BUILD_DIR);
143 mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/firefox');
79c57dc Yury Delendik Fixes 'make web' after chromium directory remaning
yurydelendik authored
144 mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/chromium');
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
145 mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/b2g');
790f608 Artur Adib remove target.pagesrepo, commit here (not bot)
arturadib authored
146
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
147 cp('-R', GENERIC_DIR + '/*', GH_PAGES_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
148 cp(FIREFOX_BUILD_DIR + '/*.xpi', FIREFOX_BUILD_DIR + '/*.rdf',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
149 GH_PAGES_DIR + EXTENSION_SRC_DIR + 'firefox/');
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
150 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
151 GH_PAGES_DIR + EXTENSION_SRC_DIR + 'chromium/');
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
152 cp('web/index.html.template', GH_PAGES_DIR + '/index.html');
10f37f7 Yury Delendik PDF.js features testing
yurydelendik authored
153 cp('-R', 'test/features', GH_PAGES_DIR);
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
154 cp('-R', B2G_BUILD_DIR, GH_PAGES_DIR + EXTENSION_SRC_DIR + 'b2g/');
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
155
f6ba384 Artur Adib Using ShellJS
arturadib authored
156 cd(GH_PAGES_DIR);
790f608 Artur Adib remove target.pagesrepo, commit here (not bot)
arturadib authored
157 exec('git init');
158 exec('git remote add origin ' + REPO);
f6ba384 Artur Adib Using ShellJS
arturadib authored
159 exec('git add -A');
790f608 Artur Adib remove target.pagesrepo, commit here (not bot)
arturadib authored
160 exec('git commit -am "gh-pages site created via make.js script"');
161 exec('git branch -m gh-pages');
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
162
f6ba384 Artur Adib Using ShellJS
arturadib authored
163 echo();
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
164 echo('Website built in ' + GH_PAGES_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
165 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
166
167 //
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
168 // make locale
169 // Creates localized resources for the viewer and extension.
170 //
171 target.locale = function() {
172 var METADATA_OUTPUT = 'extensions/firefox/metadata.inc';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
173 var CHROME_MANIFEST_OUTPUT = 'extensions/firefox/chrome.manifest.inc';
174 var EXTENSION_LOCALE_OUTPUT = 'extensions/firefox/locale';
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
175 var VIEWER_LOCALE_OUTPUT = 'web/locale/';
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
176
177 cd(ROOT_DIR);
178 echo();
179 echo('### Building localization files');
180
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
181 rm('-rf', EXTENSION_LOCALE_OUTPUT);
182 mkdir('-p', EXTENSION_LOCALE_OUTPUT);
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
183 rm('-rf', VIEWER_LOCALE_OUTPUT);
184 mkdir('-p', VIEWER_LOCALE_OUTPUT);
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
185
186 var subfolders = ls(LOCALE_SRC_DIR);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
187 subfolders.sort();
188 var metadataContent = '';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
189 var chromeManifestContent = '';
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
190 var viewerOutput = '';
191 for (var i = 0; i < subfolders.length; i++) {
192 var locale = subfolders[i];
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
193 var path = LOCALE_SRC_DIR + locale;
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
194 if (!test('-d', path))
195 continue;
196
197 if (!/^[a-z][a-z](-[A-Z][A-Z])?$/.test(locale)) {
198 echo('Skipping invalid locale: ' + locale);
199 continue;
200 }
201
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
202 mkdir('-p', EXTENSION_LOCALE_OUTPUT + '/' + locale);
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
203 mkdir('-p', VIEWER_LOCALE_OUTPUT + '/' + locale);
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
204 chromeManifestContent += 'locale pdf.js ' + locale + ' locale/' +
205 locale + '/\n';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
206
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
207 if (test('-f', path + '/viewer.properties')) {
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
208 viewerOutput += '[' + locale + ']\n' +
209 '@import url(' + locale + '/viewer.properties)\n\n';
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
210 cp(path + '/viewer.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
211 cp(path + '/viewer.properties', VIEWER_LOCALE_OUTPUT + '/' + locale);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
212 }
213
080c3e7 Brendan Dahl Merge upstream. Use new l10n.
brendandahl authored
214 if (test('-f', path + '/chrome.properties')) {
215 cp(path + '/chrome.properties', EXTENSION_LOCALE_OUTPUT + '/' + locale);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
216 }
217
218 if (test('-f', path + '/metadata.inc')) {
219 var metadata = cat(path + '/metadata.inc');
220 metadataContent += metadata;
221 }
222 }
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
223 viewerOutput.to(VIEWER_LOCALE_OUTPUT + 'locale.properties');
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
224 metadataContent.to(METADATA_OUTPUT);
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
225 chromeManifestContent.to(CHROME_MANIFEST_OUTPUT);
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
226 };
227
228 //
f6ba384 Artur Adib Using ShellJS
arturadib authored
229 // make bundle
230 // Bundles all source files into one wrapper 'pdf.js' file, in the given order.
231 //
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
232 target.bundle = function(args) {
233 args = args || {};
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
234 var defines = args.defines || DEFINES;
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
235 var excludes = args.excludes || [];
236
7b70710 Yury Delendik Traces pdf.js version
yurydelendik authored
237 target.buildnumber();
238
f6ba384 Artur Adib Using ShellJS
arturadib authored
239 cd(ROOT_DIR);
240 echo();
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
241 echo('### Bundling files into ' + BUILD_TARGET);
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
242 var reg = /\n\/\* -\*- Mode(.|\n)*?Mozilla Foundation(.|\n)*?'use strict';/g;
f6ba384 Artur Adib Using ShellJS
arturadib authored
243
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
244 function bundle(filename, dir, SRC_FILES, EXT_SRC_FILES) {
245 for (var i = 0, length = excludes.length; i < length; ++i) {
246 var exclude = excludes[i];
247 var index = SRC_FILES.indexOf(exclude);
248 if (index >= 0) {
249 SRC_FILES.splice(index, 1);
250 }
ef423ef Mack Duan Implement progressive loading of PDFs
mduan authored
251 }
252
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
253 var bundle = cat(SRC_FILES),
254 bundleVersion = EXTENSION_VERSION,
255 bundleBuild = exec('git log --format="%h" -n 1',
256 {silent: true}).output.replace('\n', '');
257
258 crlfchecker.checkIfCrlfIsPresent(SRC_FILES);
259
260 // Strip out all the vim/license headers.
261 bundle = bundle.replace(reg, '');
262
263 // Append external files last since we don't want to modify them.
264 bundle += cat(EXT_SRC_FILES);
265
266 // This just preprocesses the empty pdf.js file, we don't actually want to
267 // preprocess everything yet since other build targets use this file.
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
268 builder.preprocess(filename, dir, builder.merge(defines,
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
269 {BUNDLE: bundle,
270 BUNDLE_VERSION: bundleVersion,
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
271 BUNDLE_BUILD: bundleBuild}));
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
272 }
76d877e Brendan Dahl Strip out license for bundled version.
brendandahl authored
273
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
274 if (!test('-d', BUILD_DIR))
f6ba384 Artur Adib Using ShellJS
arturadib authored
275 mkdir(BUILD_DIR);
276
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
277 var SHARED_SRC_FILES = [
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
278 'shared/util.js',
279 'shared/colorspace.js',
280 'shared/function.js',
281 'shared/annotation.js',
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
282 ];
283
284 var MAIN_SRC_FILES = SHARED_SRC_FILES.concat([
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
285 'display/api.js',
286 'display/metadata.js',
287 'display/canvas.js',
bf432a3 Yury Delendik Refactors shared/pattern.js into core/ and display/
yurydelendik authored
288 'display/pattern_helper.js',
bb2529d Brendan Dahl Move the creation of canvas path fonts to the worker.
brendandahl authored
289 'display/font_loader.js'
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
290 ]);
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
291
292 var WORKER_SRC_FILES = [
293 'core/network.js',
294 'core/chunked_stream.js',
295 'core/pdf_manager.js',
296 'core/core.js',
297 'core/obj.js',
298 'core/charsets.js',
299 'core/cidmaps.js',
300 'core/crypto.js',
bf432a3 Yury Delendik Refactors shared/pattern.js into core/ and display/
yurydelendik authored
301 'core/pattern.js',
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
302 'core/evaluator.js',
303 'core/fonts.js',
bb2529d Brendan Dahl Move the creation of canvas path fonts to the worker.
brendandahl authored
304 'core/font_renderer.js',
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
305 'core/glyphlist.js',
306 'core/image.js',
307 'core/metrics.js',
308 'core/parser.js',
e932705 Yury Delendik Basic function.js split
yurydelendik authored
309 'core/ps_parser.js',
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
310 'core/stream.js',
311 'core/worker.js',
7b5b517 Felix Kälberer Extract duplicate arithmetic decoder to own class
fkaelberer authored
312 'core/arithmetic_decoder.js',
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
313 'core/jpx.js',
314 'core/jbig2.js',
f32e65b Brendan Dahl Read multi-byte character codes based on codespace ranges.
brendandahl authored
315 'core/bidi.js',
316 'core/cmap.js'
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
317 ];
b13798f Kalervo Kujala Add carriage return checks to make.js.
kkujala authored
318
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
319 if (!defines.SINGLE_FILE) {
320 // We want shared_src_files in both pdf.js and pdf.worker.js
321 // unless it's being built in singlefile mode.
322 WORKER_SRC_FILES = SHARED_SRC_FILES.concat(WORKER_SRC_FILES);
04e2235 Greg Jordan Fix singlefile build target
gjuggler authored
323 } else {
324 // In singlefile mode, all of the src files will be bundled into
325 // the main pdf.js outuput.
326 MAIN_SRC_FILES = MAIN_SRC_FILES.concat(WORKER_SRC_FILES);
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
327 }
328
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
329 var EXT_SRC_FILES = [
330 '../external/jpgjs/jpg.js'
331 ];
76d877e Brendan Dahl Strip out license for bundled version.
brendandahl authored
332
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
333 cd(SRC_DIR);
76d877e Brendan Dahl Strip out license for bundled version.
brendandahl authored
334
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
335 bundle('pdf.js', ROOT_DIR + BUILD_TARGET, MAIN_SRC_FILES, []);
336 var srcCopy = ROOT_DIR + BUILD_DIR + 'pdf.worker.js.temp';
337 cp('pdf.js', srcCopy);
338 bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, WORKER_SRC_FILES,
339 EXT_SRC_FILES);
340 rm(srcCopy);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
341 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
342
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
343 //
344 // make singlefile
345 // Concatenates pdf.js and pdf.worker.js into one big pdf.combined.js, and
346 // flags the script loader to not attempt to load the separate worker JS file.
347 //
348 target.singlefile = function() {
349 cd(ROOT_DIR);
350 echo();
351 echo('### Creating singlefile build');
352
353 var SINGLE_FILE_DIR = BUILD_DIR + '/singlefile/';
354 var SINGLE_FILE_TARGET = BUILD_DIR + 'pdf.combined.js';
355
356 var defines = builder.merge(DEFINES, {SINGLE_FILE: true});
357 target.bundle({defines: defines});
358
359 cd(ROOT_DIR);
360
361 rm('-rf', SINGLE_FILE_DIR);
362 mkdir('-p', SINGLE_FILE_DIR);
363 mkdir('-p', SINGLE_FILE_DIR + BUILD_DIR);
364
365 var setup = {
366 defines: defines,
367 copy: [],
368 preprocess: [
369 [BUILD_TARGETS, SINGLE_FILE_DIR + BUILD_DIR]
370 ]
371 };
372 builder.build(setup);
373
374 cd(SINGLE_FILE_DIR);
375
376 echo();
04e2235 Greg Jordan Fix singlefile build target
gjuggler authored
377 echo('### Moving pdf.js to pdf.combined.js');
1838ec0 Greg Jordan Add a singlefile target to build one concatenated file
gjuggler authored
378 var pdfJs = cat(BUILD_TARGET);
379 pdfJs.to(SINGLE_FILE_TARGET);
380
381 rm(BUILD_TARGET);
382 rm(BUILD_WORKER_TARGET);
383
384 };
385
83b6eae Vivin Paliath pr #3356
vivin authored
386 function cleanupJSSource(file) {
387 var content = cat(file);
388
389 // Strip out all the vim/license headers.
390 var reg = /\n\/\* -\*- Mode(.|\n)*?Mozilla Foundation(.|\n)*?'use strict';/g;
391 content = content.replace(reg, '');
f6ba384 Artur Adib Using ShellJS
arturadib authored
392
83b6eae Vivin Paliath pr #3356
vivin authored
393 content.to(file);
394 }
f6ba384 Artur Adib Using ShellJS
arturadib authored
395
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
396 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
397 //
398 // Extension stuff
399 //
400
76ff549 Brendan Dahl Bump version number to 0.8.
brendandahl authored
401 var EXTENSION_BASE_VERSION = '0ac55ac879d1c0eea9c0d155d5bbd9b11560f631',
402 EXTENSION_VERSION_PREFIX = '0.8.',
6abbc28 notmasteryet Changing make.js
notmasteryet authored
403 EXTENSION_BUILD_NUMBER,
404 EXTENSION_VERSION;
f6ba384 Artur Adib Using ShellJS
arturadib authored
405
406 //
407 // make extension
408 //
409 target.extension = function() {
410 cd(ROOT_DIR);
411 echo();
412 echo('### Building extensions');
413
085723a Yury Delendik make the locale stuff a precondition for make extension
yurydelendik authored
414 target.locale();
f6ba384 Artur Adib Using ShellJS
arturadib authored
415 target.firefox();
8dc41e7 Andreas Bovens adjusted some more chrome references in make.js and README.js as per @yu...
andreasbovens authored
416 target.chromium();
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
417 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
418
419 target.buildnumber = function() {
420 cd(ROOT_DIR);
421 echo();
422 echo('### Getting extension build number');
423
332ae4c Brendan Dahl Change to the Apache v2 license.
brendandahl authored
424 var lines = exec('git log --format=oneline ' +
425 EXTENSION_BASE_VERSION + '..', {silent: true}).output;
f6ba384 Artur Adib Using ShellJS
arturadib authored
426 // Build number is the number of commits since base version
332ae4c Brendan Dahl Change to the Apache v2 license.
brendandahl authored
427 EXTENSION_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
428
429 echo('Extension build number: ' + EXTENSION_BUILD_NUMBER);
6abbc28 notmasteryet Changing make.js
notmasteryet authored
430
431 EXTENSION_VERSION = EXTENSION_VERSION_PREFIX + EXTENSION_BUILD_NUMBER;
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
432 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
433
434 //
435 // make firefox
436 //
437 target.firefox = function() {
438 cd(ROOT_DIR);
439 echo();
440 echo('### Building Firefox extension');
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
441 var defines = builder.merge(DEFINES, {FIREFOX: true});
f6ba384 Artur Adib Using ShellJS
arturadib authored
442
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
443 var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
444 FIREFOX_EXTENSION_DIR = 'extensions/firefox/',
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
445 FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
f6ba384 Artur Adib Using ShellJS
arturadib authored
446 FIREFOX_EXTENSION_FILES_TO_COPY =
447 ['*.js',
448 '*.rdf',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
449 '*.svg',
cd1fd17 Brendan Dahl Add icon for extension.
brendandahl authored
450 '*.png',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
451 '*.manifest',
452 'locale',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
453 '../../LICENSE'],
f6ba384 Artur Adib Using ShellJS
arturadib authored
454 FIREFOX_EXTENSION_FILES =
6abbc28 notmasteryet Changing make.js
notmasteryet authored
455 ['bootstrap.js',
f6ba384 Artur Adib Using ShellJS
arturadib authored
456 'install.rdf',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
457 'chrome.manifest',
cd1fd17 Brendan Dahl Add icon for extension.
brendandahl authored
458 'icon.png',
459 'icon64.png',
6abbc28 notmasteryet Changing make.js
notmasteryet authored
460 'content',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
461 'locale',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
462 'LICENSE'],
f6ba384 Artur Adib Using ShellJS
arturadib authored
463 FIREFOX_EXTENSION_NAME = 'pdf.js.xpi',
464 FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';
465
085723a Yury Delendik make the locale stuff a precondition for make extension
yurydelendik authored
466 target.locale();
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
467 target.bundle({ excludes: ['core/network.js'], defines: defines });
f6ba384 Artur Adib Using ShellJS
arturadib authored
468 cd(ROOT_DIR);
469
470 // Clear out everything in the firefox extension build directory
471 rm('-rf', FIREFOX_BUILD_DIR);
472 mkdir('-p', FIREFOX_BUILD_CONTENT_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
473 mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
474 mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web');
475
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
476 cp(FIREFOX_CONTENT_DIR + 'PdfJs-stub.jsm',
477 FIREFOX_BUILD_CONTENT_DIR + 'PdfJs.jsm');
1bb7a7e Yury Delendik Adds stub PdfJs.jsm for FF15
yurydelendik authored
478
ba23a9e Yury Delendik Adds initial telemetry probes
yurydelendik authored
479 cp(FIREFOX_CONTENT_DIR + 'PdfJsTelemetry-addon.jsm',
480 FIREFOX_BUILD_CONTENT_DIR + 'PdfJsTelemetry.jsm');
481
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
482 cp(FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm',
483 FIREFOX_BUILD_CONTENT_DIR);
484
485 cp(FIREFOX_CONTENT_DIR + 'PdfRedirector.jsm',
486 FIREFOX_BUILD_CONTENT_DIR);
487
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
488 // Copy extension files
6046c55 Kalervo Kujala Fix few jslint warnings in make.js.
kkujala authored
489 cd(FIREFOX_EXTENSION_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
490 cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + FIREFOX_BUILD_DIR);
f6ba384 Artur Adib Using ShellJS
arturadib authored
491 cd(ROOT_DIR);
492
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
493 var setup = {
494 defines: defines,
495 copy: [
496 [COMMON_WEB_FILES, FIREFOX_BUILD_CONTENT_DIR + '/web'],
6046c55 Kalervo Kujala Fix few jslint warnings in make.js.
kkujala authored
497 [FIREFOX_EXTENSION_DIR + 'tools/l10n.js',
60610cd Jonas Jenwald Implement default preferences
Snuffleupagus authored
498 FIREFOX_BUILD_CONTENT_DIR + '/web'],
499 ['web/default_preferences.js', FIREFOX_BUILD_CONTENT_DIR]
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
500 ],
501 preprocess: [
babd8df Brendan Dahl Un-inline pdf.js for the extension/mozcentral and remove fetch pdf by co...
brendandahl authored
502 [COMMON_WEB_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR + '/web'],
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
503 [BUILD_TARGETS, FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR],
504 [SRC_DIR + 'core/network.js', FIREFOX_BUILD_CONTENT_DIR]
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
505 ],
506 preprocessCSS: [
507 ['firefox', 'web/viewer.css',
508 FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.css']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
509 ]
510 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
511 builder.build(setup);
f6ba384 Artur Adib Using ShellJS
arturadib authored
512
83b6eae Vivin Paliath pr #3356
vivin authored
513 cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.js');
514
c3bdf1e Artur Adib adding new find() commands
arturadib authored
515 // Remove '.DS_Store' and other hidden files
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
516 find(FIREFOX_BUILD_DIR).forEach(function(file) {
c3bdf1e Artur Adib adding new find() commands
arturadib authored
517 if (file.match(/^\./))
518 rm('-f', file);
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
519 });
f6ba384 Artur Adib Using ShellJS
arturadib authored
520
521 // Update the build version number
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
522 sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
523 FIREFOX_BUILD_DIR + '/install.rdf');
524 sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
525 FIREFOX_BUILD_DIR + '/update.rdf');
526
527 sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
528 FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
529 sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
530 FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
531 sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false',
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
532 FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm');
4bee4c6 Brendan Dahl Use different id's for moz central and extension.
brendandahl authored
533
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
534 // Update localized metadata
535 var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
536 sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata,
537 FIREFOX_BUILD_DIR + '/install.rdf');
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
538 var chromeManifest = cat(EXTENSION_SRC_DIR + '/firefox/chrome.manifest.inc');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
539 sed('-i', /.*PDFJS_SUPPORTED_LOCALES.*\n/, chromeManifest,
540 FIREFOX_BUILD_DIR + '/chrome.manifest');
427a5f1 Yury Delendik Move localization to l10n folders; create 'make locale'
yurydelendik authored
541
f6ba384 Artur Adib Using ShellJS
arturadib authored
542 // Create the xpi
543 cd(FIREFOX_BUILD_DIR);
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
544 exec('zip -r ' + FIREFOX_EXTENSION_NAME + ' ' +
545 FIREFOX_EXTENSION_FILES.join(' '));
f6ba384 Artur Adib Using ShellJS
arturadib authored
546 echo('extension created: ' + FIREFOX_EXTENSION_NAME);
547 cd(ROOT_DIR);
548
549 // Build the amo extension too (remove the updateUrl)
550 cd(FIREFOX_BUILD_DIR);
551 sed('-i', /.*updateURL.*\n/, '', 'install.rdf');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
552 exec('zip -r ' + FIREFOX_AMO_EXTENSION_NAME + ' ' +
553 FIREFOX_EXTENSION_FILES.join(' '));
f6ba384 Artur Adib Using ShellJS
arturadib authored
554 echo('AMO extension created: ' + FIREFOX_AMO_EXTENSION_NAME);
555 cd(ROOT_DIR);
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
556 };
557
558 //
559 // make mozcentral
560 //
561 target.mozcentral = function() {
562 cd(ROOT_DIR);
563 echo();
564 echo('### Building mozilla-central extension');
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
565 var defines = builder.merge(DEFINES, {MOZCENTRAL: true});
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
566
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
567 var MOZCENTRAL_DIR = BUILD_DIR + 'mozcentral/',
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
568 MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + 'browser/extensions/pdfjs/',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
569 MOZCENTRAL_CONTENT_DIR = MOZCENTRAL_EXTENSION_DIR + 'content/',
570 MOZCENTRAL_L10N_DIR = MOZCENTRAL_DIR + 'browser/locales/en-US/pdfviewer/',
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
571 MOZCENTRAL_TEST_DIR = MOZCENTRAL_EXTENSION_DIR + 'test/',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
572 FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
573 FIREFOX_EXTENSION_FILES_TO_COPY =
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
574 ['*.svg',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
575 '*.png',
6323c8e Yury Delendik Loading extension resources via stringbundle
yurydelendik authored
576 '*.manifest',
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
577 'README.mozilla',
578 '../../LICENSE'],
579 DEFAULT_LOCALE_FILES =
03032d2 Brendan Dahl Add chrome.properties for moz central build.
brendandahl authored
580 [LOCALE_SRC_DIR + 'en-US/viewer.properties',
2684c79 Tim van der Meij Cleaning up files in extension
timvandermeij authored
581 LOCALE_SRC_DIR + 'en-US/chrome.properties'],
582 FIREFOX_MC_EXCLUDED_FILES =
583 ['icon.png',
584 'icon64.png'];
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
585
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
586 target.bundle({ excludes: ['core/network.js'], defines: defines });
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
587 cd(ROOT_DIR);
588
589 // Clear out everything in the firefox extension build directory
590 rm('-rf', MOZCENTRAL_DIR);
591 mkdir('-p', MOZCENTRAL_CONTENT_DIR);
592 mkdir('-p', MOZCENTRAL_L10N_DIR);
593 mkdir('-p', MOZCENTRAL_CONTENT_DIR + BUILD_DIR);
594 mkdir('-p', MOZCENTRAL_CONTENT_DIR + '/web');
595
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
596 cp(FIREFOX_CONTENT_DIR + 'PdfJs.jsm', MOZCENTRAL_CONTENT_DIR);
ba23a9e Yury Delendik Adds initial telemetry probes
yurydelendik authored
597 cp(FIREFOX_CONTENT_DIR + 'PdfJsTelemetry.jsm', MOZCENTRAL_CONTENT_DIR);
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
598 cp(FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm', MOZCENTRAL_CONTENT_DIR);
599 cp(FIREFOX_CONTENT_DIR + 'PdfRedirector.jsm', MOZCENTRAL_CONTENT_DIR);
3d7f01d Brendan Dahl Add global pref to enable/disable. Control pdf.js in application prefer...
brendandahl authored
600
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
601 // Copy extension files
602 cd('extensions/firefox');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
603 cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY,
604 ROOT_DIR + MOZCENTRAL_EXTENSION_DIR);
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
605 mv('-f', ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome-mozcentral.manifest',
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
606 ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome.manifest');
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
607 cd(ROOT_DIR);
608
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
609 var setup = {
610 defines: defines,
611 copy: [
612 [COMMON_WEB_FILES, MOZCENTRAL_CONTENT_DIR + '/web'],
60610cd Jonas Jenwald Implement default preferences
Snuffleupagus authored
613 ['extensions/firefox/tools/l10n.js', MOZCENTRAL_CONTENT_DIR + '/web'],
614 ['web/default_preferences.js', MOZCENTRAL_CONTENT_DIR]
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
615 ],
616 preprocess: [
babd8df Brendan Dahl Un-inline pdf.js for the extension/mozcentral and remove fetch pdf by co...
brendandahl authored
617 [COMMON_WEB_FILES_PREPROCESS, MOZCENTRAL_CONTENT_DIR + '/web'],
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
618 [BUILD_TARGETS, MOZCENTRAL_CONTENT_DIR + BUILD_DIR],
619 [SRC_DIR + 'core/network.js', MOZCENTRAL_CONTENT_DIR]
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
620 ],
621 preprocessCSS: [
894c82c Yury Delendik Removes -moz-box-sizing usage
yurydelendik authored
622 ['mozcentral',
623 'web/viewer.css',
624 MOZCENTRAL_CONTENT_DIR + '/web/viewer.css']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
625 ]
626 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
627 builder.build(setup);
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
628
83b6eae Vivin Paliath pr #3356
vivin authored
629 cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.js');
630
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
631 // Remove '.DS_Store' and other hidden files
632 find(MOZCENTRAL_DIR).forEach(function(file) {
633 if (file.match(/^\./))
634 rm('-f', file);
635 });
636
2684c79 Tim van der Meij Cleaning up files in extension
timvandermeij authored
637 // Remove excluded files
638 cd(MOZCENTRAL_EXTENSION_DIR);
639 FIREFOX_MC_EXCLUDED_FILES.forEach(function(file) {
640 if (test('-f', file)) {
641 rm('-r', file);
642 }
643 });
644 cd(ROOT_DIR);
645
6aa1615 Yury Delendik Add mozcontral options
yurydelendik authored
646 // Copy default localization files
647 cp(DEFAULT_LOCALE_FILES, MOZCENTRAL_L10N_DIR);
648
649 // Update the build version number
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
650 sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
651 MOZCENTRAL_EXTENSION_DIR + 'README.mozilla');
6abbc28 notmasteryet Changing make.js
notmasteryet authored
652
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
653 sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
654 MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
655 sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX,
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
656 MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
657 sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true',
b8f7bca Brendan Dahl Use only one resource url for moz central build.
brendandahl authored
658 MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm');
4bee4c6 Brendan Dahl Use different id's for moz central and extension.
brendandahl authored
659
424f522 Artur Adib Fixed moz-central manifest; bundling Mochitests
arturadib authored
660 // Copy test files
661 mkdir('-p', MOZCENTRAL_TEST_DIR);
662 cp('-Rf', 'test/mozcentral/*', MOZCENTRAL_TEST_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
663 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
664
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
665 target.b2g = function() {
fd4e40c Brendan Dahl New GUI for B2G viewer.
brendandahl authored
666 target.locale();
7b70710 Yury Delendik Traces pdf.js version
yurydelendik authored
667
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
668 echo();
669 echo('### Building B2G (Firefox OS App)');
c79acf5 Brendan Dahl Fix the B2G viewer and enable bot preview.
brendandahl authored
670 var B2G_BUILD_CONTENT_DIR = B2G_BUILD_DIR + '/content/';
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
671 var defines = builder.merge(DEFINES, { B2G: true });
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
672 target.bundle({ defines: defines });
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
673
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
674 // Clear out everything in the b2g build directory
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
675 cd(ROOT_DIR);
676 rm('-Rf', B2G_BUILD_DIR);
677 mkdir('-p', B2G_BUILD_CONTENT_DIR);
678 mkdir('-p', B2G_BUILD_CONTENT_DIR + BUILD_DIR);
679 mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web');
680
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
681 var setup = {
682 defines: defines,
683 copy: [
fd4e40c Brendan Dahl New GUI for B2G viewer.
brendandahl authored
684 ['extensions/b2g/images', B2G_BUILD_CONTENT_DIR + '/web'],
685 ['extensions/b2g/viewer.html', B2G_BUILD_CONTENT_DIR + '/web'],
686 ['extensions/b2g/viewer.css', B2G_BUILD_CONTENT_DIR + '/web'],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
687 ['web/locale', B2G_BUILD_CONTENT_DIR + '/web'],
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
688 ['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web']
689 ],
690 preprocess: [
fd4e40c Brendan Dahl New GUI for B2G viewer.
brendandahl authored
691 ['web/viewer.js', B2G_BUILD_CONTENT_DIR + '/web'],
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
692 [BUILD_TARGETS, B2G_BUILD_CONTENT_DIR + BUILD_DIR]
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
693 ]
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
694 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
695 builder.build(setup);
83b6eae Vivin Paliath pr #3356
vivin authored
696
697 cleanupJSSource(B2G_BUILD_CONTENT_DIR + '/web/viewer.js');
6d35073 Brendan Dahl Initial build for b2g.
brendandahl authored
698 };
699
f6ba384 Artur Adib Using ShellJS
arturadib authored
700 //
701 // make chrome
702 //
8dc41e7 Andreas Bovens adjusted some more chrome references in make.js and README.js as per @yu...
andreasbovens authored
703 target.chromium = function() {
f6ba384 Artur Adib Using ShellJS
arturadib authored
704 cd(ROOT_DIR);
705 echo();
8dc41e7 Andreas Bovens adjusted some more chrome references in make.js and README.js as per @yu...
andreasbovens authored
706 echo('### Building Chromium extension');
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
707 var defines = builder.merge(DEFINES, {CHROME: true});
f6ba384 Artur Adib Using ShellJS
arturadib authored
708
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
709 var CHROME_BUILD_DIR = BUILD_DIR + '/chromium/',
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
710 CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/';
f6ba384 Artur Adib Using ShellJS
arturadib authored
711
3f530c4 Yury Delendik Specifies default workerSrc (if possible)
yurydelendik authored
712 target.bundle({ defines: defines });
f6ba384 Artur Adib Using ShellJS
arturadib authored
713 cd(ROOT_DIR);
714
715 // Clear out everything in the chrome extension build directory
716 rm('-Rf', CHROME_BUILD_DIR);
717 mkdir('-p', CHROME_BUILD_CONTENT_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
718 mkdir('-p', CHROME_BUILD_CONTENT_DIR + BUILD_DIR);
719 mkdir('-p', CHROME_BUILD_CONTENT_DIR + '/web');
f6ba384 Artur Adib Using ShellJS
arturadib authored
720
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
721 var setup = {
722 defines: defines,
723 copy: [
724 [COMMON_WEB_FILES, CHROME_BUILD_CONTENT_DIR + '/web'],
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
725 [['extensions/chromium/*.json',
726 'extensions/chromium/*.html',
727 'extensions/chromium/*.js',
728 'extensions/chromium/*.css',
729 'extensions/chromium/icon*.png',],
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
730 CHROME_BUILD_DIR],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
731 ['external/webL10n/l10n.js', CHROME_BUILD_CONTENT_DIR + '/web'],
2ab481a Yury Delendik Removes foreign for Firefox CSS prefixes
yurydelendik authored
732 ['web/viewer.css', CHROME_BUILD_CONTENT_DIR + '/web'],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
733 ['web/locale', CHROME_BUILD_CONTENT_DIR + '/web']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
734 ],
735 preprocess: [
5ecce49 Brendan Dahl Split files into worker and main thread pieces.
brendandahl authored
736 [BUILD_TARGETS, CHROME_BUILD_CONTENT_DIR + BUILD_DIR],
e5247e4 Yury Delendik Updates webL10n; using viewer.properties as is
yurydelendik authored
737 [COMMON_WEB_FILES_PREPROCESS, CHROME_BUILD_CONTENT_DIR + '/web']
492fa6e Brendan Dahl Add the new preprocessor.
brendandahl authored
738 ]
739 };
e0a6b23 Brendan Dahl Move builder/preprocessor into its own file.
brendandahl authored
740 builder.build(setup);
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
741
83b6eae Vivin Paliath pr #3356
vivin authored
742 cleanupJSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.js');
743
6ca9245 moderation Changes to allowed versioned building of Chrome extension that meets new
moderation authored
744 // Update the build version number
745 sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
746 CHROME_BUILD_DIR + '/manifest.json');
747
e181a3c Rob Wu Highly improved Chrome extension
Rob--W authored
748 // Allow PDF.js resources to be loaded by adding the files to
749 // the "web_accessible_resources" section.
750 var file_list = ls('-RA', CHROME_BUILD_CONTENT_DIR);
751 var public_chrome_files = file_list.reduce(function(war, file) {
752 // Exclude directories (naive: Exclude paths without dot)
753 if (file.indexOf('.') !== -1) {
754 // Only add a comma after the first file
755 if (war)
756 war += ',\n';
757 war += JSON.stringify('content/' + file);
758 }
759 return war;
760 }, '');
761 sed('-i', /"content\/\*"/, public_chrome_files,
762 CHROME_BUILD_DIR + '/manifest.json');
763
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
764 // Bundle the files to a Chrome extension file .crx if path to key is set
765 var pem = env['PDFJS_CHROME_KEY'];
766 if (!pem) {
767 return;
768 }
769
770 echo();
771 echo('### Bundling .crx extension into ' + CHROME_BUILD_DIR);
772
773 if (!test('-f', pem)) {
774 echo('Incorrect PDFJS_CHROME_KEY path');
775 exit(1);
776 }
777
778 var browserManifest = env['PDF_BROWSERS'] ||
779 'test/resources/browser_manifests/browser_manifest.json';
780
781 if (!test('-f', browserManifest)) {
782 echo('Browser manifest file ' + browserManifest + ' does not exist.');
783 echo('Try copying one of the examples in test/resources/browser_manifests');
784 exit(1);
785 }
786
c4eab85 Jon Buckley Issue #2008 - Fix lint errors for make.js
jbuck authored
787 var manifest;
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
788 try {
c4eab85 Jon Buckley Issue #2008 - Fix lint errors for make.js
jbuck authored
789 manifest = JSON.parse(cat(browserManifest));
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
790 } catch (e) {
791 echo('Malformed browser manifest file');
792 echo(e.message);
793 exit(1);
794 }
795
796 var executable;
797 manifest.forEach(function(browser) {
798 if (browser.name === 'chrome') {
799 executable = browser.path;
800 }
801 });
802
803 // If there was no chrome entry in the browser manifest, exit
c2cfa99 Yury Delendik Fixing new make.js lint errors
yurydelendik authored
804 if (!executable) {
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
805 echo('There was no \'chrome\' entry in the browser manifest');
806 exit(1);
807 }
808
809 // If we're on a Darwin (Mac) OS, then let's check for an .app path
810 if (process.platform === 'darwin' && executable.indexOf('.app') !== -1) {
df32b43 Artur Adib Update make.js
arturadib authored
811 executable = executable + '/Contents/MacOS/Google Chrome';
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
812 }
813
814 // If the chrome executable doesn't exist
c2cfa99 Yury Delendik Fixing new make.js lint errors
yurydelendik authored
815 if (!test('-f', executable)) {
b96152b Jakob Miland Support for building .crx file (re-visited)
saebekassebil authored
816 echo('Incorrect executable path to chrome');
817 exit(1);
818 }
819
820 // Let chrome pack the extension for us
821 exec('"' + executable + '"' +
822 ' --no-message-box' +
823 ' "--pack-extension=' + ROOT_DIR + CHROME_BUILD_DIR + '"' +
824 ' "--pack-extension-key=' + pem + '"');
825
826 // Rename to pdf.js.crx
827 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
828 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
829
830
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
831 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
832 //
833 // Test stuff
834 //
835
836 //
837 // make test
838 //
839 target.test = function() {
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
840 target.unittest({}, function() {
841 target.browsertest();
842 });
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
843 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
844
845 //
89ceead Artur Adib make bottest
arturadib authored
846 // make bottest
847 // (Special tests for the Github bot)
848 //
849 target.bottest = function() {
eea1d90 Brendan Dahl Fix bottest.
brendandahl authored
850 target.unittest({}, function() {
5afec33 Yury Delendik Adds ttx test harness
yurydelendik authored
851 target.fonttest({}, function() {
852 target.browsertest({noreftest: true});
853 });
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
854 });
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
855 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
856
857 //
858 // make browsertest
859 //
89ceead Artur Adib make bottest
arturadib authored
860 target.browsertest = function(options) {
f6ba384 Artur Adib Using ShellJS
arturadib authored
861 cd(ROOT_DIR);
862 echo();
863 echo('### Running browser tests');
864
865 var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
866 PDF_BROWSERS = env['PDF_BROWSERS'] ||
867 'resources/browser_manifests/browser_manifest.json';
f6ba384 Artur Adib Using ShellJS
arturadib authored
868
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
869 if (!test('-f', 'test/' + PDF_BROWSERS)) {
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
870 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
871 echo('Copy one of the examples in test/resources/browser_manifests/');
f6ba384 Artur Adib Using ShellJS
arturadib authored
872 exit(1);
873 }
874
3740bed Artur Adib minor fixes
arturadib authored
875 var reftest = (options && options.noreftest) ? '' : '--reftest';
89ceead Artur Adib make bottest
arturadib authored
876
f6ba384 Artur Adib Using ShellJS
arturadib authored
877 cd('test');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
878 exec(PYTHON_BIN + ' -u test.py ' + reftest + ' --browserManifestFile=' +
879 PDF_BROWSERS + ' --manifestFile=' + PDF_TEST, {async: true});
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
880 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
881
882 //
883 // make unittest
884 //
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
885 target.unittest = function(options, callback) {
f6ba384 Artur Adib Using ShellJS
arturadib authored
886 cd(ROOT_DIR);
887 echo();
888 echo('### Running unit tests');
889
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
890 var PDF_BROWSERS = env['PDF_BROWSERS'] ||
891 'resources/browser_manifests/browser_manifest.json';
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
892
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
893 if (!test('-f', 'test/' + PDF_BROWSERS)) {
894 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
895 echo('Copy one of the examples in test/resources/browser_manifests/');
e18a2c5 Brendan Dahl Use test.py for unit tests too.
brendandahl authored
896 exit(1);
897 }
898 callback = callback || function() {};
899 cd('test');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
900 exec(PYTHON_BIN + ' -u test.py --unitTest --browserManifestFile=' +
901 PDF_BROWSERS, {async: true}, callback);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
902 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
903
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
904 //
5afec33 Yury Delendik Adds ttx test harness
yurydelendik authored
905 // make fonttest
906 //
907 target.fonttest = function(options, callback) {
908 cd(ROOT_DIR);
909 echo();
910 echo('### Running font tests');
911
912 var PDF_BROWSERS = env['PDF_BROWSERS'] ||
913 'resources/browser_manifests/browser_manifest.json';
914
915 if (!test('-f', 'test/' + PDF_BROWSERS)) {
916 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
917 echo('Copy one of the examples in test/resources/browser_manifests/');
918 exit(1);
919 }
920 callback = callback || function() {};
921 cd('test');
922 exec(PYTHON_BIN + ' -u test.py --fontTest --browserManifestFile=' +
923 PDF_BROWSERS, {async: true}, callback);
924 };
925
926 //
3740bed Artur Adib minor fixes
arturadib authored
927 // make botmakeref
928 //
929 target.botmakeref = function() {
930 cd(ROOT_DIR);
931 echo();
932 echo('### Creating reference images');
933
934 var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
935 PDF_BROWSERS = env['PDF_BROWSERS'] ||
936 'resources/browser_manifests/browser_manifest.json';
3740bed Artur Adib minor fixes
arturadib authored
937
938 if (!test('-f', 'test/' + PDF_BROWSERS)) {
939 echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
940 echo('Copy one of the examples in test/resources/browser_manifests/');
3740bed Artur Adib minor fixes
arturadib authored
941 exit(1);
942 }
943
944 cd('test');
413acae Kalervo Kujala Correct gjslint warnings in make.js.
kkujala authored
945 exec(PYTHON_BIN + ' -u test.py --masterMode --noPrompts ' +
946 '--browserManifestFile=' + PDF_BROWSERS, {async: true});
a0a5c58 Artur Adib Upgrading ShellJS, introducing 'makeref'
arturadib authored
947 };
948
fb0fd9e Yury Delendik Adds mozcentralcheck and mozcentraldiff targets
yurydelendik authored
949 ////////////////////////////////////////////////////////////////////////////////
950 //
951 // Baseline operation
952 //
953 target.baseline = function() {
954 cd(ROOT_DIR);
955
956 echo();
957 echo('### Creating baseline environment');
958
959 var baselineCommit = env['BASELINE'];
960 if (!baselineCommit) {
961 echo('Baseline commit is not provided. Please specify BASELINE variable');
962 exit(1);
963 }
964
965 if (!test('-d', BUILD_DIR))
966 mkdir(BUILD_DIR);
967
968 var BASELINE_DIR = BUILD_DIR + 'baseline';
969 if (test('-d', BASELINE_DIR)) {
970 cd(BASELINE_DIR);
971 exec('git fetch origin');
972 } else {
973 cd(BUILD_DIR);
974 exec('git clone .. baseline');
975 cd(ROOT_DIR + BASELINE_DIR);
976 }
977 exec('git checkout ' + baselineCommit);
978 };
979
980 target.mozcentralbaseline = function() {
981 target.baseline();
982
983 cd(ROOT_DIR);
984
985 echo();
986 echo('### Creating mozcentral baseline environment');
987
988 var BASELINE_DIR = BUILD_DIR + 'baseline';
989 var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
990 if (test('-d', MOZCENTRAL_BASELINE_DIR))
991 rm('-rf', MOZCENTRAL_BASELINE_DIR);
992
993 cd(BASELINE_DIR);
994 if (test('-d', 'build'))
995 rm('-rf', 'build');
996 exec('node make mozcentral');
997
998 cd(ROOT_DIR);
999 mkdir(MOZCENTRAL_BASELINE_DIR);
1000 cp('-Rf', BASELINE_DIR + '/build/mozcentral/*', MOZCENTRAL_BASELINE_DIR);
1001 // fixing baseline
1002 if (test('-f', MOZCENTRAL_BASELINE_DIR +
1003 '/browser/extensions/pdfjs/PdfStreamConverter.js')) {
1004 rm(MOZCENTRAL_BASELINE_DIR +
1005 '/browser/extensions/pdfjs/PdfStreamConverter.js');
1006 }
1007
1008 cd(MOZCENTRAL_BASELINE_DIR);
1009 exec('git init');
1010 exec('git add .');
1011 exec('git commit -m "mozcentral baseline"');
1012 };
1013
1014 target.mozcentraldiff = function() {
1015 target.mozcentral();
1016
1017 cd(ROOT_DIR);
1018
1019 echo();
1020 echo('### Creating mozcentral diff');
1021
1022 var MOZCENTRAL_DIFF = BUILD_DIR + 'mozcentral.diff';
1023 if (test('-f', MOZCENTRAL_DIFF))
1024 rm(MOZCENTRAL_DIFF);
1025
1026 var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
1027 if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
1028 echo('mozcentral baseline was not found');
1029 echo('Please build one using "node make mozcentralbaseline"');
1030 exit(1);
1031 }
1032 cd(MOZCENTRAL_BASELINE_DIR);
1033 exec('git reset --hard');
1034 cd(ROOT_DIR); rm('-rf', MOZCENTRAL_BASELINE_DIR + '/*'); // trying to be safe
1035 cd(MOZCENTRAL_BASELINE_DIR);
1036 cp('-Rf', '../mozcentral/*', '.');
1037 exec('git add -A');
1038 exec('git diff --binary --cached --unified=8', {silent: true}).output.
1039 to('../mozcentral.diff');
1040
1041 echo('Result diff can be found at ' + MOZCENTRAL_DIFF);
1042 };
1043
1044 target.mozcentralcheck = function() {
1045 cd(ROOT_DIR);
1046
1047 echo();
1048 echo('### Checking mozcentral changes');
1049
1050 var mcPath = env['MC_PATH'];
1051 if (!mcPath) {
1052 echo('mozilla-central path is not provided.');
1053 echo('Please specify MC_PATH variable');
1054 exit(1);
1055 }
1056 if ((mcPath[0] != '/' && mcPath[0] != '~' && mcPath[1] != ':') ||
1057 !test('-d', mcPath)) {
1058 echo('mozilla-central path is not in absolute form or does not exist.');
1059 exit(1);
1060 }
1061
1062 var MOZCENTRAL_DIFF = BUILD_DIR + 'mozcentral_changes.diff';
1063 if (test('-f', MOZCENTRAL_DIFF)) {
1064 rm(MOZCENTRAL_DIFF);
1065 }
1066
1067 var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
1068 if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
1069 echo('mozcentral baseline was not found');
1070 echo('Please build one using "node make mozcentralbaseline"');
1071 exit(1);
1072 }
1073 cd(MOZCENTRAL_BASELINE_DIR);
1074 exec('git reset --hard');
1075 cd(ROOT_DIR); rm('-rf', MOZCENTRAL_BASELINE_DIR + '/*'); // trying to be safe
1076 cd(MOZCENTRAL_BASELINE_DIR);
1077 mkdir('browser');
1078 cd('browser');
1079 mkdir('-p', 'extensions/pdfjs');
1080 cp('-Rf', mcPath + '/browser/extensions/pdfjs/*', 'extensions/pdfjs');
1081 mkdir('-p', 'locales/en-US/pdfviewer');
1082 cp('-Rf', mcPath + '/browser/locales/en-US/pdfviewer/*',
1083 'locales/en-US/pdfviewer');
1084 // Remove '.DS_Store' and other hidden files
1085 find('.').forEach(function(file) {
1086 if (file.match(/^\.\w|~$/)) {
1087 rm('-f', file);
1088 }
1089 });
1090
1091 cd('..');
1092 exec('git add -A');
1093 var diff = exec('git diff --binary --cached --unified=8',
1094 {silent: true}).output;
1095
1096 if (diff) {
1097 echo('There were changes found at mozilla-central.');
1098 diff.to('../mozcentral_changes.diff');
1099 echo('Result diff can be found at ' + MOZCENTRAL_DIFF);
1100 exit(1);
1101 }
1102
1103 echo('Success: there are no changes at mozilla-central');
1104 };
1105
f6ba384 Artur Adib Using ShellJS
arturadib authored
1106
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
1107 ////////////////////////////////////////////////////////////////////////////////
f6ba384 Artur Adib Using ShellJS
arturadib authored
1108 //
1109 // Other
1110 //
1111
1112 //
1113 // make server
1114 //
1115 target.server = function() {
1116 cd(ROOT_DIR);
1117 echo();
1118 echo('### Starting local server');
1119
1120 cd('test');
ee16090 Yury Delendik Fixes test pdfs MD5; make server does not download
yurydelendik authored
1121 exec(PYTHON_BIN + ' -u test.py --port=8888 --noDownload', {async: true});
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1122 };
f6ba384 Artur Adib Using ShellJS
arturadib authored
1123
1124 //
1125 // make lint
1126 //
1127 target.lint = function() {
1128 cd(ROOT_DIR);
1129 echo();
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
1130 echo('### Linting JS files');
19dbeaa Jon Buckley Issue #2008 - Add jshint
jbuck authored
1131
c4eab85 Jon Buckley Issue #2008 - Fix lint errors for make.js
jbuck authored
1132 var LINT_FILES = ['make.js',
10cdb48 Jon Buckley Issue #2008 - Fix lint errors for external/builder/
jbuck authored
1133 'external/builder/',
c226147 Jon Buckley Issue #2008 - Fix lint errors for external/crlfchecker/
jbuck authored
1134 'external/crlfchecker/',
19dbeaa Jon Buckley Issue #2008 - Add jshint
jbuck authored
1135 'src/',
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
1136 'web/',
1137 'test/driver.js',
1138 'test/reporter.js',
1139 'test/unit/',
1140 'extensions/firefox/',
4a4f570 Andreas Bovens adjusted paths in make.js to reflect chromium instead of chrome
andreasbovens authored
1141 'extensions/chromium/'
19dbeaa Jon Buckley Issue #2008 - Add jshint
jbuck authored
1142 ];
1143
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
1144 var jshintPath = path.normalize('./node_modules/.bin/jshint');
1145 if (!test('-f', jshintPath)) {
1146 echo('jshint is not installed -- installing...');
2c82e72 Mitar Updated to current latest stable version of jshint.
mitar authored
1147 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
1148 }
1149
1150 exit(exec('"' + jshintPath + '" --reporter test/reporter.js ' +
5cf0d8f Yury Delendik Enforces maxlen for jshint
yurydelendik authored
1151 LINT_FILES.join(' ')).code);
cb68adb Yury Delendik Replacing gjslint with jshint; fixing jshint for windows
yurydelendik authored
1152
1153 crlfchecker.checkIfCrlfIsPresent(LINT_FILES);
19dbeaa Jon Buckley Issue #2008 - Add jshint
jbuck authored
1154 };
1155
1156 //
f6ba384 Artur Adib Using ShellJS
arturadib authored
1157 // make clean
1158 //
1159 target.clean = function() {
1160 cd(ROOT_DIR);
1161 echo();
1162 echo('### Cleaning up project builds');
1163
1164 rm('-rf', BUILD_DIR);
30888e9 notmasteryet Exclude make.js from the linting; fixes few lint make.js errors
notmasteryet authored
1165 };
b13798f Kalervo Kujala Add carriage return checks to make.js.
kkujala authored
1166
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1167 //
1168 // make makefile
1169 //
1170 target.makefile = function() {
1171 var makefileContent = 'help:\n\tnode make\n\n';
dc451b0 Yury Delendik Adds .PHONY to Makefile
yurydelendik authored
1172 var targetsNames = [];
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1173 for (var i in target) {
1174 makefileContent += i + ':\n\tnode make ' + i + '\n\n';
dc451b0 Yury Delendik Adds .PHONY to Makefile
yurydelendik authored
1175 targetsNames.push(i);
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1176 }
dc451b0 Yury Delendik Adds .PHONY to Makefile
yurydelendik authored
1177 makefileContent += '.PHONY: ' + targetsNames.join(' ') + '\n';
f4b677a Yury Delendik Generates proxy Makefile
yurydelendik authored
1178 makefileContent.to('Makefile');
1179 };
Something went wrong with that request. Please try again.