]> FriiDump Source - friidump.git/blob - build_msvc32.cmd
FriiDump 0.5.3.16: finalize release identity and documentation
[friidump.git] / build_msvc32.cmd
1 @echo off
2 setlocal EnableExtensions
3 cd /d "%~dp0"
4
5 if /I "%~1"=="clean" goto clean
6
7 if not exist "config.h" (
8   echo [ERROR] config.h is missing from the source root.
9   echo Please extract the full source ZIP before building.
10   exit /b 1
11 )
12
13 findstr /n /c:"#define snprintf" "%~dp0libmultihash\multihash.h" "%~dp0libfriidump\win32compat.h" >nul 2>nul
14 if not errorlevel 1 (
15   echo [ERROR] Legacy snprintf macro still present. Overwrite libmultihash\multihash.h and libfriidump\win32compat.h from this package.
16   exit /b 1
17 )
18
19 if not exist "build-msvc32" mkdir "build-msvc32"
20
21 set "FRIIDUMP_BUILD_COMMIT_EFFECTIVE=%FRIIDUMP_BUILD_COMMIT%"
22 if not defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE if exist "%~dp0CANDIDATE.json" (
23   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"
24 )
25 if not defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE (
26   for /f "usebackq delims=" %%G in (`git -C "%~dp0" rev-parse HEAD 2^>nul`) do set "FRIIDUMP_BUILD_COMMIT_EFFECTIVE=%%G"
27 )
28
29 if defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE (
30   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 }"
31   if errorlevel 1 exit /b %ERRORLEVEL%
32   echo [INFO] Native-report build commit: %FRIIDUMP_BUILD_COMMIT_EFFECTIVE%
33 ) else (
34   echo [INFO] Native-report build commit: not embedded ^(set FRIIDUMP_BUILD_COMMIT to a full 40-character commit^)
35 )
36
37 set "EFFECTIVE_RSP=%~dp0build-msvc32\friidump-effective.rsp"
38 copy /y "%~dp0msvc32_friidump.rsp" "%EFFECTIVE_RSP%" >nul
39 if errorlevel 1 exit /b %ERRORLEVEL%
40 if defined FRIIDUMP_BUILD_COMMIT_EFFECTIVE >>"%EFFECTIVE_RSP%" echo /DFRIIDUMP_BUILD_COMMIT=\"%FRIIDUMP_BUILD_COMMIT_EFFECTIVE%\"
41
42 call "%~dp0.vscode\msvc32.cmd" cl @"%EFFECTIVE_RSP%" /link ole32.lib
43 if errorlevel 1 exit /b %ERRORLEVEL%
44
45 call "%~dp0build_msvc32_xbox_portable_tests.cmd"
46 if errorlevel 1 exit /b %ERRORLEVEL%
47
48 set "HELP_LOG=%TEMP%\friidump-help-%RANDOM%-%RANDOM%.txt"
49 "%~dp0friidump.exe" --help > "%HELP_LOG%" 2>&1
50 type "%HELP_LOG%"
51
52 findstr /c:"FriiDump 0.5.3.16-pf1" "%HELP_LOG%" >nul
53 if errorlevel 1 (
54   echo [ERROR] FriiDump help/version smoke test failed.
55   del /q "%HELP_LOG%" >nul 2>nul
56   if exist "friidump.log" del /q "friidump.log"
57   exit /b 1
58 )
59
60 for %%T in ("--report-json" "--report-dir" "--firmware-modified") do (
61   findstr /l /c:"%%~T" "%HELP_LOG%" >nul
62   if errorlevel 1 (
63     echo [ERROR] Native-report option %%~T is missing from help output.
64     del /q "%HELP_LOG%" >nul 2>nul
65     if exist "friidump.log" del /q "friidump.log"
66     exit /b 1
67   )
68 )
69
70 for %%T in ("reports are created by default" "beside the final log" "may be combined with --report-json" "omission assumes stock") do (
71   findstr /l /c:"%%~T" "%HELP_LOG%" >nul
72   if errorlevel 1 (
73     echo [ERROR] Native-report default/override contract is missing from help output: %%~T
74     del /q "%HELP_LOG%" >nul 2>nul
75     if exist "friidump.log" del /q "friidump.log"
76     exit /b 1
77   )
78 )
79
80 del /q "%HELP_LOG%" >nul 2>nul
81 if exist "friidump.log" del /q "friidump.log"
82
83 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"
84 exit /b %ERRORLEVEL%
85
86 :clean
87 if exist "friidump.exe" del /q "friidump.exe"
88 if exist "friidump-report-fixtures.exe" del /q "friidump-report-fixtures.exe"
89 if exist "friidump-xbox-portable-metadata-test.exe" del /q "friidump-xbox-portable-metadata-test.exe"
90 if exist "build-msvc32" rmdir /s /q "build-msvc32"
91 if exist "friidump_msvc32_build_results.zip" del /q "friidump_msvc32_build_results.zip"
92 if exist "friidump.log" del /q "friidump.log"
93 exit /b 0