pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post 9f3 by Anonymous on Tue 5th Sep 2023 16:55
original post fbd661 by Anonymous on Tue 5th Sep 2023 11:50
Download diff
Show old version | new version | both versions

    
11
#!/bin/bash
22
33
#
44
# buildrdecygwin.bash - build ROVEMA RDE using Cygwin
55
#
66
77
#
88
# Written by Roland Mainz <roland.mainz@rovema.de>
99
#
1010
1111
#
1212
# Usage:
1313
#
1414
# 1. Build RDE
1515
# mkdir try10_rde_new_rds/
1616
# cd try10_rde_new_rds
1717
# git clone https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/Dependencies
1818
# git clone --recurse-submodules https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/RDE-Development
1919
# cd RDE-Development/
2020
# mkdir build_windows4
2121
# cd build_windows4/
2222
# time nice bash ../scripts/buildrdecygwin.bash buildall 2>&1 | tee -a buildlog.log
2323
#
2424
# 2a. Start RDE (manually):
2525
# $ bash -c 'PATH+=":${qtpath}/5.15.2/mingw81_64/bin" ; ./rde'
2626
#
2727
# 2b. Start RDE (via script):
2828
# $ bash buildrdecygwin.bash run
2929
#
3030
3131
3232
function calc_max_parallel_jobs
3333
{
3434
	set -o nounset
3535
3636
	typeset -li mem_total=-1
3737
	typeset -li swap_total=-1
3838
	typeset -r -li memory_per_job=$2
39+
	typeset -r -li jobs_per_cpu=$3
3940
	typeset -r -li num_cpus=$(getconf '_NPROCESSORS_ONLN')
4041
	typeset -li numjobs_in_memory
4142
	typeset -n numjobs=$1
4243
4344
	read mem_total <<<"$(awk \
4445
		$'/MemTotal/ { print $2 }' \
4546
		<'/proc/meminfo')"
4647
	read swap_total <<<"$(awk \
4748
		$'/SwapTotal/ { print $2 }' \
4849
		<'/proc/meminfo')"
4950
50-
	printf $"%s: mem_total=%d, swap_total=%d\n" \
51+
	printf $"# mem_total=%d, swap_total=%d\n" \
5252
		"$mem_total" \
5353
		"$swap_total"
5454
5555
	# data in /proc/meminto are in KB, but we need bytes
5656
	(( mem_total*=1024, swap_total*=1024 ))
5757
5858
	# handle read errors
5959
	if (( (mem_total < 0) || (swap_total < 0) )) ; then
60-
		printf $"%s: error, could not read memory data\n" "$0"
60+
		printf $"%s: error, could not read memory data\n" "$0" 1>&2
6161
		return 1
6262
	fi
6363
6464
	# we need at least 1GB of swap space
6565
	if (( swap_total < (1024*1024*1924) )) ; then
66-
		printf $"#\n# %s: ERROR: Swap memory too low %d\n#\n" "$0" "$swap_total"
66+
		printf $"#\n# %s: ERROR: Swap memory too low %d\n#\n" "$0" "$swap_total" 1>&2
6767
		return 1
6868
	fi
6969
70-
	# Reserve 256MB for the Windows OS
70+
	# Reserve 512MB for the Windows OS
71-
	(( mem_total -= 256*1024*1024 ))
71+
	(( mem_total -= 512*1024*1024 ))
7272
7373
	# calculate how much jobs would fit into the memory
7474
	(( numjobs_in_memory = (mem_total+memory_per_job+1) / memory_per_job ))
7575
76-
	# restrict the number of jobs to twice the amount of CPUs
76+
	# run "jobs_per_cpu" per CPU, only limited to the available memory
77-
	(( numjobs = (numjobs_in_memory > (num_cpus*2))?(num_cpus*2):numjobs_in_memory ))
77+
	(( numjobs = (numjobs_in_memory > (num_cpus*jobs_per_cpu))?(num_cpus*jobs_per_cpu):numjobs_in_memory ))
7878
7979
	# we want at least one job
8080
	(( numjobs = (numjobs > 1)?numjobs:1 ))
8181
8282
	# statistics
83-
	printf $"%s: memory_per_job=%d\n"	"$0" "$memory_per_job"
83+
	printf $"# number of online CPUs=%d\n"      "$num_cpus"
84-
	printf $"%s: numjobs_in_memory=%d\n"	"$0" "$numjobs_in_memory"
84+
	printf $"# memory_per_job=%d\n" 	    "$memory_per_job"
85-
	printf $"%s: numjobs=%d\n"		"$0" "$numjobs"
85+
	printf $"# numjobs_in_memory=%d\n"	    "$numjobs_in_memory"
86+
	printf $"# numjobs=%d\n"		    "$numjobs"
8687
8788
	return 0
