Sprinter: добавить отладку C-исходников и интеграцию VS Code
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Внутренний сборочный интерфейс sprinter-cc с краткой диагностикой."""
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from sdbg.build import compile_unit
|
||||
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument('command', choices=['compile'])
|
||||
p.add_argument('--plain', action='store_true')
|
||||
p.add_argument('--sdcc', type=Path, required=True)
|
||||
p.add_argument('--assembler', type=Path, required=True)
|
||||
p.add_argument('--source', type=Path, required=True)
|
||||
p.add_argument('--output', type=Path, required=True)
|
||||
args = sys.argv[1:]
|
||||
separator = args.index('--') if '--' in args else len(args)
|
||||
a = p.parse_args(args[:separator])
|
||||
try:
|
||||
compile_unit(a.sdcc, a.assembler, a.source, a.output,
|
||||
args[separator + 1:], debug=not a.plain)
|
||||
except subprocess.CalledProcessError as error:
|
||||
if error.output:
|
||||
output = error.output.decode(errors='replace') if isinstance(error.output, bytes) else error.output
|
||||
print(output, file=sys.stderr, end='' if output.endswith('\n') else '\n')
|
||||
print(f'sdbg: компиляция {a.source.name} не прошла (код {error.returncode})',
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except (ValueError, OSError) as error:
|
||||
print('sdbg: ' + str(error), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user