rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #!/usr/bin/perl
|
| 2 | # To parse info.log to get compile options and including paths.
|
| 3 | $infolog = $ARGV[0];
|
| 4 | $comp = $ARGV[1];
|
| 5 | $inc = $ARGV[2];
|
| 6 | $mtksub = $ARGV[3];
|
| 7 |
|
| 8 | open (FILE_HANDLE, "<$infolog") or die "Cannot open info.log\n";
|
| 9 | my @data = split('\[',join('',<FILE_HANDLE>));
|
| 10 | foreach my $set (@data) {
|
| 11 | next if($set =~ /^\s*$/);
|
| 12 | if($set =~ /COMMON OPTION \]/) {
|
| 13 | $common_compile_option = substr($set,$+[0]);
|
| 14 | } elsif($set =~ /COMMON INCLUDE PATH \]/) {
|
| 15 | $common_include_path = substr($set,$+[0]);
|
| 16 | } else {
|
| 17 | die "Unknown instruction $set";
|
| 18 | }
|
| 19 | }
|
| 20 | close FILE_HANDLE;
|
| 21 | #print $common_compile_option."\n";
|
| 22 | open (W,">$comp") or die "Cannot open output file $comp:$!\n";
|
| 23 | print W $common_compile_option;
|
| 24 | close W;
|
| 25 |
|
| 26 | $index=index($common_include_path,$ENV{"RVCT22INC"});
|
| 27 | $length=length($ENV{"RVCT22INC"});
|
| 28 | substr($common_include_path,$index,$length,"");
|
| 29 |
|
| 30 | open (W,">$inc") or die "Cannot open output file $inc:$!\n";
|
| 31 | print W $common_include_path;
|
| 32 | close W;
|
| 33 | open (W,">$mtksub") or die "Cannot open output file $mtksub:$!\n";
|
| 34 | @common_compile_option = split('\s', $common_compile_option);
|
| 35 | foreach (@common_compile_option) {
|
| 36 | next if ($_ eq "");
|
| 37 | print W "-D$_\n";
|
| 38 | }
|
| 39 | @common_include_path = split('\s', $common_include_path);
|
| 40 | foreach (@common_include_path) {
|
| 41 | next if ($_ eq "");
|
| 42 | print W "-I..\\mediatek\\$_\n";
|
| 43 | }
|
| 44 | close W;
|