commit-queue@webkit.org | 026ee04 | 2018-01-04 07:18:18 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 2 | |
bfulgham@apple.com | 28e3e64 | 2019-09-20 04:55:55 +0000 | [diff] [blame] | 3 | # Copyright (C) 2005-2019 Apple Inc. All rights reserved. |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 4 | # Copyright (C) 2009 Google Inc. All rights reserved. |
| 5 | # Copyright (C) 2010 moiji-mobile.com All rights reserved. |
dbates@webkit.org | a29f8cc | 2011-03-14 18:23:24 +0000 | [diff] [blame] | 6 | # Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
marcelo.lira@openbossa.org | e8121e0 | 2013-11-27 06:05:27 +0000 | [diff] [blame] | 7 | # Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 8 | # |
| 9 | # Redistribution and use in source and binary forms, with or without |
| 10 | # modification, are permitted provided that the following conditions |
| 11 | # are met: |
| 12 | # |
| 13 | # 1. Redistributions of source code must retain the above copyright |
| 14 | # notice, this list of conditions and the following disclaimer. |
| 15 | # 2. Redistributions in binary form must reproduce the above copyright |
| 16 | # notice, this list of conditions and the following disclaimer in the |
| 17 | # documentation and/or other materials provided with the distribution. |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 18 | # 3. Neither the name of Apple Inc. ("Apple") nor the names of |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 19 | # its contributors may be used to endorse or promote products derived |
| 20 | # from this software without specific prior written permission. |
| 21 | # |
| 22 | # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 23 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 25 | # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 26 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 31 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | |
| 33 | # Build script wrapper for the WebKit Open Source Project. |
| 34 | |
| 35 | use strict; |
commit-queue@webkit.org | 026ee04 | 2018-01-04 07:18:18 +0000 | [diff] [blame] | 36 | use warnings; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 37 | use File::Basename; |
| 38 | use File::Find; |
| 39 | use File::Spec; |
| 40 | use FindBin; |
marcelo.lira@openbossa.org | e8121e0 | 2013-11-27 06:05:27 +0000 | [diff] [blame] | 41 | use Getopt::Long qw(:config pass_through no_auto_abbrev); |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 42 | use lib $FindBin::Bin; |
| 43 | use webkitdirs; |
dbates@webkit.org | fb315be | 2014-01-10 23:36:58 +0000 | [diff] [blame] | 44 | use List::Util qw(first); |
eric@webkit.org | 19dfb11 | 2012-05-04 01:06:47 +0000 | [diff] [blame] | 45 | use webkitperl::FeatureList qw(getFeatureOptionList); |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 46 | use POSIX; |
commit-queue@webkit.org | c167b96 | 2020-01-08 14:07:49 +0000 | [diff] [blame] | 47 | use Text::ParseWords; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 48 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 49 | sub writeCongrats(); |
| 50 | |
commit-queue@webkit.org | be882f6 | 2018-06-29 17:47:17 +0000 | [diff] [blame] | 51 | checkRequiredSystemConfig(); |
| 52 | setConfiguration(); |
| 53 | |
| 54 | if (shouldUseFlatpak()) { |
| 55 | print "Building flatpak based environment\n"; |
philn@webkit.org | 7ee6056 | 2020-03-18 09:54:55 +0000 | [diff] [blame] | 56 | my @command = (File::Spec->catfile(sourceDir(), "Tools", "Scripts", "build-webkit")); |
| 57 | runInFlatpak(@command); |
commit-queue@webkit.org | be882f6 | 2018-06-29 17:47:17 +0000 | [diff] [blame] | 58 | } |
| 59 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 60 | my $originalWorkingDirectory = getcwd(); |
| 61 | chdirWebKit(); |
| 62 | |
| 63 | my $showHelp = 0; |
timothy_horton@apple.com | f1f0f5d | 2017-09-27 01:00:31 +0000 | [diff] [blame] | 64 | my $verbose = 0; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 65 | my $clean = 0; |
| 66 | my $minimal = 0; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 67 | my $installHeaders; |
| 68 | my $installLibs; |
| 69 | my $prefixPath; |
dbates@webkit.org | a29f8cc | 2011-03-14 18:23:24 +0000 | [diff] [blame] | 70 | my $makeArgs = ""; |
ossy@webkit.org | ac40d53 | 2016-08-09 09:11:06 +0000 | [diff] [blame] | 71 | my @cmakeArgs; |
joepeck@webkit.org | a24df34 | 2011-05-05 17:49:53 +0000 | [diff] [blame] | 72 | my $onlyWebKitProject = 0; |
eric@webkit.org | 6983a0d | 2012-05-03 23:09:41 +0000 | [diff] [blame] | 73 | my $coverageSupport = 0; |
dbates@webkit.org | df85a29 | 2014-07-28 20:48:50 +0000 | [diff] [blame] | 74 | my $shouldRunStaticAnalyzer = 0; |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 75 | my $noExperimentalFeatures = 0; |
krollin@apple.com | 2ba23ff | 2018-08-27 17:16:17 +0000 | [diff] [blame] | 76 | my $ltoMode = "default"; |
emw@apple.com | c671949 | 2022-06-13 19:20:59 +0000 | [diff] [blame] | 77 | my $useWorkspace = 1; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 78 | my $startTime = time(); |
achristensen@apple.com | ec67bb6 | 2017-02-28 07:11:13 +0000 | [diff] [blame] | 79 | my $archs32bit = 0; |
commit-queue@webkit.org | 5eb4a62 | 2017-10-17 02:30:58 +0000 | [diff] [blame] | 80 | my $skipLibraryUpdate = 0; |
timothy_horton@apple.com | c1e6d8d | 2017-10-21 21:42:51 +0000 | [diff] [blame] | 81 | my $useCCache = -1; |
commit-queue@webkit.org | 99d26d4 | 2022-02-20 16:01:42 +0000 | [diff] [blame] | 82 | my $exportCompileCommands = 0; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 83 | |
eric@webkit.org | 19dfb11 | 2012-05-04 01:06:47 +0000 | [diff] [blame] | 84 | my @features = getFeatureOptionList(); |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 85 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 86 | # Additional environment parameters |
commit-queue@webkit.org | c167b96 | 2020-01-08 14:07:49 +0000 | [diff] [blame] | 87 | push @ARGV, parse_line('\s+', 0, $ENV{'BUILD_WEBKIT_ARGS'}) if ($ENV{'BUILD_WEBKIT_ARGS'}); |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 88 | |
| 89 | # Initialize values from defaults |
| 90 | foreach (@ARGV) { |
| 91 | if ($_ eq '--minimal') { |
| 92 | $minimal = 1; |
achristensen@apple.com | ec67bb6 | 2017-02-28 07:11:13 +0000 | [diff] [blame] | 93 | } elsif ($_ eq 'ARCHS=i386' or $_ eq 'ARCHS=armv7' or $_ eq 'ARCHS=armv7s') { |
| 94 | $archs32bit = 1; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 95 | } |
| 96 | } |
| 97 | |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 98 | # Feature flags default to undefined, where they will inherit the default value |
| 99 | # specified by the build system, or to 'off' if --minimal is specified. |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 100 | foreach (@features) { |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 101 | ${$_->{value}} = ($minimal ? 0 : undef); |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 102 | } |
| 103 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 104 | my $programName = basename($0); |
| 105 | my $usage = <<EOF; |
| 106 | Usage: $programName [options] [options to pass to build system] |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 107 | -h, --help Show this help message |
| 108 | -v, --verbose Show verbose build output |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 109 | --clean Cleanup the build directory |
commit-queue@webkit.org | ebcbe06 | 2017-07-21 16:02:22 +0000 | [diff] [blame] | 110 | --generate-project-only Only generate project files |
commit-queue@webkit.org | 941fbe6 | 2013-02-09 19:09:03 +0000 | [diff] [blame] | 111 | --debug Compile with Debug configuration |
| 112 | --release Compile with Release configuration |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 113 | --sdk=<sdk> Use a specific Xcode SDK (Apple platforms only) |
jbedard@apple.com | 46dabb7 | 2017-03-09 19:46:19 +0000 | [diff] [blame] | 114 | --ios-device Use "iphoneos.internal" SDK if installed, else "iphoneos" SDK (iOS only) |
| 115 | --device DEPRECATED alias of --ios-device |
jbedard@apple.com | c107545 | 2018-06-07 16:24:49 +0000 | [diff] [blame] | 116 | --ios-simulator Use "iphonesimulator.internal" SDK if installed, else "iphonesimulator" SDK (iOS only) |
jbedard@apple.com | 46dabb7 | 2017-03-09 19:46:19 +0000 | [diff] [blame] | 117 | --simulator DEPRECATED alias of --ios-simulator |
jbedard@apple.com | 6c6fca2 | 2020-06-04 19:42:08 +0000 | [diff] [blame] | 118 | --tvos-device Use "appletvos.internal" SDK if installed, else "appletvos" SDK (tvOS only) |
| 119 | --tvos-simulator Use "appletvsimulator" (tvOS only) |
| 120 | --watchos-device Use "watchos.internal" SDK if installed, else "watchos" SDK (watchOS only) |
| 121 | --watchos-simulator Use "watchsimulator" (watchOS only) |
dbates@webkit.org | df85a29 | 2014-07-28 20:48:50 +0000 | [diff] [blame] | 122 | --coverage Enable code coverage support (Mac only) |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 123 | --analyze Enable static anaylsis (Apple platforms only) |
chris.reid@sony.com | 0f616ac | 2019-05-02 23:39:35 +0000 | [diff] [blame] | 124 | --lto-mode=<mode> Set Link Time Optimization mode (full, thin, or none) (LLVM only) |
emw@apple.com | c671949 | 2022-06-13 19:20:59 +0000 | [diff] [blame] | 125 | --no-use-workspace Build projects one at a time instead of using WebKit.xcworkspace (Apple platforms only) |
paroga@webkit.org | be8cbfb | 2011-01-03 21:04:17 +0000 | [diff] [blame] | 126 | |
bfulgham@apple.com | 28e3e64 | 2019-09-20 04:55:55 +0000 | [diff] [blame] | 127 | --ftw Build the FTW Windows port |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 128 | --gtk Build the GTK+ port |
zandobersek@gmail.com | 75ce587 | 2017-05-09 11:07:57 +0000 | [diff] [blame] | 129 | --wpe Build the WPE port |
paroga@webkit.org | be8cbfb | 2011-01-03 21:04:17 +0000 | [diff] [blame] | 130 | --wincairo Build using Cairo (rather than CoreGraphics) on Windows |
don.olmstead@sony.com | b837f67 | 2018-10-31 04:00:45 +0000 | [diff] [blame] | 131 | --playstation Build the PlayStation port |
paroga@webkit.org | be8cbfb | 2011-01-03 21:04:17 +0000 | [diff] [blame] | 132 | |
burg@cs.washington.edu | 148b17a | 2014-08-28 19:19:33 +0000 | [diff] [blame] | 133 | --inspector-frontend Copy Web Inspector user interface resources to the build directory |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 134 | |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 135 | --prefix=<path> Set installation prefix to the given path (CMake only, except Windows) |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 136 | --makeargs=<arguments> Optional Makefile flags |
ossy@webkit.org | ac40d53 | 2016-08-09 09:11:06 +0000 | [diff] [blame] | 137 | --cmakeargs=<arguments> One or more optional CMake flags (e.g. --cmakeargs="-DFOO=bar -DCMAKE_PREFIX_PATH=/usr/local") |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 138 | |
thakis@chromium.org | 0049945 | 2011-05-02 17:54:33 +0000 | [diff] [blame] | 139 | --minimal No optional features, unless explicitly enabled |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 140 | --no-experimental-features No experimental features, unless explicitly enabled (CMake only) |
thakis@chromium.org | 0049945 | 2011-05-02 17:54:33 +0000 | [diff] [blame] | 141 | |
joepeck@webkit.org | a24df34 | 2011-05-05 17:49:53 +0000 | [diff] [blame] | 142 | --only-webkit Build only the WebKit project |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 143 | |
commit-queue@webkit.org | 5eb4a62 | 2017-10-17 02:30:58 +0000 | [diff] [blame] | 144 | --skip-library-update Skip the check to see if windows libraries are up to date |
| 145 | |
timothy_horton@apple.com | c1e6d8d | 2017-10-21 21:42:51 +0000 | [diff] [blame] | 146 | --[no-]use-ccache Enable (or disable) CCache, if available |
| 147 | |
commit-queue@webkit.org | 99d26d4 | 2022-02-20 16:01:42 +0000 | [diff] [blame] | 148 | --export-compile-commands Generate compile_commands.json (Apple platforms only) |
| 149 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 150 | EOF |
| 151 | |
| 152 | my %options = ( |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 153 | 'h|help' => \$showHelp, |
timothy_horton@apple.com | f1f0f5d | 2017-09-27 01:00:31 +0000 | [diff] [blame] | 154 | 'v|verbose' => \$verbose, |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 155 | 'clean' => \$clean, |
| 156 | 'install-headers=s' => \$installHeaders, |
| 157 | 'install-libs=s' => \$installLibs, |
| 158 | 'prefix=s' => \$prefixPath, |
| 159 | 'makeargs=s' => \$makeArgs, |
ossy@webkit.org | ac40d53 | 2016-08-09 09:11:06 +0000 | [diff] [blame] | 160 | 'cmakeargs=s' => \@cmakeArgs, |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 161 | 'minimal' => \$minimal, |
joepeck@webkit.org | a24df34 | 2011-05-05 17:49:53 +0000 | [diff] [blame] | 162 | 'only-webkit' => \$onlyWebKitProject, |
eric@webkit.org | 6983a0d | 2012-05-03 23:09:41 +0000 | [diff] [blame] | 163 | 'coverage' => \$coverageSupport, |
dbates@webkit.org | df85a29 | 2014-07-28 20:48:50 +0000 | [diff] [blame] | 164 | 'analyze' => \$shouldRunStaticAnalyzer, |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 165 | 'no-experimental-features' => \$noExperimentalFeatures, |
krollin@apple.com | 2ba23ff | 2018-08-27 17:16:17 +0000 | [diff] [blame] | 166 | 'lto-mode=s' => \$ltoMode, |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 167 | 'use-workspace!' => \$useWorkspace, |
timothy_horton@apple.com | c1e6d8d | 2017-10-21 21:42:51 +0000 | [diff] [blame] | 168 | 'skip-library-update' => \$skipLibraryUpdate, |
| 169 | 'use-ccache!' => \$useCCache, |
commit-queue@webkit.org | 99d26d4 | 2022-02-20 16:01:42 +0000 | [diff] [blame] | 170 | 'export-compile-commands' => \$exportCompileCommands |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 171 | ); |
| 172 | |
| 173 | # Build usage text and options list from features |
| 174 | foreach (@features) { |
| 175 | my $opt = sprintf("%-35s", " --[no-]$_->{option}"); |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 176 | $usage .= "$opt $_->{desc}\n"; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 177 | $options{"$_->{option}!"} = $_->{value}; |
| 178 | } |
| 179 | |
| 180 | GetOptions(%options); |
| 181 | |
| 182 | if ($showHelp) { |
| 183 | print STDERR $usage; |
| 184 | exit 1; |
| 185 | } |
| 186 | |
timothy_horton@apple.com | f1f0f5d | 2017-09-27 01:00:31 +0000 | [diff] [blame] | 187 | $ENV{'VERBOSE'} = 1 if $verbose; |
| 188 | |
timothy_horton@apple.com | c1e6d8d | 2017-10-21 21:42:51 +0000 | [diff] [blame] | 189 | if ($useCCache == 1) { |
| 190 | $ENV{'WK_USE_CCACHE'} = "YES"; |
| 191 | } elsif ($useCCache == 0) { |
| 192 | $ENV{'WK_USE_CCACHE'} = "NO"; |
| 193 | } |
| 194 | |
commit-queue@webkit.org | 99d26d4 | 2022-02-20 16:01:42 +0000 | [diff] [blame] | 195 | $ENV{'EXPORT_COMPILE_COMMANDS'} = "YES" if $exportCompileCommands; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 196 | |
| 197 | my $productDir = productDir(); |
| 198 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 199 | # Check that all the project directories are there. |
mmaxfield@apple.com | 4d15b9b | 2021-11-10 22:49:56 +0000 | [diff] [blame] | 200 | my @projects = ("Source/JavaScriptCore"); |
| 201 | if (isAppleCocoaWebKit()) { |
| 202 | push @projects, ("Source/WebGPU"); |
| 203 | } |
| 204 | push @projects, ("Source/WebCore"); |
| 205 | push @projects, ("Source/WebKitLegacy"); |
| 206 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 207 | |
eric@webkit.org | 159a9c7 | 2012-03-10 01:03:10 +0000 | [diff] [blame] | 208 | # Build WTF as a separate static library on ports which support it. |
bfulgham@apple.com | 28e3e64 | 2019-09-20 04:55:55 +0000 | [diff] [blame] | 209 | splice @projects, 0, 0, "Source/WTF" if isAppleWebKit() or isWinCairo() or isFTW(); |
eric@webkit.org | 159a9c7 | 2012-03-10 01:03:10 +0000 | [diff] [blame] | 210 | |
commit-queue@webkit.org | 9694ed6 | 2017-02-09 23:46:56 +0000 | [diff] [blame] | 211 | splice @projects, 0, 0, "Source/bmalloc" if isAppleCocoaWebKit(); |
ggaren@apple.com | 672f75e | 2014-04-08 05:31:41 +0000 | [diff] [blame] | 212 | |
gyuyoung.kim@webkit.org | 8ad4f36 | 2016-08-13 06:11:49 +0000 | [diff] [blame] | 213 | # Ports using CMake will check if directories exist in the CMake configuration. |
| 214 | if (!isCMakeBuild()) { |
| 215 | for my $dir (@projects) { |
| 216 | if (! -d $dir) { |
| 217 | die "Error: No $dir directory found. Please do a fresh checkout.\n"; |
| 218 | } |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
bfulgham@apple.com | 28e3e64 | 2019-09-20 04:55:55 +0000 | [diff] [blame] | 222 | if ((isAppleWebKit() || isWinCairo() || isPlayStation() || isFTW()) && !-d "WebKitLibraries") { |
ossy@webkit.org | 443c2fb | 2011-04-05 15:07:22 +0000 | [diff] [blame] | 223 | die "Error: No WebKitLibraries directory found. Please do a fresh checkout.\n"; |
| 224 | } |
| 225 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 226 | my @options = (); |
| 227 | |
commit-queue@webkit.org | 9694ed6 | 2017-02-09 23:46:56 +0000 | [diff] [blame] | 228 | if (isAppleCocoaWebKit()) { |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 229 | push @options, XcodeOptions(); |
krollin@apple.com | 2c6d745 | 2019-05-07 21:38:27 +0000 | [diff] [blame] | 230 | |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 231 | sub option($$) |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 232 | { |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 233 | my ($feature, $isEnabled) = @_; |
| 234 | return "" if not defined $isEnabled; |
psolanki@apple.com | 4005781 | 2011-01-28 20:27:22 +0000 | [diff] [blame] | 235 | return $feature . "=" . ($isEnabled ? $feature : ""); |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | foreach (@features) { |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 239 | my $option = option($_->{define}, ${$_->{value}}); |
eric@webkit.org | 6983a0d | 2012-05-03 23:09:41 +0000 | [diff] [blame] | 240 | push @options, $option unless $option eq ""; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 241 | } |
| 242 | |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 243 | # In workspaces, build order is determined by XCBuild. |
| 244 | if (!$useWorkspace) { |
emw@apple.com | c671949 | 2022-06-13 19:20:59 +0000 | [diff] [blame] | 245 | print STDERR "warning: Building with --no-use-workspace is " . |
| 246 | "deprecated.\nIf you have a workflow requirement that depends " . |
| 247 | "on building targets in manual order, please document it in " . |
| 248 | "https://bugs.webkit.org/show_bug.cgi?id=241295.\n"; |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 249 | # ANGLE and libwebrtc must come before WebCore |
| 250 | splice @projects, 0, 0, ("Source/ThirdParty/ANGLE"); |
| 251 | # if (not $archs32bit and (portName() eq Mac or portName() eq iOS or portName() eq watchOS)) { |
| 252 | if (portName() eq Mac or portName() eq iOS) { |
| 253 | splice @projects, 0, 0, ("Source/ThirdParty/libwebrtc"); |
| 254 | } |
| 255 | |
| 256 | push @projects, ("Source/WebKit"); |
| 257 | |
| 258 | if (!isEmbeddedWebKit()) { |
| 259 | push @projects, ("Tools/MiniBrowser"); |
| 260 | |
| 261 | # WebInspectorUI must come after JavaScriptCore and WebCore but before WebKit and WebKit2 |
| 262 | my $webKitIndex = first { $projects[$_] eq "Source/WebKitLegacy" } 0..$#projects; |
| 263 | splice(@projects, $webKitIndex, 0, "Source/WebInspectorUI"); |
| 264 | } |
| 265 | |
| 266 | if (isAppleMacWebKit()) { |
| 267 | push @projects, ("Tools/lldb/lldbWebKitTester"); |
| 268 | } |
| 269 | |
| 270 | # Build Tools needed for Apple ports (except for tvOS) |
| 271 | push @projects, ("Tools/DumpRenderTree", "Tools/WebKitTestRunner", "Source/ThirdParty/gtest", "Tools/TestWebKitAPI"); |
achristensen@apple.com | eb5404b | 2017-02-22 07:59:59 +0000 | [diff] [blame] | 272 | } |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 273 | |
commit-queue@webkit.org | 5eb4a62 | 2017-10-17 02:30:58 +0000 | [diff] [blame] | 274 | } elsif (isWinCairo() && !$skipLibraryUpdate) { |
don.olmstead@sony.com | a67ac42 | 2017-08-25 17:23:20 +0000 | [diff] [blame] | 275 | (system("python Tools/Scripts/update-webkit-wincairo-libs.py") == 0) or die; |
commit-queue@webkit.org | 5eb4a62 | 2017-10-17 02:30:58 +0000 | [diff] [blame] | 276 | } elsif (isAppleWinWebKit() && !$skipLibraryUpdate) { |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 277 | # Copy WebKitSupportLibrary to the correct location in WebKitLibraries so it can be found. |
| 278 | # Will fail if WebKitSupportLibrary.zip is not in source root. |
| 279 | (system("perl Tools/Scripts/update-webkit-support-libs") == 0) or die; |
don.olmstead@sony.com | fe95624 | 2017-12-21 19:13:40 +0000 | [diff] [blame] | 280 | (system("perl Tools/Scripts/update-webkit-auxiliary-libs") == 0) or die; |
| 281 | setupAppleWinEnv() |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 282 | } |
| 283 | |
joepeck@webkit.org | a24df34 | 2011-05-05 17:49:53 +0000 | [diff] [blame] | 284 | # If asked to build just the WebKit project, overwrite the projects |
| 285 | # list after all of the port specific tweaks have been made to |
| 286 | # build options, etc. |
matthew_hanson@apple.com | 02a35fb | 2017-07-14 02:29:11 +0000 | [diff] [blame] | 287 | @projects = ("Source/WebKitLegacy") if $onlyWebKitProject; |
joepeck@webkit.org | a24df34 | 2011-05-05 17:49:53 +0000 | [diff] [blame] | 288 | |
vestbo@webkit.org | f014d63 | 2012-01-20 17:35:12 +0000 | [diff] [blame] | 289 | my $result = 0; |
| 290 | |
commit-queue@webkit.org | 4fa5398 | 2013-09-26 20:54:06 +0000 | [diff] [blame] | 291 | if (isInspectorFrontend()) { |
burg@cs.washington.edu | 148b17a | 2014-08-28 19:19:33 +0000 | [diff] [blame] | 292 | die "The --inspector-frontend option is not supported for CMake-based builds." if isCMakeBuild(); |
commit-queue@webkit.org | 4fa5398 | 2013-09-26 20:54:06 +0000 | [diff] [blame] | 293 | @projects = ("Source/WebInspectorUI"); |
| 294 | } |
| 295 | |
bfulgham@apple.com | 6d17b50 | 2015-10-30 17:05:58 +0000 | [diff] [blame] | 296 | if (isCMakeBuild() && !isAnyWindows()) { |
clopez@igalia.com | 49e9c7c | 2017-09-25 12:21:47 +0000 | [diff] [blame] | 297 | if (!canUseNinja() || defined($ENV{NUMBER_OF_PROCESSORS})) { |
| 298 | # If the user environment is not setting a specific number of process, |
| 299 | # then don't pass the number of jobs to Ninja. Because Ninja will |
| 300 | # automatically determine the number of jobs to run in parallel. |
timothy_horton@apple.com | 5a73e95 | 2017-09-18 16:54:44 +0000 | [diff] [blame] | 301 | $makeArgs .= ($makeArgs ? " " : "") . "-j" . numberOfCPUs() if $makeArgs !~ /-j\s*\d+/; |
| 302 | } |
commit-queue@webkit.org | 7c051975 | 2012-07-18 12:59:23 +0000 | [diff] [blame] | 303 | |
ossy@webkit.org | a1f81af | 2014-09-25 10:14:57 +0000 | [diff] [blame] | 304 | my $maxCPULoad = maxCPULoad() if $makeArgs !~ /-l\s*\d+\.?\d*/; |
| 305 | $makeArgs .= " -l" . maxCPULoad() if defined $maxCPULoad; |
mrobinson@webkit.org | 06f46f9 | 2014-01-22 19:55:57 +0000 | [diff] [blame] | 306 | |
mcatanzaro@igalia.com | b63f010 | 2017-11-22 18:52:52 +0000 | [diff] [blame] | 307 | # We remove CMakeCache to avoid the bots reusing cached flags when |
commit-queue@webkit.org | 7c051975 | 2012-07-18 12:59:23 +0000 | [diff] [blame] | 308 | # we enable new features. This forces a reconfiguration. |
dbates@webkit.org | 9c97e74 | 2018-06-30 02:06:23 +0000 | [diff] [blame] | 309 | my @featureArgs = cmakeArgsFromFeatures(@features, !$noExperimentalFeatures); |
mrobinson@webkit.org | 06f46f9 | 2014-01-22 19:55:57 +0000 | [diff] [blame] | 310 | removeCMakeCache(@featureArgs); |
commit-queue@webkit.org | 7c051975 | 2012-07-18 12:59:23 +0000 | [diff] [blame] | 311 | |
don.olmstead@sony.com | 7e25f13 | 2018-11-06 22:10:30 +0000 | [diff] [blame] | 312 | buildCMakeProjectOrExit($clean, $prefixPath, $makeArgs, @featureArgs, @cmakeArgs); |
paroga@webkit.org | be8cbfb | 2011-01-03 21:04:17 +0000 | [diff] [blame] | 313 | } |
| 314 | |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 315 | my $baseProductDir = baseProductDir(); |
bfulgham@apple.com | 28e3e64 | 2019-09-20 04:55:55 +0000 | [diff] [blame] | 316 | if (isAppleWinWebKit() || isWinCairo() || isPlayStation() || isFTW()) { |
dbates@webkit.org | 9c97e74 | 2018-06-30 02:06:23 +0000 | [diff] [blame] | 317 | my @featureArgs = cmakeArgsFromFeatures(@features, !$noExperimentalFeatures); |
pvollan@apple.com | d2bda6f | 2016-06-15 17:08:08 +0000 | [diff] [blame] | 318 | removeCMakeCache(@featureArgs); |
| 319 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 320 | chdirWebKit(); |
don.olmstead@sony.com | 7e25f13 | 2018-11-06 22:10:30 +0000 | [diff] [blame] | 321 | if (exitStatus(generateBuildSystemFromCMakeProject($prefixPath, @featureArgs, @cmakeArgs))) { |
commit-queue@webkit.org | 7fff7df | 2017-12-06 02:18:57 +0000 | [diff] [blame] | 322 | die "Run Visual Studio 2017 installation vcvars.bat before build-webkit when using ninja"; |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 323 | } |
commit-queue@webkit.org | ebcbe06 | 2017-07-21 16:02:22 +0000 | [diff] [blame] | 324 | |
| 325 | exit 0 if isGenerateProjectOnly(); |
| 326 | |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 327 | chdirWebKit(); |
| 328 | if (canUseNinja()) { |
commit-queue@webkit.org | 78377dc | 2016-03-24 05:13:35 +0000 | [diff] [blame] | 329 | chdir File::Spec->catdir($baseProductDir, configuration()); |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 330 | $result = system("ninja"); |
| 331 | } else { |
commit-queue@webkit.org | b555823 | 2017-02-28 20:36:43 +0000 | [diff] [blame] | 332 | $result = buildVisualStudioProject(File::Spec->catfile($baseProductDir, configuration(), "WebKit.sln"), $clean); |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 333 | } |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 334 | if (exitStatus($result)) { |
| 335 | my $scriptDir = relativeScriptsDir(); |
bfulgham@apple.com | 28e3e64 | 2019-09-20 04:55:55 +0000 | [diff] [blame] | 336 | if (isAppleWinWebKit() || isWinCairo() || isFTW()) { |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 337 | print "\n\n===== BUILD FAILED ======\n\n"; |
| 338 | print "Please ensure you have run $scriptDir/update-webkit to install dependencies.\n\n"; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 339 | print "You can view build errors by checking the BuildLog.htm files located at:\n$baseProductDir/obj/<project>/<config>.\n"; |
| 340 | } |
| 341 | exit exitStatus($result); |
| 342 | } |
commit-queue@webkit.org | 9694ed6 | 2017-02-09 23:46:56 +0000 | [diff] [blame] | 343 | } elsif (isAppleCocoaWebKit() && !isCMakeBuild()) { |
commit-queue@webkit.org | ebcbe06 | 2017-07-21 16:02:22 +0000 | [diff] [blame] | 344 | exit 0 if isGenerateProjectOnly(); |
| 345 | |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 346 | my @local_options = @options; |
| 347 | push @local_options, XcodeCoverageSupportOptions() if $coverageSupport; |
| 348 | push @local_options, XcodeStaticAnalyzerOption() if $shouldRunStaticAnalyzer; |
| 349 | push @local_options, "WK_LTO_MODE=$ltoMode" if ($ltoMode ne "default"); |
emw@apple.com | 3ab0cce | 2022-04-12 23:02:14 +0000 | [diff] [blame] | 350 | # When we know we're in a workspace (and not an individual project), turn |
| 351 | # on dependency validation errors. Other conditions (e.g. whether we're in |
| 352 | # a script phase or not) influence the actual VALIDATE_DEPENDENCIES setting |
| 353 | # recognized by the build system. |
| 354 | push @local_options, "WK_VALIDATE_DEPENDENCIES=YES_ERROR" if $useWorkspace; |
| 355 | |
| 356 | markBaseProductDirectoryAsCreatedByXcodeBuildSystem(); |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 357 | |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 358 | # Build, and abort if the build fails. |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 359 | if ($useWorkspace) { |
| 360 | my $scheme = $onlyWebKitProject ? "WebKitLegacy" : "All Modules"; |
| 361 | $result = buildXCodeWorkspace("WebKit.xcworkspace", $scheme, $clean, @local_options, @ARGV); |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 362 | if (exitStatus($result)) { |
| 363 | exit exitStatus($result); |
| 364 | } |
commit-queue@webkit.org | b402bd7 | 2022-01-26 19:22:04 +0000 | [diff] [blame] | 365 | } else { |
| 366 | for my $dir (@projects) { |
| 367 | chdir $dir or die; |
| 368 | $result = 0; |
| 369 | |
| 370 | my $project = basename($dir); |
| 371 | my $projectPath = $project =~ /gtest/ ? "xcode/gtest" : $project; |
| 372 | $result = buildXCodeProject($projectPath, $clean, @local_options, @ARGV); |
| 373 | |
| 374 | # Various build* calls above may change the CWD. |
| 375 | chdirWebKit(); |
| 376 | |
| 377 | if (exitStatus($result)) { |
| 378 | exit exitStatus($result); |
| 379 | } |
| 380 | } |
jbedard@apple.com | 18dbcb7 | 2018-09-21 17:13:34 +0000 | [diff] [blame] | 381 | } |
jbedard@apple.com | 1cd28b4 | 2017-04-13 20:08:35 +0000 | [diff] [blame] | 382 | |
bburg@apple.com | 0f40540 | 2020-08-11 23:57:15 +0000 | [diff] [blame] | 383 | if (isInspectorFrontend()) { |
| 384 | exit exitStatus($result); |
| 385 | } |
| 386 | |
emw@apple.com | d5643bb | 2022-06-15 22:46:32 +0000 | [diff] [blame] | 387 | if ($clean) { |
| 388 | # No need to have build-imagediff do cleaning, the build directory has already been deleted. |
| 389 | exit exitStatus($result); |
| 390 | } |
| 391 | |
jbedard@apple.com | 18dbcb7 | 2018-09-21 17:13:34 +0000 | [diff] [blame] | 392 | # Build ImageDiff for host |
| 393 | my @command = File::Spec->catfile(getcwd(), "/Tools/Scripts/build-imagediff"); |
| 394 | chdirWebKit(); |
| 395 | if (!-e $command[0]) { |
| 396 | die "build-imagediff script not found"; |
| 397 | } |
jbedard@apple.com | 1cd28b4 | 2017-04-13 20:08:35 +0000 | [diff] [blame] | 398 | |
jbedard@apple.com | 18dbcb7 | 2018-09-21 17:13:34 +0000 | [diff] [blame] | 399 | push @command, argumentsForConfiguration(); |
| 400 | push @command, @ARGV; |
| 401 | @command = extractNonMacOSHostConfiguration(\@command); |
| 402 | $result = system(@command); |
| 403 | if (exitStatus($result)) { |
| 404 | exit exitStatus($result); |
achristensen@apple.com | a227659 | 2015-09-18 18:00:32 +0000 | [diff] [blame] | 405 | } |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | # Don't report the "WebKit is now built" message after a clean operation. |
| 409 | exit if $clean; |
| 410 | |
vestbo@webkit.org | f014d63 | 2012-01-20 17:35:12 +0000 | [diff] [blame] | 411 | # Don't report congrats message if build was interrupted by the user. |
| 412 | exit if ($result & 127) == SIGINT; |
| 413 | |
commit-queue@webkit.org | b81b0f5 | 2012-03-17 00:13:06 +0000 | [diff] [blame] | 414 | # Explicitly chdir back to where exit will take us anyway, since the following "launcher" |
| 415 | # message is relative to that directory. |
| 416 | chdir $originalWorkingDirectory; |
| 417 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 418 | # Write out congratulations message. |
| 419 | writeCongrats(); |
| 420 | |
| 421 | exit 0; |
| 422 | |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 423 | sub writeCongrats() |
| 424 | { |
| 425 | my $launcherPath = launcherPath(); |
| 426 | my $launcherName = launcherName(); |
| 427 | my $endTime = time(); |
| 428 | my $buildTime = formatBuildTime($endTime - $startTime); |
| 429 | |
| 430 | print "\n"; |
commit-queue@webkit.org | 526d8db | 2012-11-12 07:24:24 +0000 | [diff] [blame] | 431 | print "====================================================================\n"; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 432 | print " WebKit is now built ($buildTime). \n"; |
commit-queue@webkit.org | 714a24b | 2014-02-10 13:16:01 +0000 | [diff] [blame] | 433 | if ($launcherPath && $launcherName) { |
| 434 | print " To run $launcherName with this newly-built code, use the\n"; |
| 435 | print " \"$launcherPath\" script.\n"; |
| 436 | } |
commit-queue@webkit.org | 526d8db | 2012-11-12 07:24:24 +0000 | [diff] [blame] | 437 | print "====================================================================\n"; |
mitz@apple.com | 10955a5a | 2010-12-18 00:02:12 +0000 | [diff] [blame] | 438 | } |