diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 23:57:24 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 23:57:24 +0000 |
commit | 367f8ea350e8aac8368002b78456e3c61f6a2cd1 (patch) | |
tree | 7d57e5032b0288f2468f0bda7a672c7963eb34ea /third_party/jstemplate/compile.py | |
parent | 6afd6af9cf372e1ef691a0a106772ab5db391bce (diff) | |
download | chromium_src-367f8ea350e8aac8368002b78456e3c61f6a2cd1.zip chromium_src-367f8ea350e8aac8368002b78456e3c61f6a2cd1.tar.gz chromium_src-367f8ea350e8aac8368002b78456e3c61f6a2cd1.tar.bz2 |
Move jstemplate from chrome/third_party to third_party.
All third party libraries should be in third_party.
The presubmit check complains about jstemplate's README.chromium
being nonstandard; I will fix that in a follow-up.
The interesting changes are to the .grd file and the .py file.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6901102
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83452 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/jstemplate/compile.py')
-rwxr-xr-x | third_party/jstemplate/compile.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/third_party/jstemplate/compile.py b/third_party/jstemplate/compile.py new file mode 100755 index 0000000..3d16d96 --- /dev/null +++ b/third_party/jstemplate/compile.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# A python script that combines the javascript files needed by jstemplate into +# a single file. + +import httplib +import urllib + +srcs ="util.js jsevalcontext.js jstemplate.js exports.js".split() +out = "jstemplate_compiled.js" + +# Wrap the output in an anonymous function to prevent poluting the global +# namespace. +output_wrapper = "(function(){%s})()" + +# Define the parameters for the POST request and encode them in a URL-safe +# format. See http://code.google.com/closure/compiler/docs/api-ref.html for API +# reference. +params = urllib.urlencode( + map(lambda src: ('js_code', file(src).read()), srcs) + + [ + ('compilation_level', 'ADVANCED_OPTIMIZATIONS'), + ('output_format', 'text'), + ('output_info', 'compiled_code'), + ]) + +# Always use the following value for the Content-type header. +headers = {'Content-type': 'application/x-www-form-urlencoded'} +conn = httplib.HTTPConnection('closure-compiler.appspot.com') +conn.request('POST', '/compile', params, headers) +response = conn.getresponse() +out_file = file(out, 'w') +out_file.write(output_wrapper % response.read()) +out_file.close() +conn.close() |