Ole Troan | 5c318c7 | 2020-05-05 12:23:47 +0200 | [diff] [blame] | 1 | # CRC generation |
| 2 | import json |
| 3 | |
Paul Vinciguerra | 9046e44 | 2020-11-20 23:10:09 -0500 | [diff] [blame] | 4 | process_imports = True |
| 5 | |
| 6 | |
Ole Troan | 5c318c7 | 2020-05-05 12:23:47 +0200 | [diff] [blame] | 7 | # |
| 8 | # Plugin entry point |
| 9 | # |
| 10 | def run(args, input_filename, s): |
| 11 | j = {} |
| 12 | major = 0 |
Ole Troan | ab9f573 | 2020-12-15 10:19:25 +0100 | [diff] [blame] | 13 | minor = 0 |
| 14 | patch = 0 |
Ole Troan | 5c318c7 | 2020-05-05 12:23:47 +0200 | [diff] [blame] | 15 | if 'version' in s['Option']: |
| 16 | v = s['Option']['version'] |
| 17 | (major, minor, patch) = v.split('.') |
Ole Troan | ab9f573 | 2020-12-15 10:19:25 +0100 | [diff] [blame] | 18 | j['_version'] = {'major': major, 'minor': minor, 'patch': patch} |
Ole Troan | 5c318c7 | 2020-05-05 12:23:47 +0200 | [diff] [blame] | 19 | for t in s['Define']: |
| 20 | j[t.name] = {'crc': f'{t.crc:#08x}', 'version': major, |
| 21 | 'options': t.options} |
| 22 | return json.dumps(j, indent=4, separators=(',', ': ')) |