-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild32.cmd
More file actions
113 lines (99 loc) · 3.2 KB
/
build32.cmd
File metadata and controls
113 lines (99 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@echo off
setlocal
::Build 32-bit Lazarus project "padxml" using lazbuild
SET "PROJECT_PATH=padxml.lpi"
SET "BUILD_MODE=Release"
SET "LAZARUS_DIR=%LAZARUS_DIR%"
for %%D in ("%LAZARUS_DIR%" "C:\Lazarus" "C:\lazarus") do (
if exist "%%~D\lazbuild.exe" (
SET "LAZARUS_DIR=%%~D"
)
)
if not exist "%LAZARUS_DIR%\lazbuild.exe" (
echo Lazarus not found. Set LAZARUS_DIR or install Lazarus.
exit /b 1
)
SET "LAZBUILD=%LAZARUS_DIR%\lazbuild.exe"
::Path to 32-bit FPC compiler
SET "FPC32=%FPC32_PATH%"
if not exist "%FPC32%" (
for /d %%F in ("%LAZARUS_DIR%\fpc\*") do (
if exist "%%~F\bin\i386-win32\fpc.exe" (
SET "FPC32=%%~F\bin\i386-win32\fpc.exe"
)
)
)
if not exist "%FPC32%" (
echo 32-bit FPC compiler not found. Set FPC32_PATH.
exit /b 1
)
::Rename existing 64-bit exe to padxml64.exe to avoid overwriting
if exist "padxml.exe" (
echo Renaming existing 64-bit executable...
ren "padxml.exe" "padxml64.exe"
)
echo Building 32-bit project: %PROJECT_PATH%
"%LAZBUILD%" %PROJECT_PATH% --cpu=i386 --ws=win32 --build-mode=%BUILD_MODE% --compiler=%FPC32%
IF %ERRORLEVEL% NEQ 0 (
echo 32-bit build failed!
::Restore 64-bit exe back
if exist "padxml64.exe" ren "padxml64.exe" "padxml.exe"
exit /b %ERRORLEVEL%
)
::Rename output to padxml32.exe to distinguish from 64-bit
if exist "padxml.exe" (
echo Renaming 32-bit executable...
if exist "padxml32.exe" del /F /Q "padxml32.exe"
ren "padxml.exe" "padxml32.exe"
)
::Restore 64-bit exe back to original name
if exist "padxml64.exe" (
echo Restoring 64-bit executable name...
if exist "padxml.exe" del /F /Q "padxml.exe"
ren "padxml64.exe" "padxml.exe"
)
echo 32-bit build completed successfully
::Wait 2 seconds to ensure file is free
timeout /t 2 /nobreak >nul
::Certificate settings (optional)
IF "%SIGNTOOL%"=="" (
SET "SIGNTOOL=C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\signtool.exe"
)
IF "%CERTFILE%"=="" (
IF EXIST "%~dp0installer\AlexanderT.pfx" (
SET "CERTFILE=%~dp0installer\AlexanderT.pfx"
) ELSE (
IF NOT "%CERT_PFX%"=="" (
SET "CERTFILE=%TEMP%\padxml-cert.pfx"
powershell -NoProfile -Command "[IO.File]::WriteAllBytes('%TEMP%\\padxml-cert.pfx',[Convert]::FromBase64String($env:CERT_PFX))"
) ELSE (
SET "CERTFILE="
)
)
)
SET "CERTPASS=1234"
SET "TIMESTAMP_URL=http://timestamp.digicert.com"
::Sign the 32-bit executable
if exist "padxml32.exe" (
if not "%CERTFILE%"=="" (
if exist "%CERTFILE%" (
if exist "%SIGNTOOL%" (
echo Signing 32-bit executable...
"%SIGNTOOL%" sign /f "%CERTFILE%" /p "%CERTPASS%" /fd SHA256 /tr %TIMESTAMP_URL% /td SHA256 "padxml32.exe"
IF %ERRORLEVEL% EQU 0 (
echo Signing completed successfully
) else (
echo Signing failed
)
) else (
echo Skipping signing: signtool not found.
)
) else (
echo Skipping signing: cert file not found.
)
) else (
echo Skipping signing: CERTFILE not set.
)
) else (
echo Skipping signing: missing executable.
)