-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathbuild.bat
175 lines (134 loc) · 4.57 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
setlocal
IF NOT EXIST env.bat (
echo env.bat is not set. Exiting.
exit /b 1
)
call env.bat
echo LIBTORCH_DIR=%LIBTORCH_DIR%
echo OPENVINO_DIR=%OPENVINO_DIR%
echo OPENCL_SDK_DIR=%OPENCL_SDK_DIR%
echo WHISPER_CLONE_DIR=%WHISPER_CLONE_DIR%
echo AUDACITY_CLONE_DIR=%AUDACITY_CLONE_DIR%
echo BUILD_FOLDER=%BUILD_FOLDER%
echo CONAN_HOME=%CONAN_HOME%
echo Path=%Path%
:: Copyright (C) 2024 Intel Corporation
:: SPDX-License-Identifier: GPL-3.0-only
IF "%OPENVINO_DIR%"=="" (
echo OPENVINO_DIR is not set. Exiting.
exit /b 1
)
IF "%LIBTORCH_DIR%"=="" (
echo LIBTORCH_DIR is not set. Exiting.
exit /b 1
)
IF "%OPENCL_SDK_DIR%"=="" (
echo OPENCL_SDK_DIR is not set. Exiting.
exit /b 1
)
IF "%AUDACITY_BUILD_LEVEL%"=="" (
echo AUDACITY_BUILD_LEVEL is not set. Exiting.
exit /b 1
)
IF "%AUDACITY_BUILD_CONFIG%"=="" (
echo AUDACITY_BUILD_CONFIG is not set. Exiting.
exit /b 1
)
IF "%AI_PLUGIN_REPO_SOURCE_FOLDER%"=="" (
echo AI_PLUGIN_REPO_SOURCE_FOLDER is not set. Exiting.
exit /b 1
)
IF "%AUDACITY_CLONE_DIR%"=="" (
echo AUDACITY_CLONE_DIR is not set. Exiting.
exit /b 1
)
IF "%WHISPER_CLONE_DIR%"=="" (
echo WHISPER_CLONE_DIR is not set. Exiting.
exit /b 1
)
set "bat_path=%~dp0"
set audacity_add_ov_mod_patch_path=%bat_path%add_ov_module.patch
set audacity_no_vc_runtime_install_patch=%bat_path%audacity_no_vc_runtime_install.patch
:: Set up OpenVINO build environment.
call %OPENVINO_DIR%\setupvars.bat || exit /b 1
:: Setup Libtorch end.
set LIBTORCH_ROOTDIR=%LIBTORCH_DIR%
set Path=%LIBTORCH_ROOTDIR%\lib;%Path%
:: Setup OpenCL env.
set OCL_ROOT=%OPENCL_SDK_DIR%
set Path=%OCL_ROOT%\bin;%Path%
::::::::::::::::::::::::
:: Whisper.cpp build. ::
::::::::::::::::::::::::
IF NOT EXIST %WHISPER_CLONE_DIR% (
echo Can't find whisper.cpp directory.
echo /B 1
)
:: Create build folder
mkdir whisper-build-avx
cd whisper-build-avx
:: Run CMake, specifying that you want to enable OpenVINO support.
cmake %WHISPER_CLONE_DIR% -A x64 -DWHISPER_OPENVINO=ON || exit /b 1
:: Build it:
cmake --build . --config Release || exit /b 1
:: Install built whisper collateral into a local 'installed' directory:
cmake --install . --config Release --prefix .\installed || exit /b 1
:: Setup whisper.cpp env.
set WHISPERCPP_ROOTDIR=%cd%\installed
set Path=%WHISPERCPP_ROOTDIR%\bin;%Path%
cd ..
:: Also build the non-AVX version
mkdir whisper-build-no-avx
cd whisper-build-no-avx
:: Run CMake, specifying that you want to enable OpenVINO support, but no AVX / AVX2 / other advanced instruction support
cmake %WHISPER_CLONE_DIR% -A x64 -DWHISPER_OPENVINO=ON -DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON -DWHISPER_NO_FMA=ON -DWHISPER_NO_F16C=ON || exit /b 1
:: Build it:
cmake --build . --config Release || exit /b 1
:: Install built whisper collateral into a local 'installed' directory:
cmake --install . --config Release --prefix .\installed || exit /b 1
cd ..
::::::::::::::::::::::::::::::::::::::::::::
:: Audacity + OpenVINO AI Plugins build. ::
::::::::::::::::::::::::::::::::::::::::::::
IF NOT EXIST %AUDACITY_CLONE_DIR% (
echo Can't find whisper.cpp directory.
echo /B 1
)
set current_work_dir=%cd%
:: apply patch that adds mod-openvino to build
cd %AUDACITY_CLONE_DIR%
:: Check if 'git' command exists
git --version >nul 2>&1
IF NOT ERRORLEVEL 1 (
echo Applying patch using git command...
git apply --ignore-whitespace %audacity_add_ov_mod_patch_path% || exit /b 1
git apply --ignore-whitespace %audacity_no_vc_runtime_install_patch% || exit /b 1
) ELSE (
:: Since git is not available, check if 'patch' command exists
patch --version >nul 2>&1
IF NOT ERRORLEVEL 1 (
echo Applying patch using patch command...
patch -p1 < %audacity_add_ov_mod_patch_path% || exit /b 1
patch -p1 < %audacity_no_vc_runtime_install_patch% || exit /b 1
) ELSE (
echo Neither git nor patch command is available.
exit /b 1
)
)
cd %current_work_dir%
set current_work_dir=
xcopy %AI_PLUGIN_REPO_SOURCE_FOLDER%mod-openvino "%AUDACITY_CLONE_DIR%\modules\etc\mod-openvino" /E /I || exit /b 1
:: Build Audacity + our OpenVINO module
mkdir audacity-build
cd audacity-build
if defined Python3_ROOT_DIR (
set Python3_ROOT_DIR_DEFINE=-DPython3_ROOT_DIR=%Python3_ROOT_DIR%
) else (
set Python3_ROOT_DIR_DEFINE=""
)
:: Run cmake
cmake %AUDACITY_CLONE_DIR% -DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS=TRUE -DAUDACITY_BUILD_LEVEL=%AUDACITY_BUILD_LEVEL% %Python3_ROOT_DIR_DEFINE% -DCMAKE_DISABLE_FIND_PACKAGE_MKL=TRUE -DCMAKE_DISABLE_FIND_PACKAGE_MKLDNN=TRUE || exit /b 1
:: build it
cmake --build . --config %AUDACITY_BUILD_CONFIG% || exit /b 1
cd ..
endlocal