599
|
1 |
|
|
2 |
# Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
# this package does various ancillary things for windows modules
|
|
16 |
#
|
|
17 |
#
|
|
18 |
|
|
19 |
package Winutl;
|
|
20 |
|
|
21 |
my $BaseAddress='';
|
|
22 |
my @Win32LibList=();
|
|
23 |
my $Win32Resrc='';
|
|
24 |
my $CopyForStaticLinkage=0;
|
|
25 |
my $Win32StdHeaders=0;
|
|
26 |
my $MSVCVer=0;
|
|
27 |
my $MSVCSubVer=0;
|
|
28 |
|
|
29 |
require Exporter;
|
|
30 |
@ISA=qw(Exporter);
|
|
31 |
@EXPORT=qw(
|
|
32 |
Winutl_Help_Mmp
|
|
33 |
|
|
34 |
Winutl_DoMmp_Parse
|
|
35 |
Winutl_DoMmp
|
|
36 |
|
|
37 |
Winutl_BaseAddress
|
|
38 |
Winutl_Win32LibList
|
|
39 |
Winutl_Win32Resrc
|
|
40 |
Winutl_CopyForStaticLinkage
|
|
41 |
Winutl_Win32StdHeaders
|
|
42 |
|
|
43 |
Winutl_AdjustTargetPath
|
|
44 |
|
|
45 |
Winutl_MSVCVer
|
|
46 |
Winutl_MSVCSubVer
|
|
47 |
|
|
48 |
Winutl_CheckSourceMMPMetaData
|
|
49 |
);
|
|
50 |
|
|
51 |
use Genutl;
|
|
52 |
use E32Variant;
|
|
53 |
use CheckSource;
|
|
54 |
use Pathutl;
|
|
55 |
use Cwd;
|
|
56 |
|
|
57 |
my %CheckSourceMMPMetaData;
|
|
58 |
|
|
59 |
sub Winutl_Help_Mmp {
|
|
60 |
# provide the help text for START <windows platforms> END blocks
|
|
61 |
|
|
62 |
print
|
|
63 |
"BASEADDRESS [base address for dll loading]\n",
|
|
64 |
"WIN32_LIBRARY [win32 libraries]\n",
|
|
65 |
"WIN32_RESOURCE [win32 resource]\n",
|
|
66 |
"COPY_FOR_STATIC_LINKAGE // copy dll from emulated Z drive\n",
|
|
67 |
"WIN32_HEADERS // instruct compiler to look into standard header directories\n",
|
|
68 |
" // (implied by WIN32_LIBRARY)\n"
|
|
69 |
;
|
|
70 |
}
|
|
71 |
|
|
72 |
sub Winutl_DoMmp_Parse ($$) {
|
|
73 |
# takes reference to platform text and semicolon-separated list
|
|
74 |
# of compiler-specific include directories
|
|
75 |
my @PlatTxt=@{$_[0]};
|
|
76 |
my $CompilerIncPaths=$_[1];
|
|
77 |
|
|
78 |
# process the START <windows platforms> END blocks
|
|
79 |
|
|
80 |
my $BaseTrg=&main::BaseTrg;
|
|
81 |
my $BasicTrgType=&main::BasicTrgType;
|
|
82 |
my $MakeFilePath=&main::MakeFilePath;
|
|
83 |
my $MMPFILE=&main::MmpFile;
|
|
84 |
|
|
85 |
# set up START WINS ... END block module variables
|
|
86 |
my @MmpWarn=();
|
|
87 |
my $Line;
|
|
88 |
LINE: foreach $Line (@PlatTxt) {
|
|
89 |
my $LineInfo=shift @$Line;
|
|
90 |
|
|
91 |
$LineInfo =~ /^(.+)\((\d+)\)$/;
|
|
92 |
my $CurFile = $1;
|
|
93 |
my $LineNum = $2;
|
|
94 |
my $BldInfDir = cwd;
|
|
95 |
$BldInfDir =~ s/\//\\/g;
|
|
96 |
$BldInfDir =~ s/^\w+://;
|
|
97 |
$BldInfDir .= "\\";
|
|
98 |
|
|
99 |
$_=shift @$Line;
|
|
100 |
|
|
101 |
if (/^BASEADDRESS$/oi) {
|
|
102 |
if (@$Line) {
|
|
103 |
$BaseAddress=shift @$Line;
|
|
104 |
$BaseAddress=~s/X/x/o;
|
|
105 |
next LINE;
|
|
106 |
}
|
|
107 |
push @MmpWarn, "$LineInfo : No base address specified for keyword BASEADDRESS\n";
|
|
108 |
next LINE;
|
|
109 |
}
|
|
110 |
if (/^WIN32_LIBRARY$/oi) {
|
|
111 |
if (@$Line)
|
|
112 |
{
|
|
113 |
$Win32StdHeaders = 1;
|
|
114 |
|
|
115 |
foreach (@$Line)
|
|
116 |
{
|
|
117 |
if (/^\./)
|
|
118 |
{
|
|
119 |
# local - check for UNIX slash and physical consistency of file as it exists relative to the bld.inf
|
|
120 |
CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "WIN32_LIBRARY", $_, $LineNum, $CheckSource_PhysicalCheck, $BldInfDir);
|
|
121 |
}
|
|
122 |
else
|
|
123 |
{
|
|
124 |
# global - check for UNIX slash and assume that it must be lower case
|
|
125 |
CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "WIN32_LIBRARY", $_, $LineNum);
|
|
126 |
}
|
|
127 |
$_ = &Path_Norm($_);
|
|
128 |
push @Win32LibList, $_;
|
|
129 |
}
|
|
130 |
}
|
|
131 |
else
|
|
132 |
{
|
|
133 |
push @MmpWarn, "$LineInfo : No libraries specified for keyword WIN32_LIBRARY\n";
|
|
134 |
}
|
|
135 |
next LINE;
|
|
136 |
}
|
|
137 |
if (/^WIN32_RESOURCE$/oi) {
|
|
138 |
if (@$Line) {
|
|
139 |
$Win32Resrc=shift @$Line;
|
|
140 |
|
|
141 |
CheckSource_MetaData(%CheckSourceMMPMetaData, $CurFile, "WIN32_RESOURCE", $Win32Resrc, $LineNum, $CheckSource_PhysicalCheck);
|
|
142 |
$Win32Resrc = &Path_Norm($Win32Resrc);
|
|
143 |
|
|
144 |
$Win32Resrc=&main::Path_MakeAbs($MMPFILE, $Win32Resrc);
|
|
145 |
next LINE;
|
|
146 |
}
|
|
147 |
push @MmpWarn, "$LineInfo : No resource specified for keyword WIN32_RESOURCE\n";
|
|
148 |
next LINE;
|
|
149 |
}
|
|
150 |
if (/^COPY_FOR_STATIC_LINKAGE$/oi) {
|
|
151 |
if ($BasicTrgType!~/^DLL$/oi) {
|
|
152 |
push @MmpWarn, "$LineInfo : COPY_FOR_STATIC_LINKAGE only applies to DLLs\n";
|
|
153 |
next LINE;
|
|
154 |
}
|
|
155 |
if (&main::TrgPath eq "") {
|
|
156 |
push @MmpWarn, "$LineInfo : COPY_FOR_STATIC_LINKAGE requires TARGETPATH\n";
|
|
157 |
next LINE;
|
|
158 |
}
|
|
159 |
$CopyForStaticLinkage=1;
|
|
160 |
next LINE;
|
|
161 |
}
|
|
162 |
if (/^WIN32_HEADERS$/oi) {
|
|
163 |
$Win32StdHeaders = 1;
|
|
164 |
next LINE;
|
|
165 |
}
|
|
166 |
|
|
167 |
push @MmpWarn, "$LineInfo : Unrecognised Keyword \"$_\"\n";
|
|
168 |
}
|
|
169 |
|
|
170 |
undef $Line;
|
|
171 |
if (@MmpWarn) {
|
|
172 |
warn
|
|
173 |
"\nMMPFILE \"",$MMPFILE,"\"\n",
|
|
174 |
"START .. END BLOCK WARNINGS(S)\n",
|
|
175 |
@MmpWarn,
|
|
176 |
"\n"
|
|
177 |
;
|
|
178 |
}
|
|
179 |
undef @MmpWarn;
|
|
180 |
|
|
181 |
# if Win32 Libraries required - set the Windows standard include paths
|
|
182 |
if ($Win32StdHeaders || $Win32Resrc || &main::Plat eq 'TOOLS' || &main::Plat eq 'CWTOOLS'
|
|
183 |
|| &main::Plat eq 'TOOLS2')
|
|
184 |
{ # show where to find win32 libraries
|
|
185 |
# include env variable takes everything between ';', including spaces and '"', as part of path
|
|
186 |
my @StdIncPaths=split ';', $CompilerIncPaths;
|
|
187 |
my $path;
|
|
188 |
foreach $path (@StdIncPaths) {
|
|
189 |
$path =~ s-/-\\-go; # for those working with UNIX shells
|
|
190 |
if ($path =~ /^\+/) {
|
|
191 |
# expand CodeWarrior "recursive" entries
|
|
192 |
$path =~ s-^\+--go; # remove the + from the current entry
|
|
193 |
if (opendir DIR, $path) {
|
|
194 |
my @list = grep !/^\.\.?$/, readdir DIR;
|
|
195 |
closedir DIR;
|
|
196 |
foreach (@list) {
|
|
197 |
my $newpath="$path\\$_";
|
|
198 |
if (-d $newpath) {
|
|
199 |
push @StdIncPaths,"+$newpath"; # add subdirs for later expansion
|
|
200 |
}
|
|
201 |
}
|
|
202 |
}
|
|
203 |
}
|
|
204 |
}
|
|
205 |
&main::SetStdIncPaths(@StdIncPaths);
|
|
206 |
&main::AddPlatMacros('WIN32','_WINDOWS');
|
|
207 |
}
|
|
208 |
}
|
|
209 |
|
|
210 |
sub Winutl_DoMmp ($$) {
|
|
211 |
# takes reference to platform text and semicolon-separated list
|
|
212 |
# of compiler-specific include directories
|
|
213 |
my @PlatTxt=@{$_[0]};
|
|
214 |
my $CompilerIncPaths=$_[1];
|
|
215 |
|
|
216 |
my $Plat=&main::Plat;
|
|
217 |
if ($Plat ne "WINSCW" and $Plat ne "CWTOOLS" and $Plat ne "TOOLS2") {
|
|
218 |
# check that we're using VC6 SP3
|
|
219 |
&Winutl_MSVCVer();
|
|
220 |
}
|
|
221 |
|
|
222 |
&Winutl_DoMmp_Parse(\@PlatTxt, $CompilerIncPaths);
|
|
223 |
|
|
224 |
my $BaseTrg=&main::BaseTrg;
|
|
225 |
my $BasicTrgType=&main::BasicTrgType;
|
|
226 |
my $MakeFilePath=&main::MakeFilePath;
|
|
227 |
my $MMPFILE=&main::MmpFile;
|
|
228 |
my @UidList=&main::UidList;
|
|
229 |
|
|
230 |
if ($BasicTrgType=~/^(EXE|DLL)$/oi) {
|
|
231 |
# create the UID source file
|
|
232 |
my $priority = "EPriorityForeground";
|
|
233 |
if (&main::ProcessPriority) {
|
|
234 |
$priority="EPriority".&main::ProcessPriority;
|
|
235 |
}
|
|
236 |
|
|
237 |
my $UidText=join(
|
|
238 |
"\n",
|
|
239 |
'// Makmake-generated uid source file',
|
|
240 |
'#include <e32cmn.h>',
|
|
241 |
'#pragma data_seg(".SYMBIAN")',
|
|
242 |
'__EMULATOR_IMAGE_HEADER2('
|
|
243 |
);
|
|
244 |
foreach (@UidList) {
|
|
245 |
$UidText.="$_,";
|
|
246 |
}
|
|
247 |
my $vstr = "0x".&Genutl_VersionToHexString(&main::Version);
|
|
248 |
my $vid = &main::VendorId;
|
|
249 |
if(!$vid) { $vid="0"; }
|
|
250 |
$UidText.="$priority,".(&main::CapabilityFlags)[0]."u,".(&main::CapabilityFlags)[1]."u,".&main::SecureId.",".$vid.",$vstr,"; # second capability word always 0 for now
|
|
251 |
if (&main::AllowDllData) {
|
|
252 |
$UidText.="1,";
|
|
253 |
} else {
|
|
254 |
$UidText.="0,";
|
|
255 |
}
|
|
256 |
chop $UidText;
|
|
257 |
$UidText.=")\n";
|
|
258 |
$UidText.="#pragma data_seg()\n";
|
|
259 |
unless (&main::Plat eq 'TOOLS' || &main::Plat eq 'CWTOOLS' || &main::Plat eq 'TOOLS2' ) {
|
|
260 |
&main::AddSrc("$MakeFilePath$BaseTrg.UID.CPP", $UidText);
|
|
261 |
};
|
|
262 |
}
|
|
263 |
|
|
264 |
}
|
|
265 |
|
|
266 |
sub Winutl_BaseAddress () {
|
|
267 |
$BaseAddress;
|
|
268 |
}
|
|
269 |
|
|
270 |
sub Winutl_Win32LibList () {
|
|
271 |
@Win32LibList;
|
|
272 |
}
|
|
273 |
|
|
274 |
sub Winutl_Win32Resrc () {
|
|
275 |
$Win32Resrc;
|
|
276 |
}
|
|
277 |
|
|
278 |
sub Winutl_CopyForStaticLinkage () {
|
|
279 |
$CopyForStaticLinkage;
|
|
280 |
}
|
|
281 |
|
|
282 |
sub Winutl_Win32StdHeaders () {
|
|
283 |
$Win32StdHeaders;
|
|
284 |
}
|
|
285 |
|
|
286 |
sub Winutl_AdjustTargetPath () {
|
|
287 |
my ($TrgPathRef) = @_;
|
|
288 |
|
|
289 |
if (&main::EPOCSecurePlatform) {
|
|
290 |
|
|
291 |
my $plan=1;
|
|
292 |
my @macros = &Variant_GetMacroList;
|
|
293 |
foreach my $macro (@macros) {
|
|
294 |
if ($macro =~ m/^SYMBIAN_IGNORE_BIN_TARGETPATH.*/) {
|
|
295 |
$plan = 2;
|
|
296 |
last;
|
|
297 |
}
|
|
298 |
}
|
|
299 |
|
|
300 |
if ($plan == 1) {
|
|
301 |
# Intermediate step: TARGETPATH => COPY_FOR_STATIC_LINKAGE
|
|
302 |
$CopyForStaticLinkage = 1 if ($$TrgPathRef ne "");
|
|
303 |
} else {
|
|
304 |
# Finally: Ignore TARGETPATH and COPY_FOR_STATIC_LINKAGE
|
|
305 |
# unless it's a subdir of sys\bin
|
|
306 |
if (&main::TrgPath !~ /^Z\\sys\\bin\\.+/i) {
|
|
307 |
$$TrgPathRef = "";
|
|
308 |
$CopyForStaticLinkage = 0;
|
|
309 |
}
|
|
310 |
}
|
|
311 |
}
|
|
312 |
}
|
|
313 |
|
|
314 |
sub Winutl_MSVCVer ($) {
|
|
315 |
my $platcommand=shift;
|
|
316 |
if(!defined $platcommand) {
|
|
317 |
$platcommand=0; }
|
|
318 |
open PIPE, "LINK.EXE 2>&1 |" or die "ERROR: Can't invoke LINK.EXE\n";
|
|
319 |
my $DoneCheck=0;
|
|
320 |
while (<PIPE>) {
|
|
321 |
unless ($DoneCheck) {
|
|
322 |
if (/^.+\s+Version\s+(\d)\.(\d{2})\.((\d{4})|(\d{5})(.\d{2}))\s*$/o) {
|
|
323 |
if (($1<6) or ($1==6 and $2<0) or ($1==6 and $2==0 and $3<8447)) {
|
|
324 |
warn "WARNING: Should install MSVC6 Service Pack 3\n";
|
|
325 |
}
|
|
326 |
$MSVCVer = $1;
|
|
327 |
$MSVCSubVer = $2;
|
|
328 |
$DoneCheck=1;
|
|
329 |
}
|
|
330 |
}
|
|
331 |
}
|
|
332 |
close PIPE;
|
|
333 |
# Do not throw any error when link.exe not present while displaying
|
|
334 |
# a list of the supported platforms using bldmake plat command.
|
|
335 |
if (!$DoneCheck && !$platcommand) {
|
|
336 |
# Couldn't find version information? Might not have link.exe at all
|
|
337 |
die "ERROR: failed to find version information for LINK.EXE\n";
|
|
338 |
}
|
|
339 |
|
|
340 |
$MSVCVer;
|
|
341 |
}
|
|
342 |
|
|
343 |
sub Winutl_MSVCSubVer ($) {
|
|
344 |
my $platcommand=@_;
|
|
345 |
&Winutl_MSVCVer($platcommand);
|
|
346 |
|
|
347 |
$MSVCSubVer;
|
|
348 |
}
|
|
349 |
|
|
350 |
sub Winutl_CheckSourceMMPMetaData () {
|
|
351 |
%CheckSourceMMPMetaData;
|
|
352 |
}
|
|
353 |
|
|
354 |
1;
|