xref: /aosp_15_r20/external/icu/tools/srcgen/common.sh (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker# Copyright (C) 2015 The Android Open Source Project
2*0e209d39SAndroid Build Coastguard Worker#
3*0e209d39SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*0e209d39SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*0e209d39SAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*0e209d39SAndroid Build Coastguard Worker#
7*0e209d39SAndroid Build Coastguard Worker#      http://www.apache.org/licenses/LICENSE-2.0
8*0e209d39SAndroid Build Coastguard Worker#
9*0e209d39SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*0e209d39SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*0e209d39SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*0e209d39SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*0e209d39SAndroid Build Coastguard Worker# limitations under the License.
14*0e209d39SAndroid Build Coastguard Worker
15*0e209d39SAndroid Build Coastguard Worker# Common variables and actions for inclusion in srcgen scripts.
16*0e209d39SAndroid Build Coastguard Worker
17*0e209d39SAndroid Build Coastguard Workerset -e
18*0e209d39SAndroid Build Coastguard Worker
19*0e209d39SAndroid Build Coastguard Workerif [[ -z ${ANDROID_BUILD_TOP} ]]; then
20*0e209d39SAndroid Build Coastguard Worker  echo ANDROID_BUILD_TOP not set
21*0e209d39SAndroid Build Coastguard Worker  exit 1
22*0e209d39SAndroid Build Coastguard Workerfi
23*0e209d39SAndroid Build Coastguard Worker
24*0e209d39SAndroid Build Coastguard Worker# source envsetup.sh because functions we use like mm are not exported.
25*0e209d39SAndroid Build Coastguard Workersource ${ANDROID_BUILD_TOP}/build/envsetup.sh
26*0e209d39SAndroid Build Coastguard Worker
27*0e209d39SAndroid Build Coastguard Worker# Build Options used by Android.bp
28*0e209d39SAndroid Build Coastguard Workerwhile true; do
29*0e209d39SAndroid Build Coastguard Worker  case "$1" in
30*0e209d39SAndroid Build Coastguard Worker    --do-not-make ) DO_NOT_MAKE=1; shift ;;
31*0e209d39SAndroid Build Coastguard Worker    -- ) shift; break ;;
32*0e209d39SAndroid Build Coastguard Worker    * ) break ;;
33*0e209d39SAndroid Build Coastguard Worker  esac
34*0e209d39SAndroid Build Coastguard Workerdone
35*0e209d39SAndroid Build Coastguard Worker
36*0e209d39SAndroid Build Coastguard Worker# Build the srcgen tools.
37*0e209d39SAndroid Build Coastguard Workercd ${ANDROID_BUILD_TOP}
38*0e209d39SAndroid Build Coastguard Workerif [ -z "$DO_NOT_MAKE" ]; then
39*0e209d39SAndroid Build Coastguard Worker    make -j16 android_icu4j_srcgen_binary
40*0e209d39SAndroid Build Coastguard Workerfi
41*0e209d39SAndroid Build Coastguard Worker
42*0e209d39SAndroid Build Coastguard WorkerICU_SRCGEN_DIR=${ANDROID_BUILD_TOP}/external/icu/tools/srcgen
43*0e209d39SAndroid Build Coastguard WorkerICU4J_DIR=${ANDROID_BUILD_TOP}/external/icu/icu4j
44*0e209d39SAndroid Build Coastguard WorkerANDROID_ICU4J_DIR=${ANDROID_BUILD_TOP}/external/icu/android_icu4j
45*0e209d39SAndroid Build Coastguard Worker
46*0e209d39SAndroid Build Coastguard WorkerCLASSPATH=${ANDROID_HOST_OUT}/framework/currysrc.jar:${ANDROID_HOST_OUT}/framework/android_icu4j_srcgen.jar
47*0e209d39SAndroid Build Coastguard Worker
48*0e209d39SAndroid Build Coastguard Worker# The parts of ICU4J to include during srcgen.
49*0e209d39SAndroid Build Coastguard Worker#
50*0e209d39SAndroid Build Coastguard Worker# The following are deliberately excluded:
51*0e209d39SAndroid Build Coastguard Worker#   localespi - is not supported on Android
52*0e209d39SAndroid Build Coastguard Worker#   charset - because icu4c is used instead
53*0e209d39SAndroid Build Coastguard WorkerINPUT_DIRS="\
54*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/collate/src/main \
55*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/core/src/main \
56*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/currdata/src/main \
57*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/langdata/src/main \
58*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/regiondata/src/main \
59*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/translit/src/main \
60*0e209d39SAndroid Build Coastguard Worker    "
61*0e209d39SAndroid Build Coastguard Worker
62*0e209d39SAndroid Build Coastguard WorkerINPUT_JAVA_DIRS=""
63*0e209d39SAndroid Build Coastguard WorkerINPUT_RESOURCE_DIRS=""
64*0e209d39SAndroid Build Coastguard Workerfor INPUT_DIR in ${INPUT_DIRS}; do
65*0e209d39SAndroid Build Coastguard Worker  if [ -d "${INPUT_DIR}/java" ]; then
66*0e209d39SAndroid Build Coastguard Worker    INPUT_JAVA_DIRS="${INPUT_JAVA_DIRS} ${INPUT_DIR}/java"
67*0e209d39SAndroid Build Coastguard Worker  fi
68*0e209d39SAndroid Build Coastguard Worker  if [ -d "${INPUT_DIR}/resources" ]; then
69*0e209d39SAndroid Build Coastguard Worker    INPUT_RESOURCE_DIRS="${INPUT_RESOURCE_DIRS} ${INPUT_DIR}/resources"
70*0e209d39SAndroid Build Coastguard Worker  fi
71*0e209d39SAndroid Build Coastguard Workerdone
72*0e209d39SAndroid Build Coastguard Worker
73*0e209d39SAndroid Build Coastguard WorkerSAMPLE_INPUT_DIR=${ICU4J_DIR}/samples/src/main/java/com/ibm/icu/samples
74*0e209d39SAndroid Build Coastguard Worker# Only generate sample files for code we know should compile on Android with the public APIs.
75*0e209d39SAndroid Build Coastguard WorkerSAMPLE_INPUT_FILES="\
76*0e209d39SAndroid Build Coastguard Worker    ${SAMPLE_INPUT_DIR}/text/dateintervalformat/DateIntervalFormatSample.java \
77*0e209d39SAndroid Build Coastguard Worker    ${SAMPLE_INPUT_DIR}/text/datetimepatterngenerator/DateTimePatternGeneratorSample.java \
78*0e209d39SAndroid Build Coastguard Worker    ${SAMPLE_INPUT_DIR}/text/pluralformat/PluralFormatSample.java \
79*0e209d39SAndroid Build Coastguard Worker    "
80*0e209d39SAndroid Build Coastguard Worker
81*0e209d39SAndroid Build Coastguard Worker# See above for an explanation as to why the tests for charset and localespi are not included here.
82*0e209d39SAndroid Build Coastguard WorkerTEST_INPUT_DIR=${ICU4J_DIR}/main/tests
83*0e209d39SAndroid Build Coastguard WorkerTEST_INPUT_DIRS="\
84*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/collate/src/test \
85*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/framework/src/test \
86*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/core/src/test \
87*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/common_tests/src/test \
88*0e209d39SAndroid Build Coastguard Worker    ${ICU4J_DIR}/main/translit/src/test \
89*0e209d39SAndroid Build Coastguard Worker    "
90*0e209d39SAndroid Build Coastguard Worker
91*0e209d39SAndroid Build Coastguard WorkerTEST_INPUT_JAVA_DIRS=""
92*0e209d39SAndroid Build Coastguard WorkerTEST_INPUT_RESOURCE_DIRS=""
93*0e209d39SAndroid Build Coastguard Workerfor TEST_INPUT_DIR in ${TEST_INPUT_DIRS}; do
94*0e209d39SAndroid Build Coastguard Worker  if [ -d "${TEST_INPUT_DIR}/java" ]; then
95*0e209d39SAndroid Build Coastguard Worker    TEST_INPUT_JAVA_DIRS="${TEST_INPUT_JAVA_DIRS} ${TEST_INPUT_DIR}/java"
96*0e209d39SAndroid Build Coastguard Worker  fi
97*0e209d39SAndroid Build Coastguard Worker  if [ -d "${TEST_INPUT_DIR}/resources" ]; then
98*0e209d39SAndroid Build Coastguard Worker    TEST_INPUT_RESOURCE_DIRS="${TEST_INPUT_RESOURCE_DIRS} ${TEST_INPUT_DIR}/resources"
99*0e209d39SAndroid Build Coastguard Worker  fi
100*0e209d39SAndroid Build Coastguard Workerdone
101*0e209d39SAndroid Build Coastguard Worker
102*0e209d39SAndroid Build Coastguard Worker# Allow override of the java runtime to avoid http://b/27775477
103*0e209d39SAndroid Build Coastguard WorkerSRCGEN_JAVA_BINARY=${SRCGEN_JAVA_BINARY:-java}
104