From 8350ca45c4c86b6da4fb1a4df7fb38fed8429682 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 12 Jul 2007 23:57:26 +0000 Subject: [PATCH] ICU-4567 test data generation for J X-SVN-Rev: 21957 --- icu4c/source/tools/genrb/Makefile.in | 3 + icu4c/source/tools/gentest/Makefile.in | 4 +- icu4c/source/tools/gentest/gentest.c | 116 ++++++++++++++++++++++++- 3 files changed, 119 insertions(+), 4 deletions(-) diff --git a/icu4c/source/tools/genrb/Makefile.in b/icu4c/source/tools/genrb/Makefile.in index 07859680605..53ba978fdec 100644 --- a/icu4c/source/tools/genrb/Makefile.in +++ b/icu4c/source/tools/genrb/Makefile.in @@ -41,6 +41,9 @@ DERB_OBJ = derb.o DEPS = $(OBJECTS:.o=.d) DERB_DEPS = $(DERB_OBJ:.o=.d) +-include Makefile.local + + ## List of phony targets .PHONY : all all-local install install-local clean clean-local \ distclean distclean-local dist dist-local check check-local install-man diff --git a/icu4c/source/tools/gentest/Makefile.in b/icu4c/source/tools/gentest/Makefile.in index ac1630d358f..078ff869a1a 100644 --- a/icu4c/source/tools/gentest/Makefile.in +++ b/icu4c/source/tools/gentest/Makefile.in @@ -23,8 +23,8 @@ TARGET = gentest$(EXEEXT) ifneq ($(top_builddir),$(top_srcdir)) CPPFLAGS += -I$(top_builddir)/common endif -CPPFLAGS += -I$(top_srcdir)/common -I$(srcdir)/../toolutil -LIBS = $(LIBICUTOOLUTIL) $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M) +CPPFLAGS += -I$(top_srcdir)/common -I$(srcdir)/../toolutil -I$(top_srcdir)/tools/ctestfw +LIBS = $(LIBCTESTFW) $(LIBICUTOOLUTIL) $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M) OBJECTS = gentest.o genres32.o diff --git a/icu4c/source/tools/gentest/gentest.c b/icu4c/source/tools/gentest/gentest.c index b65bd0bf5e2..4902ba35c7c 100644 --- a/icu4c/source/tools/gentest/gentest.c +++ b/icu4c/source/tools/gentest/gentest.c @@ -22,6 +22,7 @@ #include "unicode/putil.h" #include "unicode/uclean.h" #include "unicode/udata.h" +#include "unicode/udbgutil.h" #include "unewdata.h" #include "cmemory.h" #include "cstring.h" @@ -48,11 +49,14 @@ static const UDataInfo dataInfo={ static void createData(const char*, UErrorCode *); +static int outputJavaStuff(const char * progname, const char *outputDir); + static UOption options[]={ /*0*/ UOPTION_HELP_H, /*1*/ UOPTION_HELP_QUESTION_MARK, /*2*/ UOPTION_DESTDIR, - /*3*/ UOPTION_DEF("genres", 'r', UOPT_NO_ARG) + /*3*/ UOPTION_DEF("genres", 'r', UOPT_NO_ARG), + /*4*/ UOPTION_DEF("javastuff", 'j', UOPT_NO_ARG), }; extern int @@ -77,11 +81,14 @@ main(int argc, char* argv[]) { "\t\t-h or -? or --help this usage text\n" "\t\t-d or --destdir destination directory, followed by the path\n" "\t\t-r or --genres generate resource file testtable32.txt instead of UData test \n", + "\t\t-j or --javastuff generate Java source for DebugUtilities. \n", argv[0]); return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; } - if ( options[3].doesOccur ) { + if( options[4].doesOccur ) { + return outputJavaStuff( argv[0], options[2].value ); + } else if ( options[3].doesOccur ) { return genres32( argv[0], options[2].value ); } else { /* printf("Generating the test memory mapped file\n"); */ @@ -127,3 +134,108 @@ createData(const char* outputDirectory, UErrorCode *errorCode) { exit(U_INTERNAL_PROGRAM_ERROR); } } + +/* Create Java file ----------------------------------------------------- */ + +static int +outputJavaStuff(const char* progname, const char *outputDir) { + int32_t i,t,count; + char file[512]; + FILE *out; + + uprv_strcpy(file,outputDir); + if(*outputDir && /* don't put a trailing slash if outputDir is empty */ + file[strlen(file)-1]!=U_FILE_SEP_CHAR) { + uprv_strcat(file,U_FILE_SEP_STRING); + } + uprv_strcat(file,"DebugUtilitiesData.java"); + out = fopen(file, "w"); + /*puts(file);*/ + printf("%s: Generating %s\n", progname, file); + if(out == NULL) { + fprintf(stderr, "%s: Couldn't create resource test file %s\n", + progname, file); + return 1; + } + + fprintf(out, "/** Copyright (C) 2007, International Business Machines Corporation and Others. All Rights Reserved. **/\n\n"); + fprintf(out, "package com.ibm.icu.dev.test.util;\n\n"); + fprintf(out, "public class DebugUtilitiesData extends Object {\n"); + fprintf(out, " public static final String [] TYPES = { \n"); + for(t=0;t