xref: /aosp_15_r20/external/libphonenumber/srcgen/generate_android_src.sh (revision e3ee85ea7a059d2c4cb054859ee23ab42559378c)
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/libphonenumber
22
23PACKAGE_TRANSFORMATIONS="\
24    com.google:com.android \
25"
26
27MODULE_DIRS="\
28    libphonenumber \
29    geocoder \
30    internal/prefixmapper \
31"
32
33SOURCE_DIRS="\
34    src \
35"
36
37TAB_SIZE=2
38
39# Repackage the project's source.
40source ${ANDROID_BUILD_TOP}/tools/currysrc/scripts/repackage-common.sh
41
42for i in ${MODULE_DIRS}
43do
44  for s in ${SOURCE_DIRS}
45  do
46    IN=${PROJECT_DIR}/$i/$s
47    if [ -d $IN ]; then
48      OUT=${REPACKAGED_DIR}/$i/$s
49      # Copy any resources
50      echo Copying resources from ${IN} to ${OUT}
51      RESOURCES=$(find ${IN} -type f | egrep -v '(\.java|\/package\.html)' || true)
52      for RESOURCE in ${RESOURCES}; do
53        SOURCE_DIR=$(dirname ${RESOURCE})
54        RELATIVE_SOURCE_DIR=$(echo ${SOURCE_DIR} | sed "s,${IN}/,,")
55        RELATIVE_DEST_DIR=$(echo ${RELATIVE_SOURCE_DIR} | sed 's,com/google,com/android,')
56        DEST_DIR=${OUT}/${RELATIVE_DEST_DIR}
57        mkdir -p ${DEST_DIR}
58        cp $RESOURCE ${DEST_DIR}
59      done
60    fi
61  done
62done
63
64