1echo start build at `date`
2
3set -xe
4
5## These should be the only things you need to change per build
6version="5.10.4.0.0.1"
7release="R16B03-1"
8cbnum=cb13
9
10thisdir=`pwd`
11
12source cygwin.bash_profile
13
14## get the source code
15export otp_dir=otp_src_${release}
16git -c core.autocrlf=false -c core.eol=lf \
17  clone git://github.com/couchbasedeps/erlang ${otp_dir}
18
19export OTP_TOP=$(pwd)/${otp_dir}
20cd ${OTP_TOP}
21git checkout couchbase-alice
22
23# Couldn't get git to do this automatically :(
24echo Converting files to LF endings for Cygin...
25find . -type f -print0 | xargs -0 dos2unix >& /dev/null
26
27## per instructions, get tcl from erlang website
28## without this the build will fail
29## (alternative is to create a lib/gs/SKIP file)
30wget http://www.erlang.org/download/tcltk85_win32_bin.tar.gz
31gunzip tcltk85_win32_bin.tar.gz
32tar xf tcltk85_win32_bin.tar
33
34## build the source, as per instructions
35eval `./otp_build env_win32 x64`
36./otp_build autoconf 2>&1 | tee autoconf.out
37./otp_build configure --with-ssl=/cygdrive/c/OpenSSL-Win64 2>&1 | tee configure.out
38./otp_build boot -a 2>&1 | tee boot.out
39./otp_build release -a 2>&1 | tee release.out
40#./otp_build debuginfo_win32 -a 2>&1 | tee dbginfo.out
41
42## what the "release -a" command generates above in release/win32
43## is not ## what is packaged in the installer executable.
44## the installer executable also has other files like
45## lib, bin -- some of which are partly also in the release/win32
46## folder but there are some extra files
47## so, generate an installer and use that to install it to default
48## location
49./otp_build installer_win32 2>&1 | tee installerwin32.out
50./release/win32/otp_win64_${release}.exe /S
51
52installdir=/cygdrive/c/Program\ Files/erl${version}
53
54## we need VERSION.txt, erl.in.ini and CMakeLists.txt for our internal
55## cbdeps consumption. We could check the files in with placeholder
56## tokens for version. But I am just generating them here dynamically
57## because they are tiny files
58echo $release > VERSION.txt
59echo "[erlang]
60Bindir=\${CMAKE_INSTALL_PREFIX}/erts-${version}/bin
61Progname=erl
62Rootdir=\${CMAKE_INSTALL_PREFIX}
63" > erl.ini.in
64
65echo "# Just copy contents to CMAKE_INSTALL_PREFIX
66FILE (COPY bin erts-${version} lib releases usr DESTINATION \"\${CMAKE_INSTALL_PREFIX}\")
67# And install erl.ini with correct paths
68CONFIGURE_FILE(\${CMAKE_CURRENT_SOURCE_DIR}/erl.ini.in \${CMAKE_INSTALL_PREFIX}/bin/erl.ini)
69" > CMakeLists.txt
70
71## tar 'em up
72cp VERSION.txt erl.ini.in CMakeLists.txt "${installdir}"
73cd "${installdir}"
74tar --exclude="Install.exe" --exclude="Install.ini" --exclude="Uninstall.exe" -zcf ${thisdir}/erlang-windows_msvc2015-amd64-${release}-couchbase-${cbnum}.tgz *
75rm -f VERSION.txt erl.ini.in CMakeLists.txt
76
77## uninstall the erlang installation
78"${installdir}/Uninstall.exe" /S
79
80echo end build at `date`
81