forked from xnvme/xnvme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
172 lines (145 loc) · 3.41 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
REM SPDX-FileCopyrightText: Samsung Electronics Co., Ltd
REM
REM SPDX-License-Identifier: BSD-3-Clause
@echo off
@setlocal enableextensions enabledelayedexpansion
set CC=gcc
set CXX=g++
set MESON=meson
set BUILD_DIR=builddir
set GIT=git
set INFO=
set CONFIG=
set BUILD=
set CLEAN=
set CLOBBER=
set INSTALL=
:: set msys2-shell
set SH=call msys2_shell -no-start -here -use-full-path -defterm
for %%i in (%*) do (
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%\msys64;%PATH%"
set "PATH=%SystemDrive%\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
@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% --prefix=/usr"
@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 "CC: %CC%"
@echo "## xNVMe: make info [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
@echo "## xNVMe: clobber [DONE]"
@goto :eof