47 lines
2.1 KiB
Python
47 lines
2.1 KiB
Python
"""Build DSView with the Zynq Ethernet driver using the SETGUI recipe."""
|
|
import argparse
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
TEMPLATES = HERE.parents[2]
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--source', type=Path, default=Path('build/dsview-upstream'))
|
|
parser.add_argument('--output', type=Path, required=True)
|
|
parser.add_argument('--msys-root', type=Path, required=True)
|
|
parser.add_argument('--recipe', type=Path, default=HERE.parent)
|
|
args = parser.parse_args()
|
|
|
|
source, output, recipe = (p.resolve() for p in (args.source, args.output, args.recipe))
|
|
revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=source, text=True).strip()
|
|
if not revision.startswith('2e9e2c8e'):
|
|
parser.error('DSView checkout must be at revision 2e9e2c8e')
|
|
|
|
analyzer = TEMPLATES / 'hdl/logic-analyzer/include'
|
|
ethernet = TEMPLATES / 'hdl/logic-udp-ethernet/include'
|
|
inputs = (HERE / 'zynq.c', HERE / 'zynq_record.c', HERE / 'zynq_record.h',
|
|
analyzer / 'zynq_la.h', analyzer / 'zynq_la_stream.h',
|
|
ethernet / 'zynq_la_pl.h')
|
|
driver = source / 'libsigrok4DSL/hardware/zynq'
|
|
driver.mkdir(parents=True, exist_ok=True)
|
|
for path in inputs:
|
|
shutil.copy2(path, driver / path.name)
|
|
|
|
subprocess.run([sys.executable, str(recipe / 'build.py'), '--source', str(source),
|
|
'--extra-patch', str(HERE / 'ethernet.patch'),
|
|
'--output', str(output), '--msys-root', str(args.msys_root.resolve())], check=True)
|
|
source_files = output / 'zynq-source'
|
|
source_files.mkdir(exist_ok=True)
|
|
for path in (*inputs, HERE / 'ethernet.patch'):
|
|
shutil.copy2(path, source_files / path.name)
|
|
with (output / 'SOURCE.txt').open('a', encoding='utf-8') as manifest:
|
|
manifest.write('Zynq Ethernet driver and integration patch: zynq-source/\n')
|
|
(output / 'zynq-ethernet-1').write_text('DSView Zynq Ethernet protocol 1\n', encoding='utf-8')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|