-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
58 lines (50 loc) · 1.6 KB
/
build.bat
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
@echo off
setlocal enabledelayedexpansion
:: Check if argument is provided
if "%1"=="" (
echo Usage: build.bat [dll^|static]
echo dll - Build dynamic library ^(.dll^)
echo static - Build static library ^(.a^)
exit /b 1
)
:: Set paths for curl
set CURL_PATH=C:\curl
set CURL_INCLUDE=%CURL_PATH%\include
set CURL_LIB=%CURL_PATH%\lib
:: Set compiler and flags
set CC=gcc
set CFLAGS=-Wall -Wextra -I. -I%CURL_INCLUDE% -DCURL_STATICLIB
set LIBS=-L%CURL_LIB% -lcurl -lws2_32 -lwinmm -lwldap32 -lcrypt32
set OUTDIR=build
:: Check if curl paths exist
if not exist "%CURL_PATH%" (
echo Error: Curl directory not found at %CURL_PATH%
echo Please install curl or update CURL_PATH in the build script
exit /b 1
)
:: Create build directory if it doesn't exist
if not exist %OUTDIR% mkdir %OUTDIR%
:: Clean previous builds
del /Q %OUTDIR%\*.*
:: Build based on argument
if /i "%1"=="dll" (
echo Building DLL...
%CC% -shared -o %OUTDIR%\neocities.dll neocities.c %CFLAGS% -Wl,--out-implib,%OUTDIR%\libneocities.a %LIBS%
if !errorlevel! equ 0 (
echo DLL built successfully: %OUTDIR%\neocities.dll
echo Import library created: %OUTDIR%\libneocities.a
)
) else if /i "%1"=="static" (
echo Building static library...
%CC% -c neocities.c %CFLAGS%
ar rcs %OUTDIR%\libneocities.a neocities.o
del neocities.o
if !errorlevel! equ 0 (
echo Static library built successfully: %OUTDIR%\libneocities.a
)
) else (
echo Invalid argument: %1
echo Use 'dll' or 'static'
exit /b 1
)
endlocal