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