Commit 44bc9184 authored by ben's avatar ben Committed by Commit bot

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=

Review URL: https://codereview.chromium.org/1192973004

Cr-Commit-Position: refs/heads/master@{#29186}
parent d4f70f8c
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
# library. # library.
import os, re, sys, string import os, re, sys, string
import argparse import optparse
import jsmin import jsmin
import bz2 import bz2
import textwrap import textwrap
...@@ -576,25 +576,25 @@ def JS2C(sources, target, native_type, raw_file, startup_blob, emit_js): ...@@ -576,25 +576,25 @@ def JS2C(sources, target, native_type, raw_file, startup_blob, emit_js):
def main(): def main():
parser = argparse.ArgumentParser() parser = optparse.OptionParser()
parser.add_argument("out.cc", parser.add_option("--raw",
help="output filename") help="file to write the processed sources array to.")
parser.add_argument("type", parser.add_option("--startup_blob",
help="type parameter for NativesCollection template " + help="file to write the startup blob to.")
"(see NativeType enum)") parser.add_option("--js",
parser.add_argument("sources.js", help="writes a JS file output instead of a C file",
help="JS internal sources or macros.py.", action="store_true")
nargs="*") parser.set_usage("""js2c out.cc type sources.js ...
parser.add_argument("--raw", out.cc: C code to be generated.
help="file to write the processed sources array to.") type: type parameter for NativesCollection template.
parser.add_argument("--startup_blob", sources.js: JS internal sources or macros.py.""")
help="file to write the startup blob to.") (options, args) = parser.parse_args()
parser.add_argument("--js", JS2C(args[2:],
help="writes a JS file output instead of a C file", args[0],
action="store_true") args[1],
options.raw,
args = vars(parser.parse_args()) options.startup_blob,
JS2C(args["sources.js"], args["out.cc"], args["type"], args["raw"], args["startup_blob"], args["js"]) options.js)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment