Changeset 229932 in webkit
- Timestamp:
- Mar 23, 2018 4:35:03 PM (6 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r229922 r229932 1 2018-03-23 Brian Burg <bburg@apple.com> 2 3 Web Inspector: add WebKitAdditions hooks for WebInspectorUI 4 https://bugs.webkit.org/show_bug.cgi?id=183940 5 <rdar://problem/38796310> 6 7 Reviewed by Timothy Hatcher. 8 9 * Scripts/combine-resources.pl: 10 (debugLog): Added. Leave in the logging I used to debug this. 11 12 (concatenateIncludedFilesMatchingPattern): 13 (stripIncludedFilesMatchingPattern): 14 (concatenateFiles): Deleted. 15 This function tried to do too many things. Split it into 16 two functions, one for stripping includes and one for concatenating 17 files referenced by includes. 18 19 Lastly, add a negative lookahead clause for 'WebKitAdditions' so includes 20 containing that string are not combined when no input directory is passed 21 to the script. 22 23 * Scripts/copy-user-interface-resources.pl: 24 WebKitAdditions is computed either from BUILT_PRODUCTS_DIR or SDKROOT, 25 depending on the build style. Just try them in order and use the first 26 one that exists. WebInspectorUI files are in their own directory, so 27 we can assume there are files to process if that directory exists. 28 29 Copy Main.html to derived sources before doing any processing on it. 30 This makes all combining phases have the same --input-html argument. 31 32 (debugLog): Added. Leave in the logging I used to debug this. 33 34 (combineOrStripResourcesForWebKitAdditions): 35 (stripResourcesForWebKitAdditions): 36 (combineResourcesForWebKitAdditions): 37 Determine if WebKitAdditions exists and whether there are any 38 resources for WebInspectorUI present that need to be processed. 39 40 * UserInterface/Main.html: 41 Add stub .js and .css WebKitAdditions files. We can add more later 42 if it makes sense but this is good enough to validate the build machinery. 43 1 44 2018-03-23 Nikita Vasilyev <nvasilyev@apple.com> 2 45 -
trunk/Source/WebInspectorUI/Scripts/combine-resources.pl
r226395 r229932 1 1 #!/usr/bin/env perl 2 2 3 # Copyright (C) 2015 Apple Inc. All rights reserved.3 # Copyright (C) 2015-2018 Apple Inc. All rights reserved. 4 4 # 5 5 # Redistribution and use in source and binary forms, with or without … … 38 38 our $htmlFile; 39 39 our $strip; 40 our $verbose; 40 41 41 42 GetOptions('output-dir=s' => \$outputDirectory, … … 46 47 'input-html-dir=s' => \$htmlDirectory, 47 48 'input-html=s' => \$htmlFile, 49 'verbose' => \$verbose, 48 50 'strip' => \$strip); 49 51 … … 51 53 print "Usage: $0 --input-html <path> --derived-sources-dir <path> --output-dir <path> [--output-script-name <name>] [--output-style-name <name>] [--strip]\n"; 52 54 exit; 55 } 56 57 sub debugLog($) 58 { 59 my $logString = shift; 60 print "-- $logString\n" if $verbose; 53 61 } 54 62 … … 59 67 { 60 68 local $/; 61 open HTML, $htmlFile or die ;69 open HTML, $htmlFile or die "Could not open $htmlFile"; 62 70 $htmlContents = <HTML>; 63 71 close HTML; … … 69 77 mkpath $outputDirectory; 70 78 71 sub concatenate Files($$$)79 sub concatenateIncludedFilesMatchingPattern($$$) 72 80 { 73 81 my $filename = shift; … … 75 83 my $concatenatedTag = shift; 76 84 my $fileCount = 0; 85 86 debugLog("combining files for $filename with pattern $tagExpression"); 77 87 78 88 open OUT, ">", "$outputDirectory/$filename" or die "Can't open $outputDirectory/$filename: $!"; … … 92 102 my $replacementExpression = "([\t ]*)" . $tagExpression . "[\t ]*\n+"; 93 103 94 if (defined $strip) { 95 # Just strip all occurrences of the pattern. 96 $headContents =~ s/$replacementExpression//gi; 97 } else { 98 # Replace the first occurrence with a token so we can inject the concatenated tag in the same place 99 # as the first file that got consolidated. This makes sure we preserve some order if there are other 100 # items in the head that we didn't consolidate. 101 $headContents =~ s/$replacementExpression/$1%CONCATENATED%\n/i; 102 $headContents =~ s/$replacementExpression//gi; 103 $headContents =~ s/%CONCATENATED%/$concatenatedTag/; 104 } 104 # Replace the first occurrence with a token so we can inject the concatenated tag in the same place 105 # as the first file that got consolidated. This makes sure we preserve some order if there are other 106 # items in the head that we didn't consolidate. 107 $headContents =~ s/$replacementExpression/$1%CONCATENATED%\n/i; 108 $headContents =~ s/$replacementExpression//gi; 109 $headContents =~ s/%CONCATENATED%/$concatenatedTag/; 105 110 } 106 111 107 my $inputDirectoryPattern = "(?!External\/)(?!Workers\/)[^\"]*"; 112 sub stripIncludedFilesMatchingPattern($) 113 { 114 my $tagPattern = shift; 115 116 # Don't use \s so we can control the newlines we consume. 117 my $whitespaceConsumingTagPattern = "([\t ]*)" . $tagPattern . "[\t ]*\n+"; 118 $headContents =~ s/$whitespaceConsumingTagPattern//gi; 119 } 120 121 my $inputDirectoryPattern = "(?!WebKitAdditions\/)(?!External\/)(?!Workers\/)[^\"]*"; 108 122 $inputDirectoryPattern = $inputDirectory . "\/[^\"]*" if $inputDirectory; 109 123 110 concatenateFiles($outputStylesheetName, "<link rel=\"stylesheet\" href=\"($inputDirectoryPattern)\">", "<link rel=\"stylesheet\" href=\"$outputStylesheetName\">") if defined $outputStylesheetName; 111 concatenateFiles($outputScriptName, "<script src=\"($inputDirectoryPattern)\"><\/script>", "<script src=\"$outputScriptName\"></script>") if defined $outputScriptName; 124 if (defined($strip)) { 125 stripIncludedFilesMatchingPattern("<link rel=\"stylesheet\" href=\"($inputDirectoryPattern)\">"); 126 stripIncludedFilesMatchingPattern("<script src=\"($inputDirectoryPattern)\"><\/script>"); 127 } else { 128 concatenateIncludedFilesMatchingPattern($outputStylesheetName, "<link rel=\"stylesheet\" href=\"($inputDirectoryPattern)\">", "<link rel=\"stylesheet\" href=\"$outputStylesheetName\">") if defined $outputStylesheetName; 129 concatenateIncludedFilesMatchingPattern($outputScriptName, "<script src=\"($inputDirectoryPattern)\"><\/script>", "<script src=\"$outputScriptName\"></script>") if defined $outputScriptName; 130 } 112 131 113 132 $htmlContents =~ s/<head>.*<\/head>/<head>$headContents<\/head>/si; -
trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl
r226395 r229932 1 1 #!/usr/bin/env perl 2 2 3 # Copyright (C) 2015 Apple Inc. All rights reserved.3 # Copyright (C) 2015-2018 Apple Inc. All rights reserved. 4 4 # 5 5 # Redistribution and use in source and binary forms, with or without … … 26 26 use warnings; 27 27 use English; 28 use File::Basename qw(dirname); 28 29 use File::Copy qw(copy); 29 30 use File::Path qw(make_path remove_tree); 30 31 use File::Spec; 32 use Getopt::Long; 33 34 my $verbose = 0; 35 GetOptions('verbose' => \$verbose); 36 37 sub debugLog($) 38 { 39 my $logString = shift; 40 print "-- $logString\n" if $verbose; 41 } 31 42 32 43 my $useDirCopy = 0; … … 102 113 my $inspectorLicense = <<'EOF'; 103 114 /* 104 * Copyright (C) 2007-201 6Apple Inc. All rights reserved.115 * Copyright (C) 2007-2018 Apple Inc. All rights reserved. 105 116 * Copyright (C) 2008 Matt Lilek. All rights reserved. 106 117 * Copyright (C) 2008-2009 Anthony Ricaud <rik@webkit.org> … … 158 169 my $threejsPath = File::Spec->catdir($uiRoot, 'External', 'three.js'); 159 170 171 my $webkitAdditionsDir; 172 $webkitAdditionsDir = File::Spec->catdir($ENV{'BUILT_PRODUCTS_DIR'}, 'usr', 'local', 'include', 'WebKitAdditions'); 173 $webkitAdditionsDir = File::Spec->catdir($ENV{'SDKROOT'}, 'usr', 'local', 'include', 'WebKitAdditions') unless -d $webkitAdditionsDir; 174 my $webInspectorUIAdditionsDir = File::Spec->catdir($webkitAdditionsDir, 'WebInspectorUI'); 175 176 debugLog("webkitAdditionsDir: $webkitAdditionsDir"); 177 160 178 my $codeMirrorLicense = readLicenseFile(File::Spec->catfile($codeMirrorPath, 'LICENSE')); 161 179 my $esprimaLicense = readLicenseFile(File::Spec->catfile($esprimaPath, 'LICENSE')); … … 182 200 } 183 201 202 if (!$shouldCombineMain) { 203 # Keep the files separate for engineering builds. Copy these before altering Main.html 204 # in other ways, such as combining for WebKitAdditions or inlining files. 205 ditto($uiRoot, $targetResourcePath); 206 } 207 208 # Always refer to the copy in derived sources so the order of replacements does not matter. 209 make_path($derivedSourcesDir); 210 my $derivedSourcesMainHTML = File::Spec->catfile($derivedSourcesDir, 'Main.html'); 211 copy(File::Spec->catfile($uiRoot, 'Main.html'), File::Spec->catfile($derivedSourcesDir, 'Main.html')) or die "Copy failed: $!"; 212 213 sub combineOrStripResourcesForWebKitAdditions() { 214 my $combineWebKitAdditions = 0; 215 216 if (-d $webInspectorUIAdditionsDir) { 217 $combineWebKitAdditions = 1; 218 debugLog("Found $webInspectorUIAdditionsDir"); 219 } else { 220 debugLog("Didn't find $webInspectorUIAdditionsDir"); 221 } 222 223 if ($combineWebKitAdditions) { 224 debugLog("Combining resources provided by WebKitAdditions."); 225 combineResourcesForWebKitAdditions(); 226 } else { 227 debugLog("Stripping resources provided by WebKitAdditions."); 228 stripResourcesForWebKitAdditions(); 229 } 230 } 231 232 sub stripResourcesForWebKitAdditions() { 233 system($perl, $combineResourcesCmd, 234 '--input-dir', 'WebKitAdditions', 235 '--input-html', $derivedSourcesMainHTML, 236 '--derived-sources-dir', $derivedSourcesDir, 237 '--output-dir', $derivedSourcesDir, 238 '--strip'); 239 } 240 241 sub combineResourcesForWebKitAdditions() { 242 $rootPathForRelativeIncludes = dirname(dirname($webInspectorUIAdditionsDir)); 243 system($perl, $combineResourcesCmd, 244 '--input-dir', 'WebKitAdditions', 245 '--input-html', $derivedSourcesMainHTML, 246 '--input-html-dir', $rootPathForRelativeIncludes, 247 '--derived-sources-dir', $derivedSourcesDir, 248 '--output-dir', $derivedSourcesDir, 249 '--output-script-name', 'WebKitAdditions.js', 250 '--output-style-name', 'WebKitAdditions.css'); 251 252 # Export the license into WebKitAdditions files. 253 my $targetWebKitAdditionsJS = File::Spec->catfile($targetResourcePath, 'WebKitAdditions.js'); 254 seedFile($targetWebKitAdditionsJS, $inspectorLicense); 255 256 my $targetWebKitAdditionsCSS = File::Spec->catfile($targetResourcePath, 'WebKitAdditions.css'); 257 seedFile($targetWebKitAdditionsCSS, $inspectorLicense); 258 259 appendFile($targetWebKitAdditionsJS, File::Spec->catfile($derivedSourcesDir, 'WebKitAdditions.js')); 260 appendFile($targetWebKitAdditionsCSS, File::Spec->catfile($derivedSourcesDir, 'WebKitAdditions.css')); 261 } 262 184 263 if ($shouldCombineMain) { 185 264 # Remove Debug JavaScript and CSS files in Production builds. 186 265 system($perl, $combineResourcesCmd, 187 266 '--input-dir', 'Debug', 188 '--input-html', File::Spec->catfile($uiRoot, 'Main.html'),267 '--input-html', $derivedSourcesMainHTML, 189 268 '--input-html-dir', $uiRoot, 190 269 '--derived-sources-dir', $derivedSourcesDir, … … 195 274 196 275 # Combine the JavaScript and CSS files in Production builds into single files (Main.js and Main.css). 197 my $derivedSourcesMainHTML = File::Spec->catfile($derivedSourcesDir, 'Main.html');198 276 system($perl, $combineResourcesCmd, 199 277 '--input-html', $derivedSourcesMainHTML, … … 203 281 '--output-script-name', 'Main.js', 204 282 '--output-style-name', 'Main.css'); 283 284 # Process WebKitAdditions.{css,js} after Main.{js,css}. Otherwise, the combined WebKitAdditions files 285 # will get slurped into Main.{js,css} because the 'WebKitAdditions' relative URL prefix will be removed. 286 combineOrStripResourcesForWebKitAdditions(); 205 287 206 288 # Combine the CodeMirror JavaScript and CSS files in Production builds into single files (CodeMirror.js and CodeMirror.css). … … 309 391 system(qq("$python" "$jsMinScript" < "$derivedSourcesThreejsJS" >> "$targetThreejsJS")) and die "Failed to minify $derivedSourcesThreejsJS: $!"; 310 392 311 # Copy over Main.html and the Images directory. 312 copy($derivedSourcesMainHTML, File::Spec->catfile($targetResourcePath, 'Main.html')); 313 393 # Copy over the Images directory. 314 394 ditto(File::Spec->catdir($uiRoot, 'Images'), File::Spec->catdir($targetResourcePath, 'Images')); 315 395 … … 329 409 '--input-directory', $workersDir) and die "Failed to update Worker imports for optimized builds."; 330 410 } else { 331 # Keep the files separate for engineering builds. 332 ditto($uiRoot, $targetResourcePath); 333 } 411 # Always process WebKitAdditions files because the 'WebKitAdditions' path prefix is not real, 412 # so it can't proceed as a normal load from the bundle as written. This function replaces the 413 # dummy prefix with the actual WebKitAdditions path when looking for files to inline and combine. 414 combineOrStripResourcesForWebKitAdditions(); 415 } 416 417 # Always copy over Main.html because we may have combined WebKitAdditions files 418 # without minifying anything else. We always want to combine WKA so the relevant 419 # resources are copied out of Derived Sources rather than an arbitrary WKA directory. 420 copy($derivedSourcesMainHTML, File::Spec->catfile($targetResourcePath, 'Main.html')); 334 421 335 422 if ($shouldCombineTest) { -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r229443 r229932 241 241 <link rel="stylesheet" href="Debug/DebugContentView.css"> 242 242 243 <link rel="stylesheet" href="WebKitAdditions/WebInspectorUI/WebInspectorUIAdditions.css"> 244 243 245 <script src="Debug/UncaughtExceptionReporter.js"></script> 244 246 … … 868 870 <script src="Debug/DebugContentView.js"></script> 869 871 872 <script src="WebKitAdditions/WebInspectorUI/WebInspectorUIAdditions.js"></script> 873 870 874 <script> 871 875 WI.sharedApp = new WI.AppController;
Note: See TracChangeset
for help on using the changeset viewer.