OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2012 The Chromium Authors. All rights reserved. | 2 # Copyright 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Format for the JSON schema file: | 6 # Format for the JSON schema file: |
7 # { | 7 # { |
8 # "type_name": "DesiredCStructName", | 8 # "type_name": "DesiredCStructName", |
9 # "headers": [ // Optional list of headers to be included by the .h. | 9 # "headers": [ // Optional list of headers to be included by the .h. |
10 # "path/to/header.h" | 10 # "path/to/header.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 # } | 47 # } |
48 | 48 |
49 import json | 49 import json |
50 from datetime import datetime | 50 from datetime import datetime |
51 import os.path | 51 import os.path |
52 import sys | 52 import sys |
53 import optparse | 53 import optparse |
54 import re | 54 import re |
55 _script_path = os.path.realpath(__file__) | 55 _script_path = os.path.realpath(__file__) |
56 | 56 |
57 sys.path.insert(0, os.path.normpath(_script_path + "/../../")) | 57 sys.path.insert(0, os.path.normpath(_script_path + "/../../json_comment_eater")) |
58 try: | 58 try: |
59 import json_comment_eater | 59 import json_comment_eater |
60 finally: | 60 finally: |
61 sys.path.pop(0) | 61 sys.path.pop(0) |
62 | 62 |
63 import struct_generator | 63 import struct_generator |
64 import element_generator | 64 import element_generator |
65 | 65 |
66 HEAD = """// Copyright %d The Chromium Authors. All rights reserved. | 66 HEAD = """// Copyright %d The Chromium Authors. All rights reserved. |
67 // Use of this source code is governed by a BSD-style license that can be | 67 // Use of this source code is governed by a BSD-style license that can be |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 basepath = os.path.normpath(opts.destbase) | 202 basepath = os.path.normpath(opts.destbase) |
203 else: | 203 else: |
204 basepath = '' | 204 basepath = '' |
205 | 205 |
206 schema = _Load(opts.schema) | 206 schema = _Load(opts.schema) |
207 description = _Load(description_filename) | 207 description = _Load(description_filename) |
208 | 208 |
209 head = HEAD % (datetime.now().year, opts.schema, description_filename) | 209 head = HEAD % (datetime.now().year, opts.schema, description_filename) |
210 _GenerateH(basepath, output_root, head, opts.namespace, schema, description) | 210 _GenerateH(basepath, output_root, head, opts.namespace, schema, description) |
211 _GenerateCC(basepath, output_root, head, opts.namespace, schema, description) | 211 _GenerateCC(basepath, output_root, head, opts.namespace, schema, description) |
OLD | NEW |