forked from xnvme/xnvme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
194 lines (167 loc) · 4.06 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
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
@echo off
@setlocal enableextensions enabledelayedexpansion
set PROJECT=xnvme
set PROJECT_VER=0.0.27
set CC=clang
set MESON=meson
set BUILD_TYPE=release
set PLATFORM_ID=Windows
set BUILD_DIR=builddir
set NPROC=%NUMBER_OF_PROCESSORS%
set CTAGS=ctags
set GIT=git
set INFO=
set CLOBBER=
set CONFIG=
set CLEAN=
set INSTALL=
set BUILD=
:: set msys2-shell
set SH=call msys2_shell -no-start -here -use-full-path -defterm
for %%i in (%*) do (
if "%%i"=="debug" set BUILD_TYPE=debug
if "%%i"=="release" set BUILD_TYPE=release
if "%%i"=="info" set INFO=info
if "%%i"=="config" set CONFIG=config
if "%%i"=="config-debug" set CONFIG=config-debug
if "%%i"=="build" set BUILD=build
if "%%i"=="clean" set CLEAN=clean
if "%%i"=="clobber" set CLOBBER=clobber
if "%%i"=="install" set INSTALL=install
if "%%i"=="uninstall" set INSTALL=uninstall
)
set "PATH=%ALLUSERSPROFILE%\chocolatey\bin;!PATH!"
set "PATH=%SystemDrive%\tools\msys64;!PATH!"
set "PATH=%SystemDrive%\tools\msys64\mingw64\bin;!PATH!"
if "%INFO%"=="info" (
@call :info
goto :eof
)
if "%CONFIG%"=="config" (
@call :config
goto :eof
)
if "%CONFIG%"=="config-debug" (
@call :config-debug
goto :eof
)
if "%BUILD%"=="build" (
@call :build
goto :eof
)
if "%CLEAN%"=="clean" (
@call :clean
goto :eof
)
if "%INSTALL%"=="install" (
@call :install
@goto :eof
)
if "%INSTALL%"=="uninstall" (
@call :uninstall
@goto :eof
)
if "%CLOBBER%"=="clobber" (
@call :clobber
@goto :eof
)
if [%1]==[] (call :default) else (echo "Wrong arguments")
goto :eof
:default
call :info
call :tags
call :git-setup
@echo "## xNVMe: make default"
@if not exist %BUILD_DIR% (
call :config
call :build
)
@goto :eof
:config
@echo "## xNVMe: make config"
@set CC=%CC%
%SH% -c "%MESON% setup %BUILD_DIR%"
@echo "## xNVMe: make config [DONE]"
@goto :eof
:config-debug
@echo "## xNVMe: make config-debug"
@set CC=%CC%
%SH% -c "%MESON% setup %BUILD_DIR% --buildtype=debug"
@echo "## xNVMe: make config-debug [DONE]"
@goto :eof
:build
@call :info
@call :_require_builddir
@echo "## xNVMe: make build"
%SH% -c "%MESON% compile -C %BUILD_DIR%"
@echo "## xNVMe: make build [DONE]"
@goto :eof
:install
@call :_require_builddir
@echo "## xNVMe: make install"
%SH% -c "%MESON% install -C %BUILD_DIR%"
@echo "## xNVMe: make install [DONE]"
@goto :eof
:uninstall
@echo "## xNVMe: make install"
@if not exist %BUILD_DIR% (
echo "Missing builddir('%BUILD_DIR%)"
)
@cd %BUILD_DIR%
%SH% -c "%MESON% --internal uninstall"
@echo "## xNVMe: make install [DONE]"
@goto :eof
:clean
@echo "## xNVMe: make clean"
%SH% -c "rm -fr %BUILD_DIR% || true"
@echo "## xNVMe: make clean [DONE]"
@goto :eof
:info
@echo "## xNVMe: make info"
@echo "PLATFORM: %PLATFORM_ID%"
@echo "CC: %CC%"
@echo "CTAGS: %CTAGS%"
@echo "NPROC: %NPROC%"
@echo "PROJECT_VER: %PROJECT_VER%"
@echo "## xNVMe: make info [DONE]"
@goto :eof
:git-setup
@echo "## xNVMe:: git-setup"
%SH% -c "%GIT% config core.hooksPath .githooks || true"
@echo "## xNVMe:: git-setup [DONE]"
@goto :eof
:tags
@echo "## xNVMe: make tags"
%SH% -c "%CTAGS% * --languages=C -h="".c.h"" -R --exclude=builddir,include,src,tools,examples,tests,subprojects/* || true"
@echo "## xNVMe: make tags [DONE]"
@goto :eof
:_require_builddir
@if not exist %BUILD_DIR% (
echo ""
echo "+========================================+"
echo " "
echo " ERR: missing builddir: '%BUILD_DIR%' "
echo " "
echo " Configure it first by running: "
echo " "
echo " 'meson setup %BUILD_DIR%' "
echo " "
echo "+========================================+"
echo ""
)
goto :eof
::
:: clobber: clean third-party builds, drop any third-party changes and clean any
:: untracked stuff lying around
::
:clobber
@call :clean
@echo "## xNVMe: clobber"
@git clean -dfx
@git clean -dfX
@git checkout .
@rmdir /s /q subprojects\fio
@rmdir /s /q subprojects\spdk
@rmdir /s /q subprojects\liburing
@echo "## xNVMe: clobber [DONE]"
@goto :eof