[Pkg-javascript-commits] [pdf.js] 01/161: Adds make minified command
David Prévot
taffit at moszumanska.debian.org
Sat Apr 19 14:16:11 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 2b298a7a34e941ac414ce9c570f31869d96ef851
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Fri Jan 17 10:50:54 2014 -0600
Adds make minified command
---
make.js | 79 ++++++++++++++++++++++++++++++++++++++++
web/viewer-snippet-minified.html | 3 ++
web/viewer.html | 8 +++-
3 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/make.js b/make.js
index f20ec66..065a679 100644
--- a/make.js
+++ b/make.js
@@ -38,6 +38,7 @@ var ROOT_DIR = __dirname + '/', // absolute path to project's root
LOCALE_SRC_DIR = 'l10n/',
GH_PAGES_DIR = BUILD_DIR + 'gh-pages/',
GENERIC_DIR = BUILD_DIR + 'generic/',
+ MINIFIED_DIR = BUILD_DIR + 'minified/',
REPO = 'git at github.com:mozilla/pdf.js.git',
PYTHON_BIN = 'python2.7',
MOZCENTRAL_PREF_PREFIX = 'pdfjs',
@@ -53,6 +54,7 @@ var DEFINES = {
MOZCENTRAL: false,
B2G: false,
CHROME: false,
+ MINIFIED: false,
SINGLE_FILE: false
};
@@ -390,6 +392,83 @@ function cleanupJSSource(file) {
content.to(file);
}
+//
+// make minified
+// Builds the minified production viewer that should be compatible with most
+// modern HTML5 browsers. Requires Google Closure Compiler.
+//
+target.minified = function() {
+ var compilerPath = process.env['CLOSURE_COMPILER'];
+ if (!compilerPath) {
+ echo('### Closure Compiler is not set. Specify CLOSURE_COMPILER variable');
+ exit(1);
+ }
+
+ target.bundle({});
+ target.locale();
+
+ cd(ROOT_DIR);
+ echo();
+ echo('### Creating minified viewer');
+
+ rm('-rf', MINIFIED_DIR);
+ mkdir('-p', MINIFIED_DIR);
+ mkdir('-p', MINIFIED_DIR + BUILD_DIR);
+ mkdir('-p', MINIFIED_DIR + '/web');
+
+ var defines = builder.merge(DEFINES, {GENERIC: true, MINIFIED: true});
+
+ var setup = {
+ defines: defines,
+ copy: [
+ [COMMON_WEB_FILES, MINIFIED_DIR + '/web'],
+ ['web/viewer.css', MINIFIED_DIR + '/web'],
+ ['web/compressed.tracemonkey-pldi-09.pdf', MINIFIED_DIR + '/web'],
+ ['web/locale', MINIFIED_DIR + '/web']
+ ],
+ preprocess: [
+ [BUILD_TARGETS, MINIFIED_DIR + BUILD_DIR],
+ [COMMON_WEB_FILES_PREPROCESS, MINIFIED_DIR + '/web']
+ ]
+ };
+ builder.build(setup);
+
+ var viewerFiles = [
+ 'web/compatibility.js',
+ 'external/webL10n/l10n.js',
+ MINIFIED_DIR + BUILD_DIR + 'pdf.js',
+ MINIFIED_DIR + '/web/viewer.js'
+ ];
+ var cmdPrefix = 'java -jar \"' + compilerPath + '\" ' +
+ '--language_in ECMASCRIPT5 ' +
+ '--warning_level QUIET ' +
+ '--compilation_level SIMPLE_OPTIMIZATIONS ';
+
+ echo();
+ echo('### Minifying js files');
+
+ exec(cmdPrefix + viewerFiles.map(function(s) {
+ return '--js \"' + s + '\"';
+ }).join(' ') +
+ ' --js_output_file \"' + MINIFIED_DIR + '/web/pdf.viewer.js\"');
+ exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.js' + '\" ' +
+ '--js_output_file \"' + MINIFIED_DIR + '/build/pdf.min.js' + '\"');
+ exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.worker.js' + '\" ' +
+ '--js_output_file \"' + MINIFIED_DIR + '/build/pdf.worker.min.js' + '\"');
+
+ echo();
+ echo('### Cleaning js files');
+
+ rm(MINIFIED_DIR + '/web/viewer.js');
+ rm(MINIFIED_DIR + '/web/debugger.js');
+ rm(MINIFIED_DIR + '/build/pdf.js');
+ rm(MINIFIED_DIR + '/build/pdf.worker.js');
+ mv(MINIFIED_DIR + '/build/pdf.min.js',
+ MINIFIED_DIR + '/build/pdf.js');
+ mv(MINIFIED_DIR + '/build/pdf.worker.min.js',
+ MINIFIED_DIR + '/build/pdf.worker.js');
+};
+
////////////////////////////////////////////////////////////////////////////////
//
// Extension stuff
diff --git a/web/viewer-snippet-minified.html b/web/viewer-snippet-minified.html
new file mode 100644
index 0000000..0d011d3
--- /dev/null
+++ b/web/viewer-snippet-minified.html
@@ -0,0 +1,3 @@
+<!-- This snippet is used in production, see Makefile -->
+<link rel="resource" type="application/l10n" href="locale/locale.properties"/>
+<script type="text/javascript" src="pdf.viewer.js"></script>
diff --git a/web/viewer.html b/web/viewer.html
index 5c9e8a8..ec887e8 100644
--- a/web/viewer.html
+++ b/web/viewer.html
@@ -35,7 +35,7 @@ limitations under the License.
<link rel="resource" type="application/l10n" href="locale/locale.properties"/>
<!--#endif-->
-<!--#if !(FIREFOX || MOZCENTRAL || CHROME)-->
+<!--#if !(FIREFOX || MOZCENTRAL || CHROME || MINIFIED)-->
<script type="text/javascript" src="compatibility.js"></script>
<!--#endif-->
@@ -56,7 +56,7 @@ limitations under the License.
<script type="text/javascript">PDFJS.workerSrc = '../src/worker_loader.js';</script>
<!--#endif-->
-<!--#if GENERIC -->
+<!--#if (GENERIC && !MINIFIED) -->
<!--#include viewer-snippet.html-->
<!--#endif-->
@@ -79,8 +79,12 @@ limitations under the License.
<script type="text/javascript" src="hand_tool.js"></script>
<!--#endif-->
+<!--#if !MINIFIED -->
<script type="text/javascript" src="debugger.js"></script>
<script type="text/javascript" src="viewer.js"></script>
+<!--#else-->
+<!--#include viewer-snippet-minified.html-->
+<!--#endif-->
</head>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list