blob: 21a3703cf6abd3322c03866adca7df71cea359bf (
plain)
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
|
#!/bin/bash
set -o verbose
set -o errexit
# This script fetches and creates a copy of sources for snappy
# snappy uses CMake and this script will invoke CMake to generate a
# config.h for "posix", Linux, and Windows
#
# To get the sources for Snappy, run this script as follows:
#
# 1. Run on Darwin
# 2. Run on Linux
# 3. Run on s390x Linux
# 4. Run on Windows via Cygwin
#
# For s390x CMake is already installed on the ZAP dev machines, you'll
# need to add it to the $PATH before running this script with:
#
# export PATH="/opt/cmake/bin:$PATH"
#
# For Windows you will need CMake installed. If using an
# Evergreen spawn host it is not installed by default but, you can
# easily install it with the following command. (this works in
# cygwin):
#
# choco install cmake
#
# You will also need to add it to the $PATH with the following:
#
# export PATH="/cygdrive/c/Program Files/CMake/bin/:$PATH"
VERSION=1.1.7
NAME=snappy
TARBALL=$NAME-$VERSION.tar.gz
TARBALL_DIR=$NAME-$VERSION
TARBALL_DEST_DIR=$NAME-$VERSION
TEMP_DIR=/tmp/temp-$NAME-$VERSION
DEST_DIR=`git rev-parse --show-toplevel`/src/third_party/$NAME-$VERSION
UNAME=`uname | tr A-Z a-z`
if [ "$UNAME" == "linux" && "$(uname -m)" == "s390x" ]; then
TARGET_UNAME=linux_s390x
elif [ "$UNAME" == "linux" ]
TARGET_UNAME=linux
elif [[ "$UNAME" == "cygwin"* ]]; then
TARGET_UNAME=windows
else
TARGET_UNAME=posix
fi
echo TARGET_UNAME: $TARGET_UNAME
if [ ! -f $TARBALL ]; then
echo "Get tarball"
curl -L -o $NAME-$VERSION.tar.gz https://github.com/google/$NAME/archive/$VERSION.tar.gz
fi
echo $TARBALL
tar -zxvf $TARBALL
rm -rf $TEMP_DIR
mv $TARBALL_DIR $TEMP_DIR
mkdir $DEST_DIR || true
cd $TEMP_DIR
cp $TEMP_DIR/* $DEST_DIR || true
rm -f $DEST_DIR/Makefile* $DEST_DIR/config* $DEST_DIR/*sh
rm -f $DEST_DIR/compile* $DEST_DIR/depcomp $DEST_DIR/libtool
rm -f $DEST_DIR/test-driver $DEST_DIR/*.m4 $DEST_DIR/missing
echo "Generating Config.h and other files"
cmake $TEMP_DIR
# Copy over the platform independent generated files
cp $TEMP_DIR/snappy-stubs-public.h $DEST_DIR
# Copy over config.h
mkdir $DEST_DIR/build_$TARGET_UNAME
cp $TEMP_DIR/config.h $DEST_DIR/build_$TARGET_UNAME
# Change the snappy-stubs-public.h to use the defined variables
# instead of hardcoded values generated by CMake
#
# Changes lines like:
#
# #if !0 // !HAVE_SYS_UIO_H
# #if 1 // HAVE_STDINT_H
#
# To:
#
# #if !HAVE_SYS_UIO_H
# #if HAVE_STDINT_H
if [ "$TARGET_UNAME" = "posix" ]; then
sed -i '' 's/if !\{0,1\}[0-9] \/\/ \(!\{0,1\}HAVE_.*\)/if \1/' snappy-stubs-public.h
else
sed -i 's/if !\{0,1\}[0-9] \/\/ \(!\{0,1\}HAVE_.*\)/if \1/' snappy-stubs-public.h
fi
echo "Done"
|