bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 3 | # 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.com | ad191ac | 2014-05-12 22:19:35 +0000 | [diff] [blame] | 26 | use English; |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 27 | use File::Copy qw(copy); |
timothy@apple.com | afad3b0 | 2014-09-23 21:08:36 +0000 | [diff] [blame] | 28 | use File::Path qw(make_path remove_tree); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 29 | use File::Spec; |
| 30 | |
| 31 | my $useDirCopy = 0; |
| 32 | |
| 33 | # Not all systems (e.g., OS X) include File::Copy::Recursive. Only |
| 34 | # use it if we have it installed. |
| 35 | eval "use File::Copy::Recursive"; |
| 36 | unless ($@) { |
| 37 | $useDirCopy = 1; |
| 38 | File::Copy::Recursive->import(); |
| 39 | } |
| 40 | |
| 41 | sub 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 | |
| 54 | sub 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.org | d0326f9 | 2016-05-12 15:47:45 +0000 | [diff] [blame] | 64 | sub 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.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 76 | sub 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 | |
| 91 | my $inspectorLicense = <<'EOF'; |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 92 | /* |
bburg@apple.com | 057c910 | 2016-09-09 04:33:11 +0000 | [diff] [blame] | 93 | * Copyright (C) 2007-2016 Apple Inc. All rights reserved. |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 94 | * Copyright (C) 2008 Matt Lilek. All rights reserved. |
| 95 | * Copyright (C) 2008-2009 Anthony Ricaud <rik@webkit.org> |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 96 | * Copyright (C) 2009-2010 Joseph Pecoraro. All rights reserved. |
| 97 | * Copyright (C) 2009-2011 Google Inc. All rights reserved. |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 98 | * 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.org | 626328d | 2015-08-20 00:14:05 +0000 | [diff] [blame] | 105 | * 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.org | b2e1ed1 | 2016-01-06 23:46:21 +0000 | [diff] [blame] | 109 | * Copyright (C) 2015-2016 Devin Rousso <dcrousso+webkit@gmail.com>. All rights reserved. |
commit-queue@webkit.org | 9ba33ad | 2017-04-14 04:47:19 +0000 | [diff] [blame] | 110 | * Copyright (C) 2017 Sony Interactive Entertainment Inc. |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 111 | * |
| 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 | */ |
| 133 | EOF |
| 134 | |
commit-queue@webkit.org | d0326f9 | 2016-05-12 15:47:45 +0000 | [diff] [blame] | 135 | my $perl = $^X; |
bfulgham@apple.com | ad191ac | 2014-05-12 22:19:35 +0000 | [diff] [blame] | 136 | my $python = ($OSNAME =~ /cygwin/) ? "/usr/bin/python" : "python"; |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 137 | my $derivedSourcesDir = $ENV{'DERIVED_SOURCES_DIR'}; |
| 138 | my $scriptsRoot = File::Spec->catdir($ENV{'SRCROOT'}, 'Scripts'); |
bburg@apple.com | 057c910 | 2016-09-09 04:33:11 +0000 | [diff] [blame] | 139 | my $sharedScriptsRoot = File::Spec->catdir($ENV{'JAVASCRIPTCORE_PRIVATE_HEADERS_DIR'}); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 140 | my $uiRoot = File::Spec->catdir($ENV{'SRCROOT'}, 'UserInterface'); |
| 141 | my $targetResourcePath = File::Spec->catdir($ENV{'TARGET_BUILD_DIR'}, $ENV{'UNLOCALIZED_RESOURCES_FOLDER_PATH'}); |
| 142 | my $protocolDir = File::Spec->catdir($targetResourcePath, 'Protocol'); |
joepeck@webkit.org | 87a83de | 2016-03-17 21:02:07 +0000 | [diff] [blame] | 143 | my $workersDir = File::Spec->catdir($targetResourcePath, 'Workers'); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 144 | my $codeMirrorPath = File::Spec->catdir($uiRoot, 'External', 'CodeMirror'); |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 145 | my $esprimaPath = File::Spec->catdir($uiRoot, 'External', 'Esprima'); |
jonowells@apple.com | 538083f | 2014-10-17 23:50:49 +0000 | [diff] [blame] | 146 | my $eslintPath = File::Spec->catdir($uiRoot, 'External', 'ESLint'); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 147 | |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 148 | my $codeMirrorLicense = readLicenseFile(File::Spec->catfile($codeMirrorPath, 'LICENSE')); |
jonowells@apple.com | 538083f | 2014-10-17 23:50:49 +0000 | [diff] [blame] | 149 | my $esprimaLicense = readLicenseFile(File::Spec->catfile($esprimaPath, 'LICENSE')); |
| 150 | my $eslintLicense = readLicenseFile(File::Spec->catfile($eslintPath, 'LICENSE')); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 151 | make_path($protocolDir, $targetResourcePath); |
| 152 | |
| 153 | # Copy over dynamically loaded files from other frameworks, even if we aren't combining resources. |
joepeck@webkit.org | dd1777c | 2014-10-20 17:59:24 +0000 | [diff] [blame] | 154 | copy(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.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 155 | |
commit-queue@webkit.org | 7aa6043 | 2016-01-09 06:32:23 +0000 | [diff] [blame] | 156 | my $forceToolInstall = defined $ENV{'FORCE_TOOL_INSTALL'} && ($ENV{'FORCE_TOOL_INSTALL'} eq 'YES'); |
| 157 | my $shouldCombineMain = defined $ENV{'COMBINE_INSPECTOR_RESOURCES'} && ($ENV{'COMBINE_INSPECTOR_RESOURCES'} eq 'YES'); |
| 158 | my $shouldCombineTest = defined $ENV{'COMBINE_TEST_RESOURCES'} && ($ENV{'COMBINE_TEST_RESOURCES'} eq 'YES'); |
| 159 | my $combineResourcesCmd = File::Spec->catfile($scriptsRoot, 'combine-resources.pl'); |
| 160 | |
| 161 | if ($forceToolInstall) { |
joepeck@webkit.org | 80d85db | 2014-12-04 21:56:04 +0000 | [diff] [blame] | 162 | # 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.org | 80d85db | 2014-12-04 21:56:04 +0000 | [diff] [blame] | 166 | |
commit-queue@webkit.org | 7aa6043 | 2016-01-09 06:32:23 +0000 | [diff] [blame] | 167 | # Also force combining test resources for tool installs. |
| 168 | $shouldCombineTest = 1; |
| 169 | } |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 170 | |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 171 | if ($shouldCombineMain) { |
commit-queue@webkit.org | 627256b | 2016-09-04 07:10:53 +0000 | [diff] [blame] | 172 | # Remove Debug JavaScript and CSS files in Production builds. |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 173 | 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.org | 627256b | 2016-09-04 07:10:53 +0000 | [diff] [blame] | 182 | |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 183 | # Combine the JavaScript and CSS files in Production builds into single files (Main.js and Main.css). |
joepeck@webkit.org | df30d11 | 2015-12-01 21:11:44 +0000 | [diff] [blame] | 184 | my $derivedSourcesMainHTML = File::Spec->catfile($derivedSourcesDir, 'Main.html'); |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 185 | 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.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 192 | |
| 193 | # Combine the CodeMirror JavaScript and CSS files in Production builds into single files (CodeMirror.js and CodeMirror.css). |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 194 | 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.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 202 | |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 203 | # Combine the Esprima JavaScript files in Production builds into a single file (Esprima.js). |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 204 | 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.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 211 | |
jonowells@apple.com | 538083f | 2014-10-17 23:50:49 +0000 | [diff] [blame] | 212 | # Combine the ESLint JavaScript files in Production builds into a single file (ESLint.js). |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 213 | 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.com | 538083f | 2014-10-17 23:50:49 +0000 | [diff] [blame] | 220 | |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 221 | # Remove console.assert calls from the Main.js file. |
| 222 | my $derivedSourcesMainJS = File::Spec->catfile($derivedSourcesDir, 'Main.js'); |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 223 | system($perl, File::Spec->catfile($scriptsRoot, 'remove-console-asserts.pl'), |
| 224 | '--input-script', $derivedSourcesMainJS, |
| 225 | '--output-script', $derivedSourcesMainJS); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 226 | |
| 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.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 241 | seedFile($targetMainJS, $inspectorLicense); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 242 | |
| 243 | my $targetMainCSS = File::Spec->catfile($targetResourcePath, 'Main.css'); |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 244 | seedFile($targetMainCSS, $inspectorLicense); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 245 | |
| 246 | # Export the license into CodeMirror.js and CodeMirror.css. |
| 247 | my $targetCodeMirrorJS = File::Spec->catfile($targetResourcePath, 'CodeMirror.js'); |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 248 | seedFile($targetCodeMirrorJS, $codeMirrorLicense); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 249 | |
| 250 | my $targetCodeMirrorCSS = File::Spec->catfile($targetResourcePath, 'CodeMirror.css'); |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 251 | seedFile($targetCodeMirrorCSS, $codeMirrorLicense); |
| 252 | |
| 253 | # Export the license into Esprima.js. |
| 254 | my $targetEsprimaJS = File::Spec->catfile($targetResourcePath, 'Esprima.js'); |
jonowells@apple.com | 538083f | 2014-10-17 23:50:49 +0000 | [diff] [blame] | 255 | 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.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 260 | |
| 261 | # Minify the Main.js and Main.css files, with Main.js appending to the license that was exported above. |
bburg@apple.com | 057c910 | 2016-09-09 04:33:11 +0000 | [diff] [blame] | 262 | my $jsMinScript = File::Spec->catfile($sharedScriptsRoot, 'jsmin.py'); |
| 263 | my $cssMinScript = File::Spec->catfile($sharedScriptsRoot, 'cssmin.py'); |
bfulgham@apple.com | ad191ac | 2014-05-12 22:19:35 +0000 | [diff] [blame] | 264 | 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.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 266 | |
| 267 | # Minify the CodeMirror.js and CodeMirror.css files, appending to the license that was exported above. |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 268 | my $derivedSourcesCodeMirrorJS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.js'); |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 269 | my $derivedSourcesCodeMirrorCSS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.css'); |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 270 | system(qq("$python" "$jsMinScript" < "$derivedSourcesCodeMirrorJS" >> "$targetCodeMirrorJS")) and die "Failed to minify $derivedSourcesCodeMirrorJS: $!"; |
bfulgham@apple.com | ad191ac | 2014-05-12 22:19:35 +0000 | [diff] [blame] | 271 | system(qq("$python" "$cssMinScript" < "$derivedSourcesCodeMirrorCSS" >> "$targetCodeMirrorCSS")) and die "Failed to minify $derivedSourcesCodeMirrorCSS: $!"; |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 272 | |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 273 | # Minify the Esprima.js file, appending to the license that was exported above. |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 274 | my $derivedSourcesEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'Esprima.js'); |
| 275 | system(qq("$python" "$jsMinScript" < "$derivedSourcesEsprimaJS" >> "$targetEsprimaJS")) and die "Failed to minify $derivedSourcesEsprimaJS: $!"; |
timothy@apple.com | 338dc7f | 2014-08-08 06:48:52 +0000 | [diff] [blame] | 276 | |
jonowells@apple.com | 538083f | 2014-10-17 23:50:49 +0000 | [diff] [blame] | 277 | # Minify the ESLint.js file, appending to the license that was exported above. |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 278 | my $derivedSourcesESLintJS = File::Spec->catfile($derivedSourcesDir, 'ESLint.js'); |
| 279 | system(qq("$python" "$jsMinScript" < "$derivedSourcesESLintJS" >> "$targetESLintJS")) and die "Failed to minify $derivedSourcesESLintJS: $!"; |
jonowells@apple.com | 538083f | 2014-10-17 23:50:49 +0000 | [diff] [blame] | 280 | |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 281 | # 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.com | afad3b0 | 2014-09-23 21:08:36 +0000 | [diff] [blame] | 286 | # 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.org | 8c233ba | 2016-02-12 22:31:08 +0000 | [diff] [blame] | 289 | # 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.org | 87a83de | 2016-03-17 21:02:07 +0000 | [diff] [blame] | 292 | # Copy the Protocol/Legacy and Workers directories. |
bfulgham@apple.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 293 | ditto(File::Spec->catfile($uiRoot, 'Protocol', 'Legacy'), File::Spec->catfile($protocolDir, 'Legacy')); |
joepeck@webkit.org | 87a83de | 2016-03-17 21:02:07 +0000 | [diff] [blame] | 294 | ditto(File::Spec->catfile($uiRoot, 'Workers'), $workersDir); |
commit-queue@webkit.org | d25bcf9 | 2016-04-02 05:23:32 +0000 | [diff] [blame] | 295 | |
| 296 | # Remove console.assert calls from the Worker js files. |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 297 | system($perl, File::Spec->catfile($scriptsRoot, 'remove-console-asserts.pl'), |
| 298 | '--input-directory', $workersDir); |
commit-queue@webkit.org | ec94d24 | 2016-04-29 05:23:46 +0000 | [diff] [blame] | 299 | |
| 300 | # Fix import references in Workers directories. This rewrites "../../External/script.js" import paths to their new locations. |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 301 | 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.com | 1c18cab | 2014-04-08 21:29:09 +0000 | [diff] [blame] | 303 | } else { |
| 304 | # Keep the files separate for engineering builds. |
| 305 | ditto($uiRoot, $targetResourcePath); |
| 306 | } |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 307 | |
| 308 | if ($shouldCombineTest) { |
bburg@apple.com | 6444066 | 2016-09-04 04:34:57 +0000 | [diff] [blame] | 309 | # Combine the JavaScript files for testing into a single file (TestCombined.js). |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 310 | 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.com | 6444066 | 2016-09-04 04:34:57 +0000 | [diff] [blame] | 316 | |
commit-queue@webkit.org | 627256b | 2016-09-04 07:10:53 +0000 | [diff] [blame] | 317 | my $derivedSourcesTestHTML = File::Spec->catfile($derivedSourcesDir, 'Test.html'); |
| 318 | my $derivedSourcesTestJS = File::Spec->catfile($derivedSourcesDir, 'TestCombined.js'); |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 319 | # Combine the Esprima JavaScript files for testing into a single file (Esprima.js). |
bburg@apple.com | b189929 | 2016-09-09 05:07:45 +0000 | [diff] [blame] | 320 | 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.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 327 | |
| 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.org | 627256b | 2016-09-04 07:10:53 +0000 | [diff] [blame] | 336 | # Append TestCombined.js to the license that was exported above. |
| 337 | appendFile($targetTestJS, $derivedSourcesTestJS); |
| 338 | |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 339 | # Append Esprima.js to the license that was exported above. |
| 340 | my $derivedSourcesEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'TestEsprima.js'); |
commit-queue@webkit.org | d0326f9 | 2016-05-12 15:47:45 +0000 | [diff] [blame] | 341 | appendFile($targetEsprimaJS, $derivedSourcesEsprimaJS); |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 342 | |
| 343 | # Copy over Test.html. |
commit-queue@webkit.org | 627256b | 2016-09-04 07:10:53 +0000 | [diff] [blame] | 344 | copy($derivedSourcesTestHTML, File::Spec->catfile($targetResourcePath, 'Test.html')); |
bburg@apple.com | 72f5b81 | 2015-09-05 05:29:36 +0000 | [diff] [blame] | 345 | |
| 346 | # Copy the Legacy directory. |
| 347 | ditto(File::Spec->catfile($uiRoot, 'Protocol', 'Legacy'), File::Spec->catfile($protocolDir, 'Legacy')); |
| 348 | } |