6464 GIT_COMMIT=$( git rev-parse --short=12 HEAD)
6565fi
6666
67+ # ###############
68+ # Check 4: Make sure that build directories do no exist
69+ # ###############
70+
71+ # Default to building for all supported HOSTs (overridable by environment)
72+ export HOSTS=" ${HOSTS:- x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu
73+ x86_64-w64-mingw32} "
74+
75+ DISTSRC_BASE=" ${DISTSRC_BASE:- ${PWD} } "
76+
77+ # Usage: distsrc_for_host HOST
78+ #
79+ # HOST: The current platform triple we're building for
80+ #
81+ distsrc_for_host () {
82+ echo " ${DISTSRC_BASE} /distsrc-${GIT_COMMIT} -${1} "
83+ }
84+
85+ # Accumulate a list of build directories that already exist...
86+ hosts_distsrc_exists=" "
87+ for host in $HOSTS ; do
88+ if [ -e " $( distsrc_for_host " $host " ) " ]; then
89+ hosts_distsrc_exists+=" ${host} "
90+ fi
91+ done
92+
93+ if [ -n " $hosts_distsrc_exists " ]; then
94+ # ...so that we can print them out nicely in an error message
95+ cat << EOF
96+ ERR: Build directories for this commit already exist for the following platform
97+ triples you're attempting to build, probably because of previous builds.
98+ Please remove, or otherwise deal with them prior to starting another build.
99+
100+ Aborting...
101+
102+ EOF
103+ for host in $hosts_distsrc_exists ; do
104+ echo " ${host} '$( distsrc_for_host " $host " ) '"
105+ done
106+ exit 1
107+ else
108+ mkdir -p " $DISTSRC_BASE "
109+ fi
110+
67111# ########
68112# Setup #
69113# ########
@@ -116,9 +160,9 @@ and untracked files and directories will be wiped, allowing you to start anew.
116160EOF
117161}
118162
119- # Deterministically build Bitcoin Core for HOSTs (overridable by environment)
163+ # Deterministically build Bitcoin Core
120164# shellcheck disable=SC2153
121- for host in ${ HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu x86_64-w64-mingw32} ; do
165+ for host in $HOSTS ; do
122166
123167 # Display proper warning when the user interrupts the build
124168 trap ' int_trap ${host}' INT
@@ -187,12 +231,13 @@ for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv
187231 # Please read the README.md in the same directory as this file for
188232 # more information.
189233 #
190- # shellcheck disable=SC2086
234+ # shellcheck disable=SC2086,SC2031
191235 time-machine environment --manifest=" ${PWD} /contrib/guix/manifest.scm" \
192236 --container \
193237 --pure \
194238 --no-cwd \
195239 --share=" $PWD " =/bitcoin \
240+ --share=" $DISTSRC_BASE " =/distsrc-base \
196241 --share=" $OUTDIR " =/outdir \
197242 --expose=" $( git rev-parse --git-common-dir) " \
198243 ${SOURCES_PATH: +--share=" $SOURCES_PATH " } \
@@ -204,6 +249,7 @@ for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv
204249 SOURCE_DATE_EPOCH=" ${SOURCE_DATE_EPOCH:? unable to determine value} " \
205250 ${V: +V=1} \
206251 ${SOURCES_PATH: +SOURCES_PATH=" $SOURCES_PATH " } \
252+ DISTSRC=" $( DISTSRC_BASE=/distsrc-base && distsrc_for_host " $HOST " ) " \
207253 OUTDIR=/outdir \
208254 bash -c " cd /bitcoin && bash contrib/guix/libexec/build.sh"
209255 )
0 commit comments