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.

unix-build 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #!/bin/bash
  2. # This is the build script to configure and build OpenViBE on
  3. # unix-based platform.
  4. # Functions definition
  5. function usage()
  6. {
  7. echo "usage: ./unix-build [options]"
  8. echo ""
  9. echo "-h | --help : usage"
  10. echo "-v | --verbose : verbose output at building step"
  11. echo "--build-type=<Debug|Release|RelWithDebInfo> : build type"
  12. echo "--build-dir=<dirname> : build directory"
  13. echo "--install-dir=<dirname> : binaries deployment directory"
  14. echo "--test-data-dir=<dirname> : test data directory"
  15. echo "--make-package : a package will be created in build directory"
  16. echo "--hide-error-location : do not display complete error locations"
  17. echo "--sdk=<dirname> : path to the Openvibe SDK"
  18. echo "--oem-distribution=<name of the oem distribution> : distribution name, can be openvibe or mensia"
  19. echo "--userdata-subdir=<dirname> name of the userdata sub directory"
  20. }
  21. # Script starting point
  22. # As options are not mandatory, set some default values for each target
  23. # variables
  24. ov_script_dir="${PWD}"
  25. ov_build_type=Release
  26. ov_test_data_dir="${ov_script_dir}/../dependencies/test-data"
  27. ov_oem_distribution="openvibe"
  28. verbose="OFF"
  29. package_option="FALSE"
  30. display_error_location="ON"
  31. # Parse arguments
  32. for i in "$@"
  33. do
  34. case $i in
  35. -h | --help)
  36. usage
  37. exit
  38. ;;
  39. -v | --verbose)
  40. verbose="ON"
  41. shift
  42. ;;
  43. --build-type=*)
  44. ov_build_type="${i#*=}"
  45. shift
  46. ;;
  47. --build-dir=*)
  48. ov_build_dir="${i#*=}"
  49. shift
  50. ;;
  51. --install-dir=*)
  52. ov_install_dir="${i#*=}"
  53. shift
  54. ;;
  55. --make-package)
  56. package_option="TRUE"
  57. display_error_location="OFF"
  58. shift
  59. ;;
  60. --hide-error-location)
  61. display_error_location="OFF"
  62. ;;
  63. --test-data-dir=*)
  64. ov_test_data_dir="${i#*=}"
  65. shift
  66. ;;
  67. --sdk=*)
  68. ov_sdk_dir="${i#*=}"
  69. shift
  70. ;;
  71. --oem-distribution=*)
  72. ov_oem_distribution="${i#*=}"
  73. shift
  74. ;;
  75. --userdata-subdir=*)
  76. UserDataSubdir="-DOV_CONFIG_SUBDIR=${i#*=}"
  77. shift
  78. ;;
  79. *)
  80. echo "ERROR: Unknown parameter $i"
  81. exit 1
  82. ;;
  83. esac
  84. done
  85. # Check parameters validity
  86. if [[ ${ov_build_type} != "Debug" ]] \
  87. && [[ ${ov_build_type} != "Release" ]] \
  88. && [[ ${ov_build_type} != "RelWithDebInfo" ]]
  89. then
  90. echo "ERROR: ${ov_build_type} not handled as build type"
  91. exit 1
  92. fi
  93. if [[ ${ov_build_type} == "Debug" ]]; then
  94. sdk_affix="debug"
  95. elif [[ ${ov_build_type} == "Release" ]] || [[ ${ov_build_type} == "RelWithDebInfo" ]]; then
  96. sdk_affix="release"
  97. fi
  98. if [[ ! -v ov_sdk_dir ]]; then
  99. ov_sdk_dir="${ov_script_dir}/../dependencies/openvibe-sdk-${sdk_affix}"
  100. fi
  101. if [[ ! -v ov_build_dir ]]; then
  102. ov_build_dir="${ov_script_dir}/../../openvibe-designer-build/build-${ov_build_type}"
  103. fi
  104. if [[ ! -v ov_install_dir ]]; then
  105. ov_install_dir="${ov_script_dir}/../../openvibe-designer-build/dist-${ov_build_type}"
  106. fi
  107. echo "**************************************"
  108. echo "Build with parameters:"
  109. echo "[build-type] = ${ov_build_type}"
  110. echo "[build-dir] = ${ov_build_dir}"
  111. echo "[install-dir] = ${ov_install_dir}"
  112. echo "[test-data-dir] = ${ov_test_data_dir}"
  113. echo "[sdk] = ${ov_sdk_dir}"
  114. echo "[oem-distribution] = ${ov_oem_distribution}"
  115. echo "[display-error-location] = ${display_error_location}"
  116. echo "**************************************"
  117. echo ""
  118. echo ""
  119. # Special configuration for MacOS
  120. uname_string=$(uname)
  121. if [[ "$uname_string" == 'Darwin' ]]; then
  122. export PKG_CONFIG_PATH="/opt/X11/lib/pkgconfig:$PKG_CONFIG_PATH"
  123. fi
  124. # Create necessary directories
  125. mkdir -p "${ov_build_dir}" &> /dev/null
  126. # Change directory to build directory as cmake has to be run from build
  127. # directory
  128. pushd "${ov_build_dir}" &> /dev/null
  129. echo "Generating build system files with cmake..."
  130. cmake ${ov_script_dir}/.. \
  131. -G Ninja \
  132. -DCMAKE_BUILD_TYPE=${ov_build_type} \
  133. -DCMAKE_INSTALL_PREFIX=${ov_install_dir} \
  134. -DOV_PACKAGE=${package_option} \
  135. -DOV_DISPLAY_ERROR_LOCATION=${display_error_location} \
  136. -DOVT_TEST_DATA_DIR=${ov_test_data_dir} \
  137. -DFlag_VerboseOutput=${verbose} \
  138. -DOPENVIBE_SDK_PATH=${ov_sdk_dir} \
  139. -DOEM_DISTRIBUTION=${ov_oem_distribution} \
  140. ${UserDataSubdir}
  141. if [[ $? == 0 ]]; then
  142. echo "Generation succeeded!"
  143. else
  144. echo "ERROR: Generation failed"
  145. exit 1
  146. fi
  147. echo "Building project..."
  148. if [[ $verbose == "ON" ]]; then
  149. ninja -v install
  150. else
  151. ninja install
  152. fi
  153. if [[ $? == 0 ]]; then
  154. echo "Build succeeded!"
  155. else
  156. echo "ERROR: Build failed"
  157. exit 1
  158. fi
  159. if [[ ${package_option} == "TRUE" ]]; then
  160. cmake --build . --target package
  161. if [[ $? == 0 ]]; then
  162. echo "Package succeeded!"
  163. else
  164. echo "ERROR: Package failed"
  165. exit 1
  166. fi
  167. fi
  168. popd &> /dev/null
  169. exit