mcu_matlab/McuLib/templates/MCU_Wrapper/run_mex.bat

118 lines
3.1 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
:: Получаем аргументы из командной строки
:: %1 - includes_USER
:: %2 - code_USER
:: %3 - режим (например, debug)
:: Аргументы:
:: %1 — includes строка (в кавычках)
:: %2 — sources строка
:: %3 — defines строка
:: %4 — режим компиляции (debug/release)
:: Сохраняем как переменные
set filename=%~1
set includes_USER=%~2
set code_USER=%~3
set defines_USER=%~4
set defines_CONFIG=%~5
set compil_mode=%~6
:: Заменяем __EQ__ на =
set defines_USER=%defines_USER:__EQ__==%
set defines_CONFIG=%defines_CONFIG:__EQ__==%
set defines_WRAPPER=-D"MATLAB"^ -D"__sizeof_ptr=8"
:: -------------------------USERS PATHS AND CODE---------------------------
::-------------------------------------------------------------------------
:: -------------------------WRAPPER PATHS AND CODE---------------------------
:: оболочка, которая будет моделировать работу МК в симулинке
:: WRAPPER BAT START
:: WRAPPER BAT END
:: APP WRAPPER BAT START
:: APP WRAPPER BAT END
set includes_WRAPPER= %includes_WRAPPER% %includes_APP_WRAPPER%
set code_WRAPPER= %code_WRAPPER% %code_APP_WRAPPER%
:: PERIPH BAT START
:: PERIPH BAT END
::-------------------------------------------------------------------------
:: ---------------------SET PARAMS FOR MEX COMPILING-----------------------
:: -------------ALL------------
set includes= %includes_WRAPPER% %includes_PERIPH% %includes_USER%
set codes= %code_WRAPPER% %code_PERIPH% %code_USER%
set defines= %defines_WRAPPER% %defines_CONFIG% %defines_USER%
:: -------OUTPUT FOLDER--------
set output= -outdir "." -output %filename%
:: если нужен дебаг, до запускаем run_mex с припиской debug
IF %compil_mode%==debug (set debug= -g)
::-------------------------------------------------------------------------
::------START COMPILING-------
if "%7"=="echo_enable" (
echo Compiling...
echo ===========================
echo =========INCLUDES==========
echo USER:
for %%f in (%includes_USER%) do (
echo %%f
)
echo INTERNAL:
for %%f in (%includes_WRAPPER%) do (
echo %%f
)
echo PERIPH:
for %%f in (%includes_PERIPH%) do (
echo %%f
)
echo ===========================
echo ==========SOURCES==========
echo USER:
for %%f in (%code_USER%) do (
echo %%f
)
echo INTERNAL:
for %%f in (%code_WRAPPER%) do (
echo %%f
)
echo PERIPH:
for %%f in (%code_PERIPH%) do (
echo %%f
)
echo ===========================
echo ==========DEFINES==========
echo USER:
for %%d in (%defines_USER%) do (
echo %%d
)
echo CONFIG:
for %%f in (%defines_CONFIG%) do (
echo %%f
)
echo INTERNAL:
for %%f in (%defines_WRAPPER%) do (
echo %%f
)
)
echo ===========================
echo MODE: %compil_mode%
echo ===========================
mex %output% %defines% %includes% %codes% %debug%
echo %DATE% %TIME%
exit /b %ERRORLEVEL%