OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import itertools | 5 import itertools |
6 import optparse | 6 import optparse |
7 import re | 7 import re |
8 | 8 |
9 VENDOR_PATTERN = re.compile("^(?P<id>[0-9a-fA-F]{4})\s+(?P<name>.+)$") | 9 VENDOR_PATTERN = re.compile("^(?P<id>[0-9a-fA-F]{4})\s+(?P<name>.+)$") |
10 PRODUCT_PATTERN = re.compile("^\t(?P<id>[0-9a-fA-F]{4})\s+(?P<name>.+)$") | 10 PRODUCT_PATTERN = re.compile("^\t(?P<id>[0-9a-fA-F]{4})\s+(?P<name>.+)$") |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 parser.add_option("-i", "--input", help="Path to usb.ids") | 84 parser.add_option("-i", "--input", help="Path to usb.ids") |
85 parser.add_option("-o", "--output", help="Output file path") | 85 parser.add_option("-o", "--output", help="Output file path") |
86 | 86 |
87 (opts, args) = parser.parse_args() | 87 (opts, args) = parser.parse_args() |
88 table = ParseTable(opts.input) | 88 table = ParseTable(opts.input) |
89 | 89 |
90 output = """// Generated from %s | 90 output = """// Generated from %s |
91 #ifndef GENERATED_USB_IDS_H_ | 91 #ifndef GENERATED_USB_IDS_H_ |
92 #define GENERATED_USB_IDS_H_ | 92 #define GENERATED_USB_IDS_H_ |
93 | 93 |
| 94 #include <stddef.h> |
| 95 |
94 #include "device/usb/usb_ids.h" | 96 #include "device/usb/usb_ids.h" |
95 | 97 |
96 namespace device { | 98 namespace device { |
97 | 99 |
98 """ % (opts.input) | 100 """ % (opts.input) |
99 output += GenerateDeviceDefinitions(table) | 101 output += GenerateDeviceDefinitions(table) |
100 output += GenerateVendorDefinitions(table) | 102 output += GenerateVendorDefinitions(table) |
101 output += """ | 103 output += """ |
102 | 104 |
103 } // namespace device | 105 } // namespace device |
104 | 106 |
105 #endif // GENERATED_USB_IDS_H_ | 107 #endif // GENERATED_USB_IDS_H_ |
106 """ | 108 """ |
107 | 109 |
108 output_file = open(opts.output, "w+") | 110 output_file = open(opts.output, "w+") |
109 output_file.write(output) | 111 output_file.write(output) |
110 output_file.close() | 112 output_file.close() |
OLD | NEW |