Repository navigation
Expand file tree
/
Copy pathbuild.bat
More file actions
87 lines (77 loc) · 2.52 KB
/
Copy pathbuild.bat
File metadata and controls
87 lines (77 loc) · 2.52 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
@echo off
setlocal
cd /d "%~dp0"
rem ---------------------------------------------------------------------------
rem LLMChat32 build script (Open Watcom 2.0, Windows 98 compatible target)
rem
rem build.bat build build\llmchat32.exe
rem build.bat test build, then build+run tests (tests\*.exe)
rem
rem Environment: WATCOM defaults to ow_portable_v2_stable next to this script.
rem ---------------------------------------------------------------------------
if not defined WATCOM set "WATCOM=%~dp0ow_portable_v2_stable"
if not exist "%WATCOM%\binnt\wcl386.exe" (
echo [build] ERROR: wcl386.exe not found under "%WATCOM%"
echo [build] set WATCOM to a valid Open Watcom install and retry.
exit /b 1
)
set "INCLUDE=%WATCOM%\h;%WATCOM%\h\nt"
set "LIB=%WATCOM%\lib386;%WATCOM%\lib386\nt"
set "PATH=%WATCOM%\binnt;%PATH%"
if not exist build mkdir build
rem --- wolfSSL sources: only third_party\wolfssl\ow\ is committed; the ---
rem --- upstream tree is fetched on demand. Needs network; when offline, ---
rem --- fetch manually (see third_party\fetch-wolfssl.bat header). ---
if not exist third_party\wolfssl\src\ssl.c (
echo [build] wolfSSL sources missing - fetching...
call third_party\fetch-wolfssl.bat
if errorlevel 1 (
echo [build] ERROR: could not obtain wolfSSL sources - network offline?
echo [build] restore network or populate third_party\wolfssl manually.
exit /b 1
)
)
rem --- UTF-8 BOM scan (batch findstr cannot match BOM bytes, so compile ---
rem --- the tiny C scanner src\tools\bomscan.c and run it over src\) ---
wcl386 -bt=nt -bm -bc -wx -fo=build\bomscan.obj -fe=build\bomscan.exe src\tools\bomscan.c
if errorlevel 1 (
echo [build] ERROR: failed to build bomscan tool.
exit /b 1
)
build\bomscan.exe src
if errorlevel 1 (
echo [build] ERROR: UTF-8 BOM found under src\ - save files without BOM.
exit /b 1
)
if /i "%~1"=="test" goto run_tests
if not "%~1"=="" (
echo usage: build.bat [test]
exit /b 2
)
wmake
if errorlevel 1 exit /b 1
echo [build] OK - build\llmchat32.exe
exit /b 0
:run_tests
wmake test
if errorlevel 1 exit /b 1
set TEST_FAILED=0
set TEST_TOTAL=0
for %%E in (tests\*.exe) do (
set /a TEST_TOTAL+=1
echo [test] running %%~nxE
"%%E"
if errorlevel 1 (
echo [test] FAIL: %%~nxE
set TEST_FAILED=1
) else (
echo [test] pass: %%~nxE
)
)
if %TEST_FAILED%==1 exit /b 1
if %TEST_TOTAL%==0 (
echo [test] no tests yet.
) else (
echo [test] all %TEST_TOTAL% test executables passed.
)
exit /b 0