-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathmsys_build.sh
executable file
·216 lines (198 loc) · 7.14 KB
/
msys_build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/sh
# This file is a part of Julia. License is MIT: http://julialang.org/license
# Script to compile Windows Julia, using binary dependencies from nightlies.
# Should work in MSYS assuming 7zip is installed and on the path,
# or Cygwin or Linux assuming make, curl, p7zip, and mingw64-$ARCH-gcc-g++
# are installed
# Run in top-level Julia directory
cd `dirname "$0"`/../..
# Stop on error
set -e
# Fail fast on AppVeyor if there are newer pending commits in this PR
curlflags="curl --retry 10 -k -L -y 5"
if [ -n "$APPVEYOR_PULL_REQUEST_NUMBER" ]; then
# download a handy cli json parser
if ! [ -e jq.exe ]; then
$curlflags -O http://stedolan.github.io/jq/download/win64/jq.exe
fi
av_api_url="https://ci.appveyor.com/api/projects/StefanKarpinski/julia/history?recordsNumber=50"
query=".builds | map(select(.pullRequestId == \"$APPVEYOR_PULL_REQUEST_NUMBER\"))[0].buildNumber"
latestbuild="$(curl $av_api_url | ./jq "$query")"
if [ -n "$latestbuild" -a "$latestbuild" != "null" -a "$latestbuild" != "$APPVEYOR_BUILD_NUMBER" ]; then
echo "There are newer queued builds for this pull request, failing early."
exit 1
fi
fi
# If ARCH environment variable not set, choose based on uname -m
if [ -z "$ARCH" -a -z "$XC_HOST" ]; then
export ARCH=`uname -m`
elif [ -z "$ARCH" ]; then
ARCH=`echo $XC_HOST | sed 's/-w64-mingw32//'`
fi
echo "" > Make.user
echo "" > get-deps.log
# set MARCH for consistency with how binaries get built
if [ "$ARCH" = x86_64 ]; then
bits=64
archsuffix=64
echo "override MARCH = x86-64" >> Make.user
echo 'USE_BLAS64 = 1' >> Make.user
else
bits=32
archsuffix=86
echo "override MARCH = i686" >> Make.user
echo "override JULIA_CPU_TARGET = pentium4" >> Make.user
fi
# Set XC_HOST if in Cygwin or Linux
case $(uname) in
CYGWIN*)
if [ -z "$XC_HOST" ]; then
XC_HOST="$ARCH-w64-mingw32"
echo "XC_HOST = $XC_HOST" >> Make.user
fi
CROSS_COMPILE="$XC_HOST-"
# Set BUILD_MACHINE and HOSTCC in case we don't have Cygwin gcc installed
echo "override BUILD_MACHINE = $ARCH-pc-cygwin" >> Make.user
if [ -z "`which gcc 2>/dev/null`" ]; then
echo 'override HOSTCC = $(CROSS_COMPILE)gcc' >> Make.user
fi
make win-extras >> get-deps.log
SEVENZIP="dist-extras/7z"
;;
Linux)
if [ -z "$XC_HOST" ]; then
XC_HOST="$ARCH-w64-mingw32"
echo "XC_HOST = $XC_HOST" >> Make.user
fi
CROSS_COMPILE="$XC_HOST-"
make win-extras >> get-deps.log
SEVENZIP="wine dist-extras/7z.exe"
;;
*)
CROSS_COMPILE=""
SEVENZIP="7z"
;;
esac
# Download most recent Julia binary for dependencies
if ! [ -e julia-installer.exe ]; then
f=julia-latest-win$bits.exe
echo "Downloading $f"
$curlflags -O https://s3.amazonaws.com/julianightlies/bin/winnt/x$archsuffix/$f
echo "Extracting $f"
$SEVENZIP x -y $f >> get-deps.log
fi
for i in bin/*.dll Git/bin/msys-1.0.dll Git/bin/msys-perl5_8.dll Git/bin/*.exe; do
$SEVENZIP e -y julia-installer.exe "\$_OUTDIR/$i" \
-ousr\\`dirname $i | sed -e 's|/julia||' -e 's|/|\\\\|g'` >> get-deps.log
done
for i in share/julia/base/pcre_h.jl; do
$SEVENZIP e -y julia-installer.exe "\$_OUTDIR/$i" -obase >> get-deps.log
done
# suppress "bash.exe: warning: could not find /tmp, please create!"
mkdir -p usr/Git/tmp
# Remove libjulia.dll if it was copied from downloaded binary
rm -f usr/bin/libjulia.dll
rm -f usr/bin/libjulia-debug.dll
mingw=http://sourceforge.net/projects/mingw
if [ -z "$USEMSVC" ]; then
if [ -z "`which ${CROSS_COMPILE}gcc 2>/dev/null`" ]; then
f=mingw-w$bits-bin-$ARCH-20140102.7z
if ! [ -e $f ]; then
echo "Downloading $f"
$curlflags -O $mingw-w64-dgn/files/mingw-w64/$f
fi
echo "Extracting $f"
$SEVENZIP x -y $f >> get-deps.log
export PATH=$PATH:$PWD/mingw$bits/bin
# If there is a version of make.exe here, it is mingw32-make which won't work
rm -f mingw$bits/bin/make.exe
fi
export AR=${CROSS_COMPILE}ar
f=llvm-3.3-$ARCH-w64-mingw32-juliadeps.7z
# The MinGW binary version of LLVM doesn't include libgtest or libgtest_main
mkdir -p usr/lib
$AR cr usr/lib/libgtest.a
$AR cr usr/lib/libgtest_main.a
else
echo "override USEMSVC = 1" >> Make.user
echo "override ARCH = $ARCH" >> Make.user
echo "override XC_HOST = " >> Make.user
export CC="$PWD/deps/libuv/compile cl -nologo -MD -Z7"
export AR="$PWD/deps/libuv/ar-lib lib"
export LD="$PWD/linkld link"
echo "override CC = $CC" >> Make.user
echo 'override CXX = $(CC) -EHsc' >> Make.user
echo "override AR = $AR" >> Make.user
echo "override LD = $LD -DEBUG" >> Make.user
f=llvm-3.3-$ARCH-msvc12-juliadeps.7z
fi
if ! [ -e $f ]; then
echo "Downloading $f"
$curlflags -O http://sourceforge.net/projects/juliadeps-win/files/$f
fi
echo "Extracting $f"
$SEVENZIP x -y $f >> get-deps.log
echo 'override LLVM_CONFIG = $(JULIAHOME)/usr/bin/llvm-config' >> Make.user
if [ -n "$APPVEYOR" ]; then
for i in make.exe touch.exe msys-intl-8.dll msys-iconv-2.dll; do
f="/c/MinGW/msys/1.0/bin/$i"
if [ -e $f ]; then
cp $f /bin/$i
fi
done
fi
if [ -z "`which make 2>/dev/null`" ]; then
if [ -n "`uname | grep CYGWIN`" ]; then
echo "Install the Cygwin package for 'make' and try again."
exit 1
fi
f="/make/make-3.81-2/make-3.81-2-msys-1.0.11-bin.tar"
if ! [ -e `basename $f.lzma` ]; then
echo "Downloading `basename $f`"
$curlflags -O $mingw/files/MSYS/Base$f.lzma
fi
$SEVENZIP x -y `basename $f.lzma` >> get-deps.log
tar -xf `basename $f`
# msysgit has an ancient version of touch that fails with `touch -c nonexistent`
cp usr/Git/bin/echo.exe bin/touch.exe
export PATH=$PWD/bin:$PATH
fi
for lib in SUITESPARSE ARPACK BLAS LAPACK FFTW \
GMP MPFR PCRE LIBUNWIND RMATH OPENSPECFUN; do
echo "USE_SYSTEM_$lib = 1" >> Make.user
done
echo 'LIBBLAS = -L$(JULIAHOME)/usr/bin -lopenblas' >> Make.user
echo 'LIBBLASNAME = libopenblas' >> Make.user
echo 'override LIBLAPACK = $(LIBBLAS)' >> Make.user
echo 'override LIBLAPACKNAME = $(LIBBLASNAME)' >> Make.user
# Remaining dependencies:
# libuv since its static lib is no longer included in the binaries
# openlibm since we need it as a static library to work properly
# utf8proc since its headers are not in the binary download
echo 'override STAGE1_DEPS = libuv' >> Make.user
echo 'override STAGE2_DEPS = utf8proc' >> Make.user
echo 'override STAGE3_DEPS = ' >> Make.user
if [ -n "$USEMSVC" ]; then
make -C deps get-libuv
# Create a modified version of compile for wrapping link
sed -e 's/-link//' -e 's/cl/link/g' -e 's/ -Fe/ -OUT:/' \
-e 's|$dir/$lib|$dir/lib$lib|g' deps/libuv/compile > linkld
chmod +x linkld
# Openlibm doesn't build well with MSVC right now
echo 'USE_SYSTEM_OPENLIBM = 1' >> Make.user
# Since we don't have a static library for openlibm
echo 'override UNTRUSTED_SYSTEM_LIBM = 0' >> Make.user
# Compile libuv and utf8proc without -TP first, then add -TP
make -C deps install-libuv install-utf8proc
cp usr/lib/uv.lib usr/lib/libuv.a
echo 'override CC += -TP' >> Make.user
echo 'override STAGE1_DEPS += dsfmt' >> Make.user
else
echo 'override STAGE1_DEPS += openlibm' >> Make.user
make VERBOSE=1 -C base version_git.jl.phony
echo 'NO_GIT = 1' >> Make.user
fi
make check-whitespace
cat Make.user
make VERBOSE=1
#make debug