@rem ='
@perl -S "%0" %*
@goto perldone
@rem ';
#!perl -w
############## START OF PERL
use strict;
use File::Find;
use Cwd;
#--------------------------------------------------------------------
#-- constants
my $namewidth = 57;
my $countwidth = 7;
#--------------------------------------------------------------------
#-- globals
my $startingdir = '';
my $curproject = '';
my %fileinfo;
my %projectfileinfo;
my %allprojects;
my $totaldirs = 0;
$fileinfo{len0} = 0;
$fileinfo{zerocomment} = 0;
$fileinfo{total} = 0;
$fileinfo{source} = 0;
my $maxfilesize = 0;
my $maxfilename = '';
my $totalswitches = 0;
my $totalclasses = 0;
my $totallines = 0;
my $totalcodelines = 0;
#--------------------------------------------------------------------
#-- add projecttems to skip here...
sub DoProject
{
return 0 if (lc $curproject eq '' ||
lc $curproject eq '.');
return 1;
}
#--------------------------------------------------------------------
sub RollProjectTotals
{
return if !DoProject();
$totaldirs += $allprojects{$curproject}->{totaldirs};
$fileinfo{total} += $allprojects{$curproject}->{totalfiles};
$fileinfo{len0} += $allprojects{$curproject}->{total0files};
$fileinfo{zerocomment} += $allprojects{$curproject}->{zerocomment};
$fileinfo{source} += $allprojects{$curproject}->{totalsourcefiles};
if ($allprojects{$curproject}->{maxfilesize} > $maxfilesize)
{
$maxfilesize = $allprojects{$curproject}->{maxfilesize};
$maxfilename = $allprojects{$curproject}->{maxfilename};
}
$totalswitches += $allprojects{$curproject}->{totalswitches};
$totalclasses += $allprojects{$curproject}->{totalclasses};
$totallines += $allprojects{$curproject}->{totallines};
$totalcodelines += $allprojects{$curproject}->{totalcodelines};
}
#--------------------------------------------------------------------
sub ClearProjectTotals
{
return if !DoProject();
$allprojects{$curproject}->{totaldirs} = 0;
$allprojects{$curproject}->{totalfiles} = 0;
$allprojects{$curproject}->{total0files} = 0;
$allprojects{$curproject}->{zerocomment} = 0;
$allprojects{$curproject}->{maxfilesize} = 0;
$allprojects{$curproject}->{maxfilename} = '';
$allprojects{$curproject}->{totalsourcefiles} = 0;
$allprojects{$curproject}->{totalswitches} = 0;
$allprojects{$curproject}->{totalclasses} = 0;
$allprojects{$curproject}->{totallines} = 0;
$allprojects{$curproject}->{totalcodelines} = 0;
}
#--------------------------------------------------------------------
sub PrintSourceTypeSummary($)
{
my $href = shift;
my %hash = %{$href};
foreach (sort keys %hash)
{
if (/^type_/)
{
my $x = $_;
$x =~ s/^type_//;
printf " %-15.15s: %5d (%5d lines)\n", ".$x files", $hash{$_}{numfiles}, $hash{$_}{numlines};
}
}
}
#--------------------------------------------------------------------
sub adjustStats($$$)
{
my ($ext, $numlines, $numcodelines) = @_;
printf "%*d %*d %.0f\%\n", $countwidth, $numlines, $countwidth, $numcodelines,
$numlines ? ($numcodelines*100.0)/$numlines : 0.0;
$allprojects{$curproject}->{totallines} += $numlines;
$allprojects{$curproject}->{totalcodelines} += $numcodelines;
if ($numlines == 0)
{
$allprojects{$curproject}->{total0files}++;
}
elsif ($numlines == $numcodelines)
{
$allprojects{$curproject}->{zerocomment}++;
}
if ($numlines > $allprojects{$curproject}->{maxfilesize})
{
$allprojects{$curproject}->{maxfilesize} = $numlines;
$allprojects{$curproject}->{maxfilename} = $File::Find::name;
}
$projectfileinfo{$curproject}->{"type_$ext"}{numlines} += $numlines;
$fileinfo{"type_$ext"}{numlines} += $numlines;
}
#--------------------------------------------------------------------
sub readVBfile($$)
{
my ($file, $ext) = @_;
my $numlines = 0;
my $numcodelines = 0;
open FH, $file || die ;
while (<FH>)
{
$numlines++;
chomp;
s/^\s*'.*$//; # convert '...\n to nothing
s/\s//g; # conver whitespace to nothing
next if /^\s*$/; # skip blank lines
$numcodelines++;
}
adjustStats($ext, $numlines, $numcodelines);
close FH;
}
#--------------------------------------------------------------------
sub readCfile($$)
{
my ($file, $ext) = @_;
my $numlines = 0;
my $numcodelines = 0;
my $state = 0; # in code
my $codeline = 0;
my $incomment = 0;
my $inzerodef = 0;
my @deflevel = ();
open FH, $file || die ;
while (<FH>)
{
$numlines++;
chomp;
s/\/\/.*$//; # convert '//...\n' to nothing
s/\/\*.*\*\///g; # convert '/*...*/' to nothing
s/\s//g; # conver whitespace to nothing
next if /^\s*$/; # skip blank lines
# print "$_\n";
if ($incomment and /\*\// )
{
# print "term comment\n";
$incomment = 0;
}
elsif ( /\/\*/ )
{
#print "start comment\n";
$incomment = 1;
}
elsif ( /^#if0/ )
{
unshift @deflevel, 1;
$inzerodef++;
}
elsif ( /^#if/ or /^#ifndef/)
{
unshift @deflevel, 0;
}
elsif ( /^#\s*endif/ )
{
shift @deflevel;
$inzerodef -= $deflevel[0];
}
elsif (!$incomment and !$inzerodef)
{
#print "$_\n";
$allprojects{$curproject}->{totalswitches}++ if (/^switch/);
$allprojects{$curproject}->{totalclasses}++ if (/^(public|private)?class/);
$numcodelines++;
}
}
adjustStats($ext, $numlines, $numcodelines);
close FH;
}
#--------------------------------------------------------------------
sub process_file
{
my $proj = cwd();
#print "projbefore='$proj'\n";
$proj =~ s/^$startingdir//e; # remove the starting dir
($proj) = $startingdir =~ /([^\/]+)$/ if $proj eq '';
$proj =~ s/^\///; # remove leading '/'
$proj =~ s/^\.\///; # remove leading '.\'
$proj =~ s/\/.*$//; # remove sub-directories
#print "projafter ='$proj'\n";
if ($curproject ne $proj)
{
#print "curproject='$curproject' proj='$proj' '$File::Find::dir' '$_'\n";
RollProjectTotals();
$curproject = $proj;
ClearProjectTotals();
}
return if !DoProject();
if (-d)
{
$allprojects{$curproject}->{totaldirs}++;
return;
}
return if $File::Find::dir =~ /obj$/i;
return if $File::Find::dir =~ /bin$/i;
return if $File::Find::dir =~ /debug$/i;
return if $File::Find::dir =~ /release$/i;
$allprojects{$curproject}->{totalfiles}++;
if (! /\.(cs|c|cpp|h|idl|odl|rc|rc2|inl|java|bas|cls|frm)$/i )
{
#if (!/\.(py|vbs|xsl|resx|pm|pl|user|bak|aps|opt|prj|smp|s|class|jar|xml|out|html|proj|csproj|vcproj|sln|suo|bmp|exe|ocx|dll|jpg|ncb|plg|frx|vbw|scc|dsw|htm|tlb|zip|orig|bas|sql|tpl|def|lnt|doc|vsd|mdl|ptl|er1|dep|dsp|mk|mak|mk2|mmk|rgs|ico|bat|cmd|reg|frm|vbp|txt|pl)$/i)
# {
# print "x=$_\n";
# }
return ;
}
return if (/_i\.c$/ || /_p\.c$/ || /dlldatax\.[ch]/ || /dlldata\.[ch]/);
my $ext = lc $1;
$fileinfo{"type_$ext"}{numfiles}++;
$projectfileinfo{$curproject}->{"type_$ext"}{numfiles}++;
$allprojects{$curproject}->{totalsourcefiles}++;
printf "%*.*s ", $namewidth, $namewidth, $File::Find::name;
if (/\.(bas|cls|frm)$/i )
{
readVBfile($_, $ext);
}
else
{
readCfile($_, $ext);
}
}
#-------------------------------------------------------------------------------------
#-- Main
$startingdir = cwd();
#print "startingdir=$startingdir\n";
ClearProjectTotals();
printf "%*.*s %*s %*s\n", $namewidth, $namewidth, "file name", $countwidth, "total", $countwidth, "code";
printf "%*.*s %*s %*s\n", $namewidth, $namewidth, '-' x $namewidth, $countwidth, '-' x $countwidth, $countwidth, '-' x $countwidth;
my @dirlist = (".");
find(\&process_file, @dirlist);
RollProjectTotals();
print "\n";
print '-' x 79 . "\n";
foreach $curproject (sort keys %allprojects)
{
print "Project: $curproject\n";
printf " Total dirs : %5d\n", $allprojects{$curproject}->{totaldirs};
printf " Total files : %5d\n", $allprojects{$curproject}->{totalfiles};
printf " Total source files : %5d\n", $allprojects{$curproject}->{totalsourcefiles};
print " ----------------------------\n";
PrintSourceTypeSummary(\%{$projectfileinfo{$curproject}});
print " ----------------------------\n";
printf " Total 0 length files : %5d\n", $allprojects{$curproject}->{total0files};
printf " Total 0 comment files: %5d\n", $allprojects{$curproject}->{zerocomment};
printf " Largest file : %s (%5d lines)\n", $allprojects{$curproject}->{maxfilename}, $allprojects{$curproject}->{maxfilesize};
printf " Total switches : %5d\n", $allprojects{$curproject}->{totalswitches};
printf " Total classes : %5d\n", $allprojects{$curproject}->{totalclasses};
printf " Total lines : %5d\n", $allprojects{$curproject}->{totallines};
printf " Code lines : %5d\n", $allprojects{$curproject}->{totalcodelines};
printf " Percent code lines : %5.0f\%\n",
$allprojects{$curproject}->{totallines} ? ($allprojects{$curproject}->{totalcodelines}*100.0)/$allprojects{$curproject}->{totallines} : 0.0;
print "\n";
print '-' x 79 . "\n";
}
print "Totals:\n";
printf "Total dirs : %5d\n", $totaldirs;
printf "Total files : %5d\n", $fileinfo{total};
printf "Total source files : %5d\n", $fileinfo{source};
print "----------------------------\n";
PrintSourceTypeSummary(\%fileinfo);
print "----------------------------\n";
printf "Total 0 length files : %5d\n", $fileinfo{len0};
printf "Total 0 comment files: %5d\n", $fileinfo{zerocomment};
printf "Largest file : %s (%5d lines)\n", $maxfilename, $maxfilesize;
printf "Total switches : %5d\n", $totalswitches;
printf "Total classes : %5d\n", $totalclasses;
printf "Total lines : %5d\n", $totallines;
printf "Code lines : %5d\n", $totalcodelines;
printf "Percent code lines : %5.0f\%\n", $totallines ? ($totalcodelines*100.0)/$totallines : 0.0;
############## END OF PERL
__END__
:perldone
|
@rem = '--*-Perl-*--
@echo off
perl -x -S "%0" %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#!perl -w
#line 11
use strict;
use integer;
use File::Copy;
use Text::Tabs;
use File::Path;
#use lib '/dev/tools/bin';
my @todo = ();
my $verbose = 0;
my $recurse = 0;
my $inVBHeader;
my $inAttributes;
my $isLastBlank;
my $ilevel;
my $lineno;
my $casecounter;
my $numlines = 0;
#-----------------------------
sub initFormat
{
$inVBHeader = 1;
$inAttributes = 0;
$isLastBlank = 0;
$ilevel = 0;
$lineno = 0;
$casecounter = 0;
}
#-----------------------------
sub termFormat
{
}
#-----------------------------
my $INDENT = ' ';
my $TYP_BLANKLINE = 1;
my $TYP_CODE = 2;
my $TYP_HEADEREND = 3;
my $TYP_HDRATTRIB = 4;
my $TYP_HEADER = 5;
my $TYP_METHODSTART = 6;
my $TYP_METHODEND = 7;
my $TYP_LOOPEND = 8;
my $TYP_LOOPSTART = 9;
my $TYP_INLINEIF = 10;
my $TYP_ELSE = 11;
my $TYP_SELECT = 12;
my $TYP_SELECTEND = 13;
my $TYP_CASE = 14;
my $TYP_LABEL = 15;
#-----------------------------
my %decOnTokens =
(
$TYP_METHODEND => 1,
$TYP_SELECTEND => 1,
$TYP_LOOPEND => 1,
$TYP_ELSE => 1,
);
#-----------------------------
my %incOnTokens =
(
$TYP_METHODSTART => 1,
$TYP_LOOPSTART => 1,
$TYP_ELSE => 1,
$TYP_SELECT => 1,
$TYP_CASE => 1,
) ;
#-----------------------------
sub formatLine($$)
{
my ($line, $rnewlines) = @_;
$lineno++;
$numlines++;
#format here...
my $linetype;
my $indent = '';
while(1)
{
$linetype = 0;
if ($inVBHeader or $inAttributes)
{
if ($line =~ /^END$/o)
{
$linetype = $TYP_HEADEREND;
}
elsif ($line =~ /^Attribute/o)
{
$linetype = $TYP_HDRATTRIB;
}
else
{
$linetype = $TYP_HEADER;
}
}
if ($linetype == 0)
{
$line =~ s/[ \t]+$//o; # remove trailing ws
$line =~ s/^\s+//o; # remove leading ws
$line = expand($line) if $line =~ /\t/; # remove tabs
if ($line =~ /^$/o)
{
$linetype = $TYP_BLANKLINE;
}
elsif ($line =~ /^if\s+.+\s+then\s+[^' ]/oi) #must be before normal 'if'
{
$linetype = $TYP_INLINEIF;
}
elsif ($line =~ /^(if|for|while|with)\s+/oi)
{
$linetype = $TYP_LOOPSTART;
}
elsif ($line =~ /^else\s*/oi)
{
$linetype = $TYP_ELSE ;
}
elsif ($line =~ /^end\s+(if|sub|with|type|enum|function|property)\s*/oi)
{
$linetype = $TYP_METHODEND;
}
elsif ($line =~ /^(private|public|friend)\s+(sub|type|enum|function|property)\s*/oi)
{
$linetype = $TYP_METHODSTART;
}
elsif ($line =~ /^(sub|type|function|property)[ \n]/oi)
{
$linetype = $TYP_METHODSTART;
}
elsif ($line =~ /^(next|wend|loop)[ \n]/oi)
{
$linetype = $TYP_LOOPEND;
}
elsif ($line =~ /^do\s+(while|until)\s+/oi)
{
$linetype = $TYP_LOOPSTART;
}
elsif ($line =~ /^select\s+/oi)
{
$linetype = $TYP_SELECT ;
delete ($decOnTokens{$TYP_CASE});
$casecounter = 0;
}
elsif ($line =~ /^end\s+select\s*/oi)
{
$linetype = $TYP_SELECTEND;
$ilevel-- if $casecounter > 0;
}
elsif ($line =~ /^case\s+/oi)
{
$casecounter++;
$linetype = $TYP_CASE;
$decOnTokens{$TYP_CASE} = 1 if $casecounter > 1;
}
elsif ($line =~ /^\w+\s*:/oi)
{
$linetype = $TYP_LABEL;
}
else
{
$linetype = $TYP_CODE;
}
}
if ($inVBHeader)
{
if ($linetype eq $TYP_HEADEREND or $linetype eq $TYP_HDRATTRIB)
{
$inVBHeader = 0;
$inAttributes = 1;
next if ($linetype eq $TYP_HDRATTRIB);
}
}
elsif ($inAttributes)
{
if ($linetype != $TYP_HDRATTRIB)
{
$inAttributes = 0;
next;
}
}
elsif ($linetype == $TYP_BLANKLINE)
{
return if ($isLastBlank);
$isLastBlank = 1;
}
else
{
$isLastBlank = 0;
$ilevel-- if exists($decOnTokens{$linetype});
warn "***ERROR: ilevel below zero: line($lineno) \n" if $ilevel < 0;
$indent = ($INDENT x $ilevel) if $linetype != $TYP_LABEL;
$ilevel++ if exists($incOnTokens{$linetype});
}
last;
}
$line = "\n" if ($line eq '');
#printf "%2d %s%s", $linetype, $indent, $line;
push @$rnewlines, "$indent$line";
}
#-----------------------------
sub forAllLines($$)
{
my ($rlines, $rnewlines) = @_;
initFormat();
foreach my $line (@$rlines)
{
#chomp $line;
formatLine($line, $rnewlines);
}
warn "***ERROR: ilevel != zero ($ilevel)\n" if $ilevel != 0;
#warn "***ERROR: still in header?" if ($inVBHeader or $inAttributes);
termFormat();
}
#-----------------------------
sub createBackup($$)
{
my ($f, $fbak) = @_;
unlink $fbak;
rename ($f, $fbak) or die "Can't create backup for $f: $!\n";
chmod 0644, $fbak;
}
#-----------------------------
sub slurpFile($$)
{
my ($f, $rlines) = @_;
open(FH, "< $f") or die "opening: $!";
@$rlines = <FH>;
close(FH) or die "closing: $!";
}
#-----------------------------
sub saveFormattedFile($$)
{
my ($f, $rnewlines) = @_;
open(FH, "> $f") or die "opening: $!";
print FH @$rnewlines;
close(FH) or die "closing: $!";
}
#-----------------------------
sub formatFile($)
{
my ($f) = @_;
my $fbak = "$f.bak";
createBackup($f, $fbak);
my @lines;
my @newlines;
slurpFile($fbak, \@lines);
forAllLines(\@lines, \@newlines);
saveFormattedFile($f, \@newlines);
}
#-----------------------------
sub formatAllFiles
{
foreach my $f (@_)
{
print "format file: $f\n";
formatFile($f);
}
}
#-----------------------------
sub processEntity($)
{
my ($t) = @_;
my @files = ();
if (-d $t)
{
my $dir = $t;
print "Processing Directory '$dir'\n" if $verbose;
opendir(DIR, $dir) or die "can't open directory $dir: $!\n";
my @all = readdir(DIR);
print "Directory '$dir' has ", scalar @all, " entries\n" if $verbose;
@files =
map {"$dir\\$_"}
grep {/\.(cls|bas|frm)$/}
@all;
if ($recurse)
{
my @dirs =
grep{-d $_ }
map {"$dir\\$_"}
grep {! /^\.\.?/}
@all;
push @todo, @dirs;
print "Directory '$dir' has ", scalar @dirs, " directories\n" if $verbose;
}
closedir(DIR);
print "Directory '$dir' has ", scalar @files, " VB files\n" if $verbose;
}
else
{
print "Processing file: '$t'\n" if $verbose;
-e $t or die "can't find file $t: $!\n";
push @files, $t;
}
formatAllFiles(@files);
}
#-----
## main
@todo = ();
my $t = ".";
foreach my $t(@ARGV)
{
if ($t eq '-v')
{
$verbose = 1;
}
elsif ($t eq '-r')
{
$recurse = 1;
}
else
{
push @todo, $t;
}
}
push @todo, '.' if (scalar @todo == 0);
#my ($buser, $bsystem, $x1, $x2) = times;
#foreach (1..10)
#{
foreach my $entity (@todo)
{
processEntity($entity);
}
#}
#my ($auser, $asystem, $x3, $x4) = times;
#no integer;
#print "User time : ", ($auser - $buser) , "\n";
#print "System time: ", ($asystem - $bsystem) , "\n";
print "Number of lines: ", $numlines, "\n" if $verbose;
__END__
:endofperl
|
'------------------------------------------------------------------------------
'FILE DESCRIPTION: local macros for jaa
'------------------------------------------------------------------------------
'This routine has many uses if you are trying to determine the type of source
' file.
'Return value: 0 Unknown file type
' 1 C-related file, this includes .c, .cpp, .cxx, .h, .hpp, .hxx
' 2 Java-related file, this includes .jav, .java
' 3 ODL-style file, .odl, .idl
' 4 Resource file, .rc, .rc2
' 5 HTML-style file, this includes .html, and .htm
' 6 VBS-style file, .dsm
' 7 Def-style file, .def
'USE: Pass this function the document that you wish to get information for.
Function FileType (ByVal doc)
ext = doc.Name
FileType = 0
pos = Instr(ext, ".")
if pos > 0 then
Do While pos <> 1
ext = Mid(ext, pos, Len(ext) - pos + 1)
pos = Instr(ext, ".")
Loop
ext = LCase(ext)
end if
If ext = ".rc" Or ext = ".rc2" Then
FileType = 4
ElseIf doc.Language = dsCPP Then
FileType = 1
ElseIf doc.Language = dsJava Then
FileType = 2
ElseIf doc.Language = dsIDL Then
FileType = 3
ElseIf doc.Language = dsHTML_IE3 Or doc.Language = dsHTML_RFC1866 Then
FileType = 5
ElseIf doc.Language = dsVBSMacro Then '
FileType = 6
ElseIf ext = ".def" Then
FileType = 7
Else
FileType = 0
End If
End Function
Sub CommentBlk()
'DESCRIPTION: Comment a selected area
Dim win
set win = ActiveWindow
if win.type <> "Text" Then
MsgBox "This macro can only be run when a text editor window is active."
exit sub
end if
TypeOfFile = FileType(ActiveDocument)
If TypeOfFile > 0 And TypeOfFile < 5 Then 'C & Java use the same of comments.
ActiveDocument.Selection.ReplaceText "^", "//", dsMatchRegExp
'ActiveDocument.Selection = "/*" + ActiveDocument.Selection + "*/"
ElseIf TypeOfFile = 5 Then
ActiveDocument.Selection = "<!-- " + ActiveDocument.Selection + " -->"
ElseIf TypeOfFile = 6 Or TypeOfFile = 7 Then
'There is no group comment like there is in the other file types,
'so we need to iterate through each line, and prepend a ' to the line.
'Also, because VBS/DEF does not have a 'end the comment at this
'particular column' delimiter, entire lines of code must be
'commented out, not sections.
If TypeOfFile = 6 Then
CommentType = " ' "
Else
CommentType = " ; "
End If
StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If
If EndLine = StartLine Then
ActiveDocument.Selection = CommentType + ActiveDocument.Selection
Else
For i = StartLine To EndLine
ActiveDocument.Selection.GoToLine i
ActiveDocument.Selection.SelectLine
ActiveDocument.Selection = CommentType + _
ActiveDocument.Selection
Next
End If
Else
MsgBox("Unable to comment the highlighted text" + vbLf + _
"because the file type was unrecognized." + vbLf + _
"If the file has not yet been saved, " + vbLf + _
"please save it and try again.")
End If
End Sub
Sub UncommentBlk()
'DESCRIPTION: Uncomment a selected area
Dim win
set win = ActiveWindow
if win.type <> "Text" Then
MsgBox "This macro can only be run when a text editor window is active."
exit sub
end if
TypeOfFile = FileType(ActiveDocument)
If TypeOfFile > 0 And TypeOfFile < 5 Then 'C & Java use the same of comments.
ActiveDocument.Selection.ReplaceText "^\(\:b*\)//", "\1", dsMatchRegExp
Else
MsgBox("Unable to uncomment the highlighted text" + vbLf + _
"because the file type was unrecognized." + vbLf + _
"If the file has not yet been saved, " + vbLf + _
"please save it and try again.")
End If
End Sub
'Sub CreateUnitTest()
'DESCRIPTION: Create a Unit Test project
'
'for each proj in Application.Projects
' for each cfg in proj.Configurations
' cfg.AddToolSettings "cl.exe", "/WX"
' cfg.MakeCurrentSettingsDefault
' next
'next
'
'End Sub
Sub SetCommonProjectSettings(ByRef config, ByVal configdir, ByVal projname)
config.AddToolSettings "mfc", 0
config.RemoveToolSettings "cl.exe", "/Gm" 'minimal rebuild
config.RemoveToolSettings "cl.exe", "/YX" 'pch
config.RemoveToolSettings "cl.exe", "/Yu" 'pch
config.AddToolSettings "cl.exe", "/Zi" 'Debug info
config.AddToolSettings "cl.exe", "/D STRICT"
config.AddToolSettings "cl.exe", "/GX" ' exceptions
config.AddToolSettings "cl.exe", "/Fd""\projects\" & configdir & "\" & projname & "/"""
config.AddToolSettings "cl.exe", "/Fo""\projects\" & configdir & "\" & projname & "/"""
config.AddToolSettings "cl.exe", "/FR""\projects\" & configdir & "\" & projname & "/"""
config.AddToolSettings "link.exe", "/incremental:no"
config.RemoveToolSettings "link.exe", "kernel32.lib"
config.RemoveToolSettings "link.exe", "user32.lib"
config.RemoveToolSettings "link.exe", "gdi32.lib"
config.RemoveToolSettings "link.exe", "winspool.lib"
config.RemoveToolSettings "link.exe", "comdlg32.lib"
config.RemoveToolSettings "link.exe", "advapi32.lib"
config.RemoveToolSettings "link.exe", "shell32.lib"
config.RemoveToolSettings "link.exe", "ole32.lib"
config.RemoveToolSettings "link.exe", "oleaut32.lib"
config.RemoveToolSettings "link.exe", "uuid.lib"
config.RemoveToolSettings "link.exe", "odbc32.lib"
config.RemoveToolSettings "link.exe", "odbccp32.lib"
config.AddToolSettings "link.exe", "/pdb:""\projects\" & configdir & "\" & projname & "\" & projname & ".pdb"""
config.AddToolSettings "link.exe", "/out:""\projects\" & configdir & "\" & projname & "\" & projname & ".exe"""
config.AddToolSettings "bscmake.exe", "/o""\projects\" & configdir & "\" & projname & "\" & projname & ".bsc"""
end sub
Sub SetDefaultProjectSettings
Dim Proj
Set Proj = ActiveProject
if (Proj.Type <> "Build") then
Exit sub
end if
Dim config
For Each config in Proj.Configurations
'eg. config.name ==> "xxxx - Win32 Debug"
'tool= cl.exe for compiler, link.exe for linker, rc.exe for resource, mfc for mfc usage
if (Right(config.Name, 5) = "Debug") then
PrintToOutputWindow "Setting for: " & proj.Name & " Config: " & Right(config.Name, 5)
call SetCommonProjectSettings(config, "debug", proj.Name)
config.AddToolSettings "cl.exe", "/MDd"
config.AddToolSettings "link.exe", "/pdbtype:sept"
' config.AddToolSettings "Output", "bob"
config.MakeCurrentSettingsDefault
elseif (Right(config.Name, 7) = "Release") then
PrintToOutputWindow "Setting for: " & proj.Name & " Config: " & Right(config.Name, 7)
call SetCommonProjectSettings(config, "release", proj.Name)
config.AddToolSettings "cl.exe", "/MD"
config.AddToolSettings "cl.exe", "/Ob2"
config.MakeCurrentSettingsDefault
else
PrintToOutputWindow "Setting for: " & proj.Name & " Unknown configuration type: " & config.Name
end if
Next
end sub
Sub JInitialize()
'DESCRIPTION: Setup keyboard bindings for IDE
'key maps: CTRL+ALT+SHIFT+A
'editor is one of: Main, Text, Dialog, Image
AddKeyBinding "CTRL+K,CTRL+C", "CommentBlk", "Text" 'comment selected code
AddKeyBinding "CTRL+K,CTRL+U", "UncommentBlk", "Text" 'uncomment selected code
AddKeyBinding "CTRL+K,CTRL+F", "SelectionFormat", "Text" 'uncomment selected code
AddKeyBinding "CTRL+SHIFT+B", "Build", "Main" 'build current project
AddKeyBinding "CTRL+SHIFT+F", "FindInFiles", "Main" 'find text in all files
AddKeyBinding "F8", "GoToNextErrorTag", "Main" 'find next error
'AddCommand
'AddCommandBarButton dsText, "utx", 1
End Sub
|