Diff of /build_and_test.sh [000000] .. [5a4941]

Switch to unified view

a b/build_and_test.sh
1
#!/bin/bash
2
3
# Copyright 2017 Google LLC.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
7
# are met:
8
#
9
# 1. Redistributions of source code must retain the above copyright notice,
10
#    this list of conditions and the following disclaimer.
11
#
12
# 2. Redistributions in binary form must reproduce the above copyright
13
#    notice, this list of conditions and the following disclaimer in the
14
#    documentation and/or other materials provided with the distribution.
15
#
16
# 3. Neither the name of the copyright holder nor the names of its
17
#    contributors may be used to endorse or promote products derived from this
18
#    software without specific prior written permission.
19
#
20
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
# POSSIBILITY OF SUCH DAMAGE.
31
32
# NOLINT
33
set -eux -o pipefail
34
35
source settings.sh
36
37
# bazel should have been installed in build-prereq.sh, but the PATH might
38
# need to be added in this script.
39
if ! bazel; then
40
  PATH="$HOME/bin:$PATH"
41
fi
42
43
# Building examples_from_stream.so C++ library. It cannot be built correctly
44
# with the default bazel setup, so we build it manually.
45
# examples_from_stream.so is used by call_variants target therefore it has to
46
# be built before :binaries.
47
TF_CFLAGS=( $(python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
48
TF_LFLAGS=( $(python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
49
50
# shellcheck disable=SC2068
51
g++ -std=c++14 -shared \
52
        deepvariant/stream_examples_kernel.cc  \
53
        deepvariant/stream_examples_ops.cc \
54
        -o deepvariant/examples_from_stream.so \
55
        -fPIC \
56
        -l:libtensorflow_framework.so.2  \
57
        -I. \
58
        ${TF_CFLAGS[@]} \
59
        ${TF_LFLAGS[@]} \
60
        -D_GLIBCXX_USE_CXX11_ABI=1 \
61
        --std=c++17 \
62
        -DEIGEN_MAX_ALIGN_BYTES=64 \
63
        -O2
64
65
# Run all deepvariant tests.  Take bazel options from args, if any.
66
# Note: If running with GPU, tests must be executed serially due to a GPU
67
# contention issue.
68
if [[ "${DV_GPU_BUILD:-0}" = "1" ]]; then
69
  bazel test -c opt --local_test_jobs=1 ${DV_COPT_FLAGS} "$@" \
70
    deepvariant/...
71
  # GPU tests are commented out for now.
72
  # Because they seem to be all filtered out, and as a result causing an error.
73
  # See internal#comment5.
74
  # TODO: Uncomment this once it's resolved.
75
  # bazel test -c opt --local_test_jobs=1 ${DV_COPT_FLAGS} "$@" \
76
  #   deepvariant:gpu_tests
77
else
78
  # Running parallel tests on CPU.
79
  bazel test -c opt ${DV_COPT_FLAGS} "$@" deepvariant/...
80
fi
81
82
# Build the binary.
83
./build_release_binaries.sh
84
85
echo 'Expect a usage message:'
86
(python3 bazel-out/k8-opt/bin/deepvariant/call_variants.zip --help || : ) | grep '/call_variants.py:'
87