-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
62 lines (51 loc) · 1.54 KB
/
build.bat
File metadata and controls
62 lines (51 loc) · 1.54 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
@echo off
setlocal enabledelayedexpansion
:: Ask user to choose build configuration
echo Select build type:
echo [1] Debug
echo [2] Release
set /p CHOICE=Enter your choice (1 or 2):
:: Translate choice into build type
if "%CHOICE%"=="1" (
set BUILD_TYPE=debug
) else if "%CHOICE%"=="2" (
set BUILD_TYPE=release
) else (
echo Invalid choice. Please enter 1 or 2.
pause
exit /b 1
)
echo.
echo === Building in %BUILD_TYPE% mode ===
echo.
:: Build shared library using CMake
cd submodule\Websocket
if not exist build (
mkdir build
)
cd build
cmake .. -DBUILD_SHARED=ON -DBUILD_STATIC=OFF -DBUILD_EXAMPLE=OFF -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
cmake --build . --config %BUILD_TYPE%
cd ..\..\..
:: Build Rust binaries
if "%BUILD_TYPE%"=="release" (
cargo build --release --no-default-features --features server --bin server
cargo build --release --no-default-features --features client --bin client
) else (
cargo build --no-default-features --features server --bin server
cargo build --no-default-features --features client --bin client
)
:: Copy the built DLL to Rust target output
set DLL_NAME_SOURCE=LIB_SHARED.dll
set DLL_NAME_TARGET=Websocket.dll
set DLL_SOURCE=submodule\Websocket\build\bin\%BUILD_TYPE%\%DLL_NAME_SOURCE%
set DLL_DEST=target\%BUILD_TYPE%\%DLL_NAME_TARGET%
echo.
if exist %DLL_SOURCE% (
copy /Y %DLL_SOURCE% %DLL_DEST% >nul
echo DLL copied successfully to: %DLL_DEST%
) else (
echo ERROR: DLL not found at path: %DLL_SOURCE%
)
echo.
pause