1# Define custom utilities
2# Test for OSX with [ -n "$IS_OSX" ]
3
4function pre_build {
5    # Any stuff that you need to do before you start building the wheels
6    # Runs in the root directory of this repository.
7    pushd protobuf
8
9    # Build protoc
10    ./autogen.sh
11    ./configure
12
13    CXXFLAGS="-std=c++14 -fPIC -g -O2" ./configure
14    make -j8
15
16    # Generate python dependencies.
17    pushd python
18    python setup.py build_py
19    popd
20
21    popd
22}
23
24function bdist_wheel_cmd {
25    # Builds wheel with bdist_wheel, puts into wheelhouse
26    #
27    # It may sometimes be useful to use bdist_wheel for the wheel building
28    # process.  For example, versioneer has problems with versions which are
29    # fixed with bdist_wheel:
30    # https://github.com/warner/python-versioneer/issues/121
31    local abs_wheelhouse=$1
32
33    # Modify build version
34    pwd
35    ls
36    python setup.py bdist_wheel --cpp_implementation --compile_static_extension
37    cp dist/*.whl $abs_wheelhouse
38}
39
40function build_wheel {
41    build_wheel_cmd "bdist_wheel_cmd" $@
42}
43
44function run_tests {
45    # Runs tests on installed distribution from an empty directory
46    python --version
47    python -c "from google.protobuf.pyext import _message;"
48}
49