2 # ********************************************************************
4 # * Copyright (c) 2002-2006, International Business Machines Corporation and
5 # * others. All Rights Reserved.
6 # ********************************************************************
8 # Script to generate the icudata.jar and testdata.jar files. This file is
9 # part of icu4j. It is checked into CVS. It is generated from
10 # locale data in the icu4c project. See usage() notes (below)
11 # for more information.
13 # This script requires perl. For Win32, I recommend www.activestate.com.
16 # copied heavily from genrbjar.pl
30 #------------------------------------------------------------------
34 "--icu-root=s" => \
$icuRootDir,
35 "--jar=s" => \
$jarDir,
36 "--icu4j-root=s" => \
$icu4jDir,
37 "--version=s" => \
$version,
38 "--verbose" => \
$verbose,
41 $cwd = abs_path
(getcwd
);
46 unless (defined $icuRootDir){
47 $icuRootDir =abs_path
($cwd."/../../..");
49 unless (defined $icu4jDir){
50 $icu4jDir =abs_path
($icuRootDir."/../icu4j");
52 unless (defined $jarDir){
53 if(defined $ENV{'JAVA_HOME'}){
54 $jarDir=$ENV{'JAVA_HOME'}."/bin";
56 print("ERROR: JAVA_HOME enviroment variable undefined and --jar argument not specifed.\n");
61 $platform = getPlatform
();
62 $icuBinDir = $icuRootDir;
66 if(($platform eq "cygwin") || ($platform eq "linux")){
67 $icuBinDir .= "/source/bin";
68 $icuLibDir = abs_path
($icuBinDir."/../lib");
69 $path .=":$icuBinDir:$icuLibDir";
71 $libpath = $ENV{'LD_LIBRARY_PATH'}.":$icuLibDir";
72 $ENV{'LD_LIBRARY_PATH'} = $libpath;
74 #print ("##### LD_LIBRARY_PATH = $ENV{'LD_LIBRARY_PATH'}\n");
76 }elsif($platform eq "aix"){
78 $icuBinDir .= "/source/bin";
79 $icuLibDir = abs_path
($icuBinDir."/../lib");
80 $path .=":$icuBinDir:$icuLibDir";
82 $libpath = $ENV{'LIBPATH'}.":$icuLibDir";
83 $ENV{'LIBPATH'} = $libpath;
84 #print ("##### LIBPATH = $ENV{'LIBPATH'}\n");
85 }elsif($platform eq "darwin"){
86 $icuBinDir .= "/source/bin";
87 $icuLibDir = abs_path
($icuBinDir."/../lib");
88 $path .=":$icuBinDir:$icuLibDir";
90 $libpath = $ENV{'DYLD_LIBRARY_PATH'}.":$icuLibDir";
91 $ENV{'DYLD_LIBRARY_PATH'} = $libpath;
93 }elsif($platform eq "MSWin32"){
94 $icuBinDir =$icuRootDir."/bin";
99 #print ("##### PATH = $ENV{'PATH'}\n");
100 # TODO add more platforms and test on Linux and Unix
102 $icuBuildDir =$icuRootDir."/source/data/out/build";
103 $icuTestDataDir =$icuRootDir."/source/test/testdata/out/build/";
106 buildICU
($platform, $icuRootDir, $icuTestDataDir, $verbose);
108 #figure out the version and endianess
109 unless (defined $version){
110 ($version, $endian) = getVersion
();
111 #print "#################### $version, $endian ######\n";
114 $icuswap = $icuBinDir."/icuswap -tb";
115 $tempDir = $cwd."/temp";
117 $icu4jImpl = "com/ibm/icu/impl/data/";
118 $icu4jDataDir = $icu4jImpl."/icudt".$version."b";
119 $icu4jDevDataDir = "com/ibm/icu/dev/data/";
120 $icu4jTestDataDir = "$icu4jDevDataDir/testdata";
122 $icuDataDir =$icuBuildDir."/icudt".$version.checkPlatformEndianess
();
124 convertData
($icuDataDir, $icuswap, $tempDir, $icu4jDataDir, $verbose);
125 #convertData($icuDataDir."/coll/", $icuswap, $tempDir, $icu4jDataDir."/coll");
126 createJar
("$jarDir/jar", "icudata.jar", $tempDir, $icu4jDataDir, $verbose);
128 convertTestData
($icuTestDataDir, $icuswap, $tempDir, $icu4jTestDataDir, $verbose);
129 createJar
("$jarDir/jar", "testdata.jar", $tempDir, $icu4jTestDataDir, $verbose);
130 copyData
($icu4jDir, $icu4jImpl, $icu4jDevDataDir, $tempDir, $verbose);
133 #-----------------------------------------------------------------------
135 local($platform, $icuRootDir, $icuTestDataDir, $verbose) = @_;
136 $icuSrcDir = $icuRootDir."/source";
137 $icuSrcDataDir = $icuSrcDir."/data";
140 # clean the data directories
141 unlink($icuBuildDir."../");
142 unlink($icuTestDataDir."../");
144 if(($platform eq "cygwin")||($platform eq "darwin")||($platform eq "linux")){
146 cmd
("make all", $verbose);
147 chdir($icuSrcDataDir);
148 cmd
("make uni-core-data", $verbose);
149 chdir($icuTestDataDir."../../");
150 #print($icuTestDataDir."../../\n");
151 cmd
("make", $verbose);
152 }elsif($platform eq "aix"){
154 cmd
("gmake all", $verbose);
155 chdir($icuSrcDataDir);
156 cmd
("gmake uni-core-data", $verbose);
157 chdir($icuTestDataDir."../../");
158 cmd
("gmake", $verbose);
159 }elsif($platform eq "MSWin32"){
160 #devenv.com $projectFileName \/build $configurationName > \"$cLogFile\" 2>&1
161 cmd
("devenv.com allinone/allinone.sln /useenv /build Debug", $verbose);
162 # build required data. this is required coz building icu will not build all the data
163 chdir($icuSrcDataDir);
164 cmd
("NMAKE /f makedata.mak ICUMAKE=\"$icuSrcDataDir\" CFG=debug uni-core-data", $verbose);
167 print "ERROR: Could not build ICU unknown platform $platform. \n";
173 #-----------------------------------------------------------------------
176 opendir(DIR
,$icuBuildDir);
178 @list = readdir(DIR
);
182 print("ERROR: More than 1 directory in build. Can't decide the version");
185 foreach $item (@list){
186 next if($item eq "." || $item eq "..");
187 my ($ver, $end) =$item =~ m/icudt(.*)(l|b|e)$/;
192 #-----------------------------------------------------------------------
197 #-----------------------------------------------------------------------
199 local($jar, $jarFile, $tempDir, $dirToJar, $verbose) = @_;
202 print "INFO: Creating $jarFile\n";
203 if(defined $verbose){
204 $command = "$jar cvf $jarFile -C $tempDir $dirToJar";
206 $command = "$jar cf $jarFile -C $tempDir $dirToJar";
209 cmd
($command, $verbose);
211 #-----------------------------------------------------------------------
212 sub checkPlatformEndianess
{
213 my $is_big_endian = unpack("h*", pack("s", 1)) =~ /01/;
214 if ($is_big_endian) {
220 #-----------------------------------------------------------------------
222 local($icu4jDir, $icu4jImpl, $icu4jDevDataDir, $tempDir) =@_;
223 print("INFO: Copying $tempDir/icudata.jar to $icu4jDir/src/$icu4jImpl\n");
224 copy
("$tempDir/icudata.jar", "$icu4jDir/src/$icu4jImpl");
225 print("INFO: Copying $tempDir/testdata.jar $icu4jDir/src/$icu4jDevDataDir\n");
226 copy
("$tempDir/testdata.jar","$icu4jDir/src/$icu4jDevDataDir");
228 #-----------------------------------------------------------------------
230 local($icuDataDir, $icuswap, $tempDir, $icu4jDataDir) =@_;
231 my $dir = $tempDir."/".$icu4jDataDir;
232 # create the temp directory
234 # cd to the temp directory
236 my $endian = checkPlatformEndianess
();
238 opendir(DIR
,$icuDataDir);
240 @list = readdir(DIR
);
243 #print "####### $endian ############\n";
245 print "INFO: {Command: $op $icuDataDir/*.*}\n";
247 print "INFO: {Command: copy($icuDataDir/*.*, $tempDir/$icu4jDataDir/*)}\n";
252 foreach $item (@list){
253 next if($item eq "." || $item eq "..");
254 # next if($item =~ /^t_.*$\.res/ ||$item =~ /^translit_.*$\.res/ ||
255 # $item=~/$\.crs/ || $item=~ /$\.txt/ ||
256 # $item=~/icudata\.res/ || $item=~/$\.exp/ || $item=~/$\.lib/ ||
257 # $item=~/$\.obj/ || $item=~/$\.lst/);
258 next if($item =~ /^t_.*$\.res/ ||$item =~ /^translit_.*$\.res/ || $item =~ /$\.cnv/ ||
259 $item=~/$\.crs/ || $item=~ /$\.txt/ ||
260 $item=~/icudata\.res/ || $item=~/$\.exp/ || $item=~/$\.lib/ || $item=~/$\.obj/ ||
261 $item=~/cnvalias\.icu/ || $item=~/$\.lst/);
262 if(-d
"$icuDataDir/$item"){
263 convertData
("$icuDataDir/$item/", $icuswap, $tempDir, "$icu4jDataDir/$item/");
267 $command = $icuswap." $icuDataDir/$item $tempDir/$icu4jDataDir/$item";
268 cmd
($command, $verbose);
270 $rc = copy
("$icuDataDir/$item", "$tempDir/$icu4jDataDir/$item");
272 #die "ERROR: Could not copy $icuDataDir/$item to $tempDir/$icu4jDataDir/$item, $!";
278 print "INFO: DONE\n";
280 #-----------------------------------------------------------------------
282 local($icuDataDir, $icuswap, $tempDir, $icu4jDataDir) =@_;
283 my $dir = $tempDir."/".$icu4jDataDir;
284 # create the temp directory
286 # cd to the temp directory
289 print "INFO: {Command: $op $icuDataDir/*.*}\n";
291 opendir(DIR
,$icuDataDir) or die "ERROR: Could not open the $icuDataDir directory for reading $!";
293 @list = readdir(DIR
);
295 my $endian = checkPlatformEndianess
();
298 foreach $item (@list){
299 next if($item eq "." || $item eq "..");
300 next if($item =~ /$\.cnv/ || item
=~/$\.crs/ || $item=~ /$\.txt/ ||
301 $item=~/$\.exp/ || $item=~/$\.lib/ || $item=~/$\.obj/ ||
302 $item=~/$\.mak/ || $item=~/test\.icu/ || $item=~/$\.lst/);
304 $file =~ s/testdata_//g;
306 $command = "$icuswap $icuDataDir/$item $tempDir/$icu4jDataDir/$file";
307 cmd
($command, $verbose);
309 #print("Copying $icuDataDir/$item $tempDir/$icu4jDataDir/$file\n");
310 copy
("$icuDataDir/$item", "$tempDir/$icu4jDataDir/$file");
316 print "INFO: DONE\n";
318 #------------------------------------------------------------------------------------------------
324 $prompt = "Command: $cmd.." unless ($prompt);
325 if(defined $verbose){
329 my $exit_value = $? >> 8;
330 #my $signal_num = $? & 127;
331 #my $dumped_core = $? & 128;
332 if ($exit_value == 0) {
333 if(defined $verbose){
338 print "ERROR: Execution of $prompt returned ($exit_value)\n";
342 #-----------------------------------------------------------------------
348 --icu-root
=<directory where icu4c lives
>
349 --jar
=<directory where jar
.exe lives
>
350 --icu4j-root
=<directory
>
351 --version
=<ICU4C version
>
355 gendtjar
.pl
--icu-root
=\\work
\\icu
--jar
=\\jdk1
.4
.1\\bin
--icu4j-root
=\\work
\\icu4j
--version
=3.0