pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post c3c8f732 by Anonymous on Mon 31st Jul 2023 12:18
original post cd9b0 by Anonymous on Thu 27th Jul 2023 16:16
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
31-
#
32-
# Configuration paths
33-
#
34-
function configure_paths
35-
{
36-
	boost_Version='1_71_0'
37-
	qt_Version='5_15_2'
31+
3533
{
36-
	boost_Version='1_71_0'
34+
	set -o nounset
3835
39-
	#
36+
	typeset -li mem_total=-1
40-
	# Prebuild RDE build tools (compiler etc)
37+
	typeset -li swap_total=-1
41-
	# (from $ git clone https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/Dependencies #)
38+
	typeset -r -li memory_per_job=$2
42-
	#
39+
	typeset -r -li num_cpus=$(getconf '_NPROCESSORS_ONLN')
43-
	#git_rde_dependicies_dir='/cygdrive/h/tmp/winnfstest/hummingbirdnfstest1/rde_windows_developmement/Dependencies/win/'
40+
	typeset -li numjobs_in_memory
44-
	#git_rde_dependicies_dir='/home/roland_mainz/work/rde/build_dep/Dependencies/win/'
41+
	typeset -n numjobs=$1
5042
51-
	boostpath="${git_rde_dependicies_dir}/boost/boost_${boost_Version}/"
43+
	read mem_total <<<"$(awk \
52-
	qtpath="${git_rde_dependicies_dir}/qt/qt_${qt_Version}/"
44+
		$'/MemTotal/ { print $2 }' \
45+
		<'/proc/meminfo')"
5349
54-
	printf $"# building with boost version %s and qt version %s\n" "$boost_Version" "qt_Version"
50+
	printf $"%s: mem_total=%d, swap_total=%d\n" \
51+
		"$0" \
5554
56-
	# Setting-up PATH
55+
	# data in /proc/meminto are in KB, but we need bytes
57-
	export PATH="$qtpath/Tools/mingw810_64/bin/:$qtpath/5.15.2/mingw81_64/bin/:$qtpath/Tools/CMake_64/bin/:$boostpath/bin/:$boostpath/lib/:$PATH"
56+
	(( mem_total*=1024, swap_total*=1024 ))
6157
62-
function probe_paths
58+
	# handle read errors
63-
{
59+
	if (( (mem_total < 0) || (swap_total < 0) )) ; then
64-
	printf $"# Probing PATH for tools ...\n"
60+
		printf $"%s: error, could not read memory data\n" "$0"
65-
	which -a gcc
61+
		return 1
66-
	which -a g++
62+
	fi
6963
70-
	return 0
64+
	# we need at least 1GB of swap space
71-
}
65+
	if (( swap_total < (1024*1024*1924) )) ; then
66+
		printf $"#\n# %s: ERROR: Swap memory too low %d\n#\n" "$0" "$swap_total"
7269
73-
#
70+
	# calculate how much jobs would fit into the memory
74-
# Build
71+
	(( numjobs_in_memory = (mem_total+swap_total) / memory_per_job ))
7672
77-
function build_clean
73+
	# restrict the number of jobs to twice the amount of CPUs
78-
{
74+
	(( numjobs = (numjobs_in_memory > (num_cpus*2))?(num_cpus*2):numjobs_in_memory ))
8375
84-
function build_cmake_config
76+
	# we want at least one job
85-
{
77+
	(( numjobs = (numjobs >= 1)?numjobs:1 ))
9178
92-
function build_cmake_clean
79+
	# statistics
93-
{
80+
	printf $"%s: numjobs_in_memory=%d\n"	"$0" "$numjobs_in_memory"
94-
	printf $"# Target clean ...\n"
81+
	printf $"%s: numjobs=%d\n"		"$0" "$numjobs"
9682
	return 0
9783
}
9884
104-
	return 0
105-
}
85+
10090
{
101-
	printf $"# Building ...\n"
91+
	boost_Version='1_71_0'
102-
	cmake --build . -j 4
92+
	qt_Version='5_15_2'
10693
10794
#
108-
# main
95+
	# Prebuild RDE build tools (compiler etc)
96+
	# (from $ git clone https://RovemaDevelopment@dev.azure.com/RovemaDevelopment/RDE-Development/_git/Dependencies #)
10997
#
110-
set -o errexit
98+
	#git_rde_dependicies_dir='/cygdrive/h/tmp/winnfstest/hummingbirdnfstest1/rde_windows_developmement/Dependencies/win/'
111-
set -o nounset
99+
	#git_rde_dependicies_dir='/home/roland_mainz/work/rde/build_dep/Dependencies/win/'
112-
#set -o xtrace # debug
100+
	git_rde_dependicies_dir="$(realpath "$PWD/../../Dependencies")/win/"
101+
	if [[ ! -d "$git_rde_dependicies_dir" ]] ; then
113105
114-
printf $"%s: Start ...\n" "$0"
106+
	boostpath="${git_rde_dependicies_dir}/boost/boost_${boost_Version}/"
107+
	qtpath="${git_rde_dependicies_dir}/qt/qt_${qt_Version}/"
115108
116-
# Check whether we are really on Cygwin...
109+
	printf $"# building with boost version %s and qt version %s\n" "$boost_Version" "qt_Version"
121110
122-
typeset boost_Version qt_Version git_rde_dependicies_dir boostpath qtpath
111+
	# Setting-up PATH
112+
	export PATH="$qtpath/Tools/mingw810_64/bin/:$qtpath/5.15.2/mingw81_64/bin/:$qtpath/Tools/CMake_64/bin/:$boostpath/bin/:$boostpath/lib/:$PATH"
123116
124-
configure_paths
117+
function probe_paths
118+
{
125124
126-
case "${1-}" in
125+
	return 0
127-
	'buildall')
126+
}
128-
		probe_paths
127+
129-
		build_clean
128+
#
130-
		build_cmake_config
129+
# Build
131-
		build_cmake_clean
130+
#
132-
		build_cmake_targets
131+
133-
		;;
132+
function build_clean
134-
	'clean')
133+
{
135-
		build_clean
134+
	printf $"# Cleanup old build stuff ...\n"
136-
		;;
135+
	rm -Rf CMake* CPack* CTestTestfile.cmake app_translations.qrc cmake_install.cmake nowide tests RDS Makefile *.qm rde.rc rde_autogen tmp versioninfo.cpp
137-
	'run')
136+
	return 0
138-
		./rde
137+
}
146138
147-
exit 0
139+
function build_cmake_config
148-
140+
{
149-
# EOF.
141+
	printf $"# Running build configuration via cmake ...\n"
150-
142+
	# note: Windows/minGW uses '-G "MinGW Makefiles"', while compiling with Cygwin requires '-G "Unix Makefiles"'
151-
143+
	cmake -G "Unix Makefiles" -DBOOST_ROOT="$boostpath" -DBoost_LIB_PREFIX="lib" -DBoost_USE_STATIC_LIBS=TRUE -DBoost_ARCHITECTURE="-x64" -DBUILD_TESTS=ON ".."
152-
144+
	return 0
153-
145+
}
154146
155-
147+
function build_cmake_clean
156-
148+
{
157-
149+
	printf $"# Target clean ...\n"
158-
150+
	cmake --build . -j 1 --target clean
159-
151+
	return 0
160-
152+
}
161153
162-
154+
function build_cmake_targets
163-
155+
{
164-
156+
	typeset -li num_parallel_jobs=$1
165157
166-
158+
	printf $"# Building ...\n"
167159
168-
160+
	cmake --build . -j $num_parallel_jobs
169-
161+
	printf $"%s: Build done.\n" "$0"
170-
162+
	return 0
171-
163+
}
172164
173-
165+
#
174-
166+
# main
175-
167+
#
176-
168+
set -o errexit
177-
169+
set -o nounset
178-
170+
#set -o xtrace # debug
179171
180-
172+
printf $"%s: Start ...\n" "$0"
181173
182-
174+
# Check whether we are really on Cygwin...
183-
175+
if [[ "$(uname -s)" != *CYGWIN* ]] ; then
184-
176+
	printf $"%s: ERROR: Not a Cygwin environment.\n" "$0" 1>&2
185-
177+
	exit 1
186-
178+
fi
187179
188-
180+
typeset boost_Version qt_Version git_rde_dependicies_dir boostpath qtpath
189-
181+
typeset -li num_parallel_jobs
190182
191-
183+
configure_paths
192184
193-
185+
case "${1-}" in
194-
186+
	'buildall')
195-
187+
		calc_max_parallel_jobs num_parallel_jobs $((512*1024*1024)) || exit 1
196-
188+
		probe_paths
197-
189+
		build_clean
198-
190+
		build_cmake_config
199-
191+
		build_cmake_clean
200-
192+
		build_cmake_targets "$num_parallel_jobs"
201-
193+
		;;
202-
194+
	'clean')
203-
195+
		build_clean
204-
196+
		;;
205-
197+
	'run')
206-
198+
		./rde
207-
199+
		exit $?
208-
200+
		;;
209-
201+
	*)
210-
202+
		printf $"%s: Unknown cmd %q\n" "$0" "${1-}" 1>&2
211-
203+
		exit 1
212-
204+
		;;
213-
205+
esac
214206
215-
207+
exit 0
216208
217-
209+
# EOF.
218210

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