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