3 # Copyright (C) 2005, 2013 Apple Inc. All rights reserved.
4 # Copyright (C) 2007 Eric Seidel <eric@webkit.org>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. Neither the name of Apple Inc. ("Apple") nor the names of
16 # its contributors may be used to endorse or promote products derived
17 # from this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 use Getopt::Long qw(:config pass_through);
34 use lib $FindBin::Bin;
40 my $shouldRunStaticAnalyzer = 0;
41 my $coverageSupport = 0;
43 my $ftlJIT = int(isAppleMacWebKit() && !willUseIOSSimulatorSDK() || isX86_64() && (isGtk() || isEfl()));
48 my $copyLibraries = 1;
49 my $startTime = time();
51 # Additional environment parameters
52 push @ARGV, split(/ /, $ENV{'BUILD_JSC_ARGS'}) if ($ENV{'BUILD_JSC_ARGS'});
54 my $programName = basename($0);
56 Usage: $programName [options] [options to pass to build system]
57 --help Show this help message
58 --[no-]analyze Toggle code static analysis (default: $shouldRunStaticAnalyzer)
59 --[no-]coverage Toggle code coverage support (default: $coverageSupport)
60 --[no-]ftl-jit Toggle FTL JIT support (default: $ftlJIT)
61 --[no-]copy-libraries Toggle whether to copy libraries (default: $copyLibraries)
62 --cloop Use C Loop interpreter (default: $forceCLoop)
63 --cli Build the new jsc command line interface (default: $cli)
64 --makeargs=<arguments> Optional Makefile flags
65 --cmakeargs=<arguments> Optional CMake flags (e.g. --cmakeargs="-DFOO=bar -DCMAKE_PREFIX_PATH=/usr/local")
69 'analyze!' => \$shouldRunStaticAnalyzer,
70 'coverage!' => \$coverageSupport,
72 'ftl-jit!' => \$ftlJIT,
73 'cloop!' => \$forceCLoop,
75 'copy-libraries!' => \$copyLibraries,
76 'makeargs=s' => \$makeArgs,
77 'cmakeargs=s' => \$cmakeArgs
85 if (isAppleWinWebKit()) {
89 checkRequiredSystemConfig();
92 my @options = XcodeOptions();
93 my @additionalSupportOptions = ();
94 push @additionalSupportOptions, XcodeCoverageSupportOptions() if $coverageSupport;
95 push @additionalSupportOptions, XcodeStaticAnalyzerOption() if $shouldRunStaticAnalyzer;
101 if (isCMakeBuild()) {
102 $cmakeArgs .= $forceCLoop ? " -DENABLE_JIT=OFF" : " -DENABLE_JIT=ON";
103 $cmakeArgs .= $ftlJIT ? " -DENABLE_FTL_JIT=ON" : " -DENABLE_FTL_JIT=OFF";
105 my $buildTarget = "";
106 unless (isAnyWindows()) {
107 # By default we build using all of the available CPUs
108 $makeArgs .= ($makeArgs ? " " : "") . "-j" . numberOfCPUs() if $makeArgs !~ /-j\s*\d+/;
109 $buildTarget = "jsc testb3 $makeArgs";
110 } elsif (canUseNinja()) {
111 $buildTarget .= "jsc testapi";
114 # This call only returns if nothing wrong happened
115 buildCMakeProjectOrExit(0, cmakeBasedPortName(), undef, $buildTarget, (cmakeBasedPortArguments(), $cmakeArgs));
120 if (isAppleMacWebKit()) {
121 push @options, ($forceCLoop ? "ENABLE_JIT=ENABLE_JIT=0" : "ENABLE_JIT=ENABLE_JIT");
122 push @options, ($ftlJIT ? "ENABLE_FTL_JIT=ENABLE_FTL_JIT" : "ENABLE_FTL_JIT=ENABLE_FTL_JIT=0");
124 if ($copyLibraries) {
125 my @copyLibrariesArgs = ("perl", "Tools/Scripts/copy-webkitlibraries-to-product-directory");
126 push @copyLibrariesArgs, "--device" if willUseIOSDeviceSDK();
128 push @copyLibrariesArgs, "--llvm";
130 push @copyLibrariesArgs, productDir();
131 (system(@copyLibrariesArgs) == 0) or die;
137 my ($projectDirectory, $projectName) = @_;
139 chdir $projectDirectory or die "Can't find $projectName directory to build from";
140 if (isAppleMacWebKit()) {
141 $result = system "sh", "-c", ('xcodebuild -project ' . $projectName . '.xcodeproj "$@" | grep -v setenv && exit ${PIPESTATUS[0]}'), "xcodebuild", @options, @ARGV, @additionalSupportOptions;
142 } elsif (isAppleWinWebKit() || isWinCairo()) {
143 # WTF is a part of JavaScriptCore.sln because jsc.exe wouldn't start otherwise.
144 if ($projectName ne "WTF") {
145 $result = buildVisualStudioProject("$projectName.vcxproj/$projectName.sln");
148 checkForArgumentAndRemoveFromARGV("--gtk");
149 $result = buildGtkProject($projectName, 0);
151 die "Building not defined for this platform!\n";
153 exit exitStatus($result) if exitStatus($result);
159 my $endTime = time();
160 my $buildTime = formatBuildTime($endTime - $startTime);
163 print "====================================================================\n";
164 print " JavaScriptCore is now built ($buildTime). \n";
165 print "====================================================================\n";
168 if (!isAppleWinWebKit() && !isWinCairo()) {
169 buildMyProject("Source/bmalloc", "bmalloc");
171 buildMyProject("Source/WTF", "WTF");
172 buildMyProject("Source/JavaScriptCore", "JavaScriptCore");
173 if (isAppleMacWebKit() && $cli) {
174 buildMyProject("Tools/jsc-cli", "jsc-cli");