blob: 729ce40145717b1fa411e7bd7215c96291318baf [file] [log] [blame]
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +00001#!/usr/bin/perl -w
2
bburg@apple.com72f5b812015-09-05 05:29:36 +00003# Copyright (C) 2015 Apple 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# 1. Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24# THE POSSIBILITY OF SUCH DAMAGE.
25
bfulgham@apple.comad191ac2014-05-12 22:19:35 +000026use English;
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +000027use File::Copy qw(copy);
timothy@apple.comafad3b02014-09-23 21:08:36 +000028use File::Path qw(make_path remove_tree);
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +000029use File::Spec;
30
31my $useDirCopy = 0;
32
33# Not all systems (e.g., OS X) include File::Copy::Recursive. Only
34# use it if we have it installed.
35eval "use File::Copy::Recursive";
36unless ($@) {
37 $useDirCopy = 1;
38 File::Copy::Recursive->import();
39}
40
41sub ditto($$)
42{
43 my ($source, $destination) = @_;
44
45 if ($useDirCopy) {
46 File::Copy::Recursive::dircopy($source, $destination) or die "Unable to copy directory $source to $destination: $!";
47 } elsif ($^O eq 'darwin') {
48 system('ditto', $source, $destination);
49 } else {
50 die "Please install the PEP module File::Copy::Recursive";
51 }
52}
53
54sub seedFile($$)
55{
56 my ($targetFile, $seedText) = @_;
57
58 if (open(TARGET_FILE, '>', $targetFile)) {
59 print TARGET_FILE $seedText;
60 close(TARGET_FILE);
61 }
62}
63
commit-queue@webkit.orgd0326f92016-05-12 15:47:45 +000064sub appendFile($$)
65{
66 my ($targetFile, $srcFile) = @_;
67
68 open(SRC_FILE, '<', $srcFile) or die "Unable to open $srcFile: $!";
69 my @srcText = <SRC_FILE>;
70 close(SRC_FILE);
71 open(TARGET_FILE, '>>', $targetFile) or die "Unable to open $targetFile: $!";
72 print TARGET_FILE @srcText;
73 close(TARGET_FILE);
74}
75
timothy@apple.com338dc7f2014-08-08 06:48:52 +000076sub readLicenseFile($)
77{
78 my ($licenseFilePath) = @_;
79
80 open(LICENSE_FILE, '<', $licenseFilePath) or die "Unable to open $licenseFilePath: $!";
81
82 my $license = "/*\n";
83 $license .= ' * ' . $_ while <LICENSE_FILE>;
84 $license .= " */\n";
85
86 close(LICENSE_FILE);
87
88 return $license;
89}
90
91my $inspectorLicense = <<'EOF';
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +000092/*
bburg@apple.com057c9102016-09-09 04:33:11 +000093 * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +000094 * Copyright (C) 2008 Matt Lilek. All rights reserved.
95 * Copyright (C) 2008-2009 Anthony Ricaud <rik@webkit.org>
timothy@apple.com338dc7f2014-08-08 06:48:52 +000096 * Copyright (C) 2009-2010 Joseph Pecoraro. All rights reserved.
97 * Copyright (C) 2009-2011 Google Inc. All rights reserved.
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +000098 * Copyright (C) 2009 280 North Inc. All Rights Reserved.
99 * Copyright (C) 2010 Nikita Vasilyev. All rights reserved.
100 * Copyright (C) 2011 Brian Grinstead All rights reserved.
101 * Copyright (C) 2013 Matt Holden <jftholden@yahoo.com>
102 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
103 * Copyright (C) 2013 Seokju Kwon (seokju.kwon@gmail.com)
104 * Copyright (C) 2013 Adobe Systems Inc. All rights reserved.
commit-queue@webkit.org626328d2015-08-20 00:14:05 +0000105 * Copyright (C) 2013-2015 University of Washington. All rights reserved.
106 * Copyright (C) 2014-2015 Saam Barati <saambarati1@gmail.com>
107 * Copyright (C) 2014 Antoine Quint
108 * Copyright (C) 2015 Tobias Reiss <tobi+webkit@basecode.de>
commit-queue@webkit.orgb2e1ed12016-01-06 23:46:21 +0000109 * Copyright (C) 2015-2016 Devin Rousso <dcrousso+webkit@gmail.com>. All rights reserved.
commit-queue@webkit.org9ba33ad2017-04-14 04:47:19 +0000110 * Copyright (C) 2017 Sony Interactive Entertainment Inc.
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000111 *
112 * Redistribution and use in source and binary forms, with or without
113 * modification, are permitted provided that the following conditions
114 * are met:
115 * 1. Redistributions of source code must retain the above copyright
116 * notice, this list of conditions and the following disclaimer.
117 * 2. Redistributions in binary form must reproduce the above copyright
118 * notice, this list of conditions and the following disclaimer in the
119 * documentation and/or other materials provided with the distribution.
120 *
121 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
122 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
123 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
124 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
125 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
126 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
127 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
128 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
129 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
130 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
131 * THE POSSIBILITY OF SUCH DAMAGE.
132 */
133EOF
134
commit-queue@webkit.orgd0326f92016-05-12 15:47:45 +0000135my $perl = $^X;
bfulgham@apple.comad191ac2014-05-12 22:19:35 +0000136my $python = ($OSNAME =~ /cygwin/) ? "/usr/bin/python" : "python";
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000137my $derivedSourcesDir = $ENV{'DERIVED_SOURCES_DIR'};
138my $scriptsRoot = File::Spec->catdir($ENV{'SRCROOT'}, 'Scripts');
bburg@apple.com057c9102016-09-09 04:33:11 +0000139my $sharedScriptsRoot = File::Spec->catdir($ENV{'JAVASCRIPTCORE_PRIVATE_HEADERS_DIR'});
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000140my $uiRoot = File::Spec->catdir($ENV{'SRCROOT'}, 'UserInterface');
141my $targetResourcePath = File::Spec->catdir($ENV{'TARGET_BUILD_DIR'}, $ENV{'UNLOCALIZED_RESOURCES_FOLDER_PATH'});
142my $protocolDir = File::Spec->catdir($targetResourcePath, 'Protocol');
joepeck@webkit.org87a83de2016-03-17 21:02:07 +0000143my $workersDir = File::Spec->catdir($targetResourcePath, 'Workers');
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000144my $codeMirrorPath = File::Spec->catdir($uiRoot, 'External', 'CodeMirror');
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000145my $esprimaPath = File::Spec->catdir($uiRoot, 'External', 'Esprima');
jonowells@apple.com538083f2014-10-17 23:50:49 +0000146my $eslintPath = File::Spec->catdir($uiRoot, 'External', 'ESLint');
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000147
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000148my $codeMirrorLicense = readLicenseFile(File::Spec->catfile($codeMirrorPath, 'LICENSE'));
jonowells@apple.com538083f2014-10-17 23:50:49 +0000149my $esprimaLicense = readLicenseFile(File::Spec->catfile($esprimaPath, 'LICENSE'));
150my $eslintLicense = readLicenseFile(File::Spec->catfile($eslintPath, 'LICENSE'));
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000151make_path($protocolDir, $targetResourcePath);
152
153# Copy over dynamically loaded files from other frameworks, even if we aren't combining resources.
joepeck@webkit.orgdd1777c2014-10-20 17:59:24 +0000154copy(File::Spec->catfile($ENV{'JAVASCRIPTCORE_PRIVATE_HEADERS_DIR'}, 'InspectorBackendCommands.js'), File::Spec->catfile($protocolDir, 'InspectorBackendCommands.js')) or die "Copy of InspectorBackendCommands.js failed: $!";
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000155
commit-queue@webkit.org7aa60432016-01-09 06:32:23 +0000156my $forceToolInstall = defined $ENV{'FORCE_TOOL_INSTALL'} && ($ENV{'FORCE_TOOL_INSTALL'} eq 'YES');
157my $shouldCombineMain = defined $ENV{'COMBINE_INSPECTOR_RESOURCES'} && ($ENV{'COMBINE_INSPECTOR_RESOURCES'} eq 'YES');
158my $shouldCombineTest = defined $ENV{'COMBINE_TEST_RESOURCES'} && ($ENV{'COMBINE_TEST_RESOURCES'} eq 'YES');
159my $combineResourcesCmd = File::Spec->catfile($scriptsRoot, 'combine-resources.pl');
160
161if ($forceToolInstall) {
joepeck@webkit.org80d85db2014-12-04 21:56:04 +0000162 # Copy all files over individually to ensure we have Test.html / Test.js and files included from Test.html.
163 # We may then proceed to include combined & optimized resources which will output mostly to different paths
164 # but overwrite Main.html / Main.js with optimized versions.
165 ditto($uiRoot, $targetResourcePath);
joepeck@webkit.org80d85db2014-12-04 21:56:04 +0000166
commit-queue@webkit.org7aa60432016-01-09 06:32:23 +0000167 # Also force combining test resources for tool installs.
168 $shouldCombineTest = 1;
169}
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000170
bburg@apple.com72f5b812015-09-05 05:29:36 +0000171if ($shouldCombineMain) {
commit-queue@webkit.org627256b2016-09-04 07:10:53 +0000172 # Remove Debug JavaScript and CSS files in Production builds.
bburg@apple.comb1899292016-09-09 05:07:45 +0000173 system($perl, $combineResourcesCmd,
174 '--input-dir', 'Debug',
175 '--input-html', File::Spec->catfile($uiRoot, 'Main.html'),
176 '--input-html-dir', $uiRoot,
177 '--derived-sources-dir', $derivedSourcesDir,
178 '--output-dir', $derivedSourcesDir,
179 '--output-script-name', 'Debug.js',
180 '--output-style-name', 'Debug.css',
181 '--strip');
commit-queue@webkit.org627256b2016-09-04 07:10:53 +0000182
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000183 # Combine the JavaScript and CSS files in Production builds into single files (Main.js and Main.css).
joepeck@webkit.orgdf30d112015-12-01 21:11:44 +0000184 my $derivedSourcesMainHTML = File::Spec->catfile($derivedSourcesDir, 'Main.html');
bburg@apple.comb1899292016-09-09 05:07:45 +0000185 system($perl, $combineResourcesCmd,
186 '--input-html', $derivedSourcesMainHTML,
187 '--input-html-dir', $uiRoot,
188 '--derived-sources-dir', $derivedSourcesDir,
189 '--output-dir', $derivedSourcesDir,
190 '--output-script-name', 'Main.js',
191 '--output-style-name', 'Main.css');
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000192
193 # Combine the CodeMirror JavaScript and CSS files in Production builds into single files (CodeMirror.js and CodeMirror.css).
bburg@apple.comb1899292016-09-09 05:07:45 +0000194 system($perl, $combineResourcesCmd,
195 '--input-dir', 'External/CodeMirror',
196 '--input-html', $derivedSourcesMainHTML,
197 '--input-html-dir', $uiRoot,
198 '--derived-sources-dir', $derivedSourcesDir,
199 '--output-dir', $derivedSourcesDir,
200 '--output-script-name', 'CodeMirror.js',
201 '--output-style-name', 'CodeMirror.css');
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000202
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000203 # Combine the Esprima JavaScript files in Production builds into a single file (Esprima.js).
bburg@apple.comb1899292016-09-09 05:07:45 +0000204 system($perl, $combineResourcesCmd,
205 '--input-dir', 'External/Esprima',
206 '--input-html', $derivedSourcesMainHTML,
207 '--input-html-dir', $uiRoot,
208 '--derived-sources-dir', $derivedSourcesDir,
209 '--output-dir', $derivedSourcesDir,
210 '--output-script-name', 'Esprima.js');
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000211
jonowells@apple.com538083f2014-10-17 23:50:49 +0000212 # Combine the ESLint JavaScript files in Production builds into a single file (ESLint.js).
bburg@apple.comb1899292016-09-09 05:07:45 +0000213 system($perl, $combineResourcesCmd,
214 '--input-dir', 'External/ESLint',
215 '--input-html', $derivedSourcesMainHTML,
216 '--input-html-dir', $uiRoot,
217 '--derived-sources-dir', $derivedSourcesDir,
218 '--output-dir', $derivedSourcesDir,
219 '--output-script-name', 'ESLint.js');
jonowells@apple.com538083f2014-10-17 23:50:49 +0000220
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000221 # Remove console.assert calls from the Main.js file.
222 my $derivedSourcesMainJS = File::Spec->catfile($derivedSourcesDir, 'Main.js');
bburg@apple.comb1899292016-09-09 05:07:45 +0000223 system($perl, File::Spec->catfile($scriptsRoot, 'remove-console-asserts.pl'),
224 '--input-script', $derivedSourcesMainJS,
225 '--output-script', $derivedSourcesMainJS);
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000226
227 # Fix Image URLs in the Main.css file by removing the "../".
228 my $derivedSourcesMainCSS = File::Spec->catfile($derivedSourcesDir, 'Main.css');
229 if (open(INPUT_MAIN, '<', $derivedSourcesMainCSS)) {
230 local $/;
231 my $cssContents = <INPUT_MAIN>;
232 close(INPUT_MAIN);
233 open(OUTPUT_MAIN, '>', $derivedSourcesMainCSS);
234 $cssContents =~ s/\.\.\/Images/Images/g;
235 print OUTPUT_MAIN $cssContents;
236 close(OUTPUT_MAIN);
237 }
238
239 # Export the license into Main.js.
240 my $targetMainJS = File::Spec->catfile($targetResourcePath, 'Main.js');
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000241 seedFile($targetMainJS, $inspectorLicense);
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000242
243 my $targetMainCSS = File::Spec->catfile($targetResourcePath, 'Main.css');
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000244 seedFile($targetMainCSS, $inspectorLicense);
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000245
246 # Export the license into CodeMirror.js and CodeMirror.css.
247 my $targetCodeMirrorJS = File::Spec->catfile($targetResourcePath, 'CodeMirror.js');
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000248 seedFile($targetCodeMirrorJS, $codeMirrorLicense);
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000249
250 my $targetCodeMirrorCSS = File::Spec->catfile($targetResourcePath, 'CodeMirror.css');
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000251 seedFile($targetCodeMirrorCSS, $codeMirrorLicense);
252
253 # Export the license into Esprima.js.
254 my $targetEsprimaJS = File::Spec->catfile($targetResourcePath, 'Esprima.js');
jonowells@apple.com538083f2014-10-17 23:50:49 +0000255 seedFile($targetEsprimaJS, $esprimaLicense);
256
257 # Export the license into ESLint.js.
258 my $targetESLintJS = File::Spec->catfile($targetResourcePath, 'ESLint.js');
259 seedFile($targetESLintJS, $eslintLicense);
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000260
261 # Minify the Main.js and Main.css files, with Main.js appending to the license that was exported above.
bburg@apple.com057c9102016-09-09 04:33:11 +0000262 my $jsMinScript = File::Spec->catfile($sharedScriptsRoot, 'jsmin.py');
263 my $cssMinScript = File::Spec->catfile($sharedScriptsRoot, 'cssmin.py');
bfulgham@apple.comad191ac2014-05-12 22:19:35 +0000264 system(qq("$python" "$jsMinScript" < "$derivedSourcesMainJS" >> "$targetMainJS")) and die "Failed to minify $derivedSourcesMainJS: $!";
265 system(qq("$python" "$cssMinScript" < "$derivedSourcesMainCSS" >> "$targetMainCSS")) and die "Failed to minify $derivedSourcesMainCSS: $!";
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000266
267 # Minify the CodeMirror.js and CodeMirror.css files, appending to the license that was exported above.
bburg@apple.com72f5b812015-09-05 05:29:36 +0000268 my $derivedSourcesCodeMirrorJS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.js');
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000269 my $derivedSourcesCodeMirrorCSS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.css');
bburg@apple.com72f5b812015-09-05 05:29:36 +0000270 system(qq("$python" "$jsMinScript" < "$derivedSourcesCodeMirrorJS" >> "$targetCodeMirrorJS")) and die "Failed to minify $derivedSourcesCodeMirrorJS: $!";
bfulgham@apple.comad191ac2014-05-12 22:19:35 +0000271 system(qq("$python" "$cssMinScript" < "$derivedSourcesCodeMirrorCSS" >> "$targetCodeMirrorCSS")) and die "Failed to minify $derivedSourcesCodeMirrorCSS: $!";
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000272
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000273 # Minify the Esprima.js file, appending to the license that was exported above.
bburg@apple.com72f5b812015-09-05 05:29:36 +0000274 my $derivedSourcesEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'Esprima.js');
275 system(qq("$python" "$jsMinScript" < "$derivedSourcesEsprimaJS" >> "$targetEsprimaJS")) and die "Failed to minify $derivedSourcesEsprimaJS: $!";
timothy@apple.com338dc7f2014-08-08 06:48:52 +0000276
jonowells@apple.com538083f2014-10-17 23:50:49 +0000277 # Minify the ESLint.js file, appending to the license that was exported above.
bburg@apple.com72f5b812015-09-05 05:29:36 +0000278 my $derivedSourcesESLintJS = File::Spec->catfile($derivedSourcesDir, 'ESLint.js');
279 system(qq("$python" "$jsMinScript" < "$derivedSourcesESLintJS" >> "$targetESLintJS")) and die "Failed to minify $derivedSourcesESLintJS: $!";
jonowells@apple.com538083f2014-10-17 23:50:49 +0000280
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000281 # Copy over Main.html and the Images directory.
282 copy($derivedSourcesMainHTML, File::Spec->catfile($targetResourcePath, 'Main.html'));
283
284 ditto(File::Spec->catdir($uiRoot, 'Images'), File::Spec->catdir($targetResourcePath, 'Images'));
285
timothy@apple.comafad3b02014-09-23 21:08:36 +0000286 # Remove Images/gtk on Mac and Windows builds.
287 remove_tree(File::Spec->catdir($targetResourcePath, 'Images', 'gtk')) if defined $ENV{'MAC_OS_X_VERSION_MAJOR'} or defined $ENV{'OFFICIAL_BUILD'};
288
commit-queue@webkit.org8c233ba2016-02-12 22:31:08 +0000289 # Remove ESLint until needed: <https://webkit.org/b/136515> Web Inspector: JavaScript source text editor should have a linter
290 unlink $targetESLintJS;
291
joepeck@webkit.org87a83de2016-03-17 21:02:07 +0000292 # Copy the Protocol/Legacy and Workers directories.
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000293 ditto(File::Spec->catfile($uiRoot, 'Protocol', 'Legacy'), File::Spec->catfile($protocolDir, 'Legacy'));
joepeck@webkit.org87a83de2016-03-17 21:02:07 +0000294 ditto(File::Spec->catfile($uiRoot, 'Workers'), $workersDir);
commit-queue@webkit.orgd25bcf92016-04-02 05:23:32 +0000295
296 # Remove console.assert calls from the Worker js files.
bburg@apple.comb1899292016-09-09 05:07:45 +0000297 system($perl, File::Spec->catfile($scriptsRoot, 'remove-console-asserts.pl'),
298 '--input-directory', $workersDir);
commit-queue@webkit.orgec94d242016-04-29 05:23:46 +0000299
300 # Fix import references in Workers directories. This rewrites "../../External/script.js" import paths to their new locations.
bburg@apple.comb1899292016-09-09 05:07:45 +0000301 system($perl, File::Spec->catfile($scriptsRoot, 'fix-worker-imports-for-optimized-builds.pl'),
302 '--input-directory', $workersDir) and die "Failed to update Worker imports for optimized builds.";
bfulgham@apple.com1c18cab2014-04-08 21:29:09 +0000303} else {
304 # Keep the files separate for engineering builds.
305 ditto($uiRoot, $targetResourcePath);
306}
bburg@apple.com72f5b812015-09-05 05:29:36 +0000307
308if ($shouldCombineTest) {
bburg@apple.com64440662016-09-04 04:34:57 +0000309 # Combine the JavaScript files for testing into a single file (TestCombined.js).
bburg@apple.comb1899292016-09-09 05:07:45 +0000310 system($perl, $combineResourcesCmd,
311 '--input-html', File::Spec->catfile($uiRoot, 'Test.html'),
312 '--derived-sources-dir', $derivedSourcesDir,
313 '--output-dir', $derivedSourcesDir,
314 '--output-script-name', 'TestCombined.js',
315 '--output-style-name', 'TestCombined.css');
bburg@apple.com64440662016-09-04 04:34:57 +0000316
commit-queue@webkit.org627256b2016-09-04 07:10:53 +0000317 my $derivedSourcesTestHTML = File::Spec->catfile($derivedSourcesDir, 'Test.html');
318 my $derivedSourcesTestJS = File::Spec->catfile($derivedSourcesDir, 'TestCombined.js');
bburg@apple.com72f5b812015-09-05 05:29:36 +0000319 # Combine the Esprima JavaScript files for testing into a single file (Esprima.js).
bburg@apple.comb1899292016-09-09 05:07:45 +0000320 system($perl, $combineResourcesCmd,
321 '--input-dir', 'External/Esprima',
322 '--input-html', $derivedSourcesTestHTML,
323 '--input-html-dir', $uiRoot,
324 '--derived-sources-dir', $derivedSourcesDir,
325 '--output-dir', $derivedSourcesDir,
326 '--output-script-name', 'TestEsprima.js');
bburg@apple.com72f5b812015-09-05 05:29:36 +0000327
328 # Export the license into TestCombined.js.
329 my $targetTestJS = File::Spec->catfile($targetResourcePath, 'TestCombined.js');
330 seedFile($targetTestJS, $inspectorLicense);
331
332 # Export the license into Esprima.js.
333 my $targetEsprimaJS = File::Spec->catfile($targetResourcePath, 'TestEsprima.js');
334 seedFile($targetEsprimaJS, $esprimaLicense);
335
commit-queue@webkit.org627256b2016-09-04 07:10:53 +0000336 # Append TestCombined.js to the license that was exported above.
337 appendFile($targetTestJS, $derivedSourcesTestJS);
338
bburg@apple.com72f5b812015-09-05 05:29:36 +0000339 # Append Esprima.js to the license that was exported above.
340 my $derivedSourcesEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'TestEsprima.js');
commit-queue@webkit.orgd0326f92016-05-12 15:47:45 +0000341 appendFile($targetEsprimaJS, $derivedSourcesEsprimaJS);
bburg@apple.com72f5b812015-09-05 05:29:36 +0000342
343 # Copy over Test.html.
commit-queue@webkit.org627256b2016-09-04 07:10:53 +0000344 copy($derivedSourcesTestHTML, File::Spec->catfile($targetResourcePath, 'Test.html'));
bburg@apple.com72f5b812015-09-05 05:29:36 +0000345
346 # Copy the Legacy directory.
347 ditto(File::Spec->catfile($uiRoot, 'Protocol', 'Legacy'), File::Spec->catfile($protocolDir, 'Legacy'));
348}