1# Copyright (C) 2015 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# Common variables and actions for inclusion in srcgen scripts. 16 17set -e 18 19if [[ -z ${ANDROID_BUILD_TOP} ]]; then 20 echo ANDROID_BUILD_TOP not set 21 exit 1 22fi 23 24# source envsetup.sh because functions we use like mm are not exported. 25source ${ANDROID_BUILD_TOP}/build/envsetup.sh 26 27# Build Options used by Android.bp 28while true; do 29 case "$1" in 30 --do-not-make ) DO_NOT_MAKE=1; shift ;; 31 -- ) shift; break ;; 32 * ) break ;; 33 esac 34done 35 36# Build the srcgen tools. 37cd ${ANDROID_BUILD_TOP} 38if [ -z "$DO_NOT_MAKE" ]; then 39 make -j16 android_icu4j_srcgen_binary 40fi 41 42ICU_SRCGEN_DIR=${ANDROID_BUILD_TOP}/external/icu/tools/srcgen 43ICU4J_DIR=${ANDROID_BUILD_TOP}/external/icu/icu4j 44ANDROID_ICU4J_DIR=${ANDROID_BUILD_TOP}/external/icu/android_icu4j 45 46CLASSPATH=${ANDROID_HOST_OUT}/framework/currysrc.jar:${ANDROID_HOST_OUT}/framework/android_icu4j_srcgen.jar 47 48# The parts of ICU4J to include during srcgen. 49# 50# The following are deliberately excluded: 51# localespi - is not supported on Android 52# charset - because icu4c is used instead 53INPUT_DIRS="\ 54 ${ICU4J_DIR}/main/collate/src/main \ 55 ${ICU4J_DIR}/main/core/src/main \ 56 ${ICU4J_DIR}/main/currdata/src/main \ 57 ${ICU4J_DIR}/main/langdata/src/main \ 58 ${ICU4J_DIR}/main/regiondata/src/main \ 59 ${ICU4J_DIR}/main/translit/src/main \ 60 " 61 62INPUT_JAVA_DIRS="" 63INPUT_RESOURCE_DIRS="" 64for INPUT_DIR in ${INPUT_DIRS}; do 65 if [ -d "${INPUT_DIR}/java" ]; then 66 INPUT_JAVA_DIRS="${INPUT_JAVA_DIRS} ${INPUT_DIR}/java" 67 fi 68 if [ -d "${INPUT_DIR}/resources" ]; then 69 INPUT_RESOURCE_DIRS="${INPUT_RESOURCE_DIRS} ${INPUT_DIR}/resources" 70 fi 71done 72 73SAMPLE_INPUT_DIR=${ICU4J_DIR}/samples/src/main/java/com/ibm/icu/samples 74# Only generate sample files for code we know should compile on Android with the public APIs. 75SAMPLE_INPUT_FILES="\ 76 ${SAMPLE_INPUT_DIR}/text/dateintervalformat/DateIntervalFormatSample.java \ 77 ${SAMPLE_INPUT_DIR}/text/datetimepatterngenerator/DateTimePatternGeneratorSample.java \ 78 ${SAMPLE_INPUT_DIR}/text/pluralformat/PluralFormatSample.java \ 79 " 80 81# See above for an explanation as to why the tests for charset and localespi are not included here. 82TEST_INPUT_DIR=${ICU4J_DIR}/main/tests 83TEST_INPUT_DIRS="\ 84 ${ICU4J_DIR}/main/collate/src/test \ 85 ${ICU4J_DIR}/main/framework/src/test \ 86 ${ICU4J_DIR}/main/core/src/test \ 87 ${ICU4J_DIR}/main/common_tests/src/test \ 88 ${ICU4J_DIR}/main/translit/src/test \ 89 " 90 91TEST_INPUT_JAVA_DIRS="" 92TEST_INPUT_RESOURCE_DIRS="" 93for TEST_INPUT_DIR in ${TEST_INPUT_DIRS}; do 94 if [ -d "${TEST_INPUT_DIR}/java" ]; then 95 TEST_INPUT_JAVA_DIRS="${TEST_INPUT_JAVA_DIRS} ${TEST_INPUT_DIR}/java" 96 fi 97 if [ -d "${TEST_INPUT_DIR}/resources" ]; then 98 TEST_INPUT_RESOURCE_DIRS="${TEST_INPUT_RESOURCE_DIRS} ${TEST_INPUT_DIR}/resources" 99 fi 100done 101 102# Allow override of the java runtime to avoid http://b/27775477 103SRCGEN_JAVA_BINARY=${SRCGEN_JAVA_BINARY:-java} 104