@@ -3,10 +3,26 @@ set -euo pipefail
33LOCAL_HAPPY=" $PWD /_build/tools/happy"
44LOCAL_ALEX=" $PWD /_build/tools/alex"
55
6+ UNAME_S=$( uname -s)
7+ case " $UNAME_S " in
8+ MINGW* |MSYS* ) IS_WINDOWS=1; EXE_EXT=" .exe" ;;
9+ * ) IS_WINDOWS=0; EXE_EXT=" " ;;
10+ esac
11+
612RELEASE_HADRIAN_ARGS=" "
713DEV_HADRIAN_ARGS=" --docs=none"
8- RELEASE_CONFIGURE_ARGS=" --enable-tarballs-autodownload"
9- DEV_CONFIGURE_ARGS=" --enable-tarballs-autodownload"
14+ RELEASE_FLAVOUR=" release"
15+ DEV_FLAVOUR=" release+debug_info+debug_ghc+assertions"
16+
17+ # platform-specific default configure arguments
18+ case " $UNAME_S " in
19+ MINGW* |MSYS* ) DEFAULT_CONFIGURE_ARGS=" --enable-tarballs-autodownload" ;;
20+ Darwin* ) DEFAULT_CONFIGURE_ARGS=" --with-intree-gmp" ;;
21+ * ) DEFAULT_CONFIGURE_ARGS=" " ;;
22+ esac
23+
24+ RELEASE_CONFIGURE_ARGS=" $DEFAULT_CONFIGURE_ARGS "
25+ DEV_CONFIGURE_ARGS=" $DEFAULT_CONFIGURE_ARGS "
1026
1127# ###################################################################
1228# edit configuration here:
@@ -15,16 +31,18 @@ DEV_CONFIGURE_ARGS="--enable-tarballs-autodownload"
1531: ${RELEASE:= 0} # set to 1 to build release version including documentation (more build dependencies)
1632
1733# program locations
18- : ${GHC:= $(which ghc-9.6.7 2>/ dev/ null || true)}
19- : ${CABAL:= $(which cabal 2>/ dev/ null || true)}
20- : ${HAPPY:= $( [ -x "$LOCAL_HAPPY" ] && echo " $LOCAL_HAPPY " || which happy-1.20.1.1 2>/ dev/ null || true)}
21- : ${ALEX:= $( [ -x "$LOCAL_ALEX" ] && echo " $LOCAL_ALEX " || which alex 2>/ dev/ null || true)}
22- : ${TAR:= $(which tar 2>/ dev/ null || true)}
23- : ${XZ:= $(which xz 2>/ dev/ null || true)}
34+ : ${GHC:= $(command -v ghc-9.6.7 2>/ dev/ null || true)}
35+ : ${CABAL:= $(command -v cabal 2>/ dev/ null || true)}
36+ : ${PYTHON:= $(command -v python3 2>/ dev/ null || true)}
37+ : ${HAPPY:= $( [ -x "$LOCAL_HAPPY" ] && echo " $LOCAL_HAPPY " || command -v happy-1.20.1.1 2>/ dev/ null || true)}
38+ : ${ALEX:= $( [ -x "$LOCAL_ALEX" ] && echo " $LOCAL_ALEX " || command -v alex 2>/ dev/ null || true)}
39+ : ${TAR:= $(command -v tar 2>/ dev/ null || true)}
40+ : ${XZ:= $(command -v xz 2>/ dev/ null || true)}
2441
2542# override default arguments
2643: ${HADRIAN_ARGS:= $( [ "$RELEASE" -eq 1 ] && echo " $RELEASE_HADRIAN_ARGS " || echo " $DEV_HADRIAN_ARGS " )}
2744: ${CONFIGURE_ARGS:= $( [ "$RELEASE" -eq 1 ] && echo " $RELEASE_CONFIGURE_ARGS " || echo " $DEV_CONFIGURE_ARGS " )}
45+ : ${FLAVOUR:= $( [ "$RELEASE" -eq 1 ] && echo " $RELEASE_FLAVOUR " || echo " $DEV_FLAVOUR " )}
2846
2947# end configuration
3048# ###################################################################
@@ -74,17 +92,23 @@ if [ -z "$XZ" ] || [ ! -x "$XZ" ]; then
7492 echo " xz not found"
7593 exit 1
7694fi
95+ if [ -z " $PYTHON " ] || [ ! -x " $PYTHON " ]; then
96+ echo " python3 not found"
97+ exit 1
98+ fi
7799
78100export GHC
79101export CABAL
80102export HAPPY
81103export ALEX
104+ export PYTHON
82105
83106echo " using tools: "
84107echo " GHC: $GHC "
85108echo " cabal: $CABAL ($CABAL_VERSION )"
86109echo " happy: $HAPPY "
87110echo " alex: $ALEX "
111+ echo " python: $PYTHON "
88112echo " tar: $TAR "
89113echo " xz: $XZ "
90114
@@ -99,15 +123,37 @@ if [ ! -d plutus/plutus-tx ]; then
99123 exit 1
100124fi
101125# build boot GHC
126+ DID_BOOT_OR_CONFIGURE=0
102127if [ ! -x ./configure ] || [ " $REBUILD " -eq 1 ]; then
128+ echo " booting..."
103129 ./boot
130+ DID_BOOT_OR_CONFIGURE=1
104131fi
105132if [ ! -e ./mk/config.h ] || [ " $REBUILD " -eq 1 ]; then
133+ echo " configuring..."
134+ (
135+ # On Windows/MinGW64, ensure we use the CA bundle from MSYS2 to avoid SSL errors when downloading tarballs
136+ if [ " $IS_WINDOWS " -eq 1 ]; then
137+ export SSL_CERT_FILE=" $( cygpath -w /mingw64/etc/ssl/certs/ca-bundle.crt) "
138+ fi
106139 ./configure $CONFIGURE_ARGS
140+ )
141+ DID_BOOT_OR_CONFIGURE=1
142+ fi
143+
144+ # On Windows, plinth/ghc may not be a a real symlink, recreate it to
145+ # prevent it from becoming stale.
146+ if [ " $DID_BOOT_OR_CONFIGURE " -eq 1 ] && [ " $IS_WINDOWS " -eq 1 ] && [ -d plinth/ghc ] && [ ! -L plinth/ghc ]; then
147+ echo " re-creating plinth/ghc symlink..."
148+ rm -rf plinth/ghc
149+ ln -s ../ghc plinth/ghc
107150fi
108151
109152if [ ! -x ./_build/stage1/bin/ghc ] || [ " $REBUILD " -eq 1 ]; then
110- ./hadrian/build -j --flavour=release $HADRIAN_ARGS binary-dist
153+ echo " building..."
154+ echo " ./hadrian/build -j --flavour=$FLAVOUR $HADRIAN_ARGS binary-dist"
155+
156+ ./hadrian/build -j --flavour=$FLAVOUR $HADRIAN_ARGS binary-dist
111157fi
112158
113159# build Plinth GHC
@@ -129,20 +175,31 @@ CABAL_BUILD_ARGS="\
129175 --builddir=_build/${STAGE} /${TARGET_PLATFORM} \
130176 --ghc-options=\" -fhide-source-paths\" "
131177
178+ # On Windows/MinGW64, ensure we use Git for Windows (not MSYS2 git) and
179+ # prevent git from hanging on interactive credential/host-key prompts
180+ # when called as a subprocess by cabal.
181+ if [ " $IS_WINDOWS " -eq 1 ]; then
182+ if [ -d " /c/Program Files/Git/bin" ]; then
183+ export PATH=" /c/Program Files/Git/bin:$PATH "
184+ fi
185+ export GIT_TERMINAL_PROMPT=0
186+ export GIT_CONFIG_COUNT=1
187+ export GIT_CONFIG_KEY_0=" core.longpaths"
188+ export GIT_CONFIG_VALUE_0=" true"
189+ fi
190+
132191(
192+ echo " building uplc-ghc"
133193 cd plinth
194+ echo " cabal update..."
134195 " $CABAL " ${CABAL_PROJECT_ARGS} ${CABAL_ARGS} update
196+ echo " cabal build..."
135197 " $CABAL " ${CABAL_PROJECT_ARGS} ${CABAL_ARGS} build ${CABAL_BUILD_ARGS} ghc:ghc
136198)
137199
138200# add uplc-ghc to the _build dir and the bindists
139201CWRAPPER_DIR=" $BASE /hadrian/bindist/cwrappers"
140202
141- case " $TARGET_PLATFORM " in
142- * -mingw32|* -windows) IS_WINDOWS=1; EXE_EXT=" .exe" ;;
143- * ) IS_WINDOWS=0; EXE_EXT=" " ;;
144- esac
145-
146203DEST_UPLC_GHC=" $BASE /_build/stage1/bin/uplc-ghc${EXE_EXT} "
147204
148205(
0 commit comments