pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post e98be by Anonymous on Tue 1st Aug 2023 14:46
original post c3c8f732 by Anonymous on Mon 31st Jul 2023 12:18
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
3939
	typeset -r -li num_cpus=$(getconf '_NPROCESSORS_ONLN')
4040
	typeset -li numjobs_in_memory
4141
	typeset -n numjobs=$1
4242
4343
	read mem_total <<<"$(awk \
4444
		$'/MemTotal/ { print $2 }' \
4545
		<'/proc/meminfo')"
4646
	read swap_total <<<"$(awk \
4747
		$'/SwapTotal/ { print $2 }' \
4848
		<'/proc/meminfo')"
4949
5050
	printf $"%s: mem_total=%d, swap_total=%d\n" \
5151
		"$0" \
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
6060
		printf $"%s: error, could not read memory data\n" "$0"
6161
		return 1
6262
	fi
6363
6464
	# we need at least 1GB of swap space
6565
	if (( swap_total < (1024*1024*1924) )) ; then
6666
		printf $"#\n# %s: ERROR: Swap memory too low %d\n#\n" "$0" "$swap_total"
6767
		return 1
6868
	fi
6969
70+
	# Reserve 256MB for the Windows OS
7073
	# calculate how much jobs would fit into the memory
71-
	(( numjobs_in_memory = (mem_total+swap_total) / memory_per_job ))
74+
	(( numjobs_in_memory = (mem_total+memory_per_job+1) / memory_per_job ))
7275
7376
	# restrict the number of jobs to twice the amount of CPUs
7477
	(( numjobs = (numjobs_in_memory > (num_cpus*2))?(num_cpus*2):numjobs_in_memory ))
7578
7679
	# we want at least one job
77-
	(( numjobs = (numjobs >= 1)?numjobs:1 ))
80+
	(( numjobs = (numjobs > 1)?numjobs:1 ))
7881
7982
	# statistics
83+
	printf $"%s: memory_per_job=%d\n"	"$0" "$memory_per_job"
8084
	printf $"%s: numjobs_in_memory=%d\n"	"$0" "$numjobs_in_memory"
8185
	printf $"%s: numjobs=%d\n"		"$0" "$numjobs"
86+
8287
	return 0
8388
}
8489
8590
8691
#
8792
# Configuration paths
8893
#
8994
function configure_paths
9095
{
9196
	boost_Version='1_71_0'
9297
	qt_Version='5_15_2'
9398
9499
	#
95100
	# Prebuild RDE build tools (compiler etc)
96101
	# (from $ git clone https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/Dependencies #)
97102
	#
98103
	#git_rde_dependicies_dir='/cygdrive/h/tmp/winnfstest/hummingbirdnfstest1/rde_windows_developmement/Dependencies/win/'
99104
	#git_rde_dependicies_dir='/home/roland_mainz/work/rde/build_dep/Dependencies/win/'
100105
	git_rde_dependicies_dir="$(realpath "$PWD/../../Dependencies")/win/"
101106
	if [[ ! -d "$git_rde_dependicies_dir" ]] ; then
102107
		printf $"%s: ERROR: %s dir not found\n" "$0" "$git_rde_dependicies_dir" 1>&2
103108
		return 1
104109
	fi
105110
106111
	boostpath="${git_rde_dependicies_dir}/boost/boost_${boost_Version}/"
107112
	qtpath="${git_rde_dependicies_dir}/qt/qt_${qt_Version}/"
108113
109114
	printf $"# building with boost version %s and qt version %s\n" "$boost_Version" "qt_Version"
110115
111116
	# Setting-up PATH
112117
	export PATH="$qtpath/Tools/mingw810_64/bin/:$qtpath/5.15.2/mingw81_64/bin/:$qtpath/Tools/CMake_64/bin/:$boostpath/bin/:$boostpath/lib/:$PATH"
113118
	printf $"# PATH=%s\n# Windows PATH=%s\n" "$PATH" "$(cygpath -p -w "$PATH")"
114119
	return 0
115120
}
116121
117122
function probe_paths
118123
{
119124
	printf $"# Probing PATH for tools ...\n"
120125
	which -a gcc
121126
	which -a g++
122127
	which -a cmake
123128
	which -a make
124129
125130
	return 0
126131
}
127132
128133
#
129134
# Build
130135
#
131136
132137
function build_clean
133138
{
134139
	printf $"# Cleanup old build stuff ...\n"
135140
	rm -Rf CMake* CPack* CTestTestfile.cmake app_translations.qrc cmake_install.cmake nowide tests RDS Makefile *.qm rde.rc rde_autogen tmp versioninfo.cpp
136141
	return 0
137142
}
138143
139144
function build_cmake_config
140145
{
141146
	printf $"# Running build configuration via cmake ...\n"
142147
	# note: Windows/minGW uses '-G "MinGW Makefiles"', while compiling with Cygwin requires '-G "Unix Makefiles"'
143148
	cmake -G "Unix Makefiles" -DBOOST_ROOT="$boostpath" -DBoost_LIB_PREFIX="lib" -DBoost_USE_STATIC_LIBS=TRUE -DBoost_ARCHITECTURE="-x64" -DBUILD_TESTS=ON ".."
144149
	return 0
145150
}
146151
147152
function build_cmake_clean
148153
{
149154
	printf $"# Target clean ...\n"
150155
	cmake --build . -j 1 --target clean
151156
	return 0
152157
}
153158
154159
function build_cmake_targets
155160
{
156161
	typeset -li num_parallel_jobs=$1
157162
158163
	printf $"# Building ...\n"
159164
160165
	cmake --build . -j $num_parallel_jobs
161166
	printf $"%s: Build done.\n" "$0"
162167
	return 0
163168
}
164169
165170
#
166171
# main
167172
#
168173
set -o errexit
169174
set -o nounset
170175
#set -o xtrace # debug
171176
172177
printf $"%s: Start ...\n" "$0"
173178
174179
# Check whether we are really on Cygwin...
175180
if [[ "$(uname -s)" != *CYGWIN* ]] ; then
176181
	printf $"%s: ERROR: Not a Cygwin environment.\n" "$0" 1>&2
177182
	exit 1
178183
fi
179184
180185
typeset boost_Version qt_Version git_rde_dependicies_dir boostpath qtpath
181186
typeset -li num_parallel_jobs
182187
183188
configure_paths
184189
185190
case "${1-}" in
186191
	'buildall')
187192
		calc_max_parallel_jobs num_parallel_jobs $((512*1024*1024)) || exit 1
188193
		probe_paths
189194
		build_clean
190195
		build_cmake_config
191196
		build_cmake_clean
192197
		build_cmake_targets "$num_parallel_jobs"
193198
		;;
194199
	'clean')
195200
		build_clean
196201
		;;
197202
	'run')
198203
		./rde
199204
		exit $?
200205
		;;
201206
	*)
202207
		printf $"%s: Unknown cmd %q\n" "$0" "${1-}" 1>&2
203208
		exit 1
204209
		;;
205210
esac
206211
207212
exit 0
208213
209214
# EOF.
210215

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