dist: support armv7hl
[platform/upstream/dldt.git] / inference-engine / samples / build_samples_msvc.bat
1 @echo off
2
3 :: Copyright (C) 2018-2019 Intel Corporation
4 ::
5 :: Licensed under the Apache License, Version 2.0 (the "License");
6 :: you may not use this file except in compliance with the License.
7 :: You may obtain a copy of the License at
8 ::
9 ::      http://www.apache.org/licenses/LICENSE-2.0
10 ::
11 :: Unless required by applicable law or agreed to in writing, software
12 :: distributed under the License is distributed on an "AS IS" BASIS,
13 :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 :: See the License for the specific language governing permissions and
15 :: limitations under the License.
16
17
18 @setlocal
19 SETLOCAL EnableDelayedExpansion
20 set "ROOT_DIR=%~dp0"
21
22 set "SOLUTION_DIR64=%USERPROFILE%\Documents\Intel\OpenVINO\inference_engine_samples_build"
23 if "%InferenceEngine_DIR%"=="" set "InferenceEngine_DIR=%ROOT_DIR%\..\share"
24
25 set MSBUILD_BIN=
26 set VS_PATH=
27 set VS_VERSION=
28
29 if not "%1" == "" (
30    if "%1"=="VS2015" (
31       set "VS_VERSION=2015" 
32    ) else if "%1"=="VS2017" (
33       set "VS_VERSION=2017" 
34    ) else if "%1"=="VS2019" (
35       set "VS_VERSION=2019" 
36    ) else (
37       echo Unrecognized option specified "%1"
38       echo Supported command line options: VS2015, VS2017, VS2019
39       goto errorHandling
40    )
41 )
42
43 if "%INTEL_OPENVINO_DIR%"=="" (
44     if exist "%ROOT_DIR%\..\..\bin\setupvars.bat" (
45         call "%ROOT_DIR%\..\..\bin\setupvars.bat"
46     ) else (
47         if exist "%ROOT_DIR%\..\..\..\bin\setupvars.bat" (
48             call "%ROOT_DIR%\..\..\..\bin\setupvars.bat" 
49       ) else (
50          echo Failed to set the environment variables automatically    
51          echo To fix, run the following command: ^<INSTALL_DIR^>\bin\setupvars.bat
52          echo where INSTALL_DIR is the OpenVINO installation directory.
53          GOTO errorHandling
54       )
55     )
56
57
58 if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
59    set "PLATFORM=x64"
60 ) else (
61    set "PLATFORM=Win32"
62 )
63
64 set VSWHERE="false"
65 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
66    set VSWHERE="true"
67    cd "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
68 ) else if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
69       set VSWHERE="true"
70       cd "%ProgramFiles%\Microsoft Visual Studio\Installer"
71 ) else (
72    echo "vswhere tool is not found"
73 )
74
75 if !VSWHERE! == "true" (
76    if "!VS_VERSION!"=="" (
77       echo Searching the latest Visual Studio...
78       for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
79          set VS_PATH=%%i
80       )
81    ) else (
82       echo Searching Visual Studio !VS_VERSION!...
83       for /f "usebackq tokens=*" %%i in (`vswhere -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
84          set CUR_VS=%%i
85          if not "!CUR_VS:%VS_VERSION%=!"=="!CUR_VS!" (
86             set VS_PATH=!CUR_VS!
87          )
88       )
89    )
90    if exist "!VS_PATH!\MSBuild\14.0\Bin\MSBuild.exe" (
91       set "MSBUILD_BIN=!VS_PATH!\MSBuild\14.0\Bin\MSBuild.exe"
92    )
93    if exist "!VS_PATH!\MSBuild\15.0\Bin\MSBuild.exe" (
94       set "MSBUILD_BIN=!VS_PATH!\MSBuild\15.0\Bin\MSBuild.exe"
95    )
96    if exist "!VS_PATH!\MSBuild\Current\Bin\MSBuild.exe" (
97       set "MSBUILD_BIN=!VS_PATH!\MSBuild\Current\Bin\MSBuild.exe"
98    )
99 )
100
101 if "!MSBUILD_BIN!" == "" (
102    if "!VS_VERSION!"=="2015" (
103       if exist "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" (
104          set "MSBUILD_BIN=C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
105          set "MSBUILD_VERSION=14 2015"
106       )
107    ) else if "!VS_VERSION!"=="2017" (
108       if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe" (
109          set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
110          set "MSBUILD_VERSION=15 2017"
111       ) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" (
112          set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe"
113          set "MSBUILD_VERSION=15 2017"
114       ) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" (
115          set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"
116          set "MSBUILD_VERSION=15 2017"
117       )
118    )
119 ) else (
120    if not "!MSBUILD_BIN:2019=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=16 2019"
121    if not "!MSBUILD_BIN:2017=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=15 2017"
122    if not "!MSBUILD_BIN:2015=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=14 2015"
123 )
124
125 if "!MSBUILD_BIN!" == "" (
126    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
127    GOTO errorHandling
128 )
129
130 if exist "%SOLUTION_DIR64%\CMakeCache.txt" del "%SOLUTION_DIR64%\CMakeCache.txt"
131
132 echo Creating Visual Studio %MSBUILD_VERSION% %PLATFORM% files in %SOLUTION_DIR64%... && ^
133 cd "%ROOT_DIR%" && cmake -E make_directory "%SOLUTION_DIR64%" && cd "%SOLUTION_DIR64%" && cmake -G "Visual Studio !MSBUILD_VERSION!" -A %PLATFORM% "%ROOT_DIR%"
134
135 echo.
136 echo ###############^|^| Build Inference Engine samples using MS Visual Studio (MSBuild.exe) ^|^|###############
137 echo.
138 echo "!MSBUILD_BIN!" Samples.sln /p:Configuration=Release
139 "!MSBUILD_BIN!" Samples.sln /p:Configuration=Release
140 if ERRORLEVEL 1 GOTO errorHandling
141
142 echo Done.
143 goto :eof
144
145 :errorHandling
146 echo Error