]> FriiDump Source - friidump.git/blobdiff - build_msvc32.cmd
Harden GCC-4243N A102 HLDS E7 profile
[friidump.git] / build_msvc32.cmd
index b91bb7cfac364c436f47964cde0b63d6cc59231b..5bbc5cf22ed46419db4b2bc39b2f228fcf6e566c 100644 (file)
@@ -16,20 +16,78 @@ if not errorlevel 1 (
   exit /b 1
 )
 
-
 if not exist "build-msvc32" mkdir "build-msvc32"
 
-call "%~dp0.vscode\msvc32.cmd" cl @"%~dp0msvc32_friidump.rsp"
+set "FRIIDUMP_BUILD_COMMIT_EFFECTIVE=%FRIIDUMP_BUILD_COMMIT%"
+if not defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE if exist "%~dp0CANDIDATE.json" (
+  for /f "usebackq delims=" %%G in (`powershell -NoProfile -ExecutionPolicy Bypass -Command "$d = Get-Content -Raw -LiteralPath '%~dp0CANDIDATE.json' | ConvertFrom-Json; $d.candidate_implementation.commit"`) do set "FRIIDUMP_BUILD_COMMIT_EFFECTIVE=%%G"
+)
+if not defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE (
+  for /f "usebackq delims=" %%G in (`git -C "%~dp0" rev-parse HEAD 2^>nul`) do set "FRIIDUMP_BUILD_COMMIT_EFFECTIVE=%%G"
+)
+
+if defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE (
+  powershell -NoProfile -ExecutionPolicy Bypass -Command "if ($env:FRIIDUMP_BUILD_COMMIT_EFFECTIVE -notmatch '^[0-9a-fA-F]{40}$') { Write-Error 'FRIIDUMP_BUILD_COMMIT must be exactly 40 hexadecimal characters.'; exit 1 }"
+  if errorlevel 1 exit /b %ERRORLEVEL%
+  echo [INFO] Native-report build commit: %FRIIDUMP_BUILD_COMMIT_EFFECTIVE%
+) else (
+  echo [INFO] Native-report build commit: not embedded ^(set FRIIDUMP_BUILD_COMMIT to a full 40-character commit^)
+)
+
+set "EFFECTIVE_RSP=%~dp0build-msvc32\friidump-effective.rsp"
+copy /y "%~dp0msvc32_friidump.rsp" "%EFFECTIVE_RSP%" >nul
+if errorlevel 1 exit /b %ERRORLEVEL%
+if defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE >>"%EFFECTIVE_RSP%" echo /DFRIIDUMP_BUILD_COMMIT=\"%FRIIDUMP_BUILD_COMMIT_EFFECTIVE%\"
+
+call "%~dp0.vscode\msvc32.cmd" cl @"%EFFECTIVE_RSP%" /link ole32.lib
 if errorlevel 1 exit /b %ERRORLEVEL%
 
-"%~dp0friidump.exe" --help
+call "%~dp0build_msvc32_xbox_portable_tests.cmd"
 if errorlevel 1 exit /b %ERRORLEVEL%
 
-powershell -NoProfile -ExecutionPolicy Bypass -Command "Compress-Archive -Force -Path friidump.exe,docs,README,AUTHORS,COPYING,config.h,msvc32_friidump.rsp,build_msvc32.cmd,.vscode -DestinationPath friidump_msvc32_build_results.zip"
+set "HELP_LOG=%TEMP%\friidump-help-%RANDOM%-%RANDOM%.txt"
+"%~dp0friidump.exe" --help > "%HELP_LOG%" 2>&1
+type "%HELP_LOG%"
+
+findstr /c:"FriiDump 0.5.3.16-pf1" "%HELP_LOG%" >nul
+if errorlevel 1 (
+  echo [ERROR] FriiDump help/version smoke test failed.
+  del /q "%HELP_LOG%" >nul 2>nul
+  if exist "friidump.log" del /q "friidump.log"
+  exit /b 1
+)
+
+for %%T in ("--report-json" "--report-dir" "--firmware-modified") do (
+  findstr /l /c:"%%~T" "%HELP_LOG%" >nul
+  if errorlevel 1 (
+    echo [ERROR] Native-report option %%~T is missing from help output.
+    del /q "%HELP_LOG%" >nul 2>nul
+    if exist "friidump.log" del /q "friidump.log"
+    exit /b 1
+  )
+)
+
+for %%T in ("reports are created by default" "beside the final log" "may be combined with --report-json" "omission assumes stock") do (
+  findstr /l /c:"%%~T" "%HELP_LOG%" >nul
+  if errorlevel 1 (
+    echo [ERROR] Native-report default/override contract is missing from help output: %%~T
+    del /q "%HELP_LOG%" >nul 2>nul
+    if exist "friidump.log" del /q "friidump.log"
+    exit /b 1
+  )
+)
+
+del /q "%HELP_LOG%" >nul 2>nul
+if exist "friidump.log" del /q "friidump.log"
+
+powershell -NoProfile -ExecutionPolicy Bypass -Command "Compress-Archive -Force -Path friidump.exe,redump_dat,docs,README,README.md,AUTHORS,COPYING,config.h,msvc32_friidump.rsp,build_msvc32.cmd,build_msvc32_native_report_tests.cmd,msvc32_native_report_tests.rsp,build_msvc32_xbox_portable_tests.cmd,msvc32_xbox_portable_tests.rsp,tests,.vscode -DestinationPath friidump_msvc32_build_results.zip"
 exit /b %ERRORLEVEL%
 
 :clean
 if exist "friidump.exe" del /q "friidump.exe"
+if exist "friidump-report-fixtures.exe" del /q "friidump-report-fixtures.exe"
+if exist "friidump-xbox-portable-metadata-test.exe" del /q "friidump-xbox-portable-metadata-test.exe"
 if exist "build-msvc32" rmdir /s /q "build-msvc32"
 if exist "friidump_msvc32_build_results.zip" del /q "friidump_msvc32_build_results.zip"
+if exist "friidump.log" del /q "friidump.log"
 exit /b 0