auto-formatted target.json

pull/1830/head
Jimmy Brisson 2016-06-01 14:37:49 -05:00
parent ca8ae5c5d6
commit 76e6c885a2
2 changed files with 36 additions and 52 deletions

View File

@ -37,9 +37,7 @@
},
"LPCTarget": {
"inherits": ["Target"],
"post_binary_hook": {
"function": "LPCTargetCode.lpc_patch"
},
"post_binary_hook": {"function": "LPCTargetCode.lpc_patch"},
"public": false
},
"LPC11C24": {
@ -514,12 +512,12 @@
"core": "Cortex-M0+",
"extra_labels": ["Freescale", "KSDK2_MCUS", "FRDM"],
"macros": ["CPU_MKL27Z64VLH4", "FSL_RTOS_MBED"],
"supported_toolchains": ["ARM","GCC_ARM","IAR"],
"supported_toolchains": ["ARM", "GCC_ARM", "IAR"],
"supported_form_factors": ["ARDUINO"],
"is_disk_virtual": true,
"default_toolchain": "ARM",
"detect_code": ["0261"],
"progen_target": {"target":"frdm-kl27z"}
"progen_target": {"target": "frdm-kl27z"}
},
"K64F": {
"supported_form_factors": ["ARDUINO"],
@ -550,7 +548,7 @@
"is_disk_virtual": true,
"default_toolchain": "ARM",
"detect_code": ["0214"],
"progen": {"target":"hexiwear-k64f"}
"progen": {"target": "hexiwear-k64f"}
},
"NUCLEO_F030R8": {
"supported_form_factors": ["ARDUINO", "MORPHO"],
@ -741,7 +739,7 @@
"default_toolchain": "uARM",
"supported_form_factors": ["ARDUINO"],
"detect_code": ["0790"],
"progen": {"target":"nucleo-l031k6"}
"progen": {"target": "nucleo-l031k6"}
},
"NUCLEO_L053R8": {
"supported_form_factors": ["ARDUINO", "MORPHO"],
@ -913,7 +911,7 @@
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"],
"extra_labels": ["STM", "STM32F4", "STM32F411RE"],
"macros": ["HSE_VALUE=26000000", "VECT_TAB_OFFSET=0x08010000"],
"post_binary_hook": {
"post_binary_hook": {
"function": "MTSCode.combine_bins_mts_dragonfly",
"toolchains": ["GCC_ARM", "ARM_STD", "ARM_MICRO"]
},
@ -1030,14 +1028,14 @@
"macros_add": ["TARGET_MCU_NRF51_16K_S110"],
"EXPECTED_SOFTDEVICES_WITH_OFFSETS": [
{
"name" : "s110_nrf51822_8.0.0_softdevice.hex",
"boot" : "s110_nrf51822_8.0.0_bootloader.hex",
"offset" : 98304
"name": "s110_nrf51822_8.0.0_softdevice.hex",
"boot": "s110_nrf51822_8.0.0_bootloader.hex",
"offset": 98304
},
{
"name" : "s110_nrf51822_7.1.0_softdevice.hex",
"boot" : "s110_nrf51822_7.1.0_bootloader.hex",
"offset" : 90112
"name": "s110_nrf51822_7.1.0_softdevice.hex",
"boot": "s110_nrf51822_7.1.0_bootloader.hex",
"offset": 90112
}
],
"public": false
@ -1491,13 +1489,7 @@
"SAMR21G18A": {
"inherits": ["Target"],
"core": "Cortex-M0+",
"macros": [
"__SAMR21G18A__",
"I2C_MASTER_CALLBACK_MODE=true",
"EXTINT_CALLBACK_MODE=true",
"USART_CALLBACK_MODE=true",
"TC_ASYNC=true"
],
"macros": ["__SAMR21G18A__", "I2C_MASTER_CALLBACK_MODE=true", "EXTINT_CALLBACK_MODE=true", "USART_CALLBACK_MODE=true", "TC_ASYNC=true"],
"extra_labels": ["Atmel", "SAM_CortexM0P", "SAMR21"],
"supported_toolchains": ["GCC_ARM", "ARM", "uARM"],
"progen": {"target": "samr21g18a"}
@ -1505,13 +1497,7 @@
"SAMD21J18A": {
"inherits": ["Target"],
"core": "Cortex-M0+",
"macros": [
"__SAMD21J18A__",
"I2C_MASTER_CALLBACK_MODE=true",
"EXTINT_CALLBACK_MODE=true",
"USART_CALLBACK_MODE=true",
"TC_ASYNC=true"
],
"macros": ["__SAMD21J18A__", "I2C_MASTER_CALLBACK_MODE=true", "EXTINT_CALLBACK_MODE=true", "USART_CALLBACK_MODE=true", "TC_ASYNC=true"],
"extra_labels": ["Atmel", "SAM_CortexM0P", "SAMD21"],
"supported_toolchains": ["GCC_ARM", "ARM", "uARM"],
"progen": {"target": "samd21j18a"}
@ -1519,13 +1505,7 @@
"SAMD21G18A": {
"inherits": ["Target"],
"core": "Cortex-M0+",
"macros": [
"__SAMD21G18A__",
"I2C_MASTER_CALLBACK_MODE=true",
"EXTINT_CALLBACK_MODE=true",
"USART_CALLBACK_MODE=true",
"TC_ASYNC=true"
],
"macros": ["__SAMD21G18A__", "I2C_MASTER_CALLBACK_MODE=true", "EXTINT_CALLBACK_MODE=true", "USART_CALLBACK_MODE=true", "TC_ASYNC=true"],
"extra_labels": ["Atmel", "SAM_CortexM0P", "SAMD21"],
"supported_toolchains": ["GCC_ARM", "ARM", "uARM"],
"progen": {"target": "samd21g18a"}
@ -1533,13 +1513,7 @@
"SAML21J18A": {
"inherits": ["Target"],
"core": "Cortex-M0+",
"macros": [
"__SAML21J18A__",
"I2C_MASTER_CALLBACK_MODE=true",
"EXTINT_CALLBACK_MODE=true",
"USART_CALLBACK_MODE=true",
"TC_ASYNC=true"
],
"macros": ["__SAML21J18A__", "I2C_MASTER_CALLBACK_MODE=true", "EXTINT_CALLBACK_MODE=true", "USART_CALLBACK_MODE=true", "TC_ASYNC=true"],
"extra_labels": ["Atmel", "SAM_CortexM0P", "SAML21"],
"supported_toolchains": ["GCC_ARM", "ARM", "uARM"],
"progen": {"target": "samr21j18a"},
@ -1552,7 +1526,7 @@
"macros": ["__SAMG55J19__", "BOARD=75", "I2C_MASTER_CALLBACK_MODE=true", "EXTINT_CALLBACK_MODE=true", "USART_CALLBACK_MODE=true", "TC_ASYNC=true"],
"supported_toolchains": ["GCC_ARM", "ARM", "uARM"],
"default_toolchain": "ARM",
"progen": {"target":"samg55j19"},
"progen": {"target": "samg55j19"},
"progen_target": "samg55j19"
}
}

View File

@ -94,6 +94,18 @@ def parse_attributes(path) :
m = re.match(attr_matcher, line)
if m: yield m.group(1)
remove_matcher = re.compile('^#define\W+DEVICE_(\w+)\W+[10].*$')
def remove_attributes(path) :
with open(path) as input :
remainder = filter(lambda l: not re.match(remove_matcher, l), input)
with open(path,"wb") as output :
output.truncate(0)
output.write("// The 'provides' section in 'target.json' is now used"+
" to create the device's hardware preprocessor switches.\n")
output.write("// Check the 'provides' section of the target description"+
" in 'targets.json' for more details.\n")
output.writelines(remainder)
def user_select(things, message) :
print(message)
for thing, number in zip(things, range(len(things))):
@ -148,10 +160,8 @@ def add_to_targets(targets, device_file, verbose=False, remove=False) :
for t in target :
targets[t]["features"] = sorted(list(set(targets[t].setdefault("features",[]) + attrs)))
if verbose : print("[VERBOSE] target {} now features {}".format(t, attrs))
if remove :
global git_processes
git = Popen(['git', 'rm', device_file])
git_processes.append(git)
if remove is True:
remove_attributes(device_file)
if __name__ == '__main__' :
import argparse
@ -166,8 +176,8 @@ if __name__ == '__main__' :
' to convert from device.h format to a piece of targets.json')
parser.add_argument('-v', '--verbose', action='store_true',
help="print out every target that is updated in the targets.json")
parser.add_argument('-g', '--git-rm', action='store_true',
help="call git rm on every device.h file")
parser.add_argument('-r', '--rm', action='store_true',
help="remove the used attributes from a device.h file")
args = parser.parse_args()
if not args.target and not args.file and not args.all :
print("[WARNING] no action specified; auto-formatting targets.json")
@ -186,17 +196,17 @@ if __name__ == '__main__' :
for target in args.target :
device_file = find(target, os.curdir)
if device_file :
add_to_targets(targets, device_file, verbose=args.verbose, remove=args.git_rm)
add_to_targets(targets, device_file, verbose=args.verbose, remove=args.rm)
else :
print("[WARNING] could not locate a device file for target {}".format(target))
if args.file :
for file in args.file :
add_to_targets(targets, file, verbose=args.verbose, remove=args.git_rm)
add_to_targets(targets, file, verbose=args.verbose, remove=args.rm)
if args.all :
for file in find_all_devices(os.curdir, verbose=args.verbose) :
add_to_targets(targets, file, verbose=args.verbose, remove=args.git_rm)
add_to_targets(targets, file, verbose=args.verbose, remove=args.rm)
dump(targets_file_name, targets)