blob: 8cf3e87eecb3a523e53569fe830d2f06a1ae6e78 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#!/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
8open (FILE_HANDLE, "<$infolog") or die "Cannot open info.log\n";
9my @data = split('\[',join('',<FILE_HANDLE>));
10foreach 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}
20close FILE_HANDLE;
21#print $common_compile_option."\n";
22open (W,">$comp") or die "Cannot open output file $comp:$!\n";
23 print W $common_compile_option;
24close W;
25
26$index=index($common_include_path,$ENV{"RVCT22INC"});
27$length=length($ENV{"RVCT22INC"});
28substr($common_include_path,$index,$length,"");
29
30open (W,">$inc") or die "Cannot open output file $inc:$!\n";
31 print W $common_include_path;
32close W;
33open (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 }
44close W;