xref: /aosp_15_r20/external/conscrypt/srcgen/generate_android_src.sh (revision cd0cc2e34ba52cdf454361820a14d744e4bd531d)
1#!/bin/bash
2# Copyright (C) 2018 The Android Open Source Project
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
16if [[ -z "${ANDROID_BUILD_TOP}" ]]; then
17    echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2
18    exit 1
19fi
20
21PROJECT_DIR=external/conscrypt
22
23PACKAGE_TRANSFORMATIONS="\
24    org.conscrypt:com.android.org.conscrypt \
25"
26
27MODULE_DIRS="\
28    benchmark-android \
29    benchmark-base \
30    common \
31    openjdk \
32    platform \
33    testing \
34"
35DEFAULT_CONSTRUCTORS_FILE=${CONSCRYPT_DIR}/srcgen/default-constructors.txt
36
37SOURCE_DIRS="\
38    src/main/java \
39    src/test/java \
40"
41
42# Repackage the project's source.
43source ${ANDROID_BUILD_TOP}/tools/currysrc/scripts/repackage-common.sh
44
45# Remove some unused test files:
46rm -fr ${REPACKAGED_DIR}/common/src/test/java/com/android/org/conscrypt/ConscryptSuite.java
47rm -fr ${REPACKAGED_DIR}/common/src/test/java/com/android/org/conscrypt/ConscryptJava7Suite.java
48
49# Remove any leftovers from older directory layout
50rm -fr openjdk-integ-tests ${REPACKAGED_DIR}/openjdk-integ-tests
51
52echo "Reformatting generated code to adhere to format required by the preupload check"
53cd ${PROJECT_DIR}
54CLANG_STABLE_BIN=${ANDROID_BUILD_TOP}/prebuilts/clang/host/linux-x86/clang-stable/bin
55${ANDROID_BUILD_TOP}/tools/repohooks/tools/clang-format.py --fix \
56  --clang-format ${CLANG_STABLE_BIN}/clang-format \
57  --git-clang-format ${CLANG_STABLE_BIN}/git-clang-format \
58  --style file \
59  --working-tree \
60  $(git diff --name-only HEAD | grep -E "^repackaged/")
61