Append Git commit hash to firmware BIN filename

This commit is contained in:
2026-09-22 12:56:45 +03:00
parent ee7dce4615
commit 2a9f42331c
5 changed files with 34 additions and 9 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/Debug/
/UKSSTMS320F28335.CS_/
/Bin/UKSSTMS320F28335_*.bin

View File

@@ -45,7 +45,7 @@ Source="Source\External\v120\DSP2833x_headers\cmd\DSP2833x_Headers_nonBIOS.cmd"
["Debug" Settings]
FinalBuildCmd=$(Proj_dir)\bin\hex2000.exe $(Proj_dir)\bin\UKSSTMS320F28335.out -boot -sci8 -map $(Proj_dir)\bin\UKSSTMS320F28335.map -o $(Proj_dir)\bin\UKSSTMS320F28335.hex -i
FinalBuildCmd=$(Proj_dir)\bin\hex2000.exe $(Proj_dir)\bin\UKSSTMS320F28335.out -boot -sci8 -map $(Proj_dir)\bin\UKSSTMS320F28335.map -o $(Proj_dir)\bin\UKSSTMS320F28335.bin -b
FinalBuildCmd=cmd /c ""$(Proj_dir)\build_bin.bat""
["Compiler" Settings: "Debug"]
Options=-g -pdsw225 -o1 -fr"$(Proj_dir)\Debug" -fs"$(Proj_dir)\Asm" -i"$(Proj_dir)\Source\External\v120\DSP2833x_headers\include" -i"$(Proj_dir)\Source\Internal\Include" -i"$(Proj_dir)\Source\External\v120\DSP2833x_common\include" -d"_DEBUG" -d"LARGE_MODEL" -md -ml -v28 --float_support=fpu32

View File

@@ -0,0 +1,9 @@
# Результаты сборки
После сборки Debug в `Bin` создаётся файл
`UKSSTMS320F28335_<commit>.bin`, где `<commit>` — короткий хеш текущего
коммита Git (не менее 8 символов). HEX сохраняет прежнее имя.
BIN создаётся скриптом `build_bin.bat`; Git должен быть доступен в `PATH`
процесса CCS. Если определить коммит не удалось, сборка завершается ошибкой.
При наличии незакоммиченных правок хеш обозначает HEAD и не описывает эти правки.

View File

@@ -23,12 +23,11 @@ shift
goto process_arg
:end_process_arg
echo. > temp_postBuildStep_Debug.bat
pushd "%SRC_ROOT%\Bin" || exit /b 1
hex2000.exe UKSSTMS320F28335.out -boot -sci8 -map UKSSTMS320F28335.map -o UKSSTMS320F28335.hex -i
set "BUILD_RESULT=%errorlevel%"
popd
if not "%BUILD_RESULT%"=="0" exit /b %BUILD_RESULT%
echo "%SRC_ROOT%\Bin\hex2000.exe" "%SRC_ROOT%\Bin\UKSSTMS320F28335.out" -boot -sci8 -map "%SRC_ROOT%\Bin\UKSSTMS320F28335.map" -o "%SRC_ROOT%\Bin\UKSSTMS320F28335.hex" -i >> temp_postBuildStep_Debug.bat
echo "%SRC_ROOT%\Bin\hex2000.exe" "%SRC_ROOT%\Bin\UKSSTMS320F28335.out" -boot -sci8 -map "%SRC_ROOT%\Bin\UKSSTMS320F28335.map" -o "%SRC_ROOT%\Bin\UKSSTMS320F28335.bin" -b >> temp_postBuildStep_Debug.bat
call temp_postBuildStep_Debug.bat
del temp_postBuildStep_Debug.bat
endlocal
call "%SRC_ROOT%\build_bin.bat"
exit /b %errorlevel%

16
build_bin.bat Normal file
View File

@@ -0,0 +1,16 @@
@echo off
setlocal
set "SRC_ROOT=%~dp0"
set "GIT_COMMIT="
for /f "delims=" %%H in ('git -C "%SRC_ROOT%." rev-parse --short^=8 HEAD') do set "GIT_COMMIT=%%H"
if not defined GIT_COMMIT (
echo ERROR: Cannot determine the Git commit. Make Git available in PATH. 1>&2
exit /b 1
)
pushd "%SRC_ROOT%Bin" || exit /b 1
hex2000.exe UKSSTMS320F28335.out -boot -sci8 -map UKSSTMS320F28335.map -o UKSSTMS320F28335_%GIT_COMMIT%.bin -b
set "BUILD_RESULT=%errorlevel%"
popd
exit /b %BUILD_RESULT%