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# PLEASE NOTE - IF TZDATA IS EVER REMOVED FROM THE PROD ALLOWLIST, THIS _WILL_ FAIL 43# Should that happen, look into reverting to the assertions on bazel-out or switching 44sentinel_file="${OUT_DIR}/bazel/output/execroot/__main__/bazel-out/*/bin/system/timezone/apex/com.android.tzdata.apex" 45 46if [[ $(ls ${sentinel_file} | wc -l) -ne 1 ]]; then 47 echo "Expected a single configuration of 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.aosp_arm64.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 BUILD_BROKEN_DISABLE_BAZEL=true \ 63 BAZEL_STARTUP_ARGS="--max_idle_secs=5" \ 64 BAZEL_BUILD_ARGS="--color=no --curses=no --show_progress_rate_limit=5" \ 65 TARGET_PRODUCT=aosp_arm64 \ 66 TARGET_BUILD_VARIANT=userdebug \ 67 nothing \ 68 dist DIST_DIR=$DIST_DIR 69 70# Note - we could m clean and assert that the bazel build doesn't exist, but this is 71# a better use of time 72if [[ ! $(grep -L "bazel-out" ${OUT_DIR}/soong/build.aosp_arm64.ninja) ]]; then 73 echo "Expected BUILD_BROKEN override to not reference bazel-out" 74 exit 1 75fi 76 77build/soong/soong_ui.bash --make-mode clean 78 79# Rerun default setting. This verifies that removing BUILD_BROKEN_DISABLE_BAZEL 80# causes analysis to be rerun. 81build/soong/soong_ui.bash --make-mode \ 82 --mk-metrics \ 83 BAZEL_STARTUP_ARGS="--max_idle_secs=5" \ 84 BAZEL_BUILD_ARGS="--color=no --curses=no --show_progress_rate_limit=5" \ 85 TARGET_PRODUCT=aosp_arm64 \ 86 TARGET_BUILD_VARIANT=userdebug \ 87 com.android.tzdata \ 88 dist DIST_DIR=$DIST_DIR 89 90if [[ $(ls ${sentinel_file} | wc -l) -ne 1 ]]; then 91 echo "Expected a single configuration of tzdata files under bazel-out" 92 exit 1 93fi 94 95if [[ $(grep -L "bazel-out" ${OUT_DIR}/soong/build.aosp_arm64.ninja) ]]; then 96 echo "Expected default build rerun to reference bazel-out" 97 exit 1 98fi 99