webengine/osswebengine/WebKitTools/Scripts/build-webkit
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 #!/usr/bin/perl -w
       
     2 
       
     3 # Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
       
     4 #
       
     5 # Redistribution and use in source and binary forms, with or without
       
     6 # modification, are permitted provided that the following conditions
       
     7 # are met:
       
     8 #
       
     9 # 1.  Redistributions of source code must retain the above copyright
       
    10 #     notice, this list of conditions and the following disclaimer. 
       
    11 # 2.  Redistributions in binary form must reproduce the above copyright
       
    12 #     notice, this list of conditions and the following disclaimer in the
       
    13 #     documentation and/or other materials provided with the distribution. 
       
    14 # 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
       
    15 #     its contributors may be used to endorse or promote products derived
       
    16 #     from this software without specific prior written permission. 
       
    17 #
       
    18 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
       
    19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    21 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
       
    22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
    23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
       
    27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    28 
       
    29 # Simplified build script for Web Kit Open Source Project.
       
    30 
       
    31 use strict;
       
    32 use File::Basename;
       
    33 use File::Spec;
       
    34 use FindBin;
       
    35 use Getopt::Long qw(:config pass_through);
       
    36 use lib $FindBin::Bin;
       
    37 use webkitdirs;
       
    38 use POSIX;
       
    39 
       
    40 my $originalWorkingDirectory = getcwd();
       
    41 
       
    42 my $svgSupport = 1;
       
    43 my $svgExperimentalSupport = 0;
       
    44 my $xpathSupport = 1;
       
    45 my $xsltSupport = 1;
       
    46 my $coverageSupport = 0;
       
    47 my $colorSupport = 1; # Default: colorize make output
       
    48 
       
    49 GetOptions('svg!' => \$svgSupport,
       
    50            'svg-experimental!' => \$svgExperimentalSupport,
       
    51            'xpath!' => \$xpathSupport,
       
    52            'xslt!' => \$xsltSupport,
       
    53            'coverage!' => \$coverageSupport,    
       
    54            'color!' => \$colorSupport);
       
    55 
       
    56 checkRequiredSystemConfig();
       
    57 setConfiguration();
       
    58 chdirWebKit();
       
    59 
       
    60 my $productDir = productDir();
       
    61 my @options = XcodeOptions();
       
    62 my @overrideFeatureDefinesOption = ();
       
    63 
       
    64 push @overrideFeatureDefinesOption, "ENABLE_SVG" if $svgSupport;
       
    65 push @overrideFeatureDefinesOption, "ENABLE_SVG_EXPERIMENTAL_FEATURES" if $svgExperimentalSupport;
       
    66 push @overrideFeatureDefinesOption, "ENABLE_XPATH" if $xpathSupport;
       
    67 push @overrideFeatureDefinesOption, "ENABLE_XSLT" if $xsltSupport;
       
    68 my $overrideFeatureDefinesString = "FEATURE_DEFINES=" . join(" ", @overrideFeatureDefinesOption);
       
    69 
       
    70 my @coverageSupportOption = ();
       
    71 if ($coverageSupport) {
       
    72     push @coverageSupportOption, "GCC_GENERATE_TEST_COVERAGE_FILES=YES";
       
    73     push @coverageSupportOption, "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES";
       
    74     push @coverageSupportOption, "EXTRA_LINK= -ftest-coverage -fprofile-arcs";
       
    75     push @coverageSupportOption, "OTHER_CFLAGS= -MD";
       
    76     push @coverageSupportOption, "OTHER_LDFLAGS= -ftest-coverage -fprofile-arcs -framework AppKit";
       
    77 }
       
    78 
       
    79 # Check that all the project directories are there.
       
    80 my @projects = ("JavaScriptCore", "JavaScriptGlue", "WebCore", "WebKit");
       
    81 my @otherDirs = ("WebKitLibraries");
       
    82 for my $dir (@projects, @otherDirs) {
       
    83     if (! -d $dir) {
       
    84         die "Error: No $dir directory found. Please do a fresh checkout.\n";
       
    85     }
       
    86 }
       
    87 
       
    88 if (isOSX()) {
       
    89     # Copy library and header from WebKitLibraries to a findable place in the product directory.
       
    90     my $srcLib = "WebKitLibraries/libWebKitSystemInterface.a";
       
    91     my $lib = "$productDir/libWebKitSystemInterface.a";
       
    92     if (!-e $lib || -M $lib > -M $srcLib) {
       
    93         print "Updating $lib\n";
       
    94         system "ditto", $srcLib, $lib;
       
    95         system "ranlib", $lib;
       
    96     }
       
    97     
       
    98     my $srcHeader = "WebKitLibraries/WebKitSystemInterface.h";
       
    99     my $header = "$productDir/usr/local/include/WebKitSystemInterface.h";
       
   100     if (!-e $header || -M $header > -M $srcHeader) {
       
   101         print "Updating $header\n";
       
   102         system "mkdir", "-p", "$productDir/usr/local/include";
       
   103         system "ditto", $srcHeader, $header;
       
   104     }
       
   105 }
       
   106 
       
   107 if (isCygwin()) {
       
   108     # Copy WebKitSupportLibrary to the correct location in WebKitLibraries so it can be found.
       
   109     # Will fail if WebKitSupportLibrary.zip is not in source root.
       
   110     (system("perl WebKitTools/Scripts/update-webkit-support-libs") == 0) or die;
       
   111 }
       
   112 
       
   113 # Force re-link of existing libraries if different than expected
       
   114 removeLibraryDependingOnSVG("WebCore", $svgSupport);
       
   115 
       
   116 # Build, and abort if the build fails.
       
   117 for my $dir (@projects) {
       
   118     chdir $dir or die;
       
   119     my $result = 0;
       
   120     if (isGtk()) {
       
   121         if ($dir ne "WebKit") {
       
   122             chdir ".." or die;
       
   123             next;
       
   124         }
       
   125 
       
   126         $result = buildQMakeGtkProject($dir, $colorSupport);
       
   127     } elsif (isQt()) {
       
   128         if ($dir ne "WebKit") {
       
   129             chdir ".." or die;
       
   130             next;
       
   131         }
       
   132         $result = buildQMakeProject($dir, $colorSupport);
       
   133     } elsif (isOSX()) {
       
   134         $result = system "xcodebuild", "-project", "$dir.xcodeproj", @options, $overrideFeatureDefinesString, @coverageSupportOption, @ARGV;
       
   135     } elsif (isCygwin()) {
       
   136         if ($dir eq "WebKit") {
       
   137             $result = buildVisualStudioProject("win/WebKit.vcproj/WebKit.sln");
       
   138         }
       
   139     }
       
   140 
       
   141     exit WEXITSTATUS($result) if WEXITSTATUS($result);
       
   142     chdir ".." or die;
       
   143 }
       
   144 
       
   145 # Write out congratulations message.
       
   146 
       
   147 my $launcherPath = launcherPath();
       
   148 my $launcherName = launcherName();
       
   149 
       
   150 print "\n";
       
   151 print "===========================================================\n";
       
   152 print " WebKit is now built. To run $launcherName with this newly-built\n";
       
   153 print " code, use the \"$launcherPath\" script.\n";
       
   154 if ($svgSupport) {
       
   155     print "\n NOTE: WebKit has been built with SVG support enabled.\n";
       
   156     print " $launcherName will have SVG viewing capabilities.\n";
       
   157 }
       
   158 if ($svgExperimentalSupport) {
       
   159     print "\n NOTE: WebKit has been built with experimental SVG features enabled.\n";
       
   160     print " Your build supports basic animation, filters, foreignObject & use support.\n";
       
   161 }    
       
   162 print "===========================================================\n";