xref: /aosp_15_r20/external/tensorflow/tensorflow/tools/ci_build/presubmit/macos/py37_cc/build.sh (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1#!/bin/bash
2# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ==============================================================================
16
17set -e
18
19# Error if we somehow forget to set the path to bazel_wrapper.py
20set -u
21BAZEL_WRAPPER_PATH=$1
22set +u
23
24# From this point on, logs can be publicly available
25set -x
26
27function run_build () {
28  # Run configure.
29  export TF_NEED_CUDA=0
30  export PYTHON_BIN_PATH=$(which python3.7)
31  yes "" | $PYTHON_BIN_PATH configure.py
32  tag_filters="-no_oss,-gpu,-tpu,-benchmark-test,-nomac,-no_mac,-v1only"
33
34  # Get the default test targets for bazel.
35  source tensorflow/tools/ci_build/build_scripts/DEFAULT_TEST_TARGETS.sh
36
37  # TODO(b/203827187): Only build //tensorflow/python/... for now due to
38  # timeouts. We have too many tests and build also takes too long so we need to
39  # fix this after more in-depth profiling.
40  "${BAZEL_WRAPPER_PATH}" \
41    test \
42    --profile="${KOKORO_ARTIFACTS_DIR}/profile.json.gz" \
43    --build_event_binary_file="${KOKORO_ARTIFACTS_DIR}/build_events.pb" \
44    --nodistinct_host_configuration \
45    --build_tag_filters="${tag_filters}" \
46    --test_tag_filters="${tag_filters}" \
47    --action_env=PATH \
48    --remote_accept_cached=true \
49    --remote_local_fallback=false \
50    --remote_timeout=600 \
51    -- //tensorflow/python/... # ${DEFAULT_BAZEL_TARGETS} -//tensorflow/java/... -//tensorflow/lite/java/...
52
53  # Print build time statistics, including critical path.
54  bazel analyze-profile "${KOKORO_ARTIFACTS_DIR}/profile.json.gz"
55
56  # Copy log to output to be available to GitHub
57  ls -la "$(bazel info output_base)/java.log"
58  cp "$(bazel info output_base)/java.log" "${KOKORO_ARTIFACTS_DIR}/"
59}
60
61source tensorflow/tools/ci_build/release/common.sh
62install_bazelisk
63
64# Set up and install MacOS pip dependencies.
65setup_venv_macos python3.7
66run_build
67