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

Unified Diff: webkit/build/rule_gperf.py

Issue 27158: Import .gyp files into the Chromium tree (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 years, 10 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
« no previous file with comments | « webkit/build/rule_bison.py ('k') | webkit/tools/test_shell/test_shell.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/build/rule_gperf.py
===================================================================
--- webkit/build/rule_gperf.py (revision 0)
+++ webkit/build/rule_gperf.py (revision 0)
@@ -0,0 +1,54 @@
+#!/usr/bin/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.
+
+# usage: rule_gperf.py INPUT_FILE OUTPUT_DIR
+# INPUT_FILE is a path to DocTypeStrings.gperf, HTMLEntityNames.gperf, or
+# ColorData.gperf.
+# OUTPUT_DIR is where the gperf-generated .cpp file should be placed. Because
+# some users want a .c file instead of a .cpp file, the .cpp file is copied
+# to .c when done.
+
+import posixpath
+import shutil
+import subprocess
+import sys
+
+assert len(sys.argv) == 3
+
+input_file = sys.argv[1]
+output_dir = sys.argv[2]
+
+gperf_commands = {
+ 'DocTypeStrings.gperf': [
+ '-CEot', '-L', 'ANSI-C', '-k*', '-N', 'findDoctypeEntry',
+ '-F', ',PubIDInfo::eAlmostStandards,PubIDInfo::eAlmostStandards'
+ ],
+ 'HTMLEntityNames.gperf': [
+ '-a', '-L', 'ANSI-C', '-C', '-G', '-c', '-o', '-t', '-k*',
+ '-N', 'findEntity', '-D', '-s', '2'
+ ],
+ 'ColorData.gperf': [
+ '-CDEot', '-L', 'ANSI-C', '-k*', '-N', 'findColor', '-D', '-s', '2'
+ ],
+}
+
+input_name = posixpath.basename(input_file)
+assert input_name in gperf_commands
+
+(input_root, input_ext) = posixpath.splitext(input_name)
+output_cpp = posixpath.join(output_dir, input_root + '.cpp')
+
+command = ['gperf', '--output-file', output_cpp]
+command.extend(gperf_commands[input_name])
+command.append(input_file)
+
+# Do it. check_call is new in 2.5, so simulate its behavior with call and
+# assert.
+return_code = subprocess.call(command)
+assert return_code == 0
+
+output_c = posixpath.join(output_dir, input_root + '.c')
+shutil.copyfile(output_cpp, output_c)
Property changes on: webkit/build/rule_gperf.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
« no previous file with comments | « webkit/build/rule_bison.py ('k') | webkit/tools/test_shell/test_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698