From 16d9fa1bf182558e459d4fdd2830d569b4912a9e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 9 Jun 2021 23:47:18 +0200 Subject: [PATCH 1/2] Bundle the license-file for the Liberation fonts in the builds (PR 13517 follow-up) Currently only the Foxit license-file is included, which is most likely just an oversight as far as I can tell. Furthermore, to be able the tell the two license-files apart, the Foxit one is also renamed slightly. --- external/standard_fonts/{LICENSE => LICENSE_FOXIT} | 0 gulpfile.js | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) rename external/standard_fonts/{LICENSE => LICENSE_FOXIT} (100%) diff --git a/external/standard_fonts/LICENSE b/external/standard_fonts/LICENSE_FOXIT similarity index 100% rename from external/standard_fonts/LICENSE rename to external/standard_fonts/LICENSE_FOXIT diff --git a/gulpfile.js b/gulpfile.js index a1d52067e642d..28431c5dd3aad 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -817,7 +817,8 @@ function buildGeneric(defines, dir) { [ "external/standard_fonts/*.pfb", "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE", + "external/standard_fonts/LICENSE_FOXIT", + "external/standard_fonts/LICENSE_LIBERATION", ], { base: "external/standard_fonts", @@ -997,7 +998,8 @@ function buildMinified(defines, dir) { [ "external/standard_fonts/*.pfb", "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE", + "external/standard_fonts/LICENSE_FOXIT", + "external/standard_fonts/LICENSE_LIBERATION", ], { base: "external/standard_fonts", @@ -1243,7 +1245,8 @@ gulp.task( [ "external/standard_fonts/*.pfb", "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE", + "external/standard_fonts/LICENSE_FOXIT", + "external/standard_fonts/LICENSE_LIBERATION", ], { base: "external/standard_fonts", @@ -1345,7 +1348,8 @@ gulp.task( [ "external/standard_fonts/*.pfb", "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE", + "external/standard_fonts/LICENSE_FOXIT", + "external/standard_fonts/LICENSE_LIBERATION", ], { base: "external/standard_fonts", From 8f3f76f8f6785177db505c414f07d391c02d8137 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 9 Jun 2021 23:50:50 +0200 Subject: [PATCH 2/2] [gulpfile.js] Reduce unnecessary duplication when bundling CMap/StandardFont files Rather than repeating the exact same code in multiple `gulp`-tasks, we can extract it into two helper functions instead. --- gulpfile.js | 110 ++++++++++++++++++---------------------------------- 1 file changed, 38 insertions(+), 72 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 28431c5dd3aad..db4c2658da88c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -499,6 +499,26 @@ function createImageDecodersBundle(defines) { .pipe(replaceJSRootName(imageDecodersAMDName, "pdfjsImageDecoders")); } +function createCMapBundle() { + return gulp.src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], { + base: "external/bcmaps", + }); +} + +function createStandardFontBundle() { + return gulp.src( + [ + "external/standard_fonts/*.pfb", + "external/standard_fonts/*.ttf", + "external/standard_fonts/LICENSE_FOXIT", + "external/standard_fonts/LICENSE_LIBERATION", + ], + { + base: "external/standard_fonts", + } + ); +} + function checkFile(filePath) { try { const stat = fs.lstatSync(filePath); @@ -807,24 +827,9 @@ function buildGeneric(defines, dir) { base: "web/", }) .pipe(gulp.dest(dir + "web")), - gulp - .src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], { - base: "external/bcmaps", - }) - .pipe(gulp.dest(dir + "web/cmaps")), - gulp - .src( - [ - "external/standard_fonts/*.pfb", - "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE_FOXIT", - "external/standard_fonts/LICENSE_LIBERATION", - ], - { - base: "external/standard_fonts", - } - ) - .pipe(gulp.dest(dir + "web/standard_fonts")), + createCMapBundle().pipe(gulp.dest(dir + "web/cmaps")), + createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")), + preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")), preprocessCSS("web/viewer.css", "generic", defines, true) .pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)])) @@ -988,24 +993,8 @@ function buildMinified(defines, dir) { base: "web/", }) .pipe(gulp.dest(dir + "web")), - gulp - .src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], { - base: "external/bcmaps", - }) - .pipe(gulp.dest(dir + "web/cmaps")), - gulp - .src( - [ - "external/standard_fonts/*.pfb", - "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE_FOXIT", - "external/standard_fonts/LICENSE_LIBERATION", - ], - { - base: "external/standard_fonts", - } - ) - .pipe(gulp.dest(dir + "web/standard_fonts")), + createCMapBundle().pipe(gulp.dest(dir + "web/cmaps")), + createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")), preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")), preprocessCSS("web/viewer.css", "minified", defines, true) @@ -1235,24 +1224,13 @@ gulp.task( gulp .src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" }) .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")), - gulp - .src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], { - base: "external/bcmaps", - }) - .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/cmaps")), - gulp - .src( - [ - "external/standard_fonts/*.pfb", - "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE_FOXIT", - "external/standard_fonts/LICENSE_LIBERATION", - ], - { - base: "external/standard_fonts", - } - ) - .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/standard_fonts")), + createCMapBundle().pipe( + gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/cmaps") + ), + createStandardFontBundle().pipe( + gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/standard_fonts") + ), + preprocessHTML("web/viewer.html", defines).pipe( gulp.dest(MOZCENTRAL_CONTENT_DIR + "web") ), @@ -1338,24 +1316,12 @@ gulp.task( { base: "web/" } ) .pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")), - gulp - .src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], { - base: "external/bcmaps", - }) - .pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/cmaps")), - gulp - .src( - [ - "external/standard_fonts/*.pfb", - "external/standard_fonts/*.ttf", - "external/standard_fonts/LICENSE_FOXIT", - "external/standard_fonts/LICENSE_LIBERATION", - ], - { - base: "external/standard_fonts", - } - ) - .pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/standard_fonts")), + createCMapBundle().pipe( + gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/cmaps") + ), + createStandardFontBundle().pipe( + gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/standard_fonts") + ), preprocessHTML("web/viewer.html", defines).pipe( gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")