xref: /aosp_15_r20/build/bazel/rules/java/errorprone/errorProneCompatibilityFlags.sh (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15#!/bin/bash
16# This script builds two Bazel classes which output the default checks in
17# the Errorprone versions in Soong and Bazel.
18# It then runs a python script that generates a file of flags that can be
19# applied to Bazel that will ensure Bazel has the same default bugprone patterns
20# as Soong's version of Errorprone.
21#
22#
23# Usage: errorProneCompatibilityFlags.sh  <path to repository root>
24
25
26BASEDIR=$1
27TEMP_SOONG_DIR=$(mktemp -d)
28TEMP_BAZEL_DIR=$(mktemp -d)
29SOONGFILE=$(mktemp)
30BAZELFILE=$(mktemp)
31
32cd "${BASEDIR}" || { echo "Error: directory not found ${BASEDIR}"; exit 1; }
33
34build/bazel/bin/b build //build/bazel/rules/java/errorprone:PrintSoongClasses --noshow_loading_progress --noshow_progress
35"${BASEDIR}/bazel-bin/build/bazel/rules/java/errorprone/PrintSoongClasses" > $SOONGFILE
36
37build/bazel/bin/b build //build/bazel/rules/java/errorprone:PrintBazelClasses --noshow_loading_progress --noshow_progress
38"${BASEDIR}/bazel-bin/build/bazel/rules/java/errorprone/PrintBazelClasses" > $BAZELFILE
39
40prebuilts/build-tools/path/linux-x86/python3 "${BASEDIR}/build/bazel/rules/java/errorprone/generateErrorProneCompatibilityFlags.py" --soong_file=$SOONGFILE --bazel_file=$BAZELFILE
41
42
43