build-cmd.sh 5.72 KB
Newer Older
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
#!/usr/bin/env bash

cd "$(dirname "$0")"

# turn on verbose debugging output for parabuild logs.
exec 4>&1; export BASH_XTRACEFD=4; set -x
# make errors fatal
set -e
# complain about unset env variables
set -u

if [ -z "$AUTOBUILD" ] ; then
    exit 1
fi

if [ "$OSTYPE" = "cygwin" ] ; then
    autobuild="$(cygpath -u $AUTOBUILD)"
else
    autobuild="$AUTOBUILD"
fi

top="$(pwd)"
stage="$(pwd)/stage"

# load autobuild provided shell functions and variables
source_environment_tempfile="$stage/source_environment.sh"
"$autobuild" source_environment > "$source_environment_tempfile"
. "$source_environment_tempfile"

NGHTTP2_VERSION_HEADER_DIR="$top/nghttp2/lib/includes/nghttp2"
version="$(sed -n -E 's/#define NGHTTP2_VERSION "([^"]+)"/\1/p' "${NGHTTP2_VERSION_HEADER_DIR}/nghttp2ver.h" | tr -d '\r' )"
build=${AUTOBUILD_BUILD_ID:=0}
echo "${version}.${build}" > "${stage}/VERSION.txt"

# Restore all .sos
restore_sos ()
{
    for solib in "${stage}"/packages/lib/release/lib*.so*.disable; do
        if [ -f "$solib" ]; then
            mv -f "$solib" "${solib%.disable}"
        fi
    done
}


# Restore all .dylibs
restore_dylibs ()
{
    for dylib in "$stage/packages/lib"/release/*.dylib.disable; do
        if [ -f "$dylib" ]; then
            mv "$dylib" "${dylib%.disable}"
        fi
    done
}

56
57
58
59
mkdir -p "$stage/include/nghttp2"
mkdir -p "$stage/lib/debug"
mkdir -p "$stage/lib/release"

60
61
62
63
64
pushd "$top/nghttp2"
    case "$AUTOBUILD_PLATFORM" in
        windows*)
            load_vsvars

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
            mkdir -p "build"
            pushd "build"
                cmake .. -G"$AUTOBUILD_WIN_CMAKE_GEN" -T host=x64 -DENABLE_LIB_ONLY=ON \
                    -DCMAKE_SYSTEM_VERSION="10.0.17763.0" -DCMAKE_INSTALL_PREFIX="$(cygpath -m "$stage")"

                cmake --build . --config Debug --clean-first
                cmake --build . --config Release --clean-first
				
                cp -a "lib/Debug/nghttp2.dll" \
                    "$stage/lib/debug/"
                cp -a "lib/Debug/nghttp2.lib" \
                    "$stage/lib/debug/"
                cp -a "lib/Debug/nghttp2.pdb" \
                    "$stage/lib/debug/"
                cp -a "lib/Release/nghttp2.dll" \
                    "$stage/lib/release/"
                cp -a "lib/Release/nghttp2.lib" \
                    "$stage/lib/release/"

                cp -a lib/includes/nghttp2/nghttp2ver.h "$stage/include/nghttp2"
            popd
86
87
88
        ;;

        darwin*)
¡Cinder! ㊝'s avatar
¡Cinder! ㊝ committed
89
            opts="${TARGET_OPTS:--arch $AUTOBUILD_CONFIGURE_ARCH $LL_BUILD_RELEASE}"
90

91
92
93
94
95
96
97
            mkdir -p "build"
            pushd "build"
                cmake -G "Xcode" .. -DCMAKE_C_FLAGS:STRING="$opts" \
                    -DCMAKE_CXX_FLAGS:STRING="$opts" \
                    -DCMAKE_INSTALL_PREFIX="$stage" \
                    -DCMAKE_OSX_SYSROOT="macosx10.14" \
                    -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" \
¡Cinder! ㊝'s avatar
¡Cinder! ㊝ committed
98
                    -DENABLE_STATIC_LIB=ON -DENABLE_SHARED_LIB=OFF \
99
100
101
102
103
                    -DENABLE_LIB_ONLY=ON 

                cmake --build . --config Debug
                cmake --build . --config Release

¡Cinder! ㊝'s avatar
¡Cinder! ㊝ committed
104
105
                mv lib/Debug/libnghttp2*.a "$stage/lib/debug/"
                mv lib/Release/libnghttp2*.a "$stage/lib/release/"
106
107
108
                cp -a lib/includes/nghttp2/nghttp2ver.h "$stage/include/nghttp2"
            popd
            rm -rf "build"
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
        ;;

        linux*)
            # Linux build environment at Linden comes pre-polluted with stuff that can
            # seriously damage 3rd-party builds.  Environmental garbage you can expect
            # includes:
            #
            #    DISTCC_POTENTIAL_HOSTS     arch           root        CXXFLAGS
            #    DISTCC_LOCATION            top            branch      CC
            #    DISTCC_HOSTS               build_name     suffix      CXX
            #    LSDISTCC_ARGS              repo           prefix      CFLAGS
            #    cxx_version                AUTOBUILD      SIGN        CPPFLAGS
            #
            # So, clear out bits that shouldn't affect our configure-directed build
            # but which do nonetheless.
            #
            # unset DISTCC_HOSTS CC CXX CFLAGS CPPFLAGS CXXFLAGS

            # Default target per --address-size
Rye's avatar
Rye committed
128
129
            opts="${TARGET_OPTS:--m$AUTOBUILD_ADDRSIZE -fPIC -DPIC -g}"
            hardening="-fstack-protector-strong -D_FORTIFY_SOURCE=2"
130
131
132
133
134
135
136
137
138
139

            # Handle any deliberate platform targeting
            if [ -z "${TARGET_CPPFLAGS:-}" ]; then
                # Remove sysroot contamination from build environment
                unset CPPFLAGS
            else
                # Incorporate special pre-processing flags
                export CPPFLAGS="$TARGET_CPPFLAGS"
            fi

Rye's avatar
Rye committed
140
141
142
143
144
            mkdir -p "build_debug"
            pushd "build_debug"
                # Invoke cmake and use as official build
                CFLAGS="$opts -Og" CXXFLAGS="$opts -Og" \
                    cmake -DCMAKE_BUILD_TYPE="Debug" ..
145

Rye's avatar
Rye committed
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
                cmake --build . --config Debug --clean-first

                mv lib/libnghttp2*.so* "$stage/lib/debug/"
            popd
            rm -rf "build_debug"

            mkdir -p "build_release"
            pushd "build_release"
                # Invoke cmake and use as official build
                CFLAGS="$opts $hardening" CXXFLAGS="$opts $hardening" \
                    cmake -DCMAKE_BUILD_TYPE="Release" ..

                cmake --build . --config Release --clean-first

                mv lib/libnghttp2*.so* "$stage/lib/release/"
                cp -a lib/includes/nghttp2/nghttp2ver.h "$stage/include/nghttp2"
            popd
            rm -rf "build_release"
164
165
166
167
168
169
        ;;
    esac
    mkdir -p "$stage/LICENSES"
    cp "$top/nghttp2/COPYING" "$stage/LICENSES/nghttp2.txt"
popd

170
cp "$NGHTTP2_VERSION_HEADER_DIR"/nghttp2.h "$stage/include/nghttp2/"
¡Cinder! ㊝'s avatar
¡Cinder! ㊝ committed
171