pastebin - collaborative debugging tool
rovema.kpaste.net RSS


RDE: buildrdecygwin.bash
Posted by Anonymous on Tue 5th Sep 2023 11:50
raw | new post
view followups (newest first): RDE: buildrdecygwin.bash by Anonymous
modification of post by Anonymous (view diff)

  1. #!/bin/bash
  2.  
  3. #
  4. # buildrdecygwin.bash - build ROVEMA RDE using Cygwin
  5. #
  6.  
  7. #
  8. # Written by Roland Mainz <roland.mainz@rovema.de>
  9. #
  10.  
  11. #
  12. # Usage:
  13. #
  14. # 1. Build RDE
  15. # mkdir try10_rde_new_rds/
  16. # cd try10_rde_new_rds
  17. # git clone https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/Dependencies
  18. # git clone --recurse-submodules https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/RDE-Development
  19. # cd RDE-Development/
  20. # mkdir build_windows4
  21. # cd build_windows4/
  22. # time nice bash ../scripts/buildrdecygwin.bash buildall 2>&1 | tee -a buildlog.log
  23. #
  24. # 2a. Start RDE (manually):
  25. # $ bash -c 'PATH+=":${qtpath}/5.15.2/mingw81_64/bin" ; ./rde'
  26. #
  27. # 2b. Start RDE (via script):
  28. # $ bash buildrdecygwin.bash run
  29. #
  30.  
  31.  
  32. function calc_max_parallel_jobs
  33. {
  34.         set -o nounset
  35.  
  36.         typeset -li mem_total=-1
  37.         typeset -li swap_total=-1
  38.         typeset -r -li memory_per_job=$2
  39.         typeset -r -li num_cpus=$(getconf '_NPROCESSORS_ONLN')
  40.         typeset -li numjobs_in_memory
  41.         typeset -n numjobs=$1
  42.  
  43.         read mem_total <<<"$(awk \
  44.                 $'/MemTotal/ { print $2 }' \
  45.                 <'/proc/meminfo')"
  46.         read swap_total <<<"$(awk \
  47.                 $'/SwapTotal/ { print $2 }' \
  48.                 <'/proc/meminfo')"
  49.                
  50.         printf $"%s: mem_total=%d, swap_total=%d\n" \
  51.                 "$0" \
  52.                 "$mem_total" \
  53.                 "$swap_total"
  54.  
  55.         # data in /proc/meminto are in KB, but we need bytes
  56.         (( mem_total*=1024, swap_total*=1024 ))
  57.  
  58.         # handle read errors
  59.         if (( (mem_total < 0) || (swap_total < 0) )) ; then
  60.                 printf $"%s: error, could not read memory data\n" "$0"
  61.                 return 1
  62.         fi
  63.  
  64.         # we need at least 1GB of swap space
  65.         if (( swap_total < (1024*1024*1924) )) ; then
  66.                 printf $"#\n# %s: ERROR: Swap memory too low %d\n#\n" "$0" "$swap_total"
  67.                 return 1
  68.         fi
  69.  
  70.         # Reserve 256MB for the Windows OS
  71.         (( mem_total -= 256*1024*1024 ))
  72.  
  73.         # calculate how much jobs would fit into the memory
  74.         (( numjobs_in_memory = (mem_total+memory_per_job+1) / memory_per_job ))
  75.  
  76.         # restrict the number of jobs to twice the amount of CPUs
  77.         (( numjobs = (numjobs_in_memory > (num_cpus*2))?(num_cpus*2):numjobs_in_memory ))
  78.  
  79.         # we want at least one job
  80.         (( numjobs = (numjobs > 1)?numjobs:1 ))
  81.        
  82.         # statistics
  83.         printf $"%s: memory_per_job=%d\n"       "$0" "$memory_per_job"
  84.         printf $"%s: numjobs_in_memory=%d\n"    "$0" "$numjobs_in_memory"
  85.         printf $"%s: numjobs=%d\n"              "$0" "$numjobs"
  86.  
  87.         return 0
  88. }
  89.  
  90.  
  91. #
  92. # Configuration paths
  93. #
  94. function configure_paths
  95. {
  96.         boost_Version='1_71_0'
  97.         qt_Version='5_15_2'
  98.  
  99.         #
  100.         # Prebuild RDE build tools (compiler etc)
  101.         # (from $ git clone https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/Dependencies #)
  102.         #
  103.         #git_rde_dependicies_dir='/cygdrive/h/tmp/winnfstest/hummingbirdnfstest1/rde_windows_developmement/Dependencies/win/'
  104.         #git_rde_dependicies_dir='/home/roland_mainz/work/rde/build_dep/Dependencies/win/'
  105.         git_rde_dependicies_dir="$(realpath "$PWD/../../Dependencies")/win/"
  106.         if [[ ! -d "$git_rde_dependicies_dir" ]] ; then
  107.                 printf $"%s: ERROR: %s dir not found\n" "$0" "$git_rde_dependicies_dir" 1>&2
  108.                 return 1
  109.         fi
  110.  
  111.         boostpath="${git_rde_dependicies_dir}/boost/boost_${boost_Version}/"
  112.         qtpath="${git_rde_dependicies_dir}/qt/qt_${qt_Version}/"
  113.  
  114.         printf $"# building with boost version %s and qt version %s\n" "$boost_Version" "qt_Version"
  115.  
  116.         # Setting-up PATH
  117.         export PATH="$qtpath/Tools/mingw810_64/bin/:$qtpath/5.15.2/mingw81_64/bin/:$qtpath/Tools/CMake_64/bin/:$boostpath/bin/:$boostpath/lib/:$PATH"
  118.         printf $"# PATH=%s\n# Windows PATH=%s\n" "$PATH" "$(cygpath -p -w "$PATH")"
  119.         return 0
  120. }
  121.  
  122. function probe_paths
  123. {
  124.         printf $"# Probing PATH for tools ...\n"
  125.         which -a gcc
  126.         which -a g++
  127.         which -a cmake
  128.         which -a make
  129.  
  130.         return 0
  131. }
  132.  
  133. #
  134. # Build
  135. #
  136.  
  137. function build_clean
  138. {
  139.         printf $"# Cleanup old build stuff ...\n"
  140.         rm -Rf CMake* CPack* CTestTestfile.cmake app_translations.qrc cmake_install.cmake nowide tests RDS Makefile *.qm rde.rc rde_autogen tmp versioninfo.cpp
  141.         return 0
  142. }
  143.  
  144. function build_cmake_config
  145. {
  146.         printf $"# Running build configuration via cmake ...\n"
  147.         # note: Windows/minGW uses '-G "MinGW Makefiles"', while compiling with Cygwin requires '-G "Unix Makefiles"'
  148.         cmake -G "Unix Makefiles" -DBOOST_ROOT="$boostpath" -DBoost_LIB_PREFIX="lib" -DBoost_USE_STATIC_LIBS=TRUE -DBoost_ARCHITECTURE="-x64" -DBUILD_TESTS=ON ".."
  149.         return 0
  150. }
  151.  
  152. function build_cmake_clean
  153. {
  154.         printf $"# Target clean ...\n"
  155.         cmake --build . -j 1 --target clean
  156.         return 0
  157. }
  158.  
  159. function build_cmake_targets
  160. {
  161.         typeset -li num_parallel_jobs=$1
  162.  
  163.         printf $"# Building ...\n"
  164.  
  165.         cmake --build . -j $num_parallel_jobs
  166.         printf $"%s: Build done.\n" "$0"
  167.         return 0
  168. }
  169.  
  170. #
  171. # main
  172. #
  173. set -o errexit
  174. set -o nounset
  175. #set -o xtrace # debug
  176.  
  177. printf $"%s: Start ...\n" "$0"
  178.  
  179. # Check whether we are really on Cygwin...
  180. if [[ "$(uname -s)" != *CYGWIN* ]] ; then
  181.         printf $"%s: ERROR: Not a Cygwin environment.\n" "$0" 1>&2
  182.         exit 1
  183. fi
  184.  
  185. typeset boost_Version qt_Version git_rde_dependicies_dir boostpath qtpath
  186. typeset -li num_parallel_jobs
  187.  
  188. configure_paths
  189.  
  190. case "${1-}" in
  191.         'buildall')
  192.                 calc_max_parallel_jobs num_parallel_jobs $((512*1024*1024)) || exit 1
  193.                 probe_paths
  194.                 build_clean
  195.                 build_cmake_config
  196.                 build_cmake_clean
  197.                 build_cmake_targets "$num_parallel_jobs"
  198.                 ;;
  199.         'clean')
  200.                 build_clean
  201.                 ;;
  202.         'run')
  203.                 ./rde
  204.                 exit $?
  205.                 ;;
  206.         *)
  207.                 printf $"%s: Unknown cmd %q\n" "$0" "${1-}" 1>&2
  208.                 exit 1
  209.                 ;;
  210. esac
  211.  
  212. exit 0
  213.  
  214. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at