Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: remove minifying logic #6636

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions tools/js2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,15 @@
# library.

import os
from os.path import dirname
import re
import sys
import string

sys.path.append(dirname(__file__) + "/../deps/v8/tools");
import jsmin


def ToCArray(filename, lines):
return ','.join(str(ord(c)) for c in lines)


def CompressScript(lines, do_jsmin):
# If we're not expecting this code to be user visible, we can run it through
# a more aggressive minifier.
if do_jsmin:
minifier = JavaScriptMinifier()
return minifier.JSMinify(lines)

# Remove stuff from the source that we don't want to appear when
# people print the source code using Function.prototype.toString().
# Note that we could easily compress the scripts mode but don't
# since we want it to remain readable.
#lines = re.sub('//.*\n', '\n', lines) # end-of-line comments
#lines = re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', lines) # comments.
#lines = re.sub('\s+\n+', '\n', lines) # trailing whitespace
return lines


def ReadFile(filename):
file = open(filename, "rt")
try:
Expand Down Expand Up @@ -264,11 +243,9 @@ def JS2C(source, target):
for s in modules:
delay = str(s).endswith('-delay.js')
lines = ReadFile(str(s))
do_jsmin = lines.find('// jsminify this file, js2c: jsmin') != -1

lines = ExpandConstants(lines, consts)
lines = ExpandMacros(lines, macros)
lines = CompressScript(lines, do_jsmin)
data = ToCArray(s, lines)

# On Windows, "./foo.bar" in the .gyp file is passed as "foo.bar"
Expand Down