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 5.7KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. setlocal enableextensions
  4. REM no options / set to default
  5. set BuildType=Release
  6. set InitEnvScript=windows-init_env_command.cmd
  7. set PAUSE=pause
  8. set ov_script_dir=%CD%
  9. set generator=-G"Ninja"
  10. set builder=Ninja
  11. set PlatformTarget=x86
  12. :parameter_parse
  13. if /i "%1"=="-h" (
  14. echo Usage: windows-build.cmd [Build Type] [Init-env Script]
  15. echo -- Build Type option can be : --release (-r^), --debug (-d^) or --debug-symbols. Default is Release.
  16. echo -- Default Init-env script is: windows-init_env_command.cmd
  17. pause
  18. exit 0
  19. ) else if /i "%1"=="--help" (
  20. echo Usage: windows-build.cmd [Build Type] [Init-env Script]
  21. echo -- Build Type option can be : --release (-r^), --debug (-d^) or --debug-symbols. Default is Release.
  22. echo -- Default Init-env script is: windows-init_env_command.cmd
  23. pause
  24. exit 0
  25. ) else if /i "%1"=="--no-pause" (
  26. set PAUSE=echo ""
  27. SHIFT
  28. Goto parameter_parse
  29. ) else if /i "%1"=="-d" (
  30. set BuildType=Debug
  31. REM set !InitEnvScript!=%2
  32. SHIFT
  33. Goto parameter_parse
  34. ) else if /i "%1"=="--debug" (
  35. set BuildType=Debug
  36. REM set !InitEnvScript!=%2
  37. SHIFT
  38. Goto parameter_parse
  39. ) else if /i "%1"=="--debug-symbols" (
  40. set BuildType=RelWithDebInfo
  41. REM set !InitEnvScript!=%2
  42. SHIFT
  43. Goto parameter_parse
  44. ) else if /i "%1"=="-r" (
  45. set BuildType=Release
  46. REM set !InitEnvScript!=%2
  47. SHIFT
  48. Goto parameter_parse
  49. ) else if /i "%1"=="--release" (
  50. set BuildType=Release
  51. REM set !InitEnvScript!=%2
  52. SHIFT
  53. Goto parameter_parse
  54. ) else if /i "%1"=="--sdk" (
  55. set sdk=-DOPENVIBE_SDK_PATH=%2
  56. set sdk_val=%2
  57. SHIFT
  58. SHIFT
  59. Goto parameter_parse
  60. ) else if /i "%1"=="--designer" (
  61. set designer=-DDESIGNER_SDK_PATH=%2
  62. set designer_val=%2
  63. SHIFT
  64. SHIFT
  65. Goto parameter_parse
  66. ) else if /i "%1"=="--build-dir" (
  67. set ov_build_dir=%2
  68. SHIFT
  69. SHIFT
  70. Goto parameter_parse
  71. ) else if /i "%1"=="--install-dir" (
  72. set ov_install_dir=%2
  73. SHIFT
  74. SHIFT
  75. Goto parameter_parse
  76. ) else if /i "%1"=="--dependencies-dir" (
  77. set dependencies_path="-DLIST_DEPENDENCIES_PATH=%2"
  78. set dependencies_base=%2
  79. SHIFT
  80. SHIFT
  81. Goto parameter_parse
  82. ) else if /i "%1"=="--vsproject" (
  83. set vsgenerate=TRUE
  84. set builder=None
  85. SHIFT
  86. Goto parameter_parse
  87. ) else if /i "%1"=="--vsbuild" (
  88. set vsgenerate=TRUE
  89. set builder=Visual
  90. SHIFT
  91. Goto parameter_parse
  92. ) else if /i "%1" == "--userdata-subdir" (
  93. set UserDataSubdir="-DOV_CONFIG_SUBDIR=%2"
  94. SHIFT
  95. SHIFT
  96. Goto parameter_parse
  97. ) else if /i "%1"=="--platform-target" (
  98. set PlatformTarget=%2
  99. SHIFT
  100. SHIFT
  101. Goto parameter_parse
  102. ) else if not "%1" == "" (
  103. echo unrecognized option [%1]
  104. Goto terminate_error
  105. )
  106. REM else if not "%1"=="" (
  107. REM set BuildType=Release
  108. REM set !InitEnvScript!=%1
  109. REM SHIFT
  110. REM Goto parameter_parse
  111. REM )
  112. if /i "!InitEnvScript!"=="windows-init_env_command.cmd" (
  113. echo No script specified. Default will be used.
  114. )
  115. if defined vsgenerate (
  116. echo Build type is set to: MultiType.
  117. ) else (
  118. echo Build type is set to: %BuildType%.
  119. )
  120. echo Init-env Script to be called: !InitEnvScript!.
  121. REM #######################################################################################
  122. call "!InitEnvScript!" --dependencies-dir %dependencies_base% --platform-target %PlatformTarget%
  123. REM #######################################################################################
  124. if defined vsgenerate (
  125. if /i "%PlatformTarget%" == "x64" (
  126. set generator=-G"%VSCMake% Win64" -T "v120"
  127. ) else (
  128. set generator=-G"%VSCMake%" -T "v120"
  129. )
  130. if not defined build_dir (
  131. set build_dir=%root_dir%\..\openvibe-extras-build\vs-project
  132. )
  133. if not defined install_dir (
  134. set install_dir=%root_dir%\..\openvibe-extras-build\dist
  135. )
  136. ) else (
  137. set build_type="-DCMAKE_BUILD_TYPE=%BuildType%"
  138. if not defined build_dir (
  139. set build_dir=%root_dir%\..\openvibe-extras-build\build-%BuildType%
  140. )
  141. if not defined install_dir (
  142. set install_dir=%root_dir%\..\openvibe-extras-build\dist-%BuildType%
  143. )
  144. )
  145. if defined sdk (
  146. echo SDK is located at %sdk_val%
  147. ) else (
  148. echo "Using default for SDK path (check CMake for inferred value)"
  149. )
  150. if defined designer (
  151. echo Designer is located at %designer_val%
  152. ) else (
  153. echo "Using default for Designer path (check CMake for inferred value)"
  154. )
  155. echo.
  156. echo _______________________________________________________________________________
  157. echo.
  158. mkdir %ov_build_dir% 2>NUL
  159. cd /D %ov_build_dir%
  160. echo Generating makefiles for %VSCMake%.
  161. echo Building to %ov_build_dir% ...
  162. cmake %ov_script_dir%\.. %generator% %build_type% -DCMAKE_INSTALL_PREFIX=%ov_install_dir% %designer% %sdk% %dependencies_path% %UserDataSubdir%
  163. IF NOT "!ERRORLEVEL!" == "0" goto terminate_error
  164. echo.
  165. echo Building and installing ...
  166. echo.
  167. if !builder! == None (
  168. goto terminate_success
  169. ) else if !builder! == Ninja (
  170. ninja install
  171. if not "!ERRORLEVEL!" == "0" goto terminate_error
  172. ) else if !builder! == Visual (
  173. if %PlatformTarget% == x86 (
  174. set msplatform=Win32
  175. ) else (
  176. set msplatform=%PlatformTarget%
  177. )
  178. msbuild Openvibe.sln /verbosity:normal /p:Configuration=%BuildType% /p:Platform="!msplatform!"
  179. if not "!ERRORLEVEL!" == "0" goto terminate_error
  180. cmake --build . --config %BuildType% --target install
  181. if not "!ERRORLEVEL!" == "0" goto terminate_error
  182. )
  183. echo.
  184. echo Install completed !
  185. echo.
  186. echo.
  187. echo _______________________________________________________________________________
  188. echo.
  189. goto terminate_success
  190. REM #######################################################################################
  191. :terminate_error
  192. echo.
  193. echo An error occured during building process !
  194. echo.
  195. %PAUSE%
  196. cd %ov_script_dir%
  197. exit /b 1
  198. REM #######################################################################################
  199. :terminate_success
  200. %PAUSE%
  201. goto terminate
  202. REM #######################################################################################
  203. :terminate
  204. cd %ov_script_dir%