forked from mozilla/pdf.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake.js
More file actions
330 lines (279 loc) · 6.4 KB
/
Copy pathmake.js
File metadata and controls
330 lines (279 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-env node, shelljs */
'use strict';
try {
require('shelljs/make');
} catch (e) {
throw new Error('ShellJS is not installed. Run "npm install" to install ' +
'all dependencies.');
}
var ROOT_DIR = __dirname + '/', // absolute path to project's root
BUILD_DIR = 'build/';
function execGulp(cmd) {
var result = exec('gulp ' + cmd);
if (result.code) {
echo('ERROR: gulp exited with ' + result.code);
exit(result.code);
}
}
//
// make all
//
target.all = function() {
execGulp('default');
};
////////////////////////////////////////////////////////////////////////////////
//
// Production stuff
//
//
// make generic
// Builds the generic production viewer that should be compatible with most
// modern HTML5 browsers.
//
target.generic = function() {
execGulp('generic');
};
target.components = function() {
execGulp('components');
};
target.jsdoc = function() {
execGulp('jsdoc');
};
//
// make web
// Generates the website for the project, by checking out the gh-pages branch
// underneath the build directory, and then moving the various viewer files
// into place.
//
target.web = function() {
execGulp('web');
};
target.dist = function() {
execGulp('dist');
};
target.publish = function() {
execGulp('publish');
};
//
// make locale
// Creates localized resources for the viewer and extension.
//
target.locale = function() {
execGulp('locale');
};
//
// make cmaps
// Compresses cmap files. Ensure that Adobe cmap download and uncompressed at
// ./external/cmaps location.
//
target.cmaps = function () {
execGulp('cmaps');
};
//
// make bundle
// Bundles all source files into one wrapper 'pdf.js' file, in the given order.
//
target.bundle = function(args) {
execGulp('bundle');
};
//
// make singlefile
// Concatenates pdf.js and pdf.worker.js into one big pdf.combined.js, and
// flags the script loader to not attempt to load the separate worker JS file.
//
target.singlefile = function() {
execGulp('singlefile');
};
//
// make minified
// Builds the minified production viewer that should be compatible with most
// modern HTML5 browsers.
//
target.minified = function() {
execGulp('minified');
};
////////////////////////////////////////////////////////////////////////////////
//
// Extension stuff
//
//
// make extension
//
target.extension = function() {
execGulp('extension');
};
target.buildnumber = function() {
execGulp('buildnumber');
};
//
// make firefox
//
target.firefox = function() {
execGulp('firefox');
};
//
// make mozcentral
//
target.mozcentral = function() {
execGulp('mozcentral');
};
//
// make chrome
//
target.chromium = function() {
execGulp('chromium');
};
////////////////////////////////////////////////////////////////////////////////
//
// Test stuff
//
//
// make test
//
target.test = function() {
execGulp('test');
};
//
// make bottest
// (Special tests for the Github bot)
//
target.bottest = function() {
execGulp('bottest');
};
//
// make browsertest
//
target.browsertest = function(options) {
if (options && options.noreftest) {
execGulp('browsertest-noreftest');
} else {
execGulp('browsertest');
}
};
//
// make unittest
//
target.unittest = function(options, callback) {
execGulp('unittest');
};
//
// make fonttest
//
target.fonttest = function(options, callback) {
execGulp('fonttest');
};
//
// make botmakeref
//
target.botmakeref = function() {
execGulp('botmakeref');
};
////////////////////////////////////////////////////////////////////////////////
//
// Baseline operation
//
target.baseline = function() {
execGulp('baseline');
};
target.mozcentralbaseline = function() {
target.baseline();
cd(ROOT_DIR);
echo();
echo('### Creating mozcentral baseline environment');
var BASELINE_DIR = BUILD_DIR + 'baseline';
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
if (test('-d', MOZCENTRAL_BASELINE_DIR)) {
rm('-rf', MOZCENTRAL_BASELINE_DIR);
}
cd(BASELINE_DIR);
if (test('-d', 'build')) {
rm('-rf', 'build');
}
exec('node make mozcentral');
cd(ROOT_DIR);
mkdir(MOZCENTRAL_BASELINE_DIR);
cp('-Rf', BASELINE_DIR + '/build/mozcentral/*', MOZCENTRAL_BASELINE_DIR);
// fixing baseline
if (test('-f', MOZCENTRAL_BASELINE_DIR +
'/browser/extensions/pdfjs/PdfStreamConverter.js')) {
rm(MOZCENTRAL_BASELINE_DIR +
'/browser/extensions/pdfjs/PdfStreamConverter.js');
}
cd(MOZCENTRAL_BASELINE_DIR);
exec('git init');
exec('git add .');
exec('git commit -m "mozcentral baseline"');
};
target.mozcentraldiff = function() {
target.mozcentral();
cd(ROOT_DIR);
echo();
echo('### Creating mozcentral diff');
var MOZCENTRAL_DIFF = BUILD_DIR + 'mozcentral.diff';
if (test('-f', MOZCENTRAL_DIFF)) {
rm(MOZCENTRAL_DIFF);
}
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline';
if (!test('-d', MOZCENTRAL_BASELINE_DIR)) {
echo('mozcentral baseline was not found');
echo('Please build one using "gulp mozcentralbaseline"');
exit(1);
}
cd(MOZCENTRAL_BASELINE_DIR);
exec('git reset --hard');
cd(ROOT_DIR); rm('-rf', MOZCENTRAL_BASELINE_DIR + '/*'); // trying to be safe
cd(MOZCENTRAL_BASELINE_DIR);
cp('-Rf', '../mozcentral/*', '.');
exec('git add -A');
exec('git diff --binary --cached --unified=8', {silent: true}).output.
to('../mozcentral.diff');
echo('Result diff can be found at ' + MOZCENTRAL_DIFF);
};
////////////////////////////////////////////////////////////////////////////////
//
// Other
//
//
// make server
//
target.server = function () {
execGulp('server');
};
//
// make lint
//
target.lint = function() {
execGulp('lint');
};
//
// make clean
//
target.clean = function() {
execGulp('clean');
};
//
// make makefile
//
target.makefile = function () {
execGulp('makefile');
};
//
// make importl10n
//
target.importl10n = function() {
execGulp('importl10n');
};