This repository is currently being migrated. It's locked while the migration is in progress.
forked from pantsbuild/binaries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-watchman.sh
executable file
·110 lines (98 loc) · 3.38 KB
/
build-watchman.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
#!/bin/bash
set -eo pipefail
set -x
DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
DIRPATH=$(pwd -P)
BUILD_DIR="watchman_build.${DATE}"
PCRE_VERSION="8.41"
PCRE_SHASUM="dddf0995aefe04cc6267c1448ffef0e7b0560ec0"
PCRE_DIR="pcre-${PCRE_VERSION}"
PCRE_TARBALL="${PCRE_DIR}.tar.gz"
PCRE_URL="http://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VERSION}/${PCRE_TARBALL}"
PCRE_INSTALL_DIR="${DIRPATH}/${BUILD_DIR}/pcre_install"
OPENSSL_VERSION="1.0.2n"
OPENSSL_SHASUM="0ca2957869206de193603eca6d89f532f61680b1"
OPENSSL_DIR="openssl-${OPENSSL_VERSION}"
OPENSSL_TARBALL="${OPENSSL_DIR}.tar.gz"
OPENSSL_URL="https://www.openssl.org/source/${OPENSSL_TARBALL}"
OPENSSL_INSTALL_DIR="${DIRPATH}/${BUILD_DIR}/openssl_install"
case $(uname -s) in
*Linux*) PLATFORM="linux";
ARCH=`uname -p`;
SHASUM="sha1sum";
OPENSSL_ARCH="linux-x86_64";
CFLAGS="-fPIC -fwrapv -O2";
CXXFLAGS="${CFLAGS} -I${OPENSSL_INSTALL_DIR}/include";
LDFLAGS="-L${OPENSSL_INSTALL_DIR}/lib";
;;
*Darwin*) PLATFORM="mac";
ARCH=`sw_vers -productVersion | cut -f1,2 -d.`;
SHASUM="shasum";
OPENSSL_ARCH="darwin64-x86_64-cc";
CFLAGS="-fwrapv -Os";
CXXFLAGS="${CFLAGS}";
LDFLAGS="";
;;
*) echo "unsupported platform!"; exit 1;;
esac
# WATCHMAN_VERSION="4.9.0"
WATCHMAN_VERSION="4.9.0-pants1"
WATCHMAN_DEST_DIR="${DIRPATH}/build-support/bin/watchman/${PLATFORM}/${ARCH}/${WATCHMAN_VERSION}"
echo "*****************************"
echo "building watchman ${WATCHMAN_VERSION}"
echo "*****************************"
echo
mkdir -p $BUILD_DIR
pushd $BUILD_DIR
# PCRE build.
curl -LO $PCRE_URL
if [ $($SHASUM $PCRE_TARBALL | grep -c $PCRE_SHASUM) -ne "1" ]; then
set +x
echo "pcre checksum invalid! aborting build."
exit 1
fi
tar zxf $PCRE_TARBALL
pushd $PCRE_DIR
CFLAGS="${CFLAGS}" ./configure --enable-static --disable-shared --prefix="${PCRE_INSTALL_DIR}"
make
make install
popd
# OpenSSL build (Linux only).
if [ "${PLATFORM}" == "linux" ]; then
curl -LO $OPENSSL_URL
if [ $($SHASUM $OPENSSL_TARBALL | grep -c $OPENSSL_SHASUM) -ne "1" ]; then
set +x
echo "openssl checksum invalid! aborting build."
exit 1
fi
tar zxf $OPENSSL_TARBALL
pushd $OPENSSL_DIR
CFLAGS="${CFLAGS}" ./Configure no-shared -fPIC --prefix="${OPENSSL_INSTALL_DIR}" "${OPENSSL_ARCH}"
make depend
make -j8
make install
popd
fi
# Watchman build.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# TODO: Restore this, the watchman version and the `git checkout` line below once
# https://github.com/facebook/watchman/pull/559 lands and is tagged/released.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# git clone https://github.com/facebook/watchman.git watchman
git clone https://github.com/kwlzn/watchman.git watchman
pushd watchman
# git checkout v${WATCHMAN_VERSION}
git checkout kwlzn/spawn_strategy
./autogen.sh
CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" ./configure --with-pcre=../pcre_install/bin/pcre-config --disable-statedir --without-python
make watchman
mkdir -p $WATCHMAN_DEST_DIR
cp watchman $WATCHMAN_DEST_DIR/
popd
popd
rm -rf $BUILD_DIR
set +x
echo
echo "*****************************"
echo "build completed successfully!"
echo "*****************************"