112 BEGIN { |
111 BEGIN { |
113 $on_windows = $^O =~ /^MSWin/ ? 1 : 0; |
112 $on_windows = $^O =~ /^MSWin/ ? 1 : 0; |
114 $epocroot = $ENV{EPOCROOT}; |
113 $epocroot = $ENV{EPOCROOT}; |
115 die "ERROR: Must set the EPOCROOT environment variable.\n" if (!defined($epocroot)); |
114 die "ERROR: Must set the EPOCROOT environment variable.\n" if (!defined($epocroot)); |
116 print "Environmental epocroot - >$epocroot<\n"; |
115 print "Environmental epocroot - >$epocroot<\n"; |
|
116 $epocroot =~ s/:$/:\//, if $on_windows; |
117 $epocroot = abs_path($epocroot); |
117 $epocroot = abs_path($epocroot); |
118 die "ERROR: EPOCROOT must specify an existing directory.\n" if (!-d $epocroot); |
118 die "ERROR: EPOCROOT must specify an existing directory.\n" if (!-d $epocroot); |
119 ($epocroot_vol,$epocroot_dir,$epocroot_file) = File::Spec->splitpath($epocroot); |
119 ($epocroot_vol,$epocroot_dir,$epocroot_file) = File::Spec->splitpath($epocroot); |
120 $epocroot = File::Spec->catfile(($epocroot_vol,$epocroot_dir,$epocroot_file),undef); |
120 $epocroot = File::Spec->catfile(($epocroot_vol,$epocroot_dir,$epocroot_file),undef); |
121 print "EPOCROOT=$ENV{EPOCROOT} resolved as \"$epocroot\"\n"; |
121 print "EPOCROOT=$ENV{EPOCROOT} resolved as \"$epocroot\"\n"; |
150 ); |
150 ); |
151 |
151 |
152 $debug = $opts{debug}; |
152 $debug = $opts{debug}; |
153 $quiet = $opts{quiet} unless $debug; |
153 $quiet = $opts{quiet} unless $debug; |
154 |
154 |
155 if ($on_windows) { |
|
156 #The cpp needed a drive apparently |
|
157 $drive = $epocroot_vol; |
|
158 $epoc32path = File::Spec->catpath($epocroot_vol,$epoc32path,undef); |
|
159 } |
|
160 |
|
161 my $cwd = Cwd::cwd(); |
155 my $cwd = Cwd::cwd(); |
162 my ($vol,$dirs,$file) = File::Spec->splitpath($cwd); |
156 my ($vol,$dirs,$file) = File::Spec->splitpath($cwd); |
|
157 $drive = $vol, if ($on_windows); |
163 my @path_parts = File::Spec->splitdir($dirs); |
158 my @path_parts = File::Spec->splitdir($dirs); |
164 while(@path_parts[-1] ne "sf") { |
159 while(@path_parts[-1] ne "sf") { |
165 pop(@path_parts); |
160 pop(@path_parts); |
166 } |
161 } |
167 $base_path = File::Spec->catdir((@path_parts,"os")); |
162 $base_path = File::Spec->catdir((@path_parts,"os")); |
|
163 $base_path = "$drive$base_path", if ($on_windows); |
168 $rombuildpath = File::Spec->catfile($base_path,"kernelhwsrv","kernel","eka","rombuild"); |
164 $rombuildpath = File::Spec->catfile($base_path,"kernelhwsrv","kernel","eka","rombuild"); |
169 $base_path .= ($on_windows ? '\\' : '/'); |
165 $base_path .= ($on_windows ? '\\' : '/'); |
170 $e32path = ($on_windows ? "\\sf\\os" : "/sf/os"); |
166 $e32path = ($on_windows ? "\\sf\\os" : "/sf/os"); |
171 |
167 |
172 use E32Plat; |
168 use E32Plat; |
183 print "e32path = $e32path\n"; |
179 print "e32path = $e32path\n"; |
184 print "rombuildpath = $rombuildpath\n"; |
180 print "rombuildpath = $rombuildpath\n"; |
185 print "base_path = $base_path\n"; |
181 print "base_path = $base_path\n"; |
186 } |
182 } |
187 |
183 |
188 my $cppflags="-P -undef -Wno-endif-labels -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $drive$epoc32path "; |
184 #my $cppflags="-P -undef -Wno-endif-labels -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $drive$epoc32path "; |
|
185 my $cppflags="-P -undef -Wno-endif-labels -traditional -lang-c++ -nostdinc -I $rombuildpath -I $epoc32path "; |
189 |
186 |
190 # Include variant hrh file defines when processing oby and ibys with cpp |
187 # Include variant hrh file defines when processing oby and ibys with cpp |
191 # (Code copied from \\EPOC\master\cedar\generic\tools\romkit\tools\buildrom.pm - |
188 # (Code copied from \\EPOC\master\cedar\generic\tools\romkit\tools\buildrom.pm - |
192 # it used relative path to the working dir but we are using absolute path seems neater) |
189 # it used relative path to the working dir but we are using absolute path seems neater) |
193 |
190 |
608 |
605 |
609 sub rectify($$$) { |
606 sub rectify($$$) { |
610 my ($in, $out, $k) = @_; |
607 my ($in, $out, $k) = @_; |
611 my $lastblank; |
608 my $lastblank; |
612 my $lineno = 0; |
609 my $lineno = 0; |
|
610 my $epocroot_pattern = $on_windows ? $epocroot . '\\' : $epocroot; |
613 |
611 |
614 open(OUTPUT_FILE, "> $out") or die "Cannot open $out for output"; |
612 open(OUTPUT_FILE, "> $out") or die "Cannot open $out for output"; |
615 open(INPUT_FILE, "< $in") or die "Cannot open for $in input"; |
613 open(INPUT_FILE, "< $in") or die "Cannot open for $in input"; |
616 |
614 |
617 while ($line=<INPUT_FILE>) { |
615 while ($line=<INPUT_FILE>) { |
636 $line =~ s|//.*$||g; # Delete trailing c++ comments |
634 $line =~ s|//.*$||g; # Delete trailing c++ comments |
637 # prefix the epocroot dir to occurrences of 'epoc32' in all "KEYWORD=..." lines. |
635 # prefix the epocroot dir to occurrences of 'epoc32' in all "KEYWORD=..." lines. |
638 $line =~ s/(=\s*)[\\\/]epoc32/\1${epocroot}epoc32/i; |
636 $line =~ s/(=\s*)[\\\/]epoc32/\1${epocroot}epoc32/i; |
639 $epoc32_line = defined($1); |
637 $epoc32_line = defined($1); |
640 if (!$epoc32_line) { |
638 if (!$epoc32_line) { |
641 $line =~ /(=.*$epocroot)/i; |
639 $line =~ /(=.*$epocroot_pattern)/i; |
642 $epoc32_line = defined($1); |
640 $epoc32_line = defined($1); |
643 } |
641 } |
644 if (!$epoc32_line) { |
642 if (!$epoc32_line) { |
645 if ($k and $line=~/^\s*kerneltrace/i) { |
643 if ($k and $line=~/^\s*kerneltrace/i) { |
646 $line = "kerneltrace $k\n"; |
644 $line = "kerneltrace $k\n"; |
1043 close FILE; |
1041 close FILE; |
1044 die "\nERROR: No variant file specified in $cfgFile!\n" unless $file; |
1042 die "\nERROR: No variant file specified in $cfgFile!\n" unless $file; |
1045 $file =~ s/\s+//g; |
1043 $file =~ s/\s+//g; |
1046 $file =~ s|\\|\/|g, unless($on_windows); |
1044 $file =~ s|\\|\/|g, unless($on_windows); |
1047 |
1045 |
1048 if (File::Spec->file_name_is_absolute($file)) { |
1046 if ($on_windows) { |
1049 unless ( -f $file) { |
1047 if (File::Spec->file_name_is_absolute($file)) { |
1050 $file = substr $file,1; |
1048 my ($vol,$dir,$leaf) = File::Spec->splitpath($file); |
1051 $file = File::Spec->catfile($epocroot,$file); |
1049 unless ( $vol) { |
1052 } |
1050 $vol = substr $epocroot,0,2; |
1053 my ($vol,$dir,$leaf) = File::Spec->splitpath($file); |
1051 $file = substr $file,1; |
1054 die "\nERROR: Variant file specified in $cfgFile is not on the same volume as EPOCROOT\n", if (lc($vol) ne lc($cfg_vol)); |
1052 $file = File::Spec->catfile($vol,$dir,$leaf); |
1055 #$file = File::Spec->catfile($dir,$file); |
1053 } |
1056 } |
1054 die "\nERROR: Variant file specified in $cfgFile is not on the same volume as EPOCROOT\n", if (lc($vol) ne lc($cfg_vol)); |
1057 else { |
1055 } |
1058 $file = File::Spec->catfile($epoc32path,$file); |
1056 else { |
1059 } |
1057 $file = File::Spec->catfile($epoc32path,$file); |
|
1058 } |
|
1059 } |
|
1060 elsif (File::Spec->file_name_is_absolute($file) && ! -e $file) { |
|
1061 $file = File::Spec->catfile($epocroot,$file); |
|
1062 } |
1060 |
1063 |
1061 unless(-e $file) { |
1064 unless(-e $file) { |
1062 die "\nERROR: $cfgFile specifies $file which doesn't exist!\n"; |
1065 die "\nERROR: $cfgFile specifies $file which doesn't exist!\n"; |
1063 } |
1066 } |
1064 |
1067 |