소스 검색

feat(canAppl):添加自动git版本号生成

CN\zhangkai71 2 년 전
부모
커밋
6e45bc2e34
5개의 변경된 파일58개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 0
      User project/3.BasicFunction/Include/fp.def
  2. 6 1
      User project/3.BasicFunction/Source/canAppl.c
  3. 2 0
      tools/config_ps_policy.bat
  4. 5 0
      tools/fp.def
  5. 40 0
      tools/gen_fingerprint.ps1

+ 5 - 0
User project/3.BasicFunction/Include/fp.def

@@ -0,0 +1,5 @@
+#define FINGER_PRINT "8bc56ac-d"
+#define COMMIT_TIME "2023-07-18 09:26:32"
+#define COMMIT_AUTHOR "CN\zhangkai71"
+#define COMPLIE_TIME "2023-07-18 11:23:53"
+#define COMPLIE_AUTHOR "CN\zhangkai71"

+ 6 - 1
User project/3.BasicFunction/Source/canAppl.c

@@ -23,6 +23,8 @@
 #include "spi_master.h"
 #include "user.h"
 #include "FSM_2nd.h"
+
+#include "fp.def"
 /******************************
  *
  *  Parameter
@@ -218,7 +220,10 @@ void Can_voInitMC_Run(void)
     // Software version
     strncpy(MC_VerInfo.FW_Version, (char *)"V0r1r9_20230607.", 16);
     // Firmware Special Info
-    strncpy(Firmware_Special, (char *)"TC00000-MC00000-V0r0.           ", 32);
+    char chFrimware[32]="TC00000-MC00000-V0r0.";
+    strncat(chFrimware,FINGER_PRINT,9);
+    strncpy(Firmware_Special, (char *)chFrimware, 32);
+//    strncpy(Firmware_Special, (char *)"TC00000-MC00000-V0r0.           ", 32);
     // Model name
     memcpy(MC_VerInfo.Mode, flash_stPara.ubMotorVersion, sizeof(flash_stPara.ubMotorVersion));
     // SN

+ 2 - 0
tools/config_ps_policy.bat

@@ -0,0 +1,2 @@
+@echo off
+C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -Command Set-ExecutionPolicy Unrestricted

+ 5 - 0
tools/fp.def

@@ -0,0 +1,5 @@
+#define FINGER_PRINT "8bc56ac-d"
+#define COMMIT_TIME "2023-07-18 09:26:32"
+#define COMMIT_AUTHOR "CN\zhangkai71"
+#define COMPLIE_TIME "2023-07-18 11:23:53"
+#define COMPLIE_AUTHOR "CN\zhangkai71"

+ 40 - 0
tools/gen_fingerprint.ps1

@@ -0,0 +1,40 @@
+$destnation = "..\User project\3.BasicFunction\Include"
+
+$toolPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
+
+$destnation = $toolPath + '\' + $destnation
+
+$res = &"git" log --pretty=format:"%h" | Select-Object -First 1
+$sha = $res
+$res = &"git" log --pretty=format:"%at" | Select-Object -First 1
+$dt = ([datetime]'1/1/1970Z').AddSeconds([int]$res)
+$res = &"git" log --pretty=format:"%aN" | Select-Object -First 1
+$commitAuthor = $res
+
+$notClean = &"git" status -s
+
+if ($notClean)
+{
+    $fp = $sha+"-d";
+}
+else
+{
+    $fp = $sha+"-c"
+}
+
+$commitTime = $dt.ToString("yyyy-MM-dd HH:mm:ss")
+$compleTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
+$author = &"git" config user.name
+
+$fileName = $toolPath+"\fp.def"
+
+Out-File -FilePath $fileName -InputObject ('#define FINGER_PRINT "' + $fp + '"') -Encoding utf8;
+Out-File -FilePath $fileName -InputObject ('#define COMMIT_TIME "' + $commitTime + '"') -Encoding utf8 -Append;
+Out-File -FilePath $fileName -InputObject ('#define COMMIT_AUTHOR "' + $commitAuthor + '"') -Encoding utf8 -Append;
+out-File -FilePath $fileName -InputObject ('#define COMPLIE_TIME "' + $compleTime + '"') -Encoding utf8 -Append;
+out-File -FilePath $fileName -InputObject ('#define COMPLIE_AUTHOR "' + $author + '"') -Encoding utf8 -Append;
+
+Copy-Item $fileName $destnation
+
+echo "Fingerprint Generated!"
+