root/openpgpsdk/trunk/util/oink_cc.pl

Revision 330 (checked in by ben, 7 years ago)

Mark up absolute path.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Cwd;
6 use Carp;
7
8 my %flags;
9 my @args;
10 my @args2;
11 my $ifile;
12 my $cc;
13 my $is_compile;
14
15 foreach my $arg (@ARGV) {
16     if($arg =~ /^--cc=(.+)$/) {
17         $cc=$1;
18     } else {
19         $flags{$arg}=1;
20         push @args,$arg;
21         if($arg =~ /^([^-].*)\.c/) {
22             $ifile="$1.i";
23             push @args2,$ifile;
24         } else {
25             push @args2,$arg;
26         }
27         $is_compile=1 if $arg eq '-c';
28     }
29 }
30
31 my $pwd=getcwd();
32
33 if($is_compile) {
34     my $cmd="$cc -E ".join(' ',@args);
35     print STDERR "$cmd\n";
36 #    system "$cmd > $ifile";
37     open(F,"$cmd|") || croak "$cmd: $!";
38     open(O,">$ifile") || croak "$ifile: $!";
39     while(my $line=<F>) {
40       if($line =~ /^\# (\d+) "([^\/<].+)"(.*)$/) {
41         print O "# $1 \"$pwd/$2\"$3\n";
42 #       print O $line;
43       } else {
44         print O $line;
45       }
46     }
47     close O;
48     close F || croak "Errors in parse: $! $?";
49     $cmd="$cc  ".join(' ',@args2);
50     print "$cmd\n";
51     system($cmd) == 0 || croak "Errors in compile: $?";
52 } else {
53     my $cmd="$cc ".join(' ',@args);
54     print STDERR "$cmd\n";
55     system $cmd;
56 }
Note: See TracBrowser for help on using the browser.