Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: tools/grit/grit/tool/build.py

Issue 2179033002: Strip comments and whitespace from javascript resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove all compiler options that cause code tranformation Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/grit/grit/tool/build.py
diff --git a/tools/grit/grit/tool/build.py b/tools/grit/grit/tool/build.py
index 51d33415b99cf9c4003f1eaef33770cb373137b1..bc8cd78f4f0c452dacafa1008526d14369c7197d 100755
--- a/tools/grit/grit/tool/build.py
+++ b/tools/grit/grit/tool/build.py
@@ -21,6 +21,7 @@ from grit.node import include
from grit.node import message
from grit.node import structure
from grit.tool import interface
+from grit.format import minifier
Lei Zhang 2016/08/02 16:47:48 alphabetical order please
aberent 2016/08/02 20:27:42 Done.
# It would be cleaner to have each module register itself, but that would
@@ -126,6 +127,12 @@ Options:
generated will depend on a stampfile instead of the first
output in the input .grd file.
+ --js-minifier A command to run to minify Javascript. If not set then
Lei Zhang 2016/08/02 16:47:48 s/run to/run the/
aberent 2016/08/02 20:27:42 Done.
+ Javascript won't be minified. The command should read the
+ original Javascript from standard input, and output the
+ minified Javascript to standard output. A non-zero exit
+ status will be taken as indicating failure.
+
Conditional inclusion of resources only affects the output of files which
control which resources get linked into a binary, e.g. it affects .rc files
meant for compilation but it does not affect resource header files (that define
@@ -148,6 +155,7 @@ are exported to translation interchange files (e.g. XMB files), etc.
output_all_resource_defines = None
write_only_new = False
depend_on_stamp = False
+ js_minifier = None
replace_ellipsis = True
(own_opts, args) = getopt.getopt(args, 'a:o:D:E:f:w:t:h:',
('depdir=','depfile=','assert-file-list=',
@@ -155,6 +163,7 @@ are exported to translation interchange files (e.g. XMB files), etc.
'no-output-all-resource-defines',
'no-replace-ellipsis',
'depend-on-stamp',
+ 'js-minifier=',
'write-only-new='))
for (key, val) in own_opts:
if key == '-a':
@@ -195,6 +204,8 @@ are exported to translation interchange files (e.g. XMB files), etc.
write_only_new = val != '0'
elif key == '--depend-on-stamp':
depend_on_stamp = True
+ elif key == '--js-minifier':
+ js_minifier = val
if len(args):
print 'This tool takes no tool-specific arguments.'
@@ -214,6 +225,9 @@ are exported to translation interchange files (e.g. XMB files), etc.
whitelist_contents = util.ReadFile(whitelist_filename, util.RAW_TEXT)
self.whitelist_names.update(whitelist_contents.strip().split('\n'))
+ if js_minifier:
+ minifier.SetJsMinifier(js_minifier)
+
self.write_only_new = write_only_new
self.res = grd_reader.Parse(opts.input,

Powered by Google App Engine
This is Rietveld 408576698