OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 source_files = sorted(source_files, | 424 source_files = sorted(source_files, |
425 lambda l,r: IsDebuggerFile(r) - IsDebuggerFile(l)) | 425 lambda l,r: IsDebuggerFile(r) - IsDebuggerFile(l)) |
426 | 426 |
427 source_files_and_contents = [(f, ReadFile(f)) for f in source_files] | 427 source_files_and_contents = [(f, ReadFile(f)) for f in source_files] |
428 | 428 |
429 # Have a single not-quite-empty source file if there are none present; | 429 # Have a single not-quite-empty source file if there are none present; |
430 # otherwise you get errors trying to compile an empty C++ array. | 430 # otherwise you get errors trying to compile an empty C++ array. |
431 # It cannot be empty (or whitespace, which gets trimmed to empty), as | 431 # It cannot be empty (or whitespace, which gets trimmed to empty), as |
432 # the deserialization code assumes each file is nonempty. | 432 # the deserialization code assumes each file is nonempty. |
433 if not source_files_and_contents: | 433 if not source_files_and_contents: |
434 source_files_and_contents = [("dummy.js", "void 0;")] | 434 source_files_and_contents = [("dummy.js", "(function() {})")] |
435 | 435 |
436 result = Sources() | 436 result = Sources() |
437 | 437 |
438 for (source, contents) in source_files_and_contents: | 438 for (source, contents) in source_files_and_contents: |
439 try: | 439 try: |
440 lines = filters(contents) | 440 lines = filters(contents) |
441 except Error as e: | 441 except Error as e: |
442 raise Error("In file %s:\n%s" % (source, str(e))) | 442 raise Error("In file %s:\n%s" % (source, str(e))) |
443 | 443 |
444 result.modules.append(lines) | 444 result.modules.append(lines) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 parser.add_argument("--js", | 592 parser.add_argument("--js", |
593 help="writes a JS file output instead of a C file", | 593 help="writes a JS file output instead of a C file", |
594 action="store_true") | 594 action="store_true") |
595 | 595 |
596 args = vars(parser.parse_args()) | 596 args = vars(parser.parse_args()) |
597 JS2C(args["sources.js"], args["out.cc"], args["type"], args["raw"], args["star
tup_blob"], args["js"]) | 597 JS2C(args["sources.js"], args["out.cc"], args["type"], args["raw"], args["star
tup_blob"], args["js"]) |
598 | 598 |
599 | 599 |
600 if __name__ == "__main__": | 600 if __name__ == "__main__": |
601 main() | 601 main() |
OLD | NEW |