#!/usr/gnu/bin/perl -w # # Name: # mscStrip.pl. # # Purpose: # Strip MS C++ directories and files from a source tree. # Directories: Debug, Release # Files: *.ncb, *.opt, *.plg # # Parameters: # Relative path to directory. # # Exit code: # 0 -> Success. # -1 -> Failure. # # Author: # Ron Savage # http://savage.net.au/index.html # # Licence: # Australian Copyright (c) 1999-2002 Ron Savage. # # All Programs of mine are 'OSI Certified Open Source Software'; # you can redistribute them and/or modify them under the terms of # The Artistic License, a copy of which is available at: # http://www.opensource.org/licenses/index.html use strict; no strict 'refs'; use File::Find; use File::Path; use Getopt::Simple qw($switch); use ExtUtils::Manifest; require 'projectLib.pl'; # ---------------------------------------------------------------------- my(@name); my($option); # ---------------------------------------------------------------------- sub found { my($name) = $File::Find::name; $name =~ tr|\\|/|; push(@name, $name); } # End of found. # ---------------------------------------------------------------------- sub init { my($default) = { 'help' => { 'type' => '', 'env' => '-', 'default' => '', 'order' => 1, }, 'myHome' => { 'type' => '=s', 'env', => '$HOME etc', 'default' => &getHome(), 'order' => 2, }, }; $option = new Getopt::Simple; if (! $option -> getOptions($default, "Usage: mscStrip.pl [options] ") ) { # Failure. exit(-1); } } # End of init. # ----------------------------------------------------------------------------- &init(); if ($#ARGV != 0) { die("Usage: $0.pl [options] \n"); } my($workDirectory) = &prepareDir($ARGV[0]); # Move into the work directory. chdir($workDirectory) || die("Can't chdir($workDirectory): $!"); find(\&found, $workDirectory); # Build a sub which recognizes what's to be deleted. my($manifest) = $ExtUtils::Manifest::MANIFEST; open(OUT, ">$manifest") || die("Can't open $manifest: $!"); while () { print OUT $_; } close(OUT); my($matchSub) = ExtUtils::Manifest::_maniskip($manifest); unlink $manifest; # Remove the directories and files. my($i); for ($i = 0; $i <= $#name; $i++) { rmtree($name[$i], 1) if (&$matchSub($name[$i]) ); } # Success. exit(0); __END__ Debug Release \.ncb$ \.opt$ \.plg$