sbsv1/abld/group/perlprep.bat
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 599 fa7a3cc6effd
permissions -rw-r--r--
Specify extenal tool with path
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
@rem
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
@rem All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
@rem This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
@rem under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
@rem which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
@rem
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
@rem Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
@rem Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
@rem
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
@rem Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
@rem
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
@rem Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
@rem
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
@echo off
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
REM a basic perl preprocessor
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
if exist %0.bat perl -x %0.bat %1 %2 %3 %4 %5
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
if exist %0 perl -x %0 %1 %2 %3 %4 %5
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
GOTO End
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
#!perl
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
use strict;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
die "Usage:\nPERLPREP [infile] [outfile]\n" unless @ARGV==2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
my ($INFILE, $OUTFILE)=map lc $_, @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
die "Can't find $INFILE\n" unless -e $INFILE;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
if ($INFILE=~/\.(bat|cmd|pm|pl)$/io) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
	open INFILE,$INFILE or die "Can't open $INFILE: $!\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
	my $FileText='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
	while (<INFILE>) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
		s/(perl)(\.exe)?\s+-w/$1$2/io;		# remove perl -w switch - has to be first switch
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
		s/use\s+strict;\s*\n//oe;	# remove use strict; statement
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
		$FileText.=$_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
	close INFILE or die "Can't close $INFILE: $!\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
	open OUTFILE,">$OUTFILE" or die "Can't open $OUTFILE: $!\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
	print OUTFILE $FileText;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
	close OUTFILE or die "Can't close $OUTFILE: $!\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
	system "copy $INFILE $OUTFILE";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
__END__
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
:End
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58