Reviewers: Michael Achenbach, domenic,

Description:
Use optparse in js2c.py for python compatibility

Without this change, V8 won't build on RHEL/CentOS 6 because the distro
python is too old to know about the argparse module.

Can this commit be cherry-picked to the 4.4 branch?  It should apply
cleanly.

BUG=

Please review this at https://codereview.chromium.org/1192973004/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+20, -20 lines):
  M tools/js2c.py


Index: tools/js2c.py
diff --git a/tools/js2c.py b/tools/js2c.py
index f5c28440994c0f8abccef6a2d0f0699912a108b5..b5436f90bbb6d47443b5537febe61624800b5df9 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -32,7 +32,7 @@
 # library.

 import os, re, sys, string
-import argparse
+import optparse
 import jsmin
 import bz2
 import textwrap
@@ -576,25 +576,25 @@ def JS2C(sources, target, native_type, raw_file, startup_blob, emit_js):


 def main():
-  parser = argparse.ArgumentParser()
-  parser.add_argument("out.cc",
-                      help="output filename")
-  parser.add_argument("type",
- help="type parameter for NativesCollection template " +
-                           "(see NativeType enum)")
-  parser.add_argument("sources.js",
-                      help="JS internal sources or macros.py.",
-                      nargs="*")
-  parser.add_argument("--raw",
-                      help="file to write the processed sources array to.")
-  parser.add_argument("--startup_blob",
-                      help="file to write the startup blob to.")
-  parser.add_argument("--js",
-                      help="writes a JS file output instead of a C file",
-                      action="store_true")
-
-  args = vars(parser.parse_args())
- JS2C(args["sources.js"], args["out.cc"], args["type"], args["raw"], args["startup_blob"], args["js"])
+  parser = optparse.OptionParser()
+  parser.add_option("--raw",
+                    help="file to write the processed sources array to.")
+  parser.add_option("--startup_blob",
+                    help="file to write the startup blob to.")
+  parser.add_option("--js",
+                    help="writes a JS file output instead of a C file",
+                    action="store_true")
+  parser.set_usage("""js2c out.cc type sources.js ...
+        out.cc: C code to be generated.
+        type: type parameter for NativesCollection template.
+        sources.js: JS internal sources or macros.py.""")
+  (options, args) = parser.parse_args()
+  JS2C(args[2:],
+       args[0],
+       args[1],
+       options.raw,
+       options.startup_blob,
+       options.js)


 if __name__ == "__main__":


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to