• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eux
2
3# Copyright (C) 2022 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# Verifies mixed builds does not run if neither --bazel-mode-dev nor --bazel-mode
18# is set.
19# This verification script is designed to be used for continuous integration
20# tests, though may also be used for manual developer verification.
21
22if [[ -z ${OUT_DIR+x} ]]; then
23  OUT_DIR="out"
24fi
25
26if [[ -z ${DIST_DIR+x} ]]; then
27  echo "DIST_DIR not set. Using ${OUT_DIR}/dist. This should only be used for manual developer testing."
28  DIST_DIR="${OUT_DIR}/dist"
29fi
30
31# Generate the ninja file with default setting. We expect Bazel to be enabled by
32# default.
33build/soong/soong_ui.bash --make-mode \
34  --mk-metrics \
35  BAZEL_STARTUP_ARGS="--max_idle_secs=5" \
36  BAZEL_BUILD_ARGS="--color=no --curses=no --show_progress_rate_limit=5" \
37  TARGET_PRODUCT=aosp_arm64 \
38  TARGET_BUILD_VARIANT=userdebug \
39  com.android.tzdata \
40  dist DIST_DIR=$DIST_DIR
41
42
43# PLEASE NOTE - IF TZDATA IS EVER REMOVED FROM THE PROD ALLOWLIST, THIS _WILL_ FAIL
44# Should that happen, look into reverting to the assertions on bazel-out or switching
45
46if [[ ! $(ls out/bazel/output/execroot/__main__/bazel-out/aosp_arm64-userdebug-opt-ST-743b56eaae08/bin/system/timezone/apex/com.android.tzdata_staging_dir/etc/tz/tzdata) ]] ; then
47  echo "Expected tzdata files under bazel-out"
48  exit 1
49fi
50
51# Default setting should contain bazel-out, as *at least* tzdata is allowlisted for
52# default prod mode.
53if [[ $(grep -L "bazel-out" ${OUT_DIR}/soong/build.ninja) ]]; then
54  echo "Expected default build to reference bazel-out"
55  exit 1
56fi
57
58# Regenerate the ninja file with BUILD_BROKEN override. This should have mixed builds
59# disabled.
60build/soong/soong_ui.bash --make-mode \
61  --mk-metrics \
62  DISABLE_ARTIFACT_PATH_REQUIREMENTS=true \
63  BUILD_BROKEN_DISABLE_BAZEL=true \
64  BAZEL_STARTUP_ARGS="--max_idle_secs=5" \
65  BAZEL_BUILD_ARGS="--color=no --curses=no --show_progress_rate_limit=5" \
66  TARGET_PRODUCT=aosp_arm64 \
67  TARGET_BUILD_VARIANT=userdebug \
68  nothing \
69  dist DIST_DIR=$DIST_DIR
70
71# Note - we could m clean and assert that the bazel build doesn't exist, but this is
72# a better use of time
73if [[ ! $(grep -L "bazel-out" ${OUT_DIR}/soong/build.ninja) ]]; then
74  echo "Expected BUILD_BROKEN override to not reference bazel-out"
75  exit 1
76fi
77
78build/soong/soong_ui.bash --make-mode clean
79
80# Rerun default setting. This verifies that removing BUILD_BROKEN_DISABLE_BAZEL
81# causes analysis to be rerun.
82build/soong/soong_ui.bash --make-mode \
83  --mk-metrics \
84  DISABLE_ARTIFACT_PATH_REQUIREMENTS=true \
85  BAZEL_STARTUP_ARGS="--max_idle_secs=5" \
86  BAZEL_BUILD_ARGS="--color=no --curses=no --show_progress_rate_limit=5" \
87  TARGET_PRODUCT=aosp_arm64 \
88  TARGET_BUILD_VARIANT=userdebug \
89  com.android.tzdata \
90  dist DIST_DIR=$DIST_DIR
91
92if [[ ! $(ls out/bazel/output/execroot/__main__/bazel-out/aosp_arm64-userdebug-opt-ST-743b56eaae08/bin/system/timezone/apex/com.android.tzdata_staging_dir/etc/tz/tzdata) ]] ; then
93  echo "Expected tzdata files under bazel-out"
94  exit 1
95fi
96
97if [[ $(grep -L "bazel-out" ${OUT_DIR}/soong/build.ninja) ]]; then
98  echo "Expected default build rerun to reference bazel-out"
99  exit 1
100fi
101
102build/soong/soong_ui.bash --make-mode clean
103
104# Regen ninja file with mixed builds dev mode.
105build/soong/soong_ui.bash --make-mode \
106  --mk-metrics \
107  --bazel-mode-dev \
108  DISABLE_ARTIFACT_PATH_REQUIREMENTS=true \
109  BAZEL_STARTUP_ARGS="--max_idle_secs=5" \
110  BAZEL_BUILD_ARGS="--color=no --curses=no --show_progress_rate_limit=5" \
111  TARGET_PRODUCT=aosp_arm64 \
112  TARGET_BUILD_VARIANT=userdebug \
113  com.android.tzdata \
114  dist DIST_DIR=$DIST_DIR
115
116if [[ ! $(ls out/bazel/output/execroot/__main__/bazel-out/aosp_arm64-userdebug-opt-ST-743b56eaae08/bin/system/timezone/apex/com.android.tzdata_staging_dir/etc/tz/tzdata) ]] ; then
117  echo "Expected tzdata files under bazel-out"
118  exit 1
119fi
120
121if [[ $(grep -L "bazel-out" ${OUT_DIR}/soong/build.ninja) ]]; then
122  echo "Expected dev mode build to reference bazel-out"
123  exit 1
124fi
125