: eval 'exec perl -wS $0 ${1+"$@"}' if 0; #************************************************************************* # # OpenOffice.org - a multi-platform office productivity suite # # $RCSfile: checksize.pl,v $ # # $Revision: 1.3 $ # # last change: $Author: rt $ $Date: 2006/04/21 10:48:45 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. # # # GNU Lesser General Public License Version 2.1 # ============================================= # Copyright 2005 by Sun Microsystems, Inc. # 901 San Antonio Road, Palo Alto, CA 94303, USA # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License version 2.1, as published by the Free Software Foundation. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # #************************************************************************* # use XML::Parser; # ------------------------------------------------------------------------ # Other global stuff $is_debug=0; my $path = $ENV{'INPATH'} . "/"; my $quot = '"'; my %template_hash=(); my %vcproj_hash=(); # ------------------------------------------------------------------------ # Global stuff for parsing the *.vcproj files (XML::Parser) # my $ConfigurationGlobal = 1; # Release = 1, Debug=0 my $Configuration = undef; my %configelements = (); my %files = (); my %files2copy = (); my %files_special = (); my $Release = 1; # Release = 1, Debug = 0, undef = 2 my $file_tmp = ""; # temporary storage for file name my $CustomSection = 0; # ------------------------------------------------------------------------ # ------------------------------------------------------------------------ # e.g. %object_hash with Key = blabla.cpp # contains a Hash: # Header: "..\\common\\unicode\\utypes.h ..\\common\\unicode\\uset.h" # CFlags: Common (set in templates file) or special sequence # CDefs: Common (set in templates file) or special sequence # ------------------------------------------------------------------------ my $configfile = shift; my $sourcePath = shift; if ( !$configfile ) { $configfile = "createmak.cfg"; } if ( !$sourcePath ) { $inpath = $ENV{"INPATH"}; $sourcePath = $inpath . "\\misc\\build\\icu\\source"; } $dir = ""; $header = ""; $sep = "\\\\"; %project_by_id =(); %project_by_name = (); %project_dependencies = (); my @builddeps = prepare_allinone_all_mak(\%project_by_id,\%project_by_name,\%project_dependencies,$sourcePath); fillTemplateHash($configfile); create_allinone_all_mak(\@builddeps,\%project_by_id,$sourcePath); my @dirs = (); foreach $projectname(keys %project_by_name) { my $dir = $project_by_name{$projectname}[1]; $dir =~ /\.\.\\(.+)\\(.+)\.vcproj/; my $dir1 = $1; my $dir2 = $2; if ( $dir1 !~ /$dir2$/ ) { $dir1 .= "\.$dir2"; } print "$dir1 - $dir2\n" if ($is_debug); push @dirs, $dir1; } # set nonpro switch (linking against debug runtime if nonpro=1) my $nonpro = ($ENV{"PROEXT"} ne ".pro"); print "Non Product Build" if ($nonpro); foreach $dir(@dirs) { next if ($dir eq "data.makedata"); # very special don't overwrite this file # ------------------------------------------------------------------------ # Reset global stuff for parsing the *.vcproj files (XML::Parser) # $Configuration = $ConfigurationGlobal; # Release = 1, Debug=0 %configelements = (); %files = (); # contains all relevant *.c,*.cpp,*.h,*.rc files %files2copy = (); %files_special = (); $Release = 2; # Release = 1, Debug = 0, undef = 2 $file_tmp = ""; # temporary storage for file name $CustomSection = 0; # ------------------------------------------------------------------------ my $extra_mak = ""; ($dir, $extra_mak) = handle_extra_mak_files($dir); # handle e.g. tools/genrb.derb entires my @mak=(); # Array for make file *.mak my %deps=(); my %object_hash=(); my %collected_header=(); my %collect_header_target_hash=(); my %collect_object_target_hash=(); my $vcproj_file = ""; my $resource_file = ""; # $dir : common,i18n,... chomp $dir; next if ( $dir eq "" ); my $fullpath = $sourcePath . "\\" . $dir; if ( $extra_mak eq "" ) { if ($dir =~ /(.+)+\\(.+)$/) { $vcproj_file = $fullpath ."\\$2.vcproj"; } else { $vcproj_file = $fullpath ."\\$dir.vcproj"; } } else { $vcproj_file = $fullpath . "\\" . $extra_mak . ".vcproj"; } # Parse the *.vcproj file my $parser = new XML::Parser(ErrorContext => 2); $parser->setHandlers(Start => \&start_handler, Char => \&char_handler); $parser->parsefile($vcproj_file); if ( $file_tmp ) { # save a file which hasn't been saved yet $files{ $file_tmp } = 1; # save it now $file_tmp = ""; # has been saved now reset it } # is there a resource file? foreach $i (keys %files) { if ($i =~ /\.rc/) { $resource_file = $i; } } # Fill hash %deps for dependencies for all files in directory ($testdir) # %files contains all relevant files from *.vcproj getAllFilesDeps($fullpath,\%deps,\%files); my $includedir = $configelements{"Release"}{"OutputDirectory"}; # e.g. OutputDirectory = ..\..\lib $includedir =~ s/lib/include/; foreach $file( sort keys %deps) { $file =~ /(.+)\.(.+)/; my $name = $1; my $ext = $2; next if (!defined $name); $object = "\$(INTDIR)\\" . "$name.obj"; $collect_object_target_hash{$object}=1; createMakDepSection($dir,$name,$ext,$deps{$file},\@mak,\%files_special); } my %all_target_hash=(); foreach $header(sort keys %files2copy) { my $dir; my $file; #$pathdepth = "..\\.."; $file = $header; $header =~ s/^\.\\//; $inputpath = $file; $target = $includedir . "\\" . $header; $target =~ /.+\\(.+)\\.+$/; $targetpath = $configelements{"Release"}{"CommandLine"}; chomp $targetpath; # set %all_target_hash and @mak createCopySection($file,$inputpath,$target,$targetpath,\@mak,\%all_target_hash); $collect_header_target_hash{$target}=1; } my $test = $configelements{"Release"}{"OutputFile"}; $all_target_hash{$test}=1; # set name of the *.mak file my $mak_file=""; if ( $extra_mak eq "" ) { $mak_file = $vcproj_file; $mak_file =~ s/vcproj/mak/; } else { # extra_mak eg. derb, stringperf $mak_file = $fullpath . "\\$extra_mak" . "\.mak"; } # generate the content of the *.mak file # in @mak array print "extra_mak=$extra_mak\n" if ($is_debug); print "mak_file=$mak_file\n" if ($is_debug); open(MAKFILE, ">$mak_file") || die "Can't open $mak_file\n"; print_all_target($fullpath, \%all_target_hash); # $extra_mak handles further *.mak files in a directory print_flags($dir,$extra_mak,'CFlags',$nonpro); # depends on directory print_simple_flag("Rules"); print_simple_flag("Link"); print_common_linkflags(); # print_flags($fullpath,$extra_mak,'LinkFlags'); # depends on directory # print_lib32_objs($fullpath,$extra_mak,\%collect_object_target_hash,$resource_file); print_flags($dir,$extra_mak,'LinkFlags'); # depends on directory print_lib32_objs($dir,$extra_mak,\%collect_object_target_hash,$resource_file); # write @mak array into the *.mak file foreach $line(@mak) { print MAKFILE $line; } $|=1; print "."; # user entertainment $|=0; } print "\ndone\n"; exit; ############################################################################ sub getKey #01.04.2008 09:46 ############################################################################ { my $line = shift; $line =~ /\[(.+)\]/; return $1; } ##getKey ############################################################################ sub fillTemplateHash #01.04.2008 10:48 ############################################################################ { my $file = shift; open (TEMPLATE, "< $file") || die "Can't open template file $file\n"; my $key = ""; while ( $line=