Repository navigation
Expand file tree
/
Copy pathwindows_build.bat
More file actions
120 lines (103 loc) · 4.48 KB
/
Copy pathwindows_build.bat
File metadata and controls
120 lines (103 loc) · 4.48 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
::
:: Copyright (c) 2024 Intel Corporation
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http:::www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::
@echo off
setlocal EnableExtensions EnableDelayedExpansion
:: Need to set shorter build paths for bazel cache for too long commands in mediapipe compilation
:: We expect a first script argument to be "PR-1234" number passed here from jenkins so that a tmp directory will be created
IF "%~1"=="" (
echo No argument provided. Using default opt path
set "BAZEL_SHORT_PATH=C:\opt"
) ELSE (
echo Argument provided: Using install path %1
set "BAZEL_SHORT_PATH=C:\%1"
)
IF "%~2"=="--with_python" (
echo Building model server with Python
set "bazelBuildArgs=--config=win_mp_on_py_on"
set "pythonRuntimeTargets=//src/python:libpython_calculators //src/python:libovmspython"
) ELSE (
echo Building model server without Python
set "bazelBuildArgs=--config=win_mp_on_py_off"
set "pythonRuntimeTargets="
)
IF "%~3"=="--with_tests" (
echo Building model server with tests
set "buildTargets=//src:ovms //src:ovms_test //third_party:espeak_ng //third_party:espeak_ng_data !pythonRuntimeTargets!"
) ELSE (
echo Building model server without tests
set "buildTargets=//src:ovms //third_party:espeak_ng //third_party:espeak_ng_data !pythonRuntimeTargets!"
)
IF "%~4"=="--integrity" (
echo Building model server with integrity checks
set "buildWithIntegrity=--config=win_integritycheck"
) ELSE (
echo Building model server without integrity checks
set "buildWithIntegrity="
)
set "bazelStartupCmd=--output_user_root=!BAZEL_SHORT_PATH!"
set "openvino_dir=!BAZEL_SHORT_PATH!/openvino/runtime/cmake"
set /p bazelVersion=<"%~dp0.bazelversion"
set "bazelPath=C:\opt\bazel-%bazelVersion%-windows-x86_64.exe"
set "buildCommand=%bazelPath% %bazelStartupCmd% build %buildWithIntegrity% %bazelBuildArgs% --action_env OpenVINO_DIR=%openvino_dir% --jobs=%NUMBER_OF_PROCESSORS% --verbose_failures %buildTargets% 2>&1 | tee win_build.log"
set "setOvmsVersionCmd=python windows_set_ovms_version.py"
:: Setting PATH environment variable based on default windows node settings: Added ovms_windows specific python settings and c:/opt and removed unused Nvidia and OCL specific tools.
:: When changing the values here you can print the node default PATH value and base your changes on it.
set "setPath=C:\opt;C:\opt\Python312\;C:\opt\Python312\Scripts\;C:\opt\msys64\usr\bin\;%PATH%;"
set "PYTHONHOME=C:\opt\Python312"
set "envPath=win_environment.log"
set "setPythonPath=%cd%\bazel-out\x64_windows-opt\bin\src\python\binding"
set "BAZEL_SH=C:\opt\msys64\usr\bin\bash.exe"
:: Load chosen dependency versions from versions.mk
for /f "usebackq eol=# tokens=1,3" %%A in ("%cd%\versions.mk") do (
if "%%A"=="OPENCV_VERSION" if "!opencv_version!"=="" set "opencv_version=%%B"
)
:: Bazel compilation settings
set VS_2022_BT="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
IF /I EXIST %VS_2022_BT% goto :msvc_bt ELSE goto :msvc_error
:msvc_error
echo [ERROR] Required MSVC compiler not installed
goto :exit_build_error
:msvc_bt
echo [INFO] Using MSVC %VS_2022_BT%
set BAZEL_VS=%VS_2022_BT%
:: Bazel compilation settings end
:msvc_end
set "BAZEL_VC=%BAZEL_VS:"=%\VC"
set "BAZEL_VC_FULL_VERSION=14.44.35207"
:: Set proper PATH environment variable: Remove other python paths and add c:\opt with bazel to PATH
set "PATH=%setPath%"
:: Set paths with libs for execution - affects PATH
set "openvinoBatch=call !BAZEL_SHORT_PATH!\openvino\setupvars.bat"
set "opencvBatch=call C:\opt\opencv_!opencv_version!\setup_vars_opencv4.cmd"
:: Set required libraries paths
%openvinoBatch%
if !errorlevel! neq 0 exit /b !errorlevel!
%opencvBatch%
set "PYTHONPATH=%PYTHONPATH%;%setPythonPath%"
:: Log all environment variables
set > %envPath%
if !errorlevel! neq 0 exit /b !errorlevel!
:: Set ovms.exe --version parameters
%setOvmsVersionCmd% "%bazelBuildArgs%" !BAZEL_SHORT_PATH!
:: Start bazel build
%buildCommand%
if !errorlevel! neq 0 exit /b !errorlevel!
endlocal
exit /b 0
:exit_build_error
echo Build failed.
endlocal
exit /b 1