• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Exhaust(ive, ing)  (Mean, Multi)  (Test, Trouble)
3#
4# Copyright (C) 2017 and later: Unicode, Inc. and others.
5# License & terms of use: http://www.unicode.org/copyright.html
6#
7# Copyright (c) 2002-2014 IBM All Rights Reserved
8
9# Builds ICU a whole lotta times and with different options
10# Set the options below and execute this script with the shell.
11
12# This script is checked into tools/trunk/release/c. It assumes that the
13# icu directory is at the same level as the tools  directory. If this
14# is not the case, use the uconfigtest.local file to set the
15# SRC_DIR variable to point at the ICU source directory.
16# Or, alternatively, you can make a symlink tools/icu -> your_icu_dir
17# You can also use the uconfigtest.local file to override the BUILD_DIR
18# and ICUPLATFORM variables.
19
20# It can be handy to run 'tail -F uconfigtest/stats' in another window to see where things are.
21
22
23#------------------- Find full path names  -----------------------
24JOPT=-j2
25
26# check for uconfigtest.local
27if [ -f ./uconfigtest.local ]
28then
29    . ./uconfigtest.local
30fi
31
32# location of this script
33S=$(pwd)
34
35# Build root - tools/release/c/uconfigtest
36BUILD_DIR=${BUILD_DIR:-${S}/uconfigtest}
37
38if [ ! -d ${BUILD_DIR} ];
39then
40    mkdir -p ${BUILD_DIR} || exit 1
41fi
42
43FAILS=${BUILD_DIR}/fails
44STATS=${BUILD_DIR}/stats
45
46>${FAILS}
47>${STATS}
48echo >> ${STATS}
49echo >> ${STATS}
50
51# the runConfigureICU platform name
52ICUPLATFORM=${ICUPLATFORM:-Linux}
53
54# Global Config options to use
55#export COPTS=" --with-data-packaging=archive"
56export COPTS=
57
58# Global testing options to use
59export INTLTESTOPTS=-w
60export CINTLTEST_OPTS=-w
61
62
63# --- Probably will not need to modify the following variables ---
64
65# ICU directory is $S/../../../icu
66ICU=$(dirname $(dirname $(dirname ${S})))/icu
67
68# Source directory
69SRC_DIR=${SRC_DIR:-${ICU}/source}
70
71# ------------ End of config variables
72UCONFIG_H=$SRC_DIR/common/unicode/uconfig.h
73UCONFIG_LOCAL_H=uconfig_local.h
74UCONFIG_USE_LOCAL=UCONFIG_USE_LOCAL
75# Prepare uconfig.h
76if grep -q ${UCONFIG_LOCAL_H}  $UCONFIG_H ;
77then
78    echo "# $UCONFIG_H already contains our patch, no change"
79else
80    mv $UCONFIG_H ${UCONFIG_H}.orig
81    cat > $UCONFIG_H  <<EOF
82#if defined(${UCONFIG_USE_LOCAL})
83#include ${UCONFIG_LOCAL_H}"
84#endif
85/* for uconfigtest.sh - you may REMOVE above this line */
86/* ----------------------------------------------------------- */
87EOF
88cat ${UCONFIG_H}.orig >> ${UCONFIG_H}
89    echo "# $UCONFIG_H updated"
90fi
91
92
93# Start,  set a default name to start with in case something goes wrong
94
95export NAME=foo
96mkdir -p ${BUILD_DIR} ${BUILD_DIR}/times 2>/dev/null
97
98# Banner function - print a separator to split the output
99ban()
100{
101    echo
102    echo
103    echo "#- -----------------------$NAME------------- -#"
104    echo
105    echo "CPPFLAGS = $CPPFLAGS"
106    echo "UCONFIGS = $UCONFIGS"
107    echo
108    echo " build to ${BUILD_DIR}/${NAME} and install in ${BUILD_DIR}/I${NAME} "
109    echo
110
111    echo "${NAME} ---------------------------------------" >> ${STATS}
112}
113
114# Clean up the old tree before building again
115clean()
116{
117    stats clean
118    echo cleaning ${BUILD_DIR}/${NAME} and ${BUILD_DIR}/I${NAME}
119    rm -rf ${BUILD_DIR}/I${NAME} ${BUILD_DIR}/${NAME}
120    mkdir -p ${BUILD_DIR}/${NAME}
121}
122
123# Run configure with the appropriate options (out of source build)
124config()
125{
126    stats config
127    mkdir -p ${BUILD_DIR}/${NAME} 2>/dev/null
128    cd ${BUILD_DIR}/${NAME}
129    mkdir emtinc 2>/dev/null
130
131    # myconfig.h
132    cat > emtinc/${UCONFIG_LOCAL_H} <<EOF
133/* NAME=${NAME}            */
134/* UCONFIGS=${UCONFIGS}    */
135/* CPPFLAGS=${CPPFLAGS}    */
136#ifndef _MYCONFIG_H
137#define _MYCONFIG_H
138
139EOF
140    for what in `echo $UCONFIGS`;
141    do
142        echo "#define UCONFIG_${what} 1" >> emtinc/${UCONFIG_LOCAL_H}
143    done
144    cat >> emtinc/${UCONFIG_LOCAL_H} <<EOF
145#endif
146EOF
147    CPPFLAGS="${CPPFLAGS} -D${UCONFIG_USE_LOCAL} -I${BUILD_DIR}/${NAME}/emtinc"
148    echo "CPPFLAGS=\"$CPPFLAGS\" Configure ${ICUPLATFORM} ${CONFIG_OPTS} $COPTS --srcdir=$SRC_DIR"
149    $SRC_DIR/runConfigureICU ${ICUPLATFORM} $CONFIG_OPTS $COPTS --prefix=${BUILD_DIR}/I${NAME} --srcdir=$SRC_DIR 2>&1 > ${BUILD_DIR}/${NAME}/config.out
150    CONFIG_OPTS=
151}
152
153stats()
154{
155    STATUS="${NAME}: ${1} 	"`date`
156    echo ${STATUS} >> ${STATS}
157    echo "*** ${NAME} ********* ${1} ************* "
158}
159
160fail()
161{
162    FAILURE="error: ${BUILD_DIR}/${NAME}: ${1} "`date`
163    echo ${FAILURE} >> ${FAILS}
164    echo ${FAILURE} >> ${STATS}
165    echo "${FAILURE}"
166}
167
168TESTCPP=uconfig-simpleTest.cpp
169TESTCPPPATH=${S}/${TESTCPP}
170
171if [ ! -f ${TESTCPPPATH} ];
172then
173    echo error cannot load simple test ${TESTCPPPATH}
174    exit 1
175fi
176
177
178# Do an actual build
179bld()
180{
181##*##  Stream filter to put 'NAME: ' in front of
182##*##  every line:
183##*##      . . .   2>&1 | tee -a ./bld.log | sed -e "s/^/${NAME}: /"
184    cd ${BUILD_DIR}/${NAME}
185    stats "make -k ${JOPT} all ${1}"
186    /usr/bin/time -o ${BUILD_DIR}/times/${NAME}.all     make -k ${JOPT} all ${1}    DEPS=                  || fail make
187    stats install
188    /usr/bin/time -o ${BUILD_DIR}/times/${NAME}.install make -k install ${1}        DEPS=          INSTALL_DATA='ln -svf '  || fail install
189    /usr/bin/time -o ${BUILD_DIR}/times/${NAME}.il      make -k install-local ${1}  DEPS=          || fail install-local
190    stats tests
191    /usr/bin/time -o ${BUILD_DIR}/times/${NAME}.tst     make -k ${JOPT} tests ${1}  DEPS= || fail tests
192    if [ -f ${BUILD_DIR}/${NAME}/test/intltest/intltest ];
193    then
194        stats check
195        # use parallel check (pcheck)
196        /usr/bin/time -o ${BUILD_DIR}/times/${NAME}.chk     make -k ${JOPT} pcheck ${1} INTLTEST_OPTS=-w CINTLTST_OPTS=-w DEPS= || fail check
197    else
198        stats check0
199    fi
200    stats hdrtst
201    PATH=${BUILD_DIR}/I${NAME}/bin:$PATH make -k -C ${BUILD_DIR}/${NAME}/test/hdrtst/  DEPS= check    || fail hdrtst
202    stats irun
203    cp ${TESTCPPPATH} ${TESTCPP}
204    /usr/bin/time -o ${BUILD_DIR}/times/${NAME}.irun ${S}/../../scripts/icurun -i ${BUILD_DIR}/I${NAME} ${TESTCPP} || fail irun
205}
206
207
208# Do a complete cycle for a run
209# arg: opts to build
210doit()
211{
212ban ; clean ; config ; bld ${1}
213}
214
215# Set up the variables for convenience
216NO_COL="NO_COLLATION"
217NO_BRK="NO_BREAK_ITERATION"
218NO_FMT="NO_FORMATTING"
219NO_UCM="NO_LEGACY_CONVERSION"
220NO_CNV="NO_CONVERSION"
221NO_FIO="NO_FILE_IO"
222NO_XLT="NO_TRANSLITERATION"
223NO_RGX="NO_REGULAR_EXPRESSIONS"
224JS_COL="ONLY_COLLATION"
225NO_NRM="NO_NORMALIZATION"
226NO_IDN="NO_IDNA"
227NO_SVC="NO_SERVICE"
228NO_MST="$NO_COL $NO_BRK $NO_FMT $NO_UCM $NO_FIO $NO_RGX $NO_XLT $NO_NRM $NO_IDN $NO_SVC"
229NO_ALL="$NO_MST $NO_SVC"
230
231# Now, come the actual test runs
232# Each one sets a NAME, and CPPFLAGS or other flags, and calls doit
233
234do_DEFAULT()
235{
236######################
237# DEFAULT
238export NAME=DEFAULT
239export UCONFIGS=""
240export CPPFLAGS=""
241doit
242
243}
244# these are now valid:
245USE_PREBUILT_DATA="ICUDATA_SOURCE_ARCHIVE=`echo ${BUILD_DIR}/DEFAULT/data/out/tmp/*.dat`"
246# use cross build
247CROSS_BUILD="--with-cross-build=${BUILD_DIR}/DEFAULT --disable-tools --disable-extras --disable-samples"
248######################
249
250do_NO_MST()
251{
252######################
253# NO_MST
254export NAME=NO_MST
255export UCONFIGS="$NO_MST"
256export CPPFLAGS=""
257doit ${USE_PREBUILT_DATA}
258######################
259}
260
261do_NO_RGX()
262{
263######################
264# NO_RGX
265export NAME=NO_RGX
266export UCONFIGS="$NO_RGX"
267export CPPFLAGS=""
268doit
269######################
270}
271
272do_NO_COL()
273{
274######################
275# NO_COL
276export NAME=NO_COL
277export UCONFIGS="$NO_COL"
278export CPPFLAGS=""
279doit
280######################
281}
282
283do_NO_BRK()
284{
285######################
286# NO_BRK
287export NAME=NO_BRK
288export UCONFIGS="$NO_BRK"
289export CPPFLAGS=""
290doit
291######################
292}
293
294do_NO_FMT()
295{
296######################
297# NO_FMT
298export NAME=NO_FMT
299export UCONFIGS="$NO_FMT"
300export CPPFLAGS=""
301doit
302######################
303}
304
305do_NO_UCM()
306{
307######################
308# NO_UCM
309export NAME=NO_UCM
310export UCONFIGS="$NO_UCM"
311export CPPFLAGS=""
312doit
313######################
314}
315
316do_NO_FIO()
317{
318######################
319# NO_FIO
320export NAME=NO_FIO
321export UCONFIGS="$NO_FIO"
322export CPPFLAGS=""
323doit ${USE_PREBUILT_DATA}
324######################
325}
326do_NO_CNV()
327{
328######################
329# NO_FIO
330export NAME=NO_CNV
331export UCONFIGS="$NO_CNV"
332export CPPFLAGS=""
333CONFIG_OPTS="${CROSS_BUILD} --disable-tests"
334doit ${USE_PREBUILT_DATA}
335######################
336}
337
338do_NO_XLT()
339{
340######################
341# NO_XLT
342export NAME=NO_XLT
343export UCONFIGS="$NO_XLT"
344export CPPFLAGS=""
345doit
346######################
347}
348
349do_NO_IDN()
350{
351######################
352# NO_IDN
353export NAME=NO_IDN
354export UCONFIGS="$NO_IDN"
355export CPPFLAGS=""
356doit
357######################
358}
359
360do_NO_NRM()
361{
362######################
363# NO_NRM
364export NAME=NO_NRM
365export UCONFIGS="$NO_NRM"
366export CPPFLAGS=""
367doit
368######################
369}
370
371do_NO_SVC()
372{
373######################
374# NO_SVC
375export NAME=NO_SVC
376export UCONFIGS="$NO_SVC"
377export CPPFLAGS=""
378doit
379######################
380}
381
382do_JS_COL()
383{
384######################
385# JS_COL
386export NAME=JS_COL
387export UCONFIGS="$JS_COL"
388export CPPFLAGS=""
389doit
390######################
391}
392
393do_NO_ALL()
394{
395######################
396# NO_ALL
397export NAME=NO_ALL
398export UCONFIGS="$NO_ALL"
399export CPPFLAGS=""
400doit ${USE_PREBUILT_DATA}
401######################
402}
403
404# now run them
405
406# Always needed - as the host
407do_DEFAULT
408do_NO_MST
409do_NO_RGX
410do_NO_COL
411do_NO_BRK
412do_NO_FMT
413do_NO_UCM
414do_NO_FIO
415do_NO_XLT
416do_NO_CNV
417do_NO_IDN
418do_NO_NRM
419do_NO_SVC
420do_JS_COL
421do_NO_ALL
422
423NAME=done
424ban
425echo "All builds finished! Times are in ${BUILD_DIR}/times"
426echo "There were errors if the following grep finds anything."
427echo "grep status ${BUILD_DIR}/times/*"
428grep status ${BUILD_DIR}/times/*
429
430if [ -s ${FAILS} ];
431then
432    echo "Failures: "
433    cat ${FAILS}
434fi
435
436