|
1 # Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. |
|
2 # |
|
3 # Redistribution and use in source and binary forms, with or without |
|
4 # modification, are permitted provided that the following conditions |
|
5 # are met: |
|
6 # |
|
7 # 1. Redistributions of source code must retain the above copyright |
|
8 # notice, this list of conditions and the following disclaimer. |
|
9 # 2. Redistributions in binary form must reproduce the above copyright |
|
10 # notice, this list of conditions and the following disclaimer in the |
|
11 # documentation and/or other materials provided with the distribution. |
|
12 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
|
13 # its contributors may be used to endorse or promote products derived |
|
14 # from this software without specific prior written permission. |
|
15 # |
|
16 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
|
17 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
19 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
|
20 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
21 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
22 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
23 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
26 |
|
27 # Module to share code to get to WebKit directories. |
|
28 |
|
29 use strict; |
|
30 use warnings; |
|
31 use FindBin; |
|
32 use File::Basename; |
|
33 |
|
34 BEGIN { |
|
35 use Exporter (); |
|
36 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
|
37 $VERSION = 1.00; |
|
38 @ISA = qw(Exporter); |
|
39 @EXPORT = qw(&chdirWebKit &baseProductDir &productDir &XcodeOptions &XcodeOptionString &XcodeOptionStringNoConfig &passedConfiguration &setConfiguration &safariPath &checkFrameworks ¤tSVNRevision); |
|
40 %EXPORT_TAGS = ( ); |
|
41 @EXPORT_OK = (); |
|
42 } |
|
43 |
|
44 our @EXPORT_OK; |
|
45 |
|
46 my $baseProductDir; |
|
47 my @baseProductDirOption; |
|
48 my $configuration; |
|
49 my $configurationForVisualStudio; |
|
50 my $configurationProductDir; |
|
51 my $sourceDir; |
|
52 my $currentSVNRevision; |
|
53 my $osXVersion; |
|
54 my $isQt; |
|
55 my $isGtk; |
|
56 |
|
57 # Variables for Win32 support |
|
58 my $vcBuildPath; |
|
59 my $windowsTmpPath; |
|
60 |
|
61 sub determineSourceDir |
|
62 { |
|
63 return if $sourceDir; |
|
64 $sourceDir = $FindBin::Bin; |
|
65 |
|
66 # walks up path checking each directory to see if it is the main WebKit project dir, |
|
67 # defined by containing JavaScriptCore, WebCore, and WebKit |
|
68 until ((-d "$sourceDir/JavaScriptCore" && -d "$sourceDir/WebCore" && -d "$sourceDir/WebKit") || (-d "$sourceDir/Internal" && -d "$sourceDir/OpenSource")) |
|
69 { |
|
70 if ($sourceDir !~ s|/[^/]+$||) { |
|
71 die "Could not find top level webkit directory above source directory using FindBin.\n"; |
|
72 } |
|
73 } |
|
74 |
|
75 $sourceDir = "$sourceDir/OpenSource" if -d "$sourceDir/OpenSource"; |
|
76 } |
|
77 |
|
78 # used for scripts which are stored in a non-standard location |
|
79 sub setSourceDir($) |
|
80 { |
|
81 ($sourceDir) = @_; |
|
82 } |
|
83 |
|
84 sub determineBaseProductDir |
|
85 { |
|
86 return if defined $baseProductDir; |
|
87 determineSourceDir(); |
|
88 if (isOSX()) { |
|
89 open PRODUCT, "defaults read com.apple.Xcode PBXApplicationwideBuildSettings 2> /dev/null |" or die; |
|
90 $baseProductDir = join '', <PRODUCT>; |
|
91 close PRODUCT; |
|
92 |
|
93 $baseProductDir = $1 if $baseProductDir =~ /SYMROOT\s*=\s*\"(.*?)\";/s; |
|
94 undef $baseProductDir unless $baseProductDir =~ /^\//; |
|
95 |
|
96 if (!defined($baseProductDir)) { |
|
97 open PRODUCT, "defaults read com.apple.Xcode PBXProductDirectory 2> /dev/null |" or die; |
|
98 $baseProductDir = <PRODUCT>; |
|
99 close PRODUCT; |
|
100 if ($baseProductDir) { |
|
101 chomp $baseProductDir; |
|
102 undef $baseProductDir unless $baseProductDir =~ /^\//; |
|
103 } |
|
104 } |
|
105 } else { |
|
106 $baseProductDir = $ENV{"WEBKITOUTPUTDIR"}; |
|
107 if (isCygwin() && $baseProductDir) { |
|
108 my $unixBuildPath = `cygpath --unix \"$baseProductDir\"`; |
|
109 chomp $unixBuildPath; |
|
110 $baseProductDir = $unixBuildPath; |
|
111 } |
|
112 } |
|
113 |
|
114 if ($baseProductDir && isOSX()) { |
|
115 $baseProductDir =~ s|^\Q$(SRCROOT)/..\E$|$sourceDir|; |
|
116 $baseProductDir =~ s|^\Q$(SRCROOT)/../|$sourceDir/|; |
|
117 $baseProductDir =~ s|^~/|$ENV{HOME}/|; |
|
118 die "Can't handle Xcode product directory with a ~ in it.\n" if $baseProductDir =~ /~/; |
|
119 die "Can't handle Xcode product directory with a variable in it.\n" if $baseProductDir =~ /\$/; |
|
120 @baseProductDirOption = (); |
|
121 } |
|
122 |
|
123 if (!defined($baseProductDir)) { |
|
124 $baseProductDir = "$sourceDir/WebKitBuild"; |
|
125 @baseProductDirOption = ("SYMROOT=$baseProductDir", "OBJROOT=$baseProductDir") if (isOSX()); |
|
126 if (isCygwin()) { |
|
127 my $dosBuildPath = `cygpath --windows \"$baseProductDir\"`; |
|
128 chomp $dosBuildPath; |
|
129 $ENV{"WEBKITOUTPUTDIR"} = $dosBuildPath; |
|
130 } |
|
131 } |
|
132 } |
|
133 |
|
134 sub setBaseProductDir($) |
|
135 { |
|
136 ($baseProductDir) = @_; |
|
137 } |
|
138 |
|
139 sub determineConfiguration |
|
140 { |
|
141 return if defined $configuration; |
|
142 determineBaseProductDir(); |
|
143 if (open CONFIGURATION, "$baseProductDir/Configuration") { |
|
144 $configuration = <CONFIGURATION>; |
|
145 close CONFIGURATION; |
|
146 } |
|
147 if ($configuration) { |
|
148 chomp $configuration; |
|
149 # compatibility for people who have old Configuration files |
|
150 $configuration = "Release" if $configuration eq "Deployment"; |
|
151 $configuration = "Debug" if $configuration eq "Development"; |
|
152 } else { |
|
153 $configuration = "Release"; |
|
154 } |
|
155 } |
|
156 |
|
157 sub determineConfigurationForVisualStudio |
|
158 { |
|
159 return if defined $configurationForVisualStudio; |
|
160 determineConfiguration(); |
|
161 $configurationForVisualStudio = $configuration; |
|
162 return unless $configuration eq "Debug"; |
|
163 setupCygwinEnv(); |
|
164 chomp(my $dir = `cygpath -ua '$ENV{WEBKITLIBRARIESDIR}'`); |
|
165 $configurationForVisualStudio = "Debug_Internal" if -f "$dir/bin/CoreFoundation_debug.dll"; |
|
166 } |
|
167 |
|
168 sub determineConfigurationProductDir |
|
169 { |
|
170 return if defined $configurationProductDir; |
|
171 determineBaseProductDir(); |
|
172 if(isCygwin()) { |
|
173 $configurationProductDir = "$baseProductDir/bin"; |
|
174 } else { |
|
175 determineConfiguration(); |
|
176 $configurationProductDir = "$baseProductDir/$configuration"; |
|
177 } |
|
178 } |
|
179 |
|
180 sub setConfigurationProductDir($) |
|
181 { |
|
182 ($configurationProductDir) = @_; |
|
183 } |
|
184 |
|
185 sub determineCurrentSVNRevision |
|
186 { |
|
187 return if defined $currentSVNRevision; |
|
188 determineSourceDir(); |
|
189 my $svnInfo = `LC_ALL=C svn info $sourceDir | grep Revision:`; |
|
190 ($currentSVNRevision) = ($svnInfo =~ m/Revision: (\d+).*/g); |
|
191 die "Unable to determine current SVN revision in $sourceDir" unless (defined $currentSVNRevision); |
|
192 return $currentSVNRevision; |
|
193 } |
|
194 |
|
195 |
|
196 sub chdirWebKit |
|
197 { |
|
198 determineSourceDir(); |
|
199 chdir $sourceDir or die; |
|
200 } |
|
201 |
|
202 sub baseProductDir |
|
203 { |
|
204 determineBaseProductDir(); |
|
205 return $baseProductDir; |
|
206 } |
|
207 |
|
208 sub sourceDir |
|
209 { |
|
210 determineSourceDir(); |
|
211 return $sourceDir; |
|
212 } |
|
213 |
|
214 sub productDir |
|
215 { |
|
216 determineConfigurationProductDir(); |
|
217 return $configurationProductDir; |
|
218 } |
|
219 |
|
220 sub configuration() |
|
221 { |
|
222 determineConfiguration(); |
|
223 return $configuration; |
|
224 } |
|
225 |
|
226 sub configurationForVisualStudio() |
|
227 { |
|
228 determineConfigurationForVisualStudio(); |
|
229 return $configurationForVisualStudio; |
|
230 } |
|
231 |
|
232 sub currentSVNRevision |
|
233 { |
|
234 determineCurrentSVNRevision(); |
|
235 return $currentSVNRevision; |
|
236 } |
|
237 |
|
238 sub XcodeOptions |
|
239 { |
|
240 determineBaseProductDir(); |
|
241 determineConfiguration(); |
|
242 return (@baseProductDirOption, "-configuration", $configuration); |
|
243 } |
|
244 |
|
245 sub XcodeOptionString |
|
246 { |
|
247 return join " ", XcodeOptions(); |
|
248 } |
|
249 |
|
250 sub XcodeOptionStringNoConfig |
|
251 { |
|
252 return join " ", @baseProductDirOption; |
|
253 } |
|
254 |
|
255 my $passedConfiguration; |
|
256 my $searchedForPassedConfiguration; |
|
257 sub determinePassedConfiguration |
|
258 { |
|
259 return if $searchedForPassedConfiguration; |
|
260 $searchedForPassedConfiguration = 1; |
|
261 for my $i (0 .. $#ARGV) { |
|
262 my $opt = $ARGV[$i]; |
|
263 if ($opt =~ /^--debug$/i || $opt =~ /^--devel/i) { |
|
264 splice(@ARGV, $i, 1); |
|
265 $passedConfiguration = "Debug"; |
|
266 return; |
|
267 } |
|
268 if ($opt =~ /^--release$/i || $opt =~ /^--deploy/i) { |
|
269 splice(@ARGV, $i, 1); |
|
270 $passedConfiguration = "Release"; |
|
271 return; |
|
272 } |
|
273 } |
|
274 $passedConfiguration = undef; |
|
275 } |
|
276 |
|
277 sub passedConfiguration |
|
278 { |
|
279 determinePassedConfiguration(); |
|
280 return $passedConfiguration; |
|
281 } |
|
282 |
|
283 sub setConfiguration |
|
284 { |
|
285 if (my $config = shift @_) { |
|
286 $configuration = $config; |
|
287 return; |
|
288 } |
|
289 |
|
290 determinePassedConfiguration(); |
|
291 $configuration = $passedConfiguration if $passedConfiguration; |
|
292 } |
|
293 |
|
294 sub safariPathFromSafariBundle |
|
295 { |
|
296 my ($safariBundle) = @_; |
|
297 |
|
298 return "$safariBundle/Contents/MacOS/Safari" if isOSX(); |
|
299 return $safariBundle if isCygwin(); |
|
300 } |
|
301 |
|
302 sub installedSafariPath |
|
303 { |
|
304 my $safariBundle; |
|
305 |
|
306 if (isOSX()) { |
|
307 $safariBundle = "/Applications/Safari.app"; |
|
308 } elsif (isCygwin()) { |
|
309 $safariBundle = `"$configurationProductDir/FindSafari.exe"`; |
|
310 $safariBundle =~ s/[\r\n]+$//; |
|
311 $safariBundle = `cygpath -u '$safariBundle'`; |
|
312 $safariBundle =~ s/[\r\n]+$//; |
|
313 $safariBundle .= "Safari.exe"; |
|
314 } |
|
315 |
|
316 return safariPathFromSafariBundle($safariBundle); |
|
317 } |
|
318 |
|
319 # Locate Safari. |
|
320 sub safariPath |
|
321 { |
|
322 # Use WEBKIT_SAFARI environment variable if present. |
|
323 my $safariBundle = $ENV{WEBKIT_SAFARI}; |
|
324 if (!$safariBundle) { |
|
325 determineConfigurationProductDir(); |
|
326 # Use Safari.app in product directory if present (good for Safari development team). |
|
327 if (isOSX() && -d "$configurationProductDir/Safari.app") { |
|
328 $safariBundle = "$configurationProductDir/Safari.app"; |
|
329 } elsif (isCygwin() && -x "$configurationProductDir/bin/Safari.exe") { |
|
330 $safariBundle = "$configurationProductDir/bin/Safari.exe"; |
|
331 } else { |
|
332 return installedSafariPath(); |
|
333 } |
|
334 } |
|
335 my $safariPath = safariPathFromSafariBundle($safariBundle); |
|
336 die "Can't find executable at $safariPath.\n" if isOSX() && !-x $safariPath; |
|
337 return $safariPath; |
|
338 } |
|
339 |
|
340 sub builtDylibPathForName |
|
341 { |
|
342 my $framework = shift; |
|
343 determineConfigurationProductDir(); |
|
344 if (isQt() or isGtk()) { |
|
345 return "$configurationProductDir/$framework"; |
|
346 } |
|
347 if (isOSX()) { |
|
348 return "$configurationProductDir/$framework.framework/Versions/A/$framework"; |
|
349 } |
|
350 if (isCygwin()) { |
|
351 if ($framework eq "JavaScriptCore") { |
|
352 return "$baseProductDir/lib/$framework.lib"; |
|
353 } else { |
|
354 return "$baseProductDir/$framework.intermediate/$configuration/$framework.intermediate/$framework.lib"; |
|
355 } |
|
356 } |
|
357 |
|
358 die "Unsupported platform, can't determine built library locations."; |
|
359 } |
|
360 |
|
361 # Check to see that all the frameworks are built. |
|
362 sub checkFrameworks |
|
363 { |
|
364 return if isCygwin(); |
|
365 my @frameworks = ("JavaScriptCore", "WebCore"); |
|
366 push(@frameworks, "WebKit") if isOSX() and not isGtk() and not isQt(); |
|
367 for my $framework (@frameworks) { |
|
368 my $path = builtDylibPathForName($framework); |
|
369 die "Can't find built framework at \"$path\".\n" unless -x $path; |
|
370 } |
|
371 } |
|
372 |
|
373 sub hasSVGSupport |
|
374 { |
|
375 return 0 if isCygwin(); |
|
376 |
|
377 my $path = shift; |
|
378 |
|
379 if (isQt()) { |
|
380 return 1; |
|
381 } |
|
382 |
|
383 if (isGtk() and $path =~ /WebCore/) { |
|
384 $path .= "/../lib/libWebKitGtk.so"; |
|
385 } |
|
386 |
|
387 open NM, "-|", "nm", $path or die; |
|
388 my $hasSVGSupport = 0; |
|
389 while (<NM>) { |
|
390 $hasSVGSupport = 1 if /SVGElement/; |
|
391 } |
|
392 close NM; |
|
393 return $hasSVGSupport; |
|
394 } |
|
395 |
|
396 sub removeLibraryDependingOnSVG |
|
397 { |
|
398 my $frameworkName = shift; |
|
399 my $shouldHaveSVG = shift; |
|
400 |
|
401 my $path = builtDylibPathForName($frameworkName); |
|
402 return unless -x $path; |
|
403 |
|
404 my $hasSVG = hasSVGSupport($path); |
|
405 system "rm -f $path" if ($shouldHaveSVG xor $hasSVG); |
|
406 } |
|
407 |
|
408 sub checkWebCoreSVGSupport |
|
409 { |
|
410 my $required = shift; |
|
411 my $framework = "WebCore"; |
|
412 my $path = builtDylibPathForName($framework); |
|
413 my $hasSVG = hasSVGSupport($path); |
|
414 if ($required && !$hasSVG) { |
|
415 die "$framework at \"$path\" does not include SVG Support, please run build-webkit --svg\n"; |
|
416 } |
|
417 return $hasSVG; |
|
418 } |
|
419 |
|
420 sub isQt() |
|
421 { |
|
422 determineIsQt(); |
|
423 return $isQt; |
|
424 } |
|
425 |
|
426 sub determineIsQt() |
|
427 { |
|
428 return if defined($isQt); |
|
429 |
|
430 # Allow override in case QTDIR is not set. |
|
431 for my $i (0 .. $#ARGV) { |
|
432 my $opt = $ARGV[$i]; |
|
433 if ($opt =~ /^--qt/i ) { |
|
434 $isQt = 1; |
|
435 return; |
|
436 } |
|
437 } |
|
438 |
|
439 # The presence of QTDIR only means Qt if --gtk is not on the command-line |
|
440 if (isGtk()) { |
|
441 $isQt = 0; |
|
442 return; |
|
443 } |
|
444 |
|
445 $isQt = defined($ENV{'QTDIR'}); |
|
446 } |
|
447 |
|
448 sub isGtk() |
|
449 { |
|
450 determineIsGtk(); |
|
451 return $isGtk; |
|
452 } |
|
453 |
|
454 sub determineIsGtk() |
|
455 { |
|
456 return if defined($isGtk); |
|
457 |
|
458 for my $i (0 .. $#ARGV) { |
|
459 my $opt = $ARGV[$i]; |
|
460 if ($opt =~ /^--gtk$/i ) { |
|
461 $isGtk = 1; |
|
462 return; |
|
463 } |
|
464 } |
|
465 $isGtk = 0; |
|
466 } |
|
467 |
|
468 sub isCygwin() |
|
469 { |
|
470 return ($^O eq "cygwin"); |
|
471 } |
|
472 |
|
473 sub isOSX() |
|
474 { |
|
475 return ($^O eq "darwin"); |
|
476 } |
|
477 |
|
478 sub determineOSXVersion() |
|
479 { |
|
480 return if $osXVersion; |
|
481 |
|
482 if (!isOSX()) { |
|
483 $osXVersion = -1; |
|
484 return; |
|
485 } |
|
486 |
|
487 my $version = `sw_vers -productVersion`; |
|
488 my @splitVersion = split(/\./, $version); |
|
489 @splitVersion >= 2 or die "Invalid version $version"; |
|
490 $osXVersion = { |
|
491 "major" => $splitVersion[0], |
|
492 "minor" => $splitVersion[1], |
|
493 "subminor" => (defined($splitVersion[2]) ? $splitVersion[2] : 0), |
|
494 }; |
|
495 } |
|
496 |
|
497 sub osXVersion() |
|
498 { |
|
499 determineOSXVersion(); |
|
500 return $osXVersion; |
|
501 } |
|
502 |
|
503 sub isTiger() |
|
504 { |
|
505 return isOSX() && osXVersion()->{"minor"} == 4; |
|
506 } |
|
507 |
|
508 sub isLeopard() |
|
509 { |
|
510 return isOSX() && osXVersion()->{"minor"} == 5; |
|
511 } |
|
512 |
|
513 sub launcherPath() |
|
514 { |
|
515 my $relativeScriptsPath = File::Spec->catpath("", File::Spec->abs2rel(dirname($0), getcwd()), ""); |
|
516 if (isGtk() || isQt()) { |
|
517 return "$relativeScriptsPath/run-launcher"; |
|
518 } elsif (isOSX() || isCygwin()) { |
|
519 return "$relativeScriptsPath/run-safari"; |
|
520 } |
|
521 } |
|
522 |
|
523 sub launcherName() |
|
524 { |
|
525 if (isGtk()) { |
|
526 return "GtkLauncher"; |
|
527 } elsif (isQt()) { |
|
528 return "QtLauncher"; |
|
529 } elsif (isOSX() || isCygwin()) { |
|
530 return "Safari"; |
|
531 } |
|
532 } |
|
533 |
|
534 sub checkRequiredSystemConfig |
|
535 { |
|
536 if (isOSX()) { |
|
537 chomp(my $productVersion = `sw_vers -productVersion`); |
|
538 if ($productVersion lt "10.4") { |
|
539 print "*************************************************************\n"; |
|
540 print "Mac OS X Version 10.4.0 or later is required to build WebKit.\n"; |
|
541 print "You have " . $productVersion . ", thus the build will most likely fail.\n"; |
|
542 print "*************************************************************\n"; |
|
543 } |
|
544 my $xcodeVersion = `xcodebuild -version`; |
|
545 if ($xcodeVersion !~ /DevToolsCore-(\d+)/ || $1 < 747) { |
|
546 print "*************************************************************\n"; |
|
547 print "Xcode Version 2.3 or later is required to build WebKit.\n"; |
|
548 print "You have an earlier version of Xcode, thus the build will\n"; |
|
549 print "most likely fail. The latest Xcode is available from the web:\n"; |
|
550 print "http://developer.apple.com/tools/xcode\n"; |
|
551 print "*************************************************************\n"; |
|
552 } |
|
553 } elsif (isGtk() or isQt()) { |
|
554 my @cmds = qw(flex bison gperf); |
|
555 my @missing = (); |
|
556 foreach my $cmd (@cmds) { |
|
557 if (not `$cmd --version`) { |
|
558 push @missing, $cmd; |
|
559 } |
|
560 } |
|
561 if (@missing) { |
|
562 my $list = join ", ", @missing; |
|
563 die "ERROR: $list missing but required to build WebKit.\n"; |
|
564 } |
|
565 } |
|
566 # Win32 and other platforms may want to check for minimum config |
|
567 } |
|
568 |
|
569 sub setupCygwinEnv() |
|
570 { |
|
571 return if !isCygwin(); |
|
572 return if $vcBuildPath; |
|
573 |
|
574 my $programFilesPath = `cygpath "$ENV{'PROGRAMFILES'}"`; |
|
575 chomp $programFilesPath; |
|
576 $vcBuildPath = "$programFilesPath/Microsoft Visual Studio 8/Common7/IDE/devenv.com"; |
|
577 if (! -e $vcBuildPath) { |
|
578 # VC++ not found, try VC++ Express |
|
579 my $vsInstallDir; |
|
580 if ($ENV{'VSINSTALLDIR'}) { |
|
581 $vsInstallDir = $ENV{'VSINSTALLDIR'}; |
|
582 } else { |
|
583 $programFilesPath = $ENV{'PROGRAMFILES'} || "C:\\Program Files"; |
|
584 $vsInstallDir = "$programFilesPath/Microsoft Visual Studio 8"; |
|
585 } |
|
586 $vsInstallDir = `cygpath "$vsInstallDir"`; |
|
587 chomp $vsInstallDir; |
|
588 $vcBuildPath = "$vsInstallDir/Common7/IDE/VCExpress.exe"; |
|
589 if (! -e $vcBuildPath) { |
|
590 print "*************************************************************\n"; |
|
591 print "Cannot find '$vcBuildPath'\n"; |
|
592 print "Please execute the file 'vcvars32.bat' from\n"; |
|
593 print "'$programFilesPath\\Microsoft Visual Studio 8\\VC\\bin\\'\n"; |
|
594 print "to setup the necessary environment variables.\n"; |
|
595 print "*************************************************************\n"; |
|
596 die; |
|
597 } |
|
598 } |
|
599 |
|
600 chomp($ENV{'WEBKITLIBRARIESDIR'} = `cygpath -wa "$sourceDir/WebKitLibraries/win"`) unless $ENV{'WEBKITLIBRARIESDIR'}; |
|
601 |
|
602 $windowsTmpPath = `cygpath -w /tmp`; |
|
603 chomp $windowsTmpPath; |
|
604 print "Building results into: ", baseProductDir(), "\n"; |
|
605 print "WEBKITOUTPUTDIR is set to: ", $ENV{"WEBKITOUTPUTDIR"}, "\n"; |
|
606 print "WEBKITLIBRARIESDIR is set to: ", $ENV{"WEBKITLIBRARIESDIR"}, "\n"; |
|
607 } |
|
608 |
|
609 sub buildVisualStudioProject($) |
|
610 { |
|
611 my ($project) = @_; |
|
612 setupCygwinEnv(); |
|
613 |
|
614 my $config = configurationForVisualStudio(); |
|
615 |
|
616 chomp(my $winProjectPath = `cygpath -w "$project"`); |
|
617 |
|
618 print "$vcBuildPath $winProjectPath /build $config\n"; |
|
619 return system $vcBuildPath, $winProjectPath, "/build", $config; |
|
620 } |
|
621 |
|
622 sub qtMakeCommand() |
|
623 { |
|
624 chomp(my $mkspec = `qmake -query QMAKE_MKSPECS`); |
|
625 $mkspec .= "/default"; |
|
626 |
|
627 my $compiler = ""; |
|
628 open SPEC, "<$mkspec/qmake.conf" or return "make"; |
|
629 while (<SPEC>) { |
|
630 if ($_ =~ /QMAKE_CC\s*=\s*([^\s]+)/) { |
|
631 $compiler = $1; |
|
632 } |
|
633 } |
|
634 close SPEC; |
|
635 |
|
636 #print "default spec: " . $mkspec . "\n"; |
|
637 #print "compiler found: " . $compiler . "\n"; |
|
638 |
|
639 if ($compiler eq "cl") { |
|
640 return "nmake"; |
|
641 } |
|
642 |
|
643 return "make"; |
|
644 } |
|
645 |
|
646 sub buildQMakeProject($$) |
|
647 { |
|
648 my ($project, $colorize) = @_; |
|
649 |
|
650 my @buildArgs = ("-r"); |
|
651 my $make = qtMakeCommand(); |
|
652 |
|
653 my $qmakebin = "qmake"; # Allow override of the qmake binary from $PATH |
|
654 for my $i (0 .. $#ARGV) { |
|
655 my $opt = $ARGV[$i]; |
|
656 if ($opt =~ /^--qmake=(.*)/i ) { |
|
657 $qmakebin = $1; |
|
658 } elsif ($opt =~ /^--qmakearg=(.*)/i ) { |
|
659 push @buildArgs, $1; |
|
660 } |
|
661 } |
|
662 |
|
663 if ($project ne "WebKit") { |
|
664 die "Qt/Linux builds JavaScriptCore/WebCore/WebKitQt in one shot! Only call it for 'WebKit'.\n"; |
|
665 } |
|
666 |
|
667 my $config = configuration(); |
|
668 my $prefix = $ENV{"WebKitInstallationPrefix"}; |
|
669 |
|
670 push @buildArgs, "OUTPUT_DIR=" . baseProductDir() . "/$config"; |
|
671 push @buildArgs, "CONFIG+=qt-port"; |
|
672 push @buildArgs, sourceDir() . "/WebKit.pro"; |
|
673 if ($config =~ m/debug/i) { |
|
674 push @buildArgs, "CONFIG-=release"; |
|
675 push @buildArgs, "CONFIG+=debug"; |
|
676 } else { |
|
677 push @buildArgs, "CONFIG+=release"; |
|
678 push @buildArgs, "CONFIG-=debug"; |
|
679 } |
|
680 |
|
681 print "Calling '$qmakebin @buildArgs' in " . baseProductDir() . "/$config ...\n\n"; |
|
682 print "Installation directory: $prefix\n" if(defined($prefix)); |
|
683 |
|
684 my $dir = baseProductDir(); |
|
685 if (! -d $dir) { |
|
686 mkdir $dir or die "Failed to create product directory " . $dir; |
|
687 } |
|
688 $dir = $dir . "/$config"; |
|
689 if (! -d $dir) { |
|
690 mkdir $dir or die "Failed to create build directory " . $dir; |
|
691 } |
|
692 |
|
693 chdir $dir or die "Failed to cd into " . $dir . "\n"; |
|
694 |
|
695 my $result = system $qmakebin, @buildArgs; |
|
696 if($result ne 0) { |
|
697 die "Failed to setup build environment using $qmakebin!\n"; |
|
698 } |
|
699 |
|
700 my $clean = $ENV{"WEBKIT_FULLBUILD"}; |
|
701 |
|
702 if(defined $clean) { |
|
703 system "$make clean"; |
|
704 } |
|
705 |
|
706 $result = system "$make"; |
|
707 chdir ".." or die; |
|
708 return $result; |
|
709 } |
|
710 |
|
711 sub buildQMakeGtkProject($$) |
|
712 { |
|
713 my ($project, $colorize) = @_; |
|
714 |
|
715 if ($project ne "WebKit") { |
|
716 die "The Gtk portbuilds JavaScriptCore/WebCore/WebKitQt in one shot! Only call it for 'WebKit'.\n"; |
|
717 } |
|
718 |
|
719 my $config = configuration(); |
|
720 my $prefix = $ENV{"WebKitInstallationPrefix"}; |
|
721 |
|
722 my @buildArgs = ("-r"); |
|
723 |
|
724 foreach my $opt (@ARGV) { |
|
725 if ($opt =~ /^--qmakearg=(.*)/i ) { |
|
726 push @buildArgs, $1; |
|
727 } |
|
728 } |
|
729 |
|
730 push @buildArgs, "OUTPUT_DIR=" . baseProductDir() . "/$config"; |
|
731 push @buildArgs, "CONFIG-=qt"; |
|
732 push @buildArgs, "CONFIG+=gtk-port"; |
|
733 push @buildArgs, sourceDir() . "/WebKit.pro"; |
|
734 if ($config =~ m/debug/i) { |
|
735 push @buildArgs, "CONFIG-=release"; |
|
736 push @buildArgs, "CONFIG+=debug"; |
|
737 } else { |
|
738 push @buildArgs, "CONFIG+=release"; |
|
739 push @buildArgs, "CONFIG-=debug"; |
|
740 } |
|
741 |
|
742 print "Calling 'qmake @buildArgs' in " . baseProductDir() . "/$config ...\n\n"; |
|
743 print "Installation directory: $prefix\n" if(defined($prefix)); |
|
744 |
|
745 system "mkdir -p " . baseProductDir() . "/$config"; |
|
746 chdir baseProductDir() . "/$config" or die "Failed to cd into " . baseProductDir() . "/$config \n"; |
|
747 |
|
748 my $result = system "qmake-qt4", @buildArgs; |
|
749 $result = system "qmake", @buildArgs if ($result ne 0); |
|
750 if ($result ne 0) { |
|
751 die "Failed to setup build environment using qmake!\n"; |
|
752 } |
|
753 |
|
754 my $clean = $ENV{"WEBKIT_FULLBUILD"}; |
|
755 |
|
756 if (defined $clean) { |
|
757 system "make clean"; |
|
758 } |
|
759 |
|
760 $result = system "make"; |
|
761 chdir ".." or die; |
|
762 return $result; |
|
763 } |
|
764 |
|
765 sub setPathForRunningWebKitApp |
|
766 { |
|
767 my ($env) = @_; |
|
768 |
|
769 return unless isCygwin(); |
|
770 |
|
771 $env->{PATH} = join(':', productDir(), dirname(installedSafariPath()), $env->{PATH} || ""); |
|
772 } |
|
773 |
|
774 1; |