fgscanvc.pl to HTML.

index -|- end

Generated: Tue Feb 2 17:54:34 2010 from fgscanvc.pl 2009/08/08 52.8 KB.

#!perl -w
# 20090808 - Added substitution of -
# 1: $adddeps =~ s/\$\(ProjectName\)/$projname/;
# 2: $adddeps =~ s/\$\(SolutionDir\)//; $adddeps =~ s/\$\(ConfigurationName\)/$confname/; x2
# 2009/06/05 - Add (dbg) output of 'OutputFile', and added decode of 'VCLibrarianTool'
# 05/10/2008 - Part of a series of Perl scripts to compare and show changes
# in the build files of FlightGear and SimGear
# 05/10/2008 - specialised SCAN of VCPROJ file
# 05/12/2008 geoff mclane http://geoffair.net/mperl - further refinements
# DEBUG
my $dbg_v01 = 0;    # show each line - prt( "$lnnum:$xln:".scalar @tag_stack.": $tag [$line]
my $dbg_v02 = 0;    # show prt( "$lnnum:$xln: tag=$tag, Name=$pname
my $dbg_v03 = 0;    # show sources - prt( "$lnnum:$xln: [$adddefs] $tmp source
my $dbg_v04 = 0;    # show prt( "$lnnum:$xln: processing inconfig '$conf' '$pname' [$line]
my $dbg_v05 = 0;    # show prt("$lnnum:$xln: Set APPTYPE:$conf: from $apptype, to $ppdefs - CHECK!
my $dbg_v06 = 0;    # show prt("$lnnum:$xln: Got APPTYPE:$conf: NO CHANGE [$apptype] equals SubSystem ($adddeps) [".$v8_subsystems{$adddeps}."] ...
my $dbg_v07 = 0;    # show prt( "$lnnum:$xln: Entering Configurations [$line] and EXIT
my $dbg_v08 = 0;    # show prt( "$lnnum:$xln: Entering Configuration [$conf]... [$line] and EXIT
my $dbg_v09 = 0;    # show prt( "$lnnum:$xln: Entering Files [$line] and EXIT
my $dbg_v10 = 0;    # show prt( "$lnnum:$xln: 'VCCLCompilerTool' [$line]
my $dbg_v11 = 0;    # show prt( "$lnnum:$xln: ENTER Filter name=[$fname] list=[$flist]
my $dbg_v12 = 0;    # show prt( "$lnnum:$xln: Entering FileConfiguration [$line]
my $dbg_v13 = 0;    # show prt( "ADVICE:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(1) '$seek' [$line]
my $dbg_v14 = 0;    # show prt( "$lnnum:$xln: last = $last_src [".$$src_ref[-1][0]."] $fconf $seek = $adddefs
my $dbg_v15 = 0;    # show prt( "$lnnum:$xln: got POST event [$ppdefs]
my $dbg_v16 = 0;    # for AdditionalDependencies and 'AdditionalLibraryDirectories'
#  show prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(4) & (6) '$seek' [$line]
my $dbg_v17 = 0;    # show prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(12) '$seek'? [$line]\n"
my $dbg_v18 = 0;    # show prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(7) '$seek' [$line]
my $dbg_v19 = 0;    # show prt( "$lnnum:$xln: Changed(1) $seek from [".$dsp_current_sub{$var1}."] to [$adddeps]
my $dbg_v20 = 0;    # show prt( "$lnnum:$xln: Changed(2) $seek from [".$dsp_current_sub{$var2}."] to [$adddeps]
my $dbg_v21 = 0;    # show prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(5) '$seek' [$line]
my $dbg_v22 = 0;    # show prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$adddeps]
my $dbg_v23 = 0;    # show prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$tmp]\n from [$adddeps]
my $dbg_v24 = 0;    # show prt( "$lnnum:$xln: seek=$seek: Set [$var2] to [$adddeps]\n" ) if ($dbg_v24);
sub dbg_show_entering_files { $dbg_v09 = 1; }
sub dbg_show_source_files { $dbg_v03 = 1; }
sub dbg_show_output_files { $dbg_v21 = 1; $dbg_v24 = 1; }
sub dbg_set_all_scan_debug {
   $dbg_v01 = 1;    # show each line - prt( "$lnnum:$xln:".scalar @tag_stack.": $tag [$line]
   $dbg_v02 = 1;    # show prt( "$lnnum:$xln: tag=$tag, Name=$pname
   $dbg_v03 = 1;    # show sources - prt( "$lnnum:$xln: [$adddefs] $tmp source
   $dbg_v04 = 1;    # show prt( "$lnnum:$xln: processing inconfig '$conf' '$pname' [$line]
   $dbg_v05 = 1;    # show prt("$lnnum:$xln: Set APPTYPE:$conf: from $apptype, to $ppdefs - CHECK!
   $dbg_v06 = 1;    # show prt("$lnnum:$xln: Got APPTYPE:$conf: NO CHANGE [$apptype] equals SubSystem ($adddeps) [".$v8_subsystems{$adddeps}."] ...
   $dbg_v07 = 1;    # show prt( "$lnnum:$xln: Entering Configurations [$line] and EXIT
   $dbg_v08 = 1;    # show prt( "$lnnum:$xln: Entering Configuration [$conf]... [$line] and EXIT
   $dbg_v09 = 1;    # show prt( "$lnnum:$xln: Entering Files [$line] and EXIT
   $dbg_v10 = 1;    # show prt( "$lnnum:$xln: 'VCCLCompilerTool' [$line]
   $dbg_v11 = 1;    # show prt( "$lnnum:$xln: ENTER Filter name=[$fname] list=[$flist]
   $dbg_v12 = 1;    # show prt( "$lnnum:$xln: Entering FileConfiguration [$line]
   $dbg_v13 = 1;    # show prt( "ADVICE:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(1) '$seek' [$line]
   $dbg_v14 = 1;    # show prt( "$lnnum:$xln: last = $last_src [".$$src_ref[-1][0]."] $fconf $seek = $adddefs
   $dbg_v15 = 1;    # show prt( "$lnnum:$xln: got POST event [$ppdefs]
   $dbg_v16 = 1;    # for AdditionalDependencies and 'AdditionalLibraryDirectories'
#  show prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(4) & (6) '$seek' [$line]
   $dbg_v17 = 1;    # show prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(12) '$seek'? [$line]\n"
   $dbg_v18 = 1;    # show prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(7) '$seek' [$line]
   $dbg_v19 = 1;    # show prt( "$lnnum:$xln: Changed(1) $seek from [".$dsp_current_sub{$var1}."] to [$adddeps]
   $dbg_v20 = 1;    # show prt( "$lnnum:$xln: Changed(2) $seek from [".$dsp_current_sub{$var2}."] to [$adddeps]
   $dbg_v21 = 1;    # show prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(5) '$seek' [$line]
   $dbg_v22 = 1;    # show prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$adddeps]
   $dbg_v23 = 1;    # show prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$tmp]\n from [$adddeps]
   $dbg_v24 = 1;    # show prt( "$lnnum:$xln: seek=$seek: Set [$var2] to [$adddeps]\n" ) if ($dbg_v24);
}
sub show_hash_results {
    my ($dbg, $rh) = @_;
    my ($key, $val, @arr, $itm, $icnt, $i, $msg, $len, $src, $grp, $nm, $dir, $ext);
    my ($iia, $wmsg, $tmp, $ics, $mlen, $slen);
    my %srcs = ();
    my @fsrcs = ();
    foreach $key (sort keys(%{$rh}) ) {
        $val = $$rh{$key};
        $len = length($val);
        if (($key eq 'C_SOURCES')||($key eq 'H_SOURCES')) {
            # SHOW of sources and headers in VCPROJ file
            $icnt = scalar @{$val};
            $msg = "$key count $icnt sources ...";
            prt( "$msg ($icnt)\n" );
            $msg = '';
            # push(@vc_c_sources,[$adddefs, $fname, $flist]);
            $mlen = 0;
            for ($i = 0; $i < $icnt; $i++) {
                $src = $$val[$i][0];
                $slen = length($src);
                $mlen = $slen if ($slen > $mlen);
            }
            for ($i = 0; $i < $icnt; $i++) {
                $src = $$val[$i][0];
                ($nm,$dir,$ext) = fileparse( $src, qr/\.[^.]*/ );
                $nm = lc($nm);
                $iia = defined $srcs{$nm}; 
                $ics = is_c_source($src);
                if ($iia) {
                    if ($ics) {
                        $wmsg = "WARNING: Duplicate [$src]! ";
                        prtw( "$wmsg\n" );
                    }
                } else {
                    $srcs{$nm} = 1 if ($ics);
                    push(@fsrcs,$src);
                }
                $grp = $$val[$i][1];
                $msg .= "\n" if length($msg);
                $tmp = $src;
                $tmp .= ' ' while (length($tmp) < $mlen);
                $msg .= $tmp;
                $msg .= " [$grp]";
                ###$msg .= ' '.$$val[$i][2];
            }
            prt( "$msg\n" ) if ($dbg & 4);
        } else {
            # SHOW of other things extracted from the VCPROJ file
            @arr = space_split($val);
            $icnt = scalar @arr;
            $msg = "$key = [";
            $msg .= "$val]";
            $msg .= " $icnt items...";
            prt( "$msg\n" ) if !($dbg & 2);
            $msg = '';
            if (($dbg & 1)&&($icnt > 1)) {
                prt( "dbg1: Show of $icnt items ...\n" );
                for ($i = 0; $i < $icnt; $i++) {
                    $itm = $arr[$i];
                    if ($itm =~ /^\/(D|I)/) {
                        # /I or /D
                        $i++;
                        if ($i < $icnt) {
                            $src = $arr[$i];
                        } else {
                            $src = 'OUT OF ITEMS - CHECK ME!';
                        }
                        prt( "$itm $src\n" );
                    } else {
                        # other ...
                        prt( "$itm\n" );
                    }
                }
            }
        }
    }
}
sub process_VCPROJ {
    my ($fil) = shift;
    $act_vcproj = $fil;
    my (@lines, $xlncnt, $lncnt, $lnnum, $xln, $line, $tag);
    my (@attribs, %atthash, %lnmap);
    my ($pname, $adddeps, $adddefs, $ppdefs);
    my ($var1, $var2, $var3, $seek, $tmp);
    my (@arr);
    my %dsp_current_sub = get_default_sub(); # copy the DEFAULTS
    if (open INF, "<$fil") {
        %lnmap = ();
        @lines = <INF>;
        close INF;
        $xlncnt = scalar @lines;
        @lines = fg_xml_to_lines(\%lnmap, @lines);
        $lncnt = scalar @lines;
        $lnnum = 0;
        prt( "\nProcessing file [$fil], $lncnt lines ($xlncnt) ...\n" );
        my $invcproj = 0;
        my @tag_stack = ();
        my $inconfigs = 0;
        my $inconfig = 0;
        my $apptype = '';
        my $dnaptype = 0;
        my $conf = '';
        my $infiles = 0;
        my $infile = 0;
        my $fname = '';
        my $flist = '';
        my $infilt = 0;
        my $projname = '';
        my $fconf = ''; # FileConfiguration
        my $infconf = 0; # in FileConfiguration
        my @vc_c_sources = ();
        my @vc_h_sources = ();
        my $src_ref = \@vc_c_sources;
        my $last_src = '';
        my $confname = '';
        foreach $line (@lines) {
            $lnnum++;
            $xln = $lnmap{$lnnum};
            @attribs = space_split($line);
            %atthash = array_2_hash_on_equals(@attribs);
            $tag = $attribs[0];
            $pname = '';
            if (defined $atthash{'Name'}) {
                $pname = strip_quotes(trim_all($atthash{'Name'}));
                prt( "$lnnum:$xln: tag=$tag, Name=$pname\n" ) if ($dbg_v02);
            }
            if ($invcproj) {
                if ($tag =~ /<\/VisualStudioProject/) {
                    $invcproj = 0;
                    ##pop @tag_stack;
                } else {
                    # in VCPROJ file
                    if ($line =~ /\/>$/) {
                        # begin and end tag line
                    } elsif ($line =~ /^<\//) {
                        if (! @tag_stack) {
                            prtw( "Close WITHOUT stacked tag! [$line]\n" );
                        } else {
                            pop @tag_stack;
                        }
                    } else {
                        push(@tag_stack,$tag);
                    }
                    if ($inconfigs) {
                        if ($tag =~ /<\/Configurations/) {
                            $inconfigs = 0;
                            prt( "$lnnum:$xln: Exit Configurations [$line]\n" ) if ($dbg_v07);
                        } else {
                            # in configurations section
                            if ($inconfig) {
                                # in a specific config
                                if ($line =~ /^<\/Configuration/) {
                                    $inconfig = 0;
                                    prt( "$lnnum:$xln: Exit Configuration [$conf]... [$line] ...\n" ) if ($dbg_v08);
                                } else {
                                    # processing a Configuration in Configurations
                                    prt( "$lnnum:$xln: processing inconfig '$conf' '$pname' [$line]\n" ) if ($dbg_v04);
                                    if ($line =~ /<Tool\s+/ ) {
                                        if ($pname eq 'VCCLCompilerTool') {
                                            if ($conf =~ /Debug/i) {
                                                $var1 = '-NEW_INCS_DBG-';
                                                $var2 = '-NEW_DEFS_DBG-';
                                                $var3 = '-NEW_RT_DBG-';
                                            } else {
                                                $var1 = '-NEW_INCS_REL-';
                                                $var2 = '-NEW_DEFS_REL-';
                                                $var3 = '-NEW_RT_REL-';
                                                if (!($conf =~ /Release/i)) {
                                                    prtw( "WARNING:$lnnum:$xln: pname=[$conf] NOT Debug or Release - def to REL!\n" );
                                                }
                                            }
                                            prt( "$lnnum:$xln: 'VCCLCompilerTool' [$line]\n" ) if ($dbg_v10);                                            # <Tool
                                            # Name="VCCLCompilerTool"
                                            # Optimization="0"
                                            # AdditionalIncludeDirectories="../lib,../lib/curl_transport,...
                                            # PreprocessorDefinitions="_DEBUG;WIN32;_LIB;ABYSS_WIN32;CURL_STATICLIB" 
                                            # MinimalRebuild="true" 
                                            # BasicRuntimeChecks="3" 
                                            # RuntimeLibrary="1" 
                                            # PrecompiledHeaderFile=".\Debug\xmlrpccpp/xmlrpccpp.pch" 
                                            # AssemblerListingLocation=".\Debug\xmlrpccpp/" 
                                            # ObjectFile=".\Debug\xmlrpccpp/" 
                                            # ProgramDataBaseFileName=".\Debug\xmlrpccpp/" 
                                            # WarningLevel="3" 
                                            # SuppressStartupBanner="true" 
                                            # DebugInformationFormat="4" />]
                                            # WATCHOUT FOR 
                                            # AdditionalIncludeDirectories="..\..;&quot;..\..\..\zlib-1.2.3&quot;"
                                            $seek = 'AdditionalIncludeDirectories'; # -NEW_INCS_[DBG|REL]-
                                            if ( defined $atthash{$seek} ) {
                                                $ppdefs = strip_quotes(trim_all($atthash{$seek}));
                                                $ppdefs =~ s/&amp;/&/g;     # 20081205 - added
                                                $ppdefs =~ s/&quot;/"/g;
                                                $dsp_current_sub{$var1} = get_includes_string($ppdefs);
                                            } else {
                                                $dsp_current_sub{$var1} = '';
                                                prt( "ADVICE:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(1) '$seek' [$line]\n" ) if ($dbg_v13);
                                            }
                                            $seek = 'PreprocessorDefinitions';
                                            if ( defined $atthash{$seek} ) {
                                                $ppdefs = strip_quotes(trim_all($atthash{$seek}));
                                                $dsp_current_sub{$var2} = get_defines_string($ppdefs);
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(2) '$seek' [$line]\n" );
                                            }
                                            $seek = 'RuntimeLibrary';
                                            if ( defined $atthash{$seek} ) {
                                                $ppdefs = strip_quotes(trim_all($atthash{$seek}));
                                                $dsp_current_sub{$var3} = fg_get_runtime_val_2_lts($ppdefs);
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(3) '$seek' [$line]\n" );
                                            }
                                        } elsif ($pname eq 'VCLinkerTool') {
                                            if ($conf =~ /Debug/i) {
                                                $var1 = '-NEW_LIBS_DBG-';
                                                $var2 = '-NEW_OUT_DBG-';
                                            } else {
                                                $var1 = '-NEW_LIBS_REL-';
                                                $var2 = '-NEW_OUT_REL-';
                                            }
                                            # <Tool
                                            #  Name="VCLinkerTool"
                                            #  LinkLibraryDependencies="false"
                                            #  AdditionalDependencies="wsock32.lib SimGear.lib sg_d.lib ... "
                                            #  OutputFile="..\bin\FlightGearD.exe"
                                            #  LinkIncremental="0"
                                            #  SuppressStartupBanner="true"
                                            #  AdditionalLibraryDirectories="..\SimGear\$(IntDir); ..\PLIB, ..."
                                            #  IgnoreDefaultLibraryNames=""
                                            #  GenerateDebugInformation="true"
                                            #  ProgramDatabaseFile=".\Debug/FlightGear.pdb"
                                            #  SubSystem="1"
                                            #  RandomizedBaseAddress="1"
                                            #  DataExecutionPrevention="0"
                                            #  TargetMachine="1" />
                                            $seek = 'AdditionalDependencies';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $adddeps =~ s/&amp;/&/g;     # 20081205 - added
                                                $adddeps =~ s/&quot;/"/g;    # 20081205 - added
                                                $dsp_current_sub{$var1} = $adddeps;
                                                prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$adddeps]\n" ) if ($dbg_v22);
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(4) '$seek' [$line]\n" ) if ($dbg_v16);
                                            }
                                            $seek = 'OutputFile';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                # 20090808 - handle substitution
                                                # EG: 39:138-149: seek=OutputFile: Set [-NEW_OUT_REL-] 
                                                # to [.\$(ProjectName).exe]
                                                $adddeps =~ s/\$\(ProjectName\)/$projname/;
                                                $dsp_current_sub{$var2} = '/out:'.$adddeps;
                                                 if ($dbg_v24) {
                                                   prt( "$lnnum:$xln: seek=$seek: " );
                                                   prt( "Set [$var2] to [$adddeps]\n" );
                                                 }
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(5) '$seek' [$line]\n" ) if ($dbg_v21);
                                            }
                                            $seek = 'AdditionalLibraryDirectories';
                                            if (defined $atthash{$seek} ) {
                                                # must deal with a crazy string like this -
                                                # AdditionalLibraryDirectories=
                                                # "&amp;quot,..\fltk-1.1.7\lib&amp;quot,..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3&amp;quot,..\plib,
                                                # ..\pthreads-w32-2-7-0-release&amp;quot,..\gettext\lib"
                                                # after quotes removed, and the first substitution
                                                # &quot,..\fltk-1.1.7\lib&quot,..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3&quot,..\plib,
                                                # ..\pthreads-w32-2-7-0-release&quot,..\gettext\lib
                                                # after next pair of subs
                                                # ",..\fltk-1.1.7\lib",..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3",..\plib,
                                                # ..\pthreads-w32-2-7-0-release",..\gettext\lib
                                                # then removing the auotes
                                                # ,..\fltk-1.1.7\lib,..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3,..\plib,
                                                # ..\pthreads-w32-2-7-0-release,..\gettext\lib
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $adddeps =~ s/&amp;/&/g;    # 20081205 - added
                                                $adddeps =~ s/&quot;/"/g;   # 20081205 - added
                                                $adddeps =~ s/&quot/"/g;    # 20081205 - added
                                                $adddeps =~ s/"//g;         # 20081205 - added
                                                $adddeps =~ s/^,//;         # 20081205 - added
                                                $tmp = get_libpaths_string($adddeps);
                                                $dsp_current_sub{$var1} .= ' '.$tmp;
                                                prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$tmp]\n from [$adddeps]\n" ) if ($dbg_v23);
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(6) '$seek' [$line]\n" )  if ($dbg_v16);
                                            }
                                            $seek = 'SubSystem';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $apptype = adjust_app_type_per_subsystem( $apptype, $adddeps, $dbg_v05 );
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(7) '$seek' [$line]\n" ) if ($dbg_v18);
                                            }
                                        } elsif ($pname eq 'VCLibrarianTool' ) {
                                           # <Tool Name="VCLibrarianTool"
                                           # OutputFile="Win32_LIB_Debug\zlibd.lib"
                                           # SuppressStartupBanner="true" />
                                            if ($conf =~ /Debug/i) {
                                                $var2 = '-NEW_OUT_DBG-';
                                            } else {
                                                $var2 = '-NEW_OUT_REL-';
                                            }
                                            $seek = 'OutputFile';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $dsp_current_sub{$var2} = '/out:'.$adddeps;
                                                prt( "$lnnum:$xln: seek=$seek: Set [$var2] to [$adddeps]\n" ) if ($dbg_v24);
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(5) '$seek' [$line]\n" ) if ($dbg_v21);
                                            }
                                        } elsif ($pname eq 'VCPostBuildEventTool') {
                                            if ($conf =~ /Debug/i) {
                                                $var1 = '-NEW_POST_DBG-';
                                            } else {
                                                $var1 = '-NEW_POST_REL-';
                                                if (!($conf =~ /Release/i)) {
                                                    prtw( "WARNING:$lnnum:$xln: pname=[$conf] NOT Debug or Release - def to REL!\n" );
                                                }
                                            }
                                            # <Tool
                                            #  Name="VCPostBuildEventTool"
                                            #  Description="Copy Library to plib directory"
                                            #  CommandLine="copy debug\*.lib ..\..\*.*&#x0D;&#x0A;copy ul.h ..\..\ul.h&#x0D;&#x0A;copy ulRTTI.h ..\..\ulRTTI.h&#x0D;&#x0A;"
                                            #  />
                                            # this will be output to the DSP, under the paticular, config, something like
                                            # # Begin Special Build Tool
                                            # SOURCE="$(InputPath)"
                                            # PostBuild_Desc=Copy to bin
                                            # PostBuild_Cmds=copy Release\*exe bin\.   copy test.h bin\.
                                            # # End Special Build Tool
                                            if (( defined $atthash{'Description'} ) || ( defined $atthash{'CommandLine'} ) ) {
                                                $ppdefs = ""; # to 'PostBuild_Desc=';
                                                if ( defined $atthash{'Description'} ) {
                                                    $ppdefs .= add_quotes(strip_quotes(trim_all($atthash{'Description'})));
                                                }
                                                $adddeps = ""; # to ' PostBuild_Cmds=';
                                                if ( defined $atthash{'CommandLine'} ) {
                                                    $adddeps = strip_quotes(trim_ends($atthash{'CommandLine'}));
                                                    $adddeps =~ s/&quot;/"/g;   # put back the quotes, if any
                                                    $adddeps =~ s/&#x0D;&#x0A;/\t/g;    # new line to TAB for VC6
                                                    $adddeps =~ s/\t$//;    # clear any END tab
                                                }
                                                prt( "$lnnum:$xln: got POST event [$ppdefs]\n" ) if ($dbg_v15);
                                                $tmp = "# Begin Special Build Tool\n";
                                                $tmp .= "SOURCE=\"\$(InputPath)\"\n";
                                                $tmp .= "PostBuild_Desc=$ppdefs\n";
                                                # sometimes need a little 'massaging' of the command ...
                                                $tmp .= "PostBuild_Cmds=".massage_command($adddeps)."\n";
                                                $tmp .= "# End Special Build Tool\n";
                                                $dsp_current_sub{$var1} = $tmp;
                                            }
                                        }
                                    }
                                }
                            } elsif ($line =~ /^<Configuration\s+/) {
                                $conf = $pname;
                                @arr = split(/\|/,$pname);
                                $confname = $arr[0];
                                prt( "$lnnum:$xln: Entering ConfigurationName=[$confname] conf=[$conf] [$line] ...\n" ) if ($dbg_v08);
                                # 28/09/2008 - note, has quotes added
                                # "-NEW_OUTD_DBG-" $out_dir
                                # "-NEW_OUTD_REL-" $out_dir
                                # "-NEW_INTER_DBG-" $int_dir
                                # "-NEW_INTER_REL-" $int_dir
                                if ($conf =~ /Debug/i) {
                                    $var1 = "-NEW_OUTD_DBG-";
                                    $var2 = "-NEW_INTER_DBG-";
                                } else {
                                    $var1 = "-NEW_OUTD_REL-";
                                    $var2 = "-NEW_INTER_REL-";
                                    if (!($conf =~ /Release/i)) {
                                        prtw( "WARNING:$lnnum:$xln: pname=[$conf] NOT Debug or Release - def to REL!\n" );
                                    }
                                }
                                #  // This is an internal type to Visual Studio, it seems that:
                                #  // 4 == static library
                                #  // 2 == dll
                                #  // 1 == executable
                                #  // 10 == utility
                                $seek = 'ConfigurationType';
                                if (defined $atthash{$seek}) {
                                    $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                    $apptype = get_app_conf_type($adddeps);
                                    $dnaptype = 1;  # signal, we have an APP TYPE - VERY IMPORTANT
                                } else {
                                    prtw( "WARNING:$lnnum:$xln: DOES NOT CONTAIN(8) '$seek' [$line]\n" );
                                }
                                $seek = 'OutputDirectory';
                                if (defined $atthash{$seek}) {
                                   # 20090808 - improved to handle
                                   # EG: 9:18-24: Changed(1) OutputDirectory from ["Debug"]
                                   # to ["$(SolutionDir)$(ConfigurationName)"]
                                   #$adddeps = add_quotes(strip_dotrel(strip_quotes(trim_all($atthash{$seek}))));
                                    $adddeps = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                                    $adddeps =~ s/\$\(SolutionDir\)//;
                                    $adddeps =~ s/\$\(ConfigurationName\)/$confname/;
                                    if ($dsp_current_sub{$var1} ne add_quotes($adddeps)) {
                                        if ($dbg_v19) {
                                           prt( "$lnnum:$xln: Changed(1) [$seek]" );
                                           prt( " from [".$dsp_current_sub{$var1}."]" );
                                           prt( " to [".add_quotes($adddeps)."]\n" );
                                        }
                                    }
                                    $dsp_current_sub{$var1} = add_quotes($adddeps);
                                } else {
                                    prtw( "WARNING:$lnnum:$xln: DOES NOT CONTAIN(9) '$seek' [$line]\n" );
                                }
                                $seek = 'IntermediateDirectory';
                                if (defined $atthash{$seek}) {
                                   # 20090808 - improved to handle
                                   # 9:18-24: Changed(2) IntermediateDirectory from ["Debug"] 
                                   # to ["$(ConfigurationName)"]
                                   # $adddeps = add_quotes(strip_dotrel(strip_quotes(trim_all($atthash{$seek}))));
                                   $adddeps = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                                   $adddeps =~ s/\$\(SolutionDir\)//;
                                   $adddeps =~ s/\$\(ConfigurationName\)/$confname/;
                                   if ($dsp_current_sub{$var2} ne add_quotes($adddeps)) {
                                       if ($dbg_v20) {
                                          prt( "$lnnum:$xln: Changed(2) [$seek]" );
                                          prt( " from [".$dsp_current_sub{$var2}."]" );
                                          prt( " to [".add_quotes($adddeps)."]\n" );
                                       }
                                   }
                                   $dsp_current_sub{$var2} = add_quotes($adddeps);
                                } else {
                                    prtw( "WARNING:$lnnum:$xln: DOES NOT CONTAIN(10) '$seek' [$line]\n" );
                                }
                                $inconfig = 1;
                            }
                        }
                    } elsif ($infiles) {
                        if ($tag =~ /\/Files/) {
                            prt( "$lnnum:$xln: Exit Files [$line]\n" ) if ($dbg_v09);
                            $infiles = 0;
                        } else {
                            # processing the <Files> section
                            # ##############################
                            if ($infilt) {
                                if ($line =~ /^<\/Filter/) {
                                    $infilt = 0;
                                    prt( "$lnnum:$xln: EXIT Filter name=[$fname] list=[$flist]\n" ) if ($dbg_v11);
                                    $flist = '';    # 20081205 - kill list on exit
                                } else {
                                    if ($infile) {
                                        if ($line =~ /^<\/File/) {
                                            $infile = 0;
                                        } else {
                                            # processing a <Files><Filter...><File ... may have
                                            # In <Files ...>
                                            # WATCH FOR THIS
                                            # <File RelativePath="..\..\scripts\pngw32.def">
                                            # <FileConfiguration Name="LIB Release|Win32" ExcludedFromBuild="true">
                                            # <Tool Name="VCCustomBuildTool" />
                                            # </FileConfiguration>
                                            # <FileConfiguration Name="LIB Debug|Win32" ExcludedFromBuild="true">
                                            # <Tool Name="VCCustomBuildTool" />
                                            # </FileConfiguration>
                                            # </File>
                                            # <FileConfiguration Name="Release|Win32" >
                                            # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                            # </FileConfiguration>
                                            # <FileConfiguration Name="Debug|Win32" >
                                            # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                            # </FileConfiguration>
                                            if ($tag =~ /<FileConfiguration/) {
                                                $infconf = 1;
                                                $fconf = $pname;
                                                $seek = 'ExcludedFromBuild';
                                                $adddefs = '';
                                                if (defined $atthash{$seek} ) {
                                                    $adddefs = strip_quotes(trim_all($atthash{$seek}));
                                                    if (length($adddefs) && ($adddefs =~ /true/)) {
                                                        $$src_ref[-1][3] = 1;
                                                        prt( "$lnnum:$xln: last = $last_src [".$$src_ref[-1][0]."] $fconf $seek = $adddefs\n" ) if ($dbg_v14);
                                                    }
                                                }
                                                prt( "$lnnum:$xln: Entering FileConfiguration [$line]\n") if ($dbg_v12);
                                            }
                                        }
                                    } elsif ($line =~ /^<File\s+/) {
                                        $seek = 'RelativePath';
                                        if (defined $atthash{$seek}) {
                                            $var1 = $atthash{$seek};
                                            $var1 =~ s/>$//;
                                            $last_src = strip_dotrel(strip_quotes(trim_all($var1)));
                                            if (is_c_source_extended($last_src)) {
                                                #push(@vc_c_sources,[$last_src, $fname, $flist, 0]);
                                                $var1 = (length($fname) ? $fname : get_def_src_grp());
                                                $var2 = (length($flist) ? $flist : get_def_src_filt());
                                                push(@vc_c_sources,[$last_src, $var1, $var2, 0]);
                                                $src_ref = \@vc_c_sources;
                                                $tmp = 'C';
                                            } else {
                                                #push(@vc_h_sources,[$last_src, $fname, $flist, 0]);
                                                $var1 = (length($fname) ? $fname : get_def_hdr_grp());
                                                $var2 = (length($flist) ? $flist : get_def_hdr_filt());
                                                push(@vc_h_sources,[$last_src, $var1, $var2, 0]);
                                                $src_ref = \@vc_h_sources;
                                                $tmp = 'H';
                                            }
                                            prt( "$lnnum:$xln: [$last_src] $tmp source\n" ) if ($dbg_v03);
                                        } else {
                                            prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(11) '$seek'? [$line]\n" );
                                        }
                                        $infile = 1;
                                    }
                                }
                            } elsif ($line =~ /^<Filter\s+/) {
                                $fname = $pname;
                                $seek = 'Filter';
                                if (defined $atthash{$seek} ) {
                                    $flist = strip_quotes(trim_all($atthash{$seek}));
                                    # handle this Filter="&quot;h;hpp;hxx;hm;inl&quot;&gt;"
                                    $flist =~ s/&gt;//g;    # 20081205 - remove this, if exists
                                    $flist =~ s/&quot;/"/g; # 20081205 - put QUOTES back
                                    $flist = strip_quotes($flist);  # now again remove them
                                } else {
                                    # example: alut.vcproj
                                    # <Filter Name="ALUT Header">
                                    # <File RelativePath="..\..\..\include\AL\alut.h">
                                    # </File></Filter>
                                    prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(12) '$seek'? [$line]\n" ) if ($dbg_v17);
                                }
                                prt( "$lnnum:$xln: ENTER Filter name=[$fname] list=[$flist]\n" ) if ($dbg_v11);
                                $infilt = 1;
                            } else {
                                # some VCPROJ files have NO <Filter ...><File...>...</File></Filter>
                                if ($infile) {
                                    if ($line =~ /^<\/File/) {
                                        $infile = 0;
                                    } else {
                                        # processing a <Files><File ... may have
                                        # In <Files ...>
                                        # WATCH FOR THIS
                                        # <File RelativePath="..\..\scripts\pngw32.def">
                                        # <FileConfiguration Name="LIB Release|Win32" ExcludedFromBuild="true">
                                        # <Tool Name="VCCustomBuildTool" />
                                        # </FileConfiguration>
                                        # <FileConfiguration Name="LIB Debug|Win32" ExcludedFromBuild="true">
                                        # <Tool Name="VCCustomBuildTool" />
                                        # </FileConfiguration>
                                        # </File>
                                        # <FileConfiguration Name="Release|Win32" >
                                        # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                        # </FileConfiguration>
                                        # <FileConfiguration Name="Debug|Win32" >
                                        # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                        # </FileConfiguration>
                                        if ($tag =~ /<FileConfiguration/) {
                                            $infconf = 1;
                                            $fconf = $pname;
                                            $seek = 'ExcludedFromBuild';
                                            $adddefs = '';
                                            if (defined $atthash{$seek} ) {
                                                $adddefs = strip_quotes(trim_all($atthash{$seek}));
                                                if (length($adddefs) && ($adddefs =~ /true/)) {
                                                    $$src_ref[-1][3] = 1;
                                                    prt( "$lnnum:$xln: last = $last_src [".$$src_ref[-1][0]."] $fconf $seek = $adddefs\n" ) if ($dbg_v14);
                                                }
                                            }
                                            prt( "$lnnum:$xln: Entering FileConfiguration [$line]\n") if ($dbg_v12);
                                        }
                                    }
                                } elsif ($line =~ /^<File\s+/) {
                                    $seek = 'RelativePath';
                                    if (defined $atthash{$seek}) {
                                        $last_src = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                                        if (is_c_source_extended($last_src)) {
                                            #push(@vc_c_sources,[$last_src, $fname, $flist, 0]);
                                            $var1 = (length($fname) ? $fname : get_def_src_grp());
                                            $var2 = (length($flist) ? $flist : get_def_src_filt());
                                            push(@vc_c_sources,[$last_src, $var1, $var2, 0]);
                                            $src_ref = \@vc_c_sources;
                                            $tmp = 'C';
                                        } else {
                                            #push(@vc_h_sources,[$last_src, $fname, $flist, 0]);
                                            $var1 = (length($fname) ? $fname : get_def_hdr_grp());
                                            $var2 = (length($flist) ? $flist : get_def_hdr_filt());
                                            push(@vc_h_sources,[$last_src, $var1, $var2, 0]);
                                            $src_ref = \@vc_h_sources;
                                            $tmp = 'H';
                                        }
                                        prt( "$lnnum:$xln: [$last_src] $tmp source\n" ) if ($dbg_v03);
                                    } else {
                                        prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(13) '$seek'? [$line]\n" );
                                    }
                                    $infile = 1;
                                }
                            }
                        }
                    } else {
                        if ($tag =~ /<Configurations/) {
                            $inconfigs = 1;
                            prt( "$lnnum:$xln: Entering Configurations [$line]\n" ) if ($dbg_v08);
                        } elsif ($tag =~ /<Files/) {
                            prt( "$lnnum:$xln: Entering Files [$line]\n" ) if ($dbg_v09);
                            $infiles = 1;
                        }
                    }
                }
                ###if ($infconf && (($tag =~ /<\/FileConfiguration/)||($line eq '</FileConfiguration>'))) {
                if ($infconf && ($tag =~ /<\/FileConfiguration/)) {
                    $infconf = 0;
                    prt( "$lnnum:$xln: Exit FileConfiguration [$line]\n" ) if ($dbg_v12);
                }
            } else {
                if ($tag =~ /<VisualStudioProject/) {
                    $invcproj = 1;
                    ##push(@tag_stack, $tag);
                    # <VisualStudioProject
                    #  ProjectType="Visual C++" 
                    #  Version="9.00" 
                    #  Name="FlightGear"
                    #  ProjectGUID="{5C747AB8-6441-46B3-95D2-9D948C80EC77}"
                    #  TargetFrameworkVersion="131072" >
                    $seek = 'Name';
                    if (!defined $atthash{$seek} ) {
                        mydie( "ERROR: 'VisualStudioProject' DOES NOT CONTAIN(14) a porject NAME! NO GO!! ABORTING!!!\n" );
                    }
                    $projname = $pname;
                    $adddeps = '';
                    $adddefs = '';
                    $seek = 'ProjectType';
                    if (defined $atthash{$seek}) {
                        $adddefs = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                    }
                    $seek = 'Version';
                    if (defined $atthash{$seek}) {
                        $adddeps = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                    }
                    prt( "$lnnum:$xln: Project [$projname], using [$adddefs], version [$adddeps] ...\n" );
                }
            }
            prt( "$lnnum:$xln:".scalar @tag_stack.": $tag [$line]\n" ) if ($dbg_v01);
        }
        prtw( "WARNING: tag_stack NOT empty! ".$tag_stack[0]."\n") if (@tag_stack);
        $dsp_current_sub{'C_SOURCES'} = [@vc_c_sources];
        $dsp_current_sub{'H_SOURCES'} = [@vc_h_sources];
        $dsp_current_sub{'APP_TYPE'} = $apptype;
        $dsp_current_sub{'-NEW_PROJECT_NAME-'} = $projname;
    } else {
        mydie( "ERROR: Unable to open $fil ... $! ... check name, location ...\n" );
    }
    return %dsp_current_sub;
}
sub fg_xml_to_lines {
    my ($rlm, @lns) = @_;
    my $intag = 0;
    my $text = '';
    my @nlines = ();
    my ($fln, $ln, $ch, $pch, $nch, $len, $i, $i2, $tag, $xml, $dnx);
    my ($lnnm, $lnb, $nlnm);
    $pch = '';
    $nch = '';
    $tag = '';
    $xml = '';
    $dnx = 0;
    $lnnm = 0;
    $nlnm = 0;
    $lnb = 0;
    foreach $fln (@lns) {
        chomp $fln;
        $ln = trim_all($fln);
        $len = length($ln);
        $lnnm++;    # count another xml line
        for ($i = 0; $i < $len; $i++) {
            $i2 = $i + 1;
            $ch = substr($ln,$i,1);
            $nch = (($i2 < $len) ? substr($ln,$i2,1) : ' ');
            if ($intag) {
                # on first SPACE
                $tag .= $ch;
                if ($ch eq '>') {
                    # end of XML tag
                    $nlnm++;
                    push(@nlines,$tag);
                    ### prt( "push(\@xlnmap, [ $nlnm, $lnb, $lnnm ]); # each NEW line has BEGIN and END\n" );
                    $$rlm{$nlnm} = "$lnb-$lnnm";    # each NEW line has BEGIN and END
                    $tag = '';
                    $intag = 0;
                    $xml = '';
                }
            } else {
                if ($ch eq '<') {
                    $tag = $ch; # start a tag line
                    $intag = 1; # signal in a tag
                    $xml = '';
                    $dnx = 0;
                    $lnb = $lnnm;    # set the BEGIN xml line
                }
            }
            $pch = $ch;
        }
        # done a line - this is like a SPACE
        if ($intag && length($tag)) {
            $tag .= ' ' if !($tag =~ /\s$/);
        }
    }
    if (length($tag)) {
        prtw("WARNING: xml re-lining error! Left pending tag [$tag]\nin $act_vcproj file ...\n");
    }
    return @nlines;
}
sub get_string_with_sep {
    my ($sep, $txt) = @_;
    my @av = split(/[,;]/, $txt);
    my $ref = '';
    foreach my $tx (@av) {
        $tx = substr($tx,1) if ($tx =~ /^\s/);
        if (length($tx)) {
            $ref .= ' ' if length($ref);
            # remove any existing quotes, but add quotes for sure
            $ref .= $sep.add_quotes(strip_quotes($tx));
        }
    }
    return $ref;
}
sub get_includes_string {
    my ($txt) = shift;
    return get_string_with_sep('/I ', $txt);
}
sub get_defines_string {
    my ($txt) = shift;
    return get_string_with_sep('/D ', $txt);
}
sub get_libpaths_string {
    my ($txt) = shift;
    return get_string_with_sep('/libpath:', $txt);
}
# added 07/12/2008 from fgscanvc.pl in Dell02:D:\fg\26
sub xml_array_to_lines {
    my ($rlm, @lns) = @_;
    my $intag = 0;
    my $text = '';
    my @nlines = ();
    my ($fln, $ln, $ch, $pch, $nch, $len, $i, $i2, $tag, $xml, $dnx);
    my ($lnnm, $lnb, $nlnm);
   my ($ppch, $rem, $incomm);
    $pch = '';
    $nch = '';
    $tag = '';
    $xml = '';
   $ppch = '';
    $dnx = 0;
    $lnnm = 0;
    $nlnm = 0;
    $lnb = 0;
   $incomm = 0;
   $text = '';
    foreach $fln (@lns) {
        chomp $fln;
        $ln = trim_all($fln);
        $len = length($ln);
        $lnnm++;    # count another xml line
        for ($i = 0; $i < $len; $i++) {
            $i2 = $i + 1;
            $ch = substr($ln,$i,1);
            $nch = (($i2 < $len) ? substr($ln,$i2,1) : ' ');
            if ($intag) {
                # on close of tag
                $tag .= $ch;
                if ($ch eq '>') {
                    # end of XML tag
               if (( ! $incomm) || ( $incomm && ($pch eq '-') && ($ppch eq '-') )) {
                  $nlnm++;
                  push(@nlines,$tag);
                  ### prt( "push(\@xlnmap, [ $nlnm, $lnb, $lnnm ]); # each NEW line has BEGIN and END\n" );
                  $$rlm{$nlnm} = "$lnb-$lnnm";    # each NEW line has BEGIN and END
                  $tag = '';
                  $intag = 0;
                  $xml = '';
                  $incomm = 0;
               }
                }
            } else {
                if ($ch eq '<') {
               if (length($text)) {
                  $nlnm++;
                  push(@nlines,$text);
                  ### prt( "push(\@xlnmap, [ $nlnm, $lnb, $lnnm ]); # each NEW line has BEGIN and END\n" );
                  $$rlm{$nlnm} = "$lnb-$lnnm";    # each NEW line has BEGIN and END
                  $text = '';
               }
               if ($nch eq '!') {
                  # potential start of comment <!-- until -->
                  $rem = $len - $i;
                  if (($rem > 4) && (substr($ln,$i,4) eq '<!--')) {
                     $incomm = 1;
                  }
               }
                    $tag = $ch; # start a tag line
                    $intag = 1; # signal in a tag
                    $xml = '';
                    $dnx = 0;
                    $lnb = $lnnm;    # set the BEGIN xml line
                } else {
               $text .= $ch;
            }
            }
         $ppch = $pch;
            $pch = $ch;
        }
        # done a line - this is like a SPACE
        if ($intag && length($tag)) {
            $tag .= ' ' if !($tag =~ /\s$/);
        }
    }
    if (length($tag)) {
        prtw("WARNING: xml re-lining error! Left pending tag [$tag]\nin $act_vcproj file ...\n");
    }
    return @nlines;
}
1;
# eof fgscanvc.pl

index -|- top

checked by tidy  Valid HTML 4.01 Transitional