8889
}
8990
9091
9192
#
9293
# Configuration paths
9394
#
9495
function configure_paths
9596
{
9697
	boost_Version='1_71_0'
9798
	qt_Version='5_15_2'
9899
99100
	#
100101
	# Prebuild RDE build tools (compiler etc)
101102
	# (from $ git clone https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/Dependencies #)
102103
	#
103104
	#git_rde_dependicies_dir='/cygdrive/h/tmp/winnfstest/hummingbirdnfstest1/rde_windows_developmement/Dependencies/win/'
104105
	#git_rde_dependicies_dir='/home/roland_mainz/work/rde/build_dep/Dependencies/win/'
105106
	git_rde_dependicies_dir="$(realpath "$PWD/../../Dependencies")/win/"
106107
	if [[ ! -d "$git_rde_dependicies_dir" ]] ; then
107108
		printf $"%s: ERROR: %s dir not found\n" "$0" "$git_rde_dependicies_dir" 1>&2
108109
		return 1
109110
	fi
110111
111112
	boostpath="${git_rde_dependicies_dir}/boost/boost_${boost_Version}/"
112113
	qtpath="${git_rde_dependicies_dir}/qt/qt_${qt_Version}/"
113114
114115
	printf $"# building with boost version %s and qt version %s\n" "$boost_Version" "qt_Version"
115116
116117
	# Setting-up PATH
117118
	export PATH="$qtpath/Tools/mingw810_64/bin/:$qtpath/5.15.2/mingw81_64/bin/:$qtpath/Tools/CMake_64/bin/:$boostpath/bin/:$boostpath/lib/:$PATH"
118119
	printf $"# PATH=%s\n# Windows PATH=%s\n" "$PATH" "$(cygpath -p -w "$PATH")"
119120
	return 0
120121
}
121122
122123
function probe_paths
123124
{
124125
	printf $"# Probing PATH for tools ...\n"
125126
	which -a gcc
126127
	which -a g++
127128
	which -a cmake
128129
	which -a make
129130
130131
	return 0
131132
}
132133
133134
#
134135
# Build
135136
#
136137
137138
function build_clean
138139
{
139140
	printf $"# Cleanup old build stuff ...\n"
140141
	rm -Rf CMake* CPack* CTestTestfile.cmake app_translations.qrc cmake_install.cmake nowide tests RDS Makefile *.qm rde.rc rde_autogen tmp versioninfo.cpp
141142
	return 0
142143
}
143144
144145
function build_cmake_config
145146
{
146147
	printf $"# Running build configuration via cmake ...\n"
147148
	# note: Windows/minGW uses '-G "MinGW Makefiles"', while compiling with Cygwin requires '-G "Unix Makefiles"'
148149
	cmake -G "Unix Makefiles" -DBOOST_ROOT="$boostpath" -DBoost_LIB_PREFIX="lib" -DBoost_USE_STATIC_LIBS=TRUE -DBoost_ARCHITECTURE="-x64" -DBUILD_TESTS=ON ".."
149150
	return 0
150151
}
151152
152153
function build_cmake_clean
153154
{
154155
	printf $"# Target clean ...\n"
155156
	cmake --build . -j 1 --target clean
156157
	return 0
157158
}
158159
159160
function build_cmake_targets
160161
{
161162
	typeset -li num_parallel_jobs=$1
162163
163164
	printf $"# Building ...\n"
164-
165165
	cmake --build . -j $num_parallel_jobs
166-
	printf $"%s: Build done.\n" "$0"
166+
	printf $"# Build done.\n"
167167
	return 0
168168
}
169169
170+
170171
#
171172
# main
172173
#
173174
set -o errexit
174175
set -o nounset
175176
#set -o xtrace # debug
176177
177-
printf $"%s: Start ...\n" "$0"
178+
printf $"# %s: Start ...\n\n" "$0"
178179
180+
printf $"# uname=%q\n" "$(uname -a)"
179182
# Check whether we are really on Cygwin...
180183
if [[ "$(uname -s)" != *CYGWIN* ]] ; then
181184
	printf $"%s: ERROR: Not a Cygwin environment.\n" "$0" 1>&2
182185
	exit 1
183186
fi
184187
185188
typeset boost_Version qt_Version git_rde_dependicies_dir boostpath qtpath
186189
typeset -li num_parallel_jobs
187190
188191
configure_paths
189192
190193
case "${1-}" in
191-
	'buildall')
194+
	'rebuildall')
192-
		calc_max_parallel_jobs num_parallel_jobs $((512*1024*1024)) || exit 1
195+
		calc_max_parallel_jobs num_parallel_jobs $((512*1024*1024)) 3 || exit 1
193196
		probe_paths
194197
		build_clean
195198
		build_cmake_config
196199
		build_cmake_clean
197200
		build_cmake_targets "$num_parallel_jobs"
198201
		;;
202+
	'build')
199207
	'clean')
200208
		build_clean
201209
		;;
202210
	'run')
203211
		./rde
204212
		exit $?
205213
		;;
206214
	*)
207215
		printf $"%s: Unknown cmd %q\n" "$0" "${1-}" 1>&2
208216
		exit 1
209217
		;;
210218
esac
211219
212220
exit 0
213221
214222
# EOF.
215223

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