-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathbuild.bat
More file actions
152 lines (123 loc) · 3.49 KB
/
build.bat
File metadata and controls
152 lines (123 loc) · 3.49 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@echo off
REM Richkware Build Script for Windows
REM Interactive build configuration
echo === Richkware Build Script ===
echo.
REM Check if running on Windows
if "%OS%" neq "Windows_NT" (
echo This script is for Windows. Use build.sh on Unix-like systems.
pause
exit /b 1
)
REM Function to prompt user for input
:PromptUser
setlocal enabledelayedexpansion
set "prompt=%~1"
set "default=%~2"
set "response="
set /p "response=%prompt% [%default%]: "
if "!response!"=="" set "response=%default%"
echo !response!
goto :eof
REM Platform selection
echo.
echo Select target platform:
echo 1) Windows (native)
echo 2) Linux (Cross-compilation)
echo 3) macOS (Cross-compilation)
set /p "platform_choice=Enter choice [1]: "
if "%platform_choice%"=="" set platform_choice=1
if "%platform_choice%"=="1" (
set TARGET_PLATFORM=Windows
) else if "%platform_choice%"=="2" (
set TARGET_PLATFORM=Linux
) else if "%platform_choice%"=="3" (
set TARGET_PLATFORM=macOS
) else (
echo Invalid choice. Using Windows.
set TARGET_PLATFORM=Windows
)
echo Target platform: %TARGET_PLATFORM%
REM Build type
echo.
call :PromptUser "Build type (Release/Debug)" "Release"
set BUILD_TYPE=%errorlevel%
REM Build options
echo.
echo Build options:
call :PromptUser "Enable unit tests (ON/OFF)" "ON"
set ENABLE_TESTS=%errorlevel%
call :PromptUser "Enable examples (ON/OFF)" "OFF"
set ENABLE_EXAMPLES=%errorlevel%
call :PromptUser "Enable AddressSanitizer (ON/OFF)" "OFF"
set ENABLE_ASAN=%errorlevel%
call :PromptUser "Enable ThreadSanitizer (ON/OFF)" "OFF"
set ENABLE_TSAN=%errorlevel%
call :PromptUser "Enable code coverage (ON/OFF)" "OFF"
set ENABLE_COVERAGE=%errorlevel%
REM Output directory
set BUILD_DIR=build
if "%TARGET_PLATFORM%"=="Linux" (
set BUILD_DIR=build_linux
)
if "%TARGET_PLATFORM%"=="macOS" (
set BUILD_DIR=build_macos
)
echo.
echo Build directory: %BUILD_DIR%
REM Create build directory
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
cd "%BUILD_DIR%"
REM Configure CMake
echo.
echo Configuring CMake...
set CMAKE_ARGS=-DCMAKE_BUILD_TYPE=%BUILD_TYPE%
set CMAKE_ARGS=%CMAKE_ARGS% -DRICHKWARE_BUILD_TESTS=%ENABLE_TESTS%
set CMAKE_ARGS=%CMAKE_ARGS% -DRICHKWARE_BUILD_EXAMPLES=%ENABLE_EXAMPLES%
set CMAKE_ARGS=%CMAKE_ARGS% -DRICHKWARE_ENABLE_ASAN=%ENABLE_ASAN%
set CMAKE_ARGS=%CMAKE_ARGS% -DRICHKWARE_ENABLE_TSAN=%ENABLE_TSAN%
set CMAKE_ARGS=%CMAKE_ARGS% -DRICHKWARE_ENABLE_COVERAGE=%ENABLE_COVERAGE%
REM Platform-specific options
if "%TARGET_PLATFORM%"=="Linux" (
set CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_TOOLCHAIN_FILE=../cmake/linux-cross.cmake
echo Cross-compiling for Linux
)
if "%TARGET_PLATFORM%"=="macOS" (
set CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_TOOLCHAIN_FILE=../cmake/macos-cross.cmake
echo Cross-compiling for macOS
)
echo CMake command: cmake .. %CMAKE_ARGS%
cmake .. %CMAKE_ARGS%
if errorlevel 1 (
echo CMake configuration failed!
cd ..
pause
exit /b 1
)
REM Build
echo.
echo Building project...
REM Try to detect number of cores for parallel build
set CORES=%NUMBER_OF_PROCESSORS%
if "%CORES%"=="" set CORES=4
cmake --build . --config %BUILD_TYPE% --parallel %CORES%
if errorlevel 1 (
echo Build failed!
cd ..
pause
exit /b 1
)
echo.
echo Build completed successfully!
echo Executables are in: %BUILD_DIR%\bin\
echo Libraries are in: %BUILD_DIR%\lib\
REM Run tests if enabled
if "%ENABLE_TESTS%"=="ON" (
echo.
echo Running tests...
ctest --output-on-failure --build-config %BUILD_TYPE%
)
cd ..
echo.
echo Build script completed. Press any key to exit.
pause >nul