PageRenderTime 941ms CodeModel.GetById 23ms RepoModel.GetById 10ms app.codeStats 0ms

/tags/Robespierre_2.0_post-merge/WebKitTools/Scripts/webkitdirs.pm

https://github.com/weissms/owb-mirror
Perl | 734 lines | 623 code | 73 blank | 38 comment | 72 complexity | 79073607f96949e2985608824345d971 MD5 | raw file
  1. # Copyright (C) 2005, 2006 Apple Computer, 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. # Module to share code to get to WebKit directories.
  27. use strict;
  28. use warnings;
  29. use FindBin;
  30. BEGIN {
  31. use Exporter ();
  32. our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
  33. $VERSION = 1.00;
  34. @ISA = qw(Exporter);
  35. @EXPORT = qw(&chdirWebKit &baseProductDir &productDir &XcodeOptions &XcodeOptionString &XcodeOptionStringNoConfig &passedConfiguration &setConfiguration &safariPath &checkFrameworks &currentSVNRevision);
  36. %EXPORT_TAGS = ( );
  37. @EXPORT_OK = ();
  38. }
  39. our @EXPORT_OK;
  40. my $baseProductDir;
  41. my @baseProductDirOption;
  42. my $configuration;
  43. my $configurationProductDir;
  44. my $sourceDir;
  45. my $currentSVNRevision;
  46. my $osXVersion;
  47. my $isQt;
  48. my $isGtk;
  49. # Variables for Win32 support
  50. my $vcBuildPath;
  51. my $windowsTmpPath;
  52. sub determineSourceDir
  53. {
  54. return if $sourceDir;
  55. $sourceDir = $FindBin::Bin;
  56. # walks up path checking each directory to see if it is the main WebKit project dir,
  57. # defined by containing JavaScriptCore, WebCore, and WebKit
  58. until ((-d "$sourceDir/JavaScriptCore" && -d "$sourceDir/WebCore" && -d "$sourceDir/WebKit") || (-d "$sourceDir/Internal" && -d "$sourceDir/OpenSource"))
  59. {
  60. if ($sourceDir !~ s|/[^/]+$||) {
  61. die "Could not find top level webkit directory above source directory using FindBin.\n";
  62. }
  63. }
  64. $sourceDir = "$sourceDir/OpenSource" if -d "$sourceDir/OpenSource";
  65. }
  66. # used for scripts which are stored in a non-standard location
  67. sub setSourceDir($)
  68. {
  69. ($sourceDir) = @_;
  70. }
  71. sub determineBaseProductDir
  72. {
  73. return if defined $baseProductDir;
  74. determineSourceDir();
  75. if (isOSX()) {
  76. open PRODUCT, "defaults read com.apple.Xcode PBXApplicationwideBuildSettings 2> /dev/null |" or die;
  77. $baseProductDir = join '', <PRODUCT>;
  78. close PRODUCT;
  79. $baseProductDir = $1 if $baseProductDir =~ /SYMROOT\s*=\s*\"(.*?)\";/s;
  80. undef $baseProductDir unless $baseProductDir =~ /^\//;
  81. if (!defined($baseProductDir)) {
  82. open PRODUCT, "defaults read com.apple.Xcode PBXProductDirectory 2> /dev/null |" or die;
  83. $baseProductDir = <PRODUCT>;
  84. close PRODUCT;
  85. if ($baseProductDir) {
  86. chomp $baseProductDir;
  87. undef $baseProductDir unless $baseProductDir =~ /^\//;
  88. }
  89. }
  90. } else {
  91. $baseProductDir = $ENV{"WEBKITOUTPUTDIR"};
  92. if (isCygwin() && $baseProductDir) {
  93. my $unixBuildPath = `cygpath --unix \"$baseProductDir\"`;
  94. chomp $unixBuildPath;
  95. $baseProductDir = $unixBuildPath;
  96. }
  97. }
  98. if ($baseProductDir && isOSX()) {
  99. $baseProductDir =~ s|^\Q$(SRCROOT)/..\E$|$sourceDir|;
  100. $baseProductDir =~ s|^\Q$(SRCROOT)/../|$sourceDir/|;
  101. $baseProductDir =~ s|^~/|$ENV{HOME}/|;
  102. die "Can't handle Xcode product directory with a ~ in it.\n" if $baseProductDir =~ /~/;
  103. die "Can't handle Xcode product directory with a variable in it.\n" if $baseProductDir =~ /\$/;
  104. @baseProductDirOption = ();
  105. }
  106. if (!defined($baseProductDir)) {
  107. $baseProductDir = "$sourceDir/WebKitBuild";
  108. @baseProductDirOption = ("SYMROOT=$baseProductDir", "OBJROOT=$baseProductDir") if (isOSX());
  109. if (isCygwin()) {
  110. my $dosBuildPath = `cygpath --windows \"$baseProductDir\"`;
  111. chomp $dosBuildPath;
  112. $ENV{"WEBKITOUTPUTDIR"} = $dosBuildPath;
  113. }
  114. }
  115. }
  116. sub setBaseProductDir($)
  117. {
  118. ($baseProductDir) = @_;
  119. }
  120. sub determineConfiguration
  121. {
  122. return if defined $configuration;
  123. determineBaseProductDir();
  124. if (open CONFIGURATION, "$baseProductDir/Configuration") {
  125. $configuration = <CONFIGURATION>;
  126. close CONFIGURATION;
  127. }
  128. if ($configuration) {
  129. chomp $configuration;
  130. # compatibility for people who have old Configuration files
  131. $configuration = "Release" if $configuration eq "Deployment";
  132. $configuration = "Debug" if $configuration eq "Development";
  133. } else {
  134. $configuration = "Release";
  135. }
  136. }
  137. sub determineConfigurationProductDir
  138. {
  139. return if defined $configurationProductDir;
  140. determineBaseProductDir();
  141. if(isCygwin()) {
  142. $configurationProductDir = "$baseProductDir/bin";
  143. } else {
  144. determineConfiguration();
  145. $configurationProductDir = "$baseProductDir/$configuration";
  146. }
  147. }
  148. sub setConfigurationProductDir($)
  149. {
  150. ($configurationProductDir) = @_;
  151. }
  152. sub determineCurrentSVNRevision
  153. {
  154. return if defined $currentSVNRevision;
  155. determineSourceDir();
  156. my $svnInfo = `LC_ALL=C svn info $sourceDir | grep Revision:`;
  157. ($currentSVNRevision) = ($svnInfo =~ m/Revision: (\d+).*/g);
  158. die "Unable to determine current SVN revision in $sourceDir" unless (defined $currentSVNRevision);
  159. return $currentSVNRevision;
  160. }
  161. sub chdirWebKit
  162. {
  163. determineSourceDir();
  164. chdir $sourceDir or die;
  165. }
  166. sub baseProductDir
  167. {
  168. determineBaseProductDir();
  169. return $baseProductDir;
  170. }
  171. sub sourceDir
  172. {
  173. determineSourceDir();
  174. return $sourceDir;
  175. }
  176. sub productDir
  177. {
  178. determineConfigurationProductDir();
  179. return $configurationProductDir;
  180. }
  181. sub configuration()
  182. {
  183. determineConfiguration();
  184. return $configuration;
  185. }
  186. sub currentSVNRevision
  187. {
  188. determineCurrentSVNRevision();
  189. return $currentSVNRevision;
  190. }
  191. sub XcodeOptions
  192. {
  193. determineBaseProductDir();
  194. determineConfiguration();
  195. return (@baseProductDirOption, "-configuration", $configuration);
  196. }
  197. sub XcodeOptionString
  198. {
  199. return join " ", XcodeOptions();
  200. }
  201. sub XcodeOptionStringNoConfig
  202. {
  203. return join " ", @baseProductDirOption;
  204. }
  205. my $passedConfiguration;
  206. my $searchedForPassedConfiguration;
  207. sub determinePassedConfiguration
  208. {
  209. return if $searchedForPassedConfiguration;
  210. $searchedForPassedConfiguration = 1;
  211. for my $i (0 .. $#ARGV) {
  212. my $opt = $ARGV[$i];
  213. if ($opt =~ /^--debug$/i || $opt =~ /^--devel/i) {
  214. splice(@ARGV, $i, 1);
  215. $passedConfiguration = "Debug";
  216. return;
  217. }
  218. if ($opt =~ /^--release$/i || $opt =~ /^--deploy/i) {
  219. splice(@ARGV, $i, 1);
  220. $passedConfiguration = "Release";
  221. return;
  222. }
  223. }
  224. $passedConfiguration = undef;
  225. }
  226. sub passedConfiguration
  227. {
  228. determinePassedConfiguration();
  229. return $passedConfiguration;
  230. }
  231. sub setConfiguration
  232. {
  233. if (my $config = shift @_) {
  234. $configuration = $config;
  235. return;
  236. }
  237. determinePassedConfiguration();
  238. $configuration = $passedConfiguration if $passedConfiguration;
  239. }
  240. # Locate Safari.
  241. sub safariPath
  242. {
  243. # Use WEBKIT_SAFARI environment variable if present.
  244. my $safariBundle = $ENV{WEBKIT_SAFARI};
  245. if (!$safariBundle) {
  246. determineConfigurationProductDir();
  247. # Use Safari.app in product directory if present (good for Safari development team).
  248. if (isOSX() && -d "$configurationProductDir/Safari.app") {
  249. $safariBundle = "$configurationProductDir/Safari.app";
  250. } elsif (isCygwin() && -x "$configurationProductDir/bin/Safari.exe") {
  251. $safariBundle = "$configurationProductDir/bin/Safari.exe";
  252. } else {
  253. # Otherwise use the installed Safari
  254. if (isOSX()) {
  255. $safariBundle = "/Applications/Safari.app";
  256. } elsif (isCygwin()) {
  257. chomp(my $programFiles = `cygpath -u '$ENV{"PROGRAMFILES"}'`);
  258. $safariBundle = "$programFiles/Safari/Safari.exe";
  259. }
  260. }
  261. }
  262. my $safariPath;
  263. if (isOSX()) {
  264. $safariPath = "$safariBundle/Contents/MacOS/Safari";
  265. } elsif (isCygwin()) {
  266. $safariPath = $safariBundle;
  267. }
  268. die "Can't find executable at $safariPath.\n" if isOSX() && !-x $safariPath;
  269. return $safariPath;
  270. }
  271. sub builtDylibPathForName
  272. {
  273. my $framework = shift;
  274. determineConfigurationProductDir();
  275. if (isOwb()) {
  276. return $ENV{"OWB_BUILD_DIR"};
  277. }
  278. if (isQt() or isGtk()) {
  279. return "$configurationProductDir/$framework";
  280. }
  281. if (isOSX()) {
  282. return "$configurationProductDir/$framework.framework/Versions/A/$framework";
  283. }
  284. if (isCygwin()) {
  285. if ($framework eq "JavaScriptCore") {
  286. return "$baseProductDir/lib/$framework.lib";
  287. } else {
  288. return "$baseProductDir/$framework.intermediate/$configuration/$framework.intermediate/$framework.lib";
  289. }
  290. }
  291. die "Unsupported platform, can't determine built library locations.";
  292. }
  293. # Check to see that all the frameworks are built.
  294. sub checkFrameworks
  295. {
  296. return if isCygwin();
  297. my @frameworks = ("JavaScriptCore", "WebCore");
  298. push(@frameworks, "WebKit") if isOSX() and not isGtk() and not isQt();
  299. for my $framework (@frameworks) {
  300. my $path = builtDylibPathForName($framework);
  301. die "Can't find built framework at \"$path\".\n" unless -x $path;
  302. }
  303. }
  304. sub hasSVGSupport
  305. {
  306. return 0 if isCygwin() || isOwb();
  307. my $path = shift;
  308. if (isQt()) {
  309. return 1;
  310. }
  311. if (isGtk() and $path =~ /WebCore/) {
  312. $path .= "/../lib/libWebKitGtk.so";
  313. }
  314. open NM, "-|", "nm", $path or die;
  315. my $hasSVGSupport = 0;
  316. while (<NM>) {
  317. $hasSVGSupport = 1 if /SVGElement/;
  318. }
  319. close NM;
  320. return $hasSVGSupport;
  321. }
  322. sub removeLibraryDependingOnSVG
  323. {
  324. my $frameworkName = shift;
  325. my $shouldHaveSVG = shift;
  326. my $path = builtDylibPathForName($frameworkName);
  327. return unless -x $path;
  328. my $hasSVG = hasSVGSupport($path);
  329. system "rm -f $path" if ($shouldHaveSVG xor $hasSVG);
  330. }
  331. sub checkWebCoreSVGSupport
  332. {
  333. my $required = shift;
  334. my $framework = "WebCore";
  335. my $path = builtDylibPathForName($framework);
  336. my $hasSVG = hasSVGSupport($path);
  337. if ($required && !$hasSVG) {
  338. die "$framework at \"$path\" does not include SVG Support, please run build-webkit --svg\n";
  339. }
  340. return $hasSVG;
  341. }
  342. sub isOwb()
  343. {
  344. return defined($ENV{'OWB_BUILD_DIR'})
  345. }
  346. sub isQt()
  347. {
  348. determineIsQt();
  349. return $isQt;
  350. }
  351. sub determineIsQt()
  352. {
  353. return if defined($isQt);
  354. # Allow override in case QTDIR is not set.
  355. for my $i (0 .. $#ARGV) {
  356. my $opt = $ARGV[$i];
  357. if ($opt =~ /^--qt/i ) {
  358. $isQt = 1;
  359. return;
  360. }
  361. }
  362. $isQt = defined($ENV{'QTDIR'});
  363. }
  364. sub isGtk()
  365. {
  366. determineIsGtk();
  367. return $isGtk;
  368. }
  369. sub determineIsGtk()
  370. {
  371. return if defined($isGtk);
  372. for my $i (0 .. $#ARGV) {
  373. my $opt = $ARGV[$i];
  374. if ($opt =~ /^--gtk$/i ) {
  375. $isGtk = 1;
  376. return;
  377. }
  378. }
  379. $isGtk = 0;
  380. }
  381. sub isCygwin()
  382. {
  383. return ($^O eq "cygwin");
  384. }
  385. sub isOSX()
  386. {
  387. return ($^O eq "darwin");
  388. }
  389. sub determineOSXVersion()
  390. {
  391. return if $osXVersion;
  392. if (!isOSX()) {
  393. $osXVersion = -1;
  394. return;
  395. }
  396. my $version = `sw_vers -productVersion`;
  397. my @splitVersion = split(/\./, $version);
  398. @splitVersion >= 2 or die "Invalid version $version";
  399. $osXVersion = {
  400. "major" => $splitVersion[0],
  401. "minor" => $splitVersion[1],
  402. "subminor" => (defined($splitVersion[2]) ? $splitVersion[2] : 0),
  403. };
  404. }
  405. sub osXVersion()
  406. {
  407. determineOSXVersion();
  408. return $osXVersion;
  409. }
  410. sub isTiger()
  411. {
  412. return isOSX() && osXVersion()->{"minor"} == 4;
  413. }
  414. sub isLeopard()
  415. {
  416. return isOSX() && osXVersion()->{"minor"} == 5;
  417. }
  418. sub launcherPath()
  419. {
  420. my $relativeScriptsPath = File::Spec->catpath("", File::Spec->abs2rel(dirname($0), getcwd()), "");
  421. if (isGtk() || isQt()) {
  422. return "$relativeScriptsPath/run-launcher";
  423. } elsif (isOSX() || isCygwin()) {
  424. return "$relativeScriptsPath/run-safari";
  425. }
  426. }
  427. sub launcherName()
  428. {
  429. if (isGtk()) {
  430. return "GtkLauncher";
  431. } elsif (isQt()) {
  432. return "QtLauncher";
  433. } elsif (isOSX() || isCygwin()) {
  434. return "Safari";
  435. }
  436. }
  437. sub checkRequiredSystemConfig
  438. {
  439. if (isOSX()) {
  440. chomp(my $productVersion = `sw_vers -productVersion`);
  441. if ($productVersion lt "10.4") {
  442. print "*************************************************************\n";
  443. print "Mac OS X Version 10.4.0 or later is required to build WebKit.\n";
  444. print "You have " . $productVersion . ", thus the build will most likely fail.\n";
  445. print "*************************************************************\n";
  446. }
  447. my $xcodeVersion = `xcodebuild -version`;
  448. if ($xcodeVersion !~ /DevToolsCore-(\d+)/ || $1 < 747) {
  449. print "*************************************************************\n";
  450. print "Xcode Version 2.3 or later is required to build WebKit.\n";
  451. print "You have an earlier version of Xcode, thus the build will\n";
  452. print "most likely fail. The latest Xcode is available from the web:\n";
  453. print "http://developer.apple.com/tools/xcode\n";
  454. print "*************************************************************\n";
  455. }
  456. } elsif (isGtk() or isQt()) {
  457. my @cmds = qw(flex bison gperf);
  458. my @missing = ();
  459. foreach my $cmd (@cmds) {
  460. if (not `$cmd --version`) {
  461. push @missing, $cmd;
  462. }
  463. }
  464. if (@missing) {
  465. my $list = join ", ", @missing;
  466. die "ERROR: $list missing but required to build WebKit.\n";
  467. }
  468. }
  469. # Win32 and other platforms may want to check for minimum config
  470. }
  471. sub setupCygwinEnv()
  472. {
  473. return if !isCygwin();
  474. return if $vcBuildPath;
  475. my $programFilesPath = `cygpath "$ENV{'PROGRAMFILES'}"`;
  476. chomp $programFilesPath;
  477. $vcBuildPath = "$programFilesPath/Microsoft Visual Studio 8/Common7/IDE/devenv.com";
  478. if (! -e $vcBuildPath) {
  479. # VC++ not found, try VC++ Express
  480. my $vsInstallDir;
  481. if ($ENV{'VSINSTALLDIR'}) {
  482. $vsInstallDir = $ENV{'VSINSTALLDIR'};
  483. } else {
  484. $programFilesPath = $ENV{'PROGRAMFILES'} || "C:\\Program Files";
  485. $vsInstallDir = "$programFilesPath/Microsoft Visual Studio 8";
  486. }
  487. $vsInstallDir = `cygpath "$vsInstallDir"`;
  488. chomp $vsInstallDir;
  489. $vcBuildPath = "$vsInstallDir/Common7/IDE/VCExpress.exe";
  490. if (! -e $vcBuildPath) {
  491. print "*************************************************************\n";
  492. print "Cannot find '$vcBuildPath'\n";
  493. print "Please execute the file 'vcvars32.bat' from\n";
  494. print "'$programFilesPath\\Microsoft Visual Studio 8\\VC\\bin\\'\n";
  495. print "to setup the necessary environment variables.\n";
  496. print "*************************************************************\n";
  497. die;
  498. }
  499. }
  500. chomp($ENV{'WEBKITLIBRARIESDIR'} = `cygpath -wa "$sourceDir/WebKitLibraries/win"`) unless $ENV{'WEBKITLIBRARIESDIR'};
  501. $windowsTmpPath = `cygpath -w /tmp`;
  502. chomp $windowsTmpPath;
  503. print "Building results into: ", baseProductDir(), "\n";
  504. print "WEBKITOUTPUTDIR is set to: ", $ENV{"WEBKITOUTPUTDIR"}, "\n";
  505. print "WEBKITLIBRARIESDIR is set to: ", $ENV{"WEBKITLIBRARIESDIR"}, "\n";
  506. }
  507. sub buildVisualStudioProject($)
  508. {
  509. my ($project) = @_;
  510. setupCygwinEnv();
  511. my $config = configuration();
  512. chomp(my $winProjectPath = `cygpath -w "$project"`);
  513. print "$vcBuildPath $winProjectPath /build $config";
  514. my $result = system $vcBuildPath, $winProjectPath, "/build", $config;
  515. return $result;
  516. }
  517. sub qtMakeCommand()
  518. {
  519. chomp(my $mkspec = `qmake -query QMAKE_MKSPECS`);
  520. $mkspec .= "/default";
  521. my $compiler = "";
  522. open SPEC, "<$mkspec/qmake.conf" or return "make";
  523. while (<SPEC>) {
  524. if ($_ =~ /QMAKE_CC\s*=\s*([^\s]+)/) {
  525. $compiler = $1;
  526. }
  527. }
  528. close SPEC;
  529. #print "default spec: " . $mkspec . "\n";
  530. #print "compiler found: " . $compiler . "\n";
  531. if ($compiler eq "cl") {
  532. return "nmake";
  533. }
  534. return "make";
  535. }
  536. sub buildQMakeProject($$)
  537. {
  538. my ($project, $colorize) = @_;
  539. my @buildArgs = ("-r");
  540. my $make = qtMakeCommand();
  541. my $qmakebin = "qmake"; # Allow override of the qmake binary from $PATH
  542. for my $i (0 .. $#ARGV) {
  543. my $opt = $ARGV[$i];
  544. if ($opt =~ /^--qmake=(.*)/i ) {
  545. $qmakebin = $1;
  546. } elsif ($opt =~ /^--qmakearg=(.*)/i ) {
  547. push @buildArgs, $1;
  548. }
  549. }
  550. if ($project ne "WebKit") {
  551. die "Qt/Linux builds JavaScriptCore/WebCore/WebKitQt in one shot! Only call it for 'WebKit'.\n";
  552. }
  553. my $config = configuration();
  554. my $prefix = $ENV{"WebKitInstallationPrefix"};
  555. push @buildArgs, "OUTPUT_DIR=" . baseProductDir() . "/$config";
  556. push @buildArgs, "CONFIG+=qt-port";
  557. push @buildArgs, sourceDir() . "/WebKit.pro";
  558. if ($config =~ m/debug/i) {
  559. push @buildArgs, "CONFIG-=release";
  560. push @buildArgs, "CONFIG+=debug";
  561. } else {
  562. push @buildArgs, "CONFIG+=release";
  563. push @buildArgs, "CONFIG-=debug";
  564. }
  565. print "Calling '$qmakebin @buildArgs' in " . baseProductDir() . "/$config ...\n\n";
  566. print "Installation directory: $prefix\n" if(defined($prefix));
  567. my $dir = baseProductDir();
  568. if (! -d $dir) {
  569. mkdir $dir or die "Failed to create product directory " . $dir;
  570. }
  571. $dir = $dir . "/$config";
  572. if (! -d $dir) {
  573. mkdir $dir or die "Failed to create build directory " . $dir;
  574. }
  575. chdir $dir or die "Failed to cd into " . $dir . "\n";
  576. my $result = system $qmakebin, @buildArgs;
  577. if($result ne 0) {
  578. die "Failed to setup build environment using $qmakebin!\n";
  579. }
  580. my $clean = $ENV{"WEBKIT_FULLBUILD"};
  581. if(defined $clean) {
  582. system "$make clean";
  583. }
  584. $result = system "$make";
  585. chdir ".." or die;
  586. return $result;
  587. }
  588. sub buildQMakeGtkProject($$)
  589. {
  590. my ($project, $colorize) = @_;
  591. if ($project ne "WebKit") {
  592. die "The Gtk portbuilds JavaScriptCore/WebCore/WebKitQt in one shot! Only call it for 'WebKit'.\n";
  593. }
  594. my $config = configuration();
  595. my $prefix = $ENV{"WebKitInstallationPrefix"};
  596. my @buildArgs = ("-r");
  597. foreach my $opt (@ARGV) {
  598. if ($opt =~ /^--qmakearg=(.*)/i ) {
  599. push @buildArgs, $1;
  600. }
  601. }
  602. push @buildArgs, "OUTPUT_DIR=" . baseProductDir() . "/$config";
  603. push @buildArgs, "CONFIG-=qt";
  604. push @buildArgs, "CONFIG+=gtk-port";
  605. push @buildArgs, sourceDir() . "/WebKit.pro";
  606. if ($config =~ m/debug/i) {
  607. push @buildArgs, "CONFIG-=release";
  608. push @buildArgs, "CONFIG+=debug";
  609. } else {
  610. push @buildArgs, "CONFIG+=release";
  611. push @buildArgs, "CONFIG-=debug";
  612. }
  613. print "Calling 'qmake @buildArgs' in " . baseProductDir() . "/$config ...\n\n";
  614. print "Installation directory: $prefix\n" if(defined($prefix));
  615. system "mkdir -p " . baseProductDir() . "/$config";
  616. chdir baseProductDir() . "/$config" or die "Failed to cd into " . baseProductDir() . "/$config \n";
  617. my $result = system "qmake-qt4", @buildArgs;
  618. $result = system "qmake", @buildArgs if ($result ne 0);
  619. if ($result ne 0) {
  620. die "Failed to setup build environment using qmake!\n";
  621. }
  622. my $clean = $ENV{"WEBKIT_FULLBUILD"};
  623. if (defined $clean) {
  624. system "make clean";
  625. }
  626. $result = system "make";
  627. chdir ".." or die;
  628. return $result;
  629. }
  630. 1;