-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
195 lines (177 loc) · 5.08 KB
/
build.bat
File metadata and controls
195 lines (177 loc) · 5.08 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
@echo off
REM Build script for Atom project using xmake or CMake
REM Author: Max Qian
echo ===============================================
echo Atom Project Build Script
echo ===============================================
REM Parse command-line options
set BUILD_TYPE=release
set BUILD_PYTHON=n
set BUILD_SHARED=n
set BUILD_EXAMPLES=n
set BUILD_TESTS=n
set BUILD_CFITSIO=n
set BUILD_SSH=n
set BUILD_SYSTEM=cmake
set CLEAN_BUILD=n
set SHOW_HELP=n
:parse_args
if "%~1"=="" goto end_parse_args
if /i "%~1"=="--debug" (
set BUILD_TYPE=debug
goto next_arg
)
if /i "%~1"=="--python" (
set BUILD_PYTHON=y
goto next_arg
)
if /i "%~1"=="--shared" (
set BUILD_SHARED=y
goto next_arg
)
if /i "%~1"=="--examples" (
set BUILD_EXAMPLES=y
goto next_arg
)
if /i "%~1"=="--tests" (
set BUILD_TESTS=y
goto next_arg
)
if /i "%~1"=="--cfitsio" (
set BUILD_CFITSIO=y
goto next_arg
)
if /i "%~1"=="--ssh" (
set BUILD_SSH=y
goto next_arg
)
if /i "%~1"=="--xmake" (
set BUILD_SYSTEM=xmake
goto next_arg
)
if /i "%~1"=="--cmake" (
set BUILD_SYSTEM=cmake
goto next_arg
)
if /i "%~1"=="--clean" (
set CLEAN_BUILD=y
goto next_arg
)
if /i "%~1"=="--help" (
set SHOW_HELP=y
goto next_arg
) else (
echo Unknown option: %1
set SHOW_HELP=y
goto next_arg
)
:next_arg
shift
goto parse_args
:end_parse_args
REM Show help if requested
if "%SHOW_HELP%"=="y" (
echo Usage: build.bat [options]
echo.
echo Options:
echo --debug Build in debug mode
echo --python Enable Python bindings
echo --shared Build shared libraries
echo --examples Build examples
echo --tests Build tests
echo --cfitsio Enable CFITSIO support
echo --ssh Enable SSH support
echo --xmake Use XMake build system
echo --cmake Use CMake build system (default)
echo --clean Clean build directory before building
echo --help Show this help message
echo.
exit /b 0
)
echo Build configuration:
echo Build type: %BUILD_TYPE%
echo Python bindings: %BUILD_PYTHON%
echo Shared libraries: %BUILD_SHARED%
echo Build examples: %BUILD_EXAMPLES%
echo Build tests: %BUILD_TESTS%
echo CFITSIO support: %BUILD_CFITSIO%
echo SSH support: %BUILD_SSH%
echo Build system: %BUILD_SYSTEM%
echo Clean build: %CLEAN_BUILD%
echo.
REM Check if the selected build system is available
if "%BUILD_SYSTEM%"=="xmake" (
where xmake >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo Error: xmake not found in PATH
echo Please install xmake from https://xmake.io/
exit /b 1
)
) else (
where cmake >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo Error: cmake not found in PATH
echo Please install CMake from https://cmake.org/download/
exit /b 1
)
)
REM Clean build directory if requested
if "%CLEAN_BUILD%"=="y" (
echo Cleaning build directory...
if exist build rmdir /s /q build
mkdir build
)
REM Build using the selected system
if "%BUILD_SYSTEM%"=="xmake" (
echo Building with XMake...
REM Configure XMake options
set XMAKE_ARGS=
if "%BUILD_TYPE%"=="debug" set XMAKE_ARGS=%XMAKE_ARGS% -m debug
if "%BUILD_PYTHON%"=="y" set XMAKE_ARGS=%XMAKE_ARGS% --python=y
if "%BUILD_SHARED%"=="y" set XMAKE_ARGS=%XMAKE_ARGS% --shared=y
if "%BUILD_EXAMPLES%"=="y" set XMAKE_ARGS=%XMAKE_ARGS% --examples=y
if "%BUILD_TESTS%"=="y" set XMAKE_ARGS=%XMAKE_ARGS% --tests=y
if "%BUILD_CFITSIO%"=="y" set XMAKE_ARGS=%XMAKE_ARGS% --cfitsio=y
if "%BUILD_SSH%"=="y" set XMAKE_ARGS=%XMAKE_ARGS% --ssh=y
REM Run XMake
echo Configuring XMake project...
xmake f %XMAKE_ARGS%
if %ERRORLEVEL% NEQ 0 (
echo Error: XMake configuration failed
exit /b 1
)
echo Building project...
xmake
if %ERRORLEVEL% NEQ 0 (
echo Error: XMake build failed
exit /b 1
)
) else (
echo Building with CMake...
REM Configure CMake options
set CMAKE_ARGS=-B build
if "%BUILD_TYPE%"=="debug" set CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_BUILD_TYPE=Debug
if "%BUILD_TYPE%"=="release" set CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_BUILD_TYPE=Release
if "%BUILD_PYTHON%"=="y" set CMAKE_ARGS=%CMAKE_ARGS% -DATOM_BUILD_PYTHON_BINDINGS=ON
if "%BUILD_SHARED%"=="y" set CMAKE_ARGS=%CMAKE_ARGS% -DBUILD_SHARED_LIBS=ON
if "%BUILD_EXAMPLES%"=="y" set CMAKE_ARGS=%CMAKE_ARGS% -DATOM_BUILD_EXAMPLES=ON
if "%BUILD_TESTS%"=="y" set CMAKE_ARGS=%CMAKE_ARGS% -DATOM_BUILD_TESTS=ON
if "%BUILD_CFITSIO%"=="y" set CMAKE_ARGS=%CMAKE_ARGS% -DATOM_USE_CFITSIO=ON
if "%BUILD_SSH%"=="y" set CMAKE_ARGS=%CMAKE_ARGS% -DATOM_USE_SSH=ON
REM Run CMake
echo Configuring CMake project...
cmake %CMAKE_ARGS% .
if %ERRORLEVEL% NEQ 0 (
echo Error: CMake configuration failed
exit /b 1
)
echo Building project...
cmake --build build --config %BUILD_TYPE%
if %ERRORLEVEL% NEQ 0 (
echo Error: CMake build failed
exit /b 1
)
)
echo.
echo Build completed successfully!
echo ===============================================