Fix UMP logger boot initialization and configurable protocol build
This commit is contained in:
@@ -1,21 +1,28 @@
|
||||
"""Сборка и запуск исходного регистратора с подменой GPIO/IRQ на Windows.
|
||||
|
||||
Нужны Clang и lld-link в PATH. Проверяется алгоритм, но не ABI и тайминги TI.
|
||||
Нужны GCC либо Clang и lld-link в PATH. TEMPLATES_ROOT задаёт библиотеку. Проверяется алгоритм, но не ABI и тайминги TI.
|
||||
DLL создаётся во временной папке; исходные .out/.hex прошивки не затрагиваются.
|
||||
"""
|
||||
import ctypes
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
templates = Path(os.environ.get('TEMPLATES_ROOT', root.parent / 'newProject/SETGUI/third_party/templates'))
|
||||
protocol = templates / 'c/set-protocol'
|
||||
compiler = os.environ.get('CC') or shutil.which('clang') or shutil.which('gcc')
|
||||
if not compiler:
|
||||
raise SystemExit('Clang or GCC is required in PATH')
|
||||
link_flags = [] if 'gcc' in Path(compiler).name else ['-nostdlib', '-fuse-ld=lld', '-Wl,/noentry,/nodefaultlib']
|
||||
with tempfile.TemporaryDirectory(prefix='ump-recorder-') as directory:
|
||||
library = Path(directory) / 'recorder_test.dll'
|
||||
subprocess.run([
|
||||
'clang', '-shared', '-nostdlib', '-fuse-ld=lld',
|
||||
'-Wl,/noentry,/nodefaultlib', '-Wno-unknown-pragmas', '-Wno-int-to-pointer-cast',
|
||||
compiler, '-shared', *link_flags, '-Wno-unknown-pragmas', '-Wno-int-to-pointer-cast',
|
||||
'-Itests/ump_logger/stubs', '-ISource/Internal/Include',
|
||||
'-I' + str(protocol), '-I' + str(protocol / 'ports/tms320f28335'),
|
||||
'tests/ump_logger/recorder_test.c', 'Source/Internal/shared_ump.c', '-o', str(library),
|
||||
], cwd=root, check=True)
|
||||
# Отдельный процесс освобождает DLL до удаления временной папки Windows.
|
||||
|
||||
Reference in New Issue
Block a user