#!/usr/bin/env perl eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' & eval 'exec perl -w -S $0 $argv:q' if 0; # ****************************************************************** # Author: Chad Elliott # Date: 7/10/2008 # Description: Visual Studio doesn't support a post clean build step, # so this script will do it. # ****************************************************************** # ****************************************************************** # Pragma Section # ****************************************************************** use strict; use FileHandle; use File::Basename; use Cwd; # ****************************************************************** # Data Section # ****************************************************************** my $version = '1.0'; # ****************************************************************** # Subroutine Section # ****************************************************************** sub read_proj { my($cfg, $file) = @_; my $fh = new FileHandle(); my $cmd; if (open($fh, $file)) { my $cfg_ok; my $next_name; my $next_command; while(<$fh>) { ## Locate the start of a Configuration section if (//g; $cmd =~ s/</) { if (/^Project\([^)]+\)\s*=\s*"[^\"]+",\s*"([^\"]+)"/) { clean_proj($cfg, $1); } } close($fh); } } # ****************************************************************** # Main Section # ****************************************************************** if ($#ARGV == -1) { print "PostClean v$version\n", "Usage: ", basename($0), " [CFG=] \n\n", "Executes the MPC generated VCPostCleanEventTool commands in a project.\n", "These events are ignored by VisualStudio and must be handled by an outside\n", "tool (i.e., this script).\n"; exit(0); } ## Determine the project or solution configuration (defaulting to the ## default created by MPC). my $cfg = 'Debug|Win32'; if ($ARGV[0] =~ /^CFG=(.+)/) { $cfg = $1; shift(@ARGV); } foreach my $file (@ARGV) { if ($file =~ /\.sln$/) { clean_sln($cfg, $file); } else { ## It's not a solution file, we'll assume it's a project clean_proj($cfg, $file); } }