-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild_windows.bat
145 lines (128 loc) · 5.3 KB
/
build_windows.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
@echo off
:: Copyright (C) 2018-2019 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.
@setlocal
SETLOCAL EnableDelayedExpansion
set "ROOT_DIR=%~dp0"
set "SOLUTION_DIR64=.\build"
set MSBUILD_BIN=
set VS_PATH=
set VS_VERSION=
if not "%1" == "" (
if "%1"=="VS2015" (
set "VS_VERSION=2015"
) else if "%1"=="VS2017" (
set "VS_VERSION=2017"
) else if "%1"=="VS2019" (
set "VS_VERSION=2019"
) else (
echo Unrecognized option specified "%1"
echo Supported command line options: VS2015, VS2017, VS2019
goto errorHandling
)
)
if "%INTEL_OPENVINO_DIR%"=="" (
if exist "%ROOT_DIR%\..\..\bin\setupvars.bat" (
call "%ROOT_DIR%\..\..\bin\setupvars.bat"
) else (
if exist "%ROOT_DIR%\..\..\..\bin\setupvars.bat" (
call "%ROOT_DIR%\..\..\..\bin\setupvars.bat"
) else (
echo Failed to set the environment variables automatically
echo To fix, run the following command: ^<INSTALL_DIR^>\bin\setupvars.bat
echo where INSTALL_DIR is the OpenVINO installation directory.
GOTO errorHandling
)
)
)
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
set "PLATFORM=x64"
) else (
set "PLATFORM=Win32"
)
set VSWHERE="false"
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
set VSWHERE="true"
cd "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
) else if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
set VSWHERE="true"
cd "%ProgramFiles%\Microsoft Visual Studio\Installer"
) else (
echo "vswhere tool is not found"
)
if !VSWHERE! == "true" (
if "!VS_VERSION!"=="" (
echo Searching the latest Visual Studio...
for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set VS_PATH=%%i
)
) else (
echo Searching Visual Studio !VS_VERSION!...
for /f "usebackq tokens=*" %%i in (`vswhere -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set CUR_VS=%%i
if not "!CUR_VS:%VS_VERSION%=!"=="!CUR_VS!" (
set VS_PATH=!CUR_VS!
)
)
)
if exist "!VS_PATH!\MSBuild\14.0\Bin\MSBuild.exe" (
set "MSBUILD_BIN=!VS_PATH!\MSBuild\14.0\Bin\MSBuild.exe"
)
if exist "!VS_PATH!\MSBuild\15.0\Bin\MSBuild.exe" (
set "MSBUILD_BIN=!VS_PATH!\MSBuild\15.0\Bin\MSBuild.exe"
)
if exist "!VS_PATH!\MSBuild\Current\Bin\MSBuild.exe" (
set "MSBUILD_BIN=!VS_PATH!\MSBuild\Current\Bin\MSBuild.exe"
)
)
if "!MSBUILD_BIN!" == "" (
if "!VS_VERSION!"=="2015" (
if exist "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" (
set "MSBUILD_BIN=C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
set "MSBUILD_VERSION=14 2015"
)
) else if "!VS_VERSION!"=="2017" (
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe" (
set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
set "MSBUILD_VERSION=15 2017"
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" (
set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe"
set "MSBUILD_VERSION=15 2017"
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" (
set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"
set "MSBUILD_VERSION=15 2017"
)
)
) else (
if not "!MSBUILD_BIN:2019=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=16 2019"
if not "!MSBUILD_BIN:2017=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=15 2017"
if not "!MSBUILD_BIN:2015=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=14 2015"
)
if "!MSBUILD_BIN!" == "" (
echo Build tools for Microsoft Visual Studio !VS_VERSION! cannot be found. If you use Visual Studio 2017, please download and install build tools from https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017
GOTO errorHandling
)
if exist "%SOLUTION_DIR64%\CMakeCache.txt" del "%SOLUTION_DIR64%\CMakeCache.txt"
echo Creating Visual Studio %MSBUILD_VERSION% %PLATFORM% files in %SOLUTION_DIR64%... && ^
cmake -E make_directory "%SOLUTION_DIR64%" && cd "%SOLUTION_DIR64%" && cmake -G "Visual Studio !MSBUILD_VERSION!" -A %PLATFORM% "%ROOT_DIR%"
echo.
echo ###############^|^| Build Inference Engine Demos using MS Visual Studio (MSBuild.exe) ^|^|###############
echo.
echo "!MSBUILD_BIN!" MyYogini.sln /p:Configuration=Release
"!MSBUILD_BIN!" MyYogini.sln /p:Configuration=Release
if ERRORLEVEL 1 GOTO errorHandling
echo Done.
goto :eof
:errorHandling
echo Error