tools/gen-device-svd: make source URL configurable
Этот коммит содержится в:
родитель
b705b332a7
коммит
7c16f6c904
2 изменённых файлов: 16 добавлений и 8 удалений
2
Makefile
2
Makefile
|
@ -50,7 +50,7 @@ fmt:
|
||||||
gen-device: gen-device-nrf gen-device-avr
|
gen-device: gen-device-nrf gen-device-avr
|
||||||
|
|
||||||
gen-device-nrf:
|
gen-device-nrf:
|
||||||
./tools/gen-device-svd.py lib/nrfx/mdk/ src/device/nrf/
|
./tools/gen-device-svd.py lib/nrfx/mdk/ src/device/nrf/ --source=https://github.com/NordicSemiconductor/nrfx/tree/master/mdk
|
||||||
go fmt ./src/device/nrf
|
go fmt ./src/device/nrf
|
||||||
|
|
||||||
gen-device-avr:
|
gen-device-avr:
|
||||||
|
|
|
@ -6,6 +6,7 @@ from xml.dom import minidom
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import re
|
import re
|
||||||
|
import argparse
|
||||||
|
|
||||||
class Device:
|
class Device:
|
||||||
# dummy
|
# dummy
|
||||||
|
@ -24,7 +25,7 @@ def formatText(text):
|
||||||
text = text.strip()
|
text = text.strip()
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def readSVD(path):
|
def readSVD(path, sourceURL):
|
||||||
# Read ARM SVD files.
|
# Read ARM SVD files.
|
||||||
device = Device()
|
device = Device()
|
||||||
xml = minidom.parse(path)
|
xml = minidom.parse(path)
|
||||||
|
@ -123,7 +124,7 @@ def readSVD(path):
|
||||||
licenseBlock = '\n'.join(map(str.rstrip, licenseBlock.split('\n'))) # strip trailing whitespace
|
licenseBlock = '\n'.join(map(str.rstrip, licenseBlock.split('\n'))) # strip trailing whitespace
|
||||||
device.metadata = {
|
device.metadata = {
|
||||||
'file': os.path.basename(path),
|
'file': os.path.basename(path),
|
||||||
'descriptorSource': 'https://github.com/NordicSemiconductor/nrfx/tree/master/mdk',
|
'descriptorSource': sourceURL,
|
||||||
'name': deviceName,
|
'name': deviceName,
|
||||||
'nameLower': deviceName.lower(),
|
'nameLower': deviceName.lower(),
|
||||||
'description': deviceDescription,
|
'description': deviceDescription,
|
||||||
|
@ -370,17 +371,24 @@ Default_Handler:
|
||||||
for intr in device.interrupts:
|
for intr in device.interrupts:
|
||||||
out.write(' IRQ {name}_IRQHandler\n'.format(**intr))
|
out.write(' IRQ {name}_IRQHandler\n'.format(**intr))
|
||||||
|
|
||||||
def generate(indir, outdir):
|
def generate(indir, outdir, sourceURL):
|
||||||
if not os.path.isdir(outdir):
|
if not os.path.isdir(outdir):
|
||||||
os.mkdir(outdir)
|
os.mkdir(outdir)
|
||||||
for filepath in sorted(glob(indir + '/*.svd')):
|
for filepath in sorted(glob(indir + '/*.svd')):
|
||||||
print(filepath)
|
print(filepath)
|
||||||
device = readSVD(filepath)
|
device = readSVD(filepath, sourceURL)
|
||||||
writeGo(outdir, device)
|
writeGo(outdir, device)
|
||||||
writeAsm(outdir, device)
|
writeAsm(outdir, device)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
indir = sys.argv[1] # directory with register descriptor files (*.svd, *.atdf)
|
parser = argparse.ArgumentParser(description='Generate Go register descriptors and interrupt vectors from .svd files')
|
||||||
outdir = sys.argv[2] # output directory
|
parser.add_argument('indir', metavar='indir', type=str,
|
||||||
generate(indir, outdir)
|
help='input directory containing .svd files')
|
||||||
|
parser.add_argument('outdir', metavar='outdir', type=str,
|
||||||
|
help='output directory')
|
||||||
|
parser.add_argument('--source', metavar='source', type=str,
|
||||||
|
help='output directory',
|
||||||
|
default='<unknown>')
|
||||||
|
args = parser.parse_args()
|
||||||
|
generate(args.indir, args.outdir, args.source)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче