2 eval 'exec perl -wS $0 ${1+"$@"}'
4 #*************************************************************************
6 # OpenOffice.org - a multi-platform office productivity suite
8 # $RCSfile: fast_merge.pl,v $
10 # $Revision: 1.1.2.2 $
12 # last change: $Author: ihi $ $Date: 2007/07/20 10:37:53 $
14 # The Contents of this file are made available subject to
15 # the terms of GNU Lesser General Public License Version 2.1.
18 # GNU Lesser General Public License Version 2.1
19 # =============================================
20 # Copyright 2005 by Sun Microsystems, Inc.
21 # 901 San Antonio Road, Palo Alto, CA 94303, USA
23 # This library is free software; you can redistribute it and/or
24 # modify it under the terms of the GNU Lesser General Public
25 # License version 2.1, as published by the Free Software Foundation.
27 # This library is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 # Lesser General Public License for more details.
32 # You should have received a copy of the GNU Lesser General Public
33 # License along with this library; if not, write to the Free Software
34 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 #*************************************************************************
52 my $last_localize_file;
59 if ( defined $ENV{USE_SHELL
} && $ENV{USE_SHELL
} eq '4nt' ) { $WIN = 'TRUE'; }
62 $SIG{INT
} = 'inthandler';
63 $SIG{QUIT
} = 'quithandler';
77 my $lock_file = $merge_dir."/lock.mk";
78 $lock_file =~ s/\//\\/g
, if ( $WIN ) ;
80 read_sdf_file_names
();
93 $reference = getNextIdentifier
( );
98 if( $_->module eq $reference->module && $_->dir eq $reference->dir )
105 if( $#current+1 ne 0 )
107 ( $path , $localize_file ) = make_paths
();
109 write_buffer
( $path , $localize_file );
114 ##########################################################################################
119 print "WARNING: Lock file '$lock_file' 'found, waiting ....\n";
121 sleep 10 , while( -e
$lock_file && $cnt++ < 180 );
126 print "Writing lock file '$lock_file'\n";
127 open FILE
, ">$lock_file" or die "Can't create lock file '$lock_file'";
128 print FILE
"L10N_LOCK=YES" ;
134 print "Deleting lock file '$lock_file'\n";
135 unlink $lock_file, if( -e
$lock_file );
140 release_lock
() , if( $state eq "locked" );
145 release_lock
() , if( $state eq "locked" );
151 foreach my $file ( @file_names )
153 my $obj = new sdf_obj
;
154 open my $FILEHANDLE , "<$file" or die "Can't open file '$file'";
155 $obj->FILEHANDLE ( $FILEHANDLE ) ;
156 getNextSdfObj
( $obj );
158 print "Open file '$file'\n";
162 # get the next module/file
163 sub getNextIdentifier
166 return $a->module.$a->dir cmp $b->module.$b->dir;
168 return shift @sorted;
171 # update the obj with the next line
175 my $line = readline ( $obj->FILEHANDLE );
176 if ( $line eq undef )
178 $obj->endoffile( "true" );
182 $line =~ /^(([^\t]*)\t([^\t]*).*)/o ;
183 if( defined $1 && defined $2 && defined $3 )
188 $obj->dir ( getDir
( $3 ) );
200 sub getNextSdfObjModule
203 while( !$obj->endoffile )
205 my $line = readline ( $obj->FILEHANDLE );
206 if ( $line eq undef )
208 $obj->endoffile( "true" );
212 $line =~ /^(([^\t]*)\t([^\t]*).*)/o ;
213 if( defined $1 && defined $2 && defined $3 )
218 $obj->dir ( getDir
( $3 ) );
227 return $obj , if( $obj->module eq $module_name )
236 my @tmp_path = split /\\/ , $path;
238 $path = join '\\' , @tmp_path;
248 push @tmpfiles , $_, if( !$_->endoffile );
256 my $localizeFile = $merge_dir."\\".$current[ 0 ]->module."\\".$current[ 0 ]->file;
257 my $path = getDir
( $localizeFile );
258 if ( !$WIN ) { $path =~ s/\\/\//g
; }
260 $localizeFile = $path."\\localize.sdf";
261 if ( !$WIN ) { $localizeFile =~ s/\\/\//g
; }
263 return ( $path , $localizeFile );
269 my( $path , $localize_file ) = make_paths
();
271 $last_localize_file = $localize_file;
273 write_buffer
( $path , $localize_file );
278 return , if ( $#current+1 eq 0 );
279 my( $path , $localize_file ) = make_paths
();
280 if( $path eq $last_path )
287 write_buffer
( $last_path , $last_localize_file );
290 $last_localize_file = $localize_file;
299 foreach my $elem ( @current )
302 $amodule=$elem->module;
304 $plainline=$elem->line;
305 push @buffer, $plainline;
306 getNextSdfObj
( $elem );
307 } while ( !$elem->endoffile && $amodule eq $elem->module && $afile eq $elem->file );
313 my $localize_file = shift;
314 my $cnt = $#buffer+1;
315 print "Write to $path $cnt lines\n";
316 open FILE
, ">>$localize_file" or die "Can't open file '$localize_file'\n";
325 my $success = GetOptions
( 'sdf_files=s' => \
$sdf_filename , 'merge_dir=s' => \
$merge_dir ); #, 'module=s' => \$module_name );
326 if( ! ( $sdf_filename && $merge_dir && $success ) )
335 print "Usage: fast_merge -sdf_files <file containing sdf file names> -merge_dir <directory>\n" ;
338 sub read_sdf_file_names
340 open FILE
, "<$sdf_filename" or die "Can't open file '$sdf_filename'\n";
343 push @file_names , split " " , $_ ;