- doxygen styling added - CDC -> ACM refactor - type refactoring - examples categorized - flatUSB_config.h examples added
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import json
|
|
from sys import argv
|
|
|
|
import Descriptor as desc
|
|
|
|
import StructGenerator as sg
|
|
from itertools import chain
|
|
|
|
from ConfigGenerator import ConfigGenerator
|
|
|
|
# print welcome message
|
|
print("----\nflatUSB descriptor generator by Epagris\n----\n")
|
|
|
|
# check number of parameters
|
|
if len(argv) < 3:
|
|
print("Insufficient parameters!\nCorrect usage: `main.py <input json> <target directory>`\nExiting.")
|
|
exit(0)
|
|
|
|
# fetch USB settings
|
|
usb_config_file_name = argv[1]
|
|
usb_target_dir = argv[2]
|
|
|
|
# print input and output parameters
|
|
print("Input JSON: ", usb_config_file_name)
|
|
print("Target directory: ", usb_target_dir)
|
|
|
|
with open(usb_config_file_name, 'r') as usb_config_file:
|
|
usb_config_data = usb_config_file.read()
|
|
usb_config = json.loads(usb_config_data)
|
|
|
|
# process "misc"
|
|
if "misc" in usb_config:
|
|
misc = usb_config["misc"]
|
|
|
|
# mutable descriptors
|
|
if "mutable_descriptors" in misc:
|
|
if misc["mutable_descriptors"]:
|
|
desc.Descriptor.QUALIFIERS = ""
|
|
|
|
# generate config
|
|
cfggen = ConfigGenerator(usb_config)
|
|
cfggen.generate(usb_target_dir)
|
|
|
|
# print complete message
|
|
print("Descriptor generation complete!") |