You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

windows-build.cmd 6.3KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. setlocal enableextensions
  4. set BuildType=Release
  5. set PauseCommand=pause
  6. set RerunCmake=false
  7. set PackageOption=FALSE
  8. set BrandName=OpenViBE
  9. set DisplayErrorLocation=ON
  10. set DependenciesPath=
  11. set init_env_cmd=windows-initialize-environment.cmd
  12. set generator=-G"Ninja"
  13. set builder=Ninja
  14. set script_dir=%~dp0
  15. set PlatformTarget=x86
  16. goto parameter_parse
  17. :print_help
  18. echo Usage: %0 [options]
  19. echo.
  20. echo -h ^|--help usage
  21. echo --no-pause will not pause during script execution
  22. echo -d^|--debug build in debug mode
  23. echo -r^|--release build in release mode
  24. echo --make-package make packages at the end
  25. echo --hide-error-location do not display complete error locations
  26. echo --rerun-cmake force cmake rerun
  27. echo --userdata-subdir [dirname] name of the userdata sub directory
  28. echo --brand-name [brand name] name of the brand to prefix titles and documentation
  29. echo --build-unit build unit tests
  30. echo --build-validation build validation tests
  31. echo --build-dir [dirname] build directory
  32. echo --install-dir [dirname] binaries deployment directory
  33. echo --dependencies-dir [dirname] directory where dependencies are located
  34. echo --test-data-dir [dirname] test data directory
  35. echo --test-output-dir [dirname] test output files directory
  36. echo --python-exec [path] path to the python executable to use
  37. echo --vsproject Create visual studio project (.sln)
  38. echo --vsbuild Create visual studio project (.sln) and compiles it
  39. echo --platform-target [x86 or x64] Create a 32 or 64 bit. 32bit is the default
  40. echo.
  41. exit /b
  42. :parameter_parse
  43. if /i "%1" == "-h" (
  44. goto print_help
  45. ) else if /i "%1" == "--help" (
  46. goto print_help
  47. ) else if /i "%1" == "--no-pause" (
  48. set PauseCommand=echo ""
  49. SHIFT
  50. Goto parameter_parse
  51. ) else if /i "%1" == "-d" (
  52. set BuildType=Debug
  53. SHIFT
  54. Goto parameter_parse
  55. ) else if /i "%1" == "--debug" (
  56. set BuildType=Debug
  57. SHIFT
  58. Goto parameter_parse
  59. ) else if /i "%1" == "-r" (
  60. set BuildType=Release
  61. SHIFT
  62. Goto parameter_parse
  63. ) else if /i "%1" == "--release" (
  64. set BuildType=Release
  65. SHIFT
  66. Goto parameter_parse
  67. ) else if /i "%1" == "--make-package" (
  68. set PackageOption=TRUE
  69. set DisplayErrorLocation=OFF
  70. SHIFT
  71. Goto parameter_parse
  72. ) else if /i "%1" == "--hide-error-location" (
  73. set DisplayErrorLocation=OFF
  74. SHIFT
  75. Goto parameter_parse
  76. ) else if /i "%1" == "--rerun-cmake" (
  77. set RerunCmake="true"
  78. SHIFT
  79. Goto parameter_parse
  80. ) else if /i "%1" == "--build-unit" (
  81. set ov_build_unit=true
  82. SHIFT
  83. Goto parameter_parse
  84. ) else if /i "%1" == "--build-validation" (
  85. set ov_build_validation=true
  86. SHIFT
  87. Goto parameter_parse
  88. ) else if /i "%1" == "--test-data-dir" (
  89. set ov_cmake_test_data="-DOVT_TEST_DATA_DIR=%2"
  90. SHIFT
  91. SHIFT
  92. Goto parameter_parse
  93. ) else if /i "%1" == "--test-output-dir" (
  94. set ov_cmake_test_output="%2"
  95. SHIFT
  96. SHIFT
  97. Goto parameter_parse
  98. ) else if /i "%1" == "--python-exec" (
  99. set python_exec="-DPYTHON_EXECUTABLE=%2"
  100. SHIFT
  101. SHIFT
  102. Goto parameter_parse
  103. ) else if /i "%1" == "--userdata-subdir" (
  104. set UserDataSubdir="-DOV_CONFIG_SUBDIR=%2"
  105. SHIFT
  106. SHIFT
  107. Goto parameter_parse
  108. ) else if /i "%1" == "--brand-name" (
  109. set BrandName="%2"
  110. SHIFT
  111. SHIFT
  112. Goto parameter_parse
  113. ) else if /i "%1"=="--build-dir" (
  114. set build_dir=%2
  115. SHIFT
  116. SHIFT
  117. Goto parameter_parse
  118. ) else if /i "%1"=="--install-dir" (
  119. set install_dir=%2
  120. SHIFT
  121. SHIFT
  122. Goto parameter_parse
  123. ) else if /i "%1"=="--dependencies-dir" (
  124. set DependenciesPath="-DOV_CUSTOM_DEPENDENCIES_PATH=%2"
  125. set init_env_cmd=windows-initialize-environment.cmd --dependencies-dir %2
  126. SHIFT
  127. SHIFT
  128. Goto parameter_parse
  129. ) else if /i "%1"=="--vsproject" (
  130. set vsgenerate=TRUE
  131. set builder=None
  132. SHIFT
  133. Goto parameter_parse
  134. ) else if /i "%1"=="--vsbuild" (
  135. set vsgenerate=TRUE
  136. set builder=Visual
  137. SHIFT
  138. Goto parameter_parse
  139. ) else if /i "%1"=="--platform-target" (
  140. set PlatformTarget=%2
  141. SHIFT
  142. SHIFT
  143. Goto parameter_parse
  144. )else if not "%1" == "" (
  145. echo unrecognized option [%1]
  146. Goto terminate_error
  147. )
  148. if defined vsgenerate (
  149. echo Build type is set to: MultiType.
  150. ) else (
  151. echo Build type is set to: %BuildType%.
  152. )
  153. setlocal
  154. call %init_env_cmd% --platform-target %PlatformTarget%
  155. echo Compiler is: %VSCMake%
  156. if defined vsgenerate (
  157. if /i "%PlatformTarget%" == "x64" (
  158. set generator=-G"%VSCMake% Win64" -T "v120"
  159. ) else (
  160. set generator=-G"%VSCMake%" -T "v120"
  161. )
  162. if not defined build_dir (
  163. set build_dir=%script_dir%\..\..\openvibe-sdk-build\vs-project-%PlatformTarget%
  164. )
  165. if not defined install_dir (
  166. set install_dir=%script_dir%\..\..\openvibe-sdk-build\dist-%PlatformTarget%
  167. )
  168. ) else (
  169. set build_type="-DCMAKE_BUILD_TYPE=%BuildType%"
  170. if not defined build_dir (
  171. set build_dir=%script_dir%\..\..\openvibe-sdk-build\build-%BuildType%-%PlatformTarget%
  172. )
  173. if not defined install_dir (
  174. set install_dir=%script_dir%\..\..\openvibe-sdk-build\dist-%BuildType%-%PlatformTarget%
  175. )
  176. )
  177. if not defined ov_cmake_test_output (
  178. set ov_cmake_test_output=%build_dir%\validation-test-output\
  179. )
  180. mkdir %build_dir% 2>NUL
  181. pushd %build_dir%
  182. set CallCmake=false
  183. if not exist "%build_dir%\CMakeCache.txt" set CallCmake="true"
  184. if %RerunCmake%=="true" set CallCmake="true"
  185. if %CallCmake%=="true" (
  186. cmake %script_dir%\.. %generator% ^
  187. %build_type% ^
  188. -DCMAKE_INSTALL_PREFIX=%install_dir% ^
  189. -DOV_PACKAGE=%PackageOption% ^
  190. -DOV_DISPLAY_ERROR_LOCATION=%DisplayErrorLocation% ^
  191. -DBUILD_UNIT_TEST=%ov_build_unit% ^
  192. -DBUILD_VALIDATION_TEST=%ov_build_validation% ^
  193. %ov_cmake_test_data% ^
  194. -DBRAND_NAME=%BrandName% ^
  195. %UserDataSubdir% ^
  196. -DOVT_VALIDATION_TEST_OUTPUT_DIR=%ov_cmake_test_output% ^
  197. %python_exec% ^
  198. %DependenciesPath%
  199. )
  200. if not "!ERRORLEVEL!" == "0" goto terminate_error
  201. if !builder! == None (
  202. goto terminate_success
  203. ) else if !builder! == Ninja (
  204. ninja install
  205. if not "!ERRORLEVEL!" == "0" goto terminate_error
  206. ) else if !builder! == Visual (
  207. if %PlatformTarget% == x86 (
  208. set msplatform=Win32
  209. ) else (
  210. set msplatform=%PlatformTarget%
  211. )
  212. msbuild OpenVIBE.sln /p:Configuration=%BuildType% /p:Platform="!msplatform!"
  213. if not "!ERRORLEVEL!" == "0" goto terminate_error
  214. cmake --build . --config %BuildType% --target install
  215. if not "!ERRORLEVEL!" == "0" goto terminate_error
  216. )
  217. if %PackageOption% == TRUE (
  218. cmake --build . --target package
  219. if not "!ERRORLEVEL!" == "0" goto terminate_error
  220. )
  221. goto terminate_success
  222. :terminate_error
  223. echo An error occured during building process !
  224. %PauseCommand%
  225. goto terminate
  226. :terminate_success
  227. %PauseCommand%
  228. goto terminate
  229. :terminate
  230. popd
  231. endlocal