Title: [238638] trunk/Source/WTF
Revision
238638
Author
[email protected]
Date
2018-11-28 14:07:45 -0800 (Wed, 28 Nov 2018)

Log Message

Update generate-unified-source-bundles.rb to generate .xcfilelist files
https://bugs.webkit.org/show_bug.cgi?id=192029
<rdar://problem/46285918>

Reviewed by Alex Christensen.

Update generate-unified-source-bundles.rb to generate output for
.xcfilelist files. These files are used to indicate the sets of input
and output files to Run Script build phases in Xcode. By invoking
generate-unified-source-bundles.rb with -generate-xcfilelists, the
script generates these .xcfilelist files. These .xcfilelist files can
then be used to specify the inputs and outputs of the Generate Unified
Sources build phases.

* Scripts/generate-unified-source-bundles.rb:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (238637 => 238638)


--- trunk/Source/WTF/ChangeLog	2018-11-28 22:07:20 UTC (rev 238637)
+++ trunk/Source/WTF/ChangeLog	2018-11-28 22:07:45 UTC (rev 238638)
@@ -1,3 +1,21 @@
+2018-11-28  Keith Rollin  <[email protected]>
+
+        Update generate-unified-source-bundles.rb to generate .xcfilelist files
+        https://bugs.webkit.org/show_bug.cgi?id=192029
+        <rdar://problem/46285918>
+
+        Reviewed by Alex Christensen.
+
+        Update generate-unified-source-bundles.rb to generate output for
+        .xcfilelist files. These files are used to indicate the sets of input
+        and output files to Run Script build phases in Xcode. By invoking
+        generate-unified-source-bundles.rb with -generate-xcfilelists, the
+        script generates these .xcfilelist files. These .xcfilelist files can
+        then be used to specify the inputs and outputs of the Generate Unified
+        Sources build phases.
+
+        * Scripts/generate-unified-source-bundles.rb:
+
 2018-11-28  Alexey Proskuryakov  <[email protected]>
 
         Remove another OS version check from NetworkDataTaskCocoa.mm

Modified: trunk/Source/WTF/Scripts/generate-unified-source-bundles.rb (238637 => 238638)


--- trunk/Source/WTF/Scripts/generate-unified-source-bundles.rb	2018-11-28 22:07:20 UTC (rev 238637)
+++ trunk/Source/WTF/Scripts/generate-unified-source-bundles.rb	2018-11-28 22:07:45 UTC (rev 238638)
@@ -38,6 +38,7 @@
     puts "<sources-list-file> may be separate arguments or one semicolon separated string"
     puts "--help                          (-h) Print this message"
     puts "--verbose                       (-v) Adds extra logging to stderr."
+    puts
     puts "Required arguments:"
     puts "--source-tree-path              (-s) Path to the root of the source directory."
     puts "--derived-sources-path          (-d) Path to the directory where the unified source files should be placed."
@@ -44,6 +45,9 @@
     puts
     puts "Optional arguments:"
     puts "--print-bundled-sources              Print bundled sources rather than generating sources"
+    puts "--generate-xcfilelists               Generate .xcfilelist files"
+    puts "--input-xcfilelist-path              Path of the generated input .xcfilelist file"
+    puts "--output-xcfilelist-path             Path of the generated output .xcfilelist file"
     puts "--feature-flags                 (-f) Space or semicolon separated list of enabled feature flags"
     puts
     puts "Generation options:"
@@ -59,6 +63,8 @@
 $featureFlags = {}
 $verbose = false
 $mode = :GenerateBundles
+$inputXCFilelistPath = nil
+$outputXCFilelistPath = nil
 $maxCppBundleCount = nil
 $maxObjCBundleCount = nil
 
@@ -72,6 +78,9 @@
                ['--source-tree-path', '-s', GetoptLong::REQUIRED_ARGUMENT],
                ['--feature-flags', '-f', GetoptLong::REQUIRED_ARGUMENT],
                ['--print-bundled-sources', GetoptLong::NO_ARGUMENT],
+               ['--generate-xcfilelists', GetoptLong::NO_ARGUMENT],
+               ['--input-xcfilelist-path', GetoptLong::REQUIRED_ARGUMENT],
+               ['--output-xcfilelist-path', GetoptLong::REQUIRED_ARGUMENT],
                ['--max-cpp-bundle-count', GetoptLong::REQUIRED_ARGUMENT],
                ['--max-obj-c-bundle-count', GetoptLong::REQUIRED_ARGUMENT]).each {
     | opt, arg |
@@ -82,8 +91,6 @@
         $verbose = true
     when '--derived-sources-path'
         $derivedSourcesPath = Pathname.new(arg)
-        $unifiedSourceOutputPath = $derivedSourcesPath + Pathname.new("unified-sources")
-        FileUtils.mkpath($unifiedSourceOutputPath) if !$unifiedSourceOutputPath.exist?
     when '--source-tree-path'
         $sourceTreePath = Pathname.new(arg)
         usage("Source tree #{arg} does not exist.") if !$sourceTreePath.exist?
@@ -91,6 +98,12 @@
         arg.gsub(/\s+/, ";").split(";").map { |x| $featureFlags[x] = true }
     when '--print-bundled-sources'
         $mode = :PrintBundledSources
+    when '--generate-xcfilelists'
+        $mode = :GenerateXCFilelists
+    when '--input-xcfilelist-path'
+        $inputXCFilelistPath = arg
+    when '--output-xcfilelist-path'
+        $outputXCFilelistPath = arg
     when '--max-cpp-bundle-count'
         $maxCppBundleCount = arg.to_i
     when '--max-obj-c-bundle-count'
@@ -98,6 +111,9 @@
     end
 }
 
+$unifiedSourceOutputPath = $derivedSourcesPath + Pathname.new("unified-sources")
+FileUtils.mkpath($unifiedSourceOutputPath) if !$unifiedSourceOutputPath.exist? && $mode != :GenerateXCFilelists
+
 usage("--derived-sources-path must be specified.") if !$unifiedSourceOutputPath
 usage("--source-tree-path must be specified.") if !$sourceTreePath
 log("Putting unified sources in #{$unifiedSourceOutputPath}")
@@ -108,6 +124,8 @@
 sourceListFiles = ARGV.to_a.map { | sourceFileList | sourceFileList.split(";") }.flatten
 log("Source files: #{sourceListFiles}")
 $generatedSources = []
+$inputSources = []
+$outputSources = []
 
 class SourceFile
     attr_reader :unifiable, :fileIndex, :path
@@ -146,7 +164,13 @@
     end
 
     def to_s
-        if $mode == :GenerateBundles || !derived?
+        if $mode == :GenerateXCFilelists
+            if derived?
+                ($derivedSourcesPath + @path).to_s
+            else
+                '$(SRCROOT)/' + @path.to_s
+            end
+        elsif $mode == :GenerateBundles || !derived?
             @path.to_s
         else
             ($derivedSourcesPath + @path).to_s
@@ -167,6 +191,10 @@
 
     def writeFile(file, text)
         bundleFile = $unifiedSourceOutputPath + file
+        if $mode == :GenerateXCFilelists
+            $outputSources << bundleFile
+            return
+        end
         if (!bundleFile.exist? || IO::read(bundleFile) != @currentBundleText)
             log("Writing bundle #{bundleFile} with: \n#{@currentBundleText}")
             IO::write(bundleFile, @currentBundleText)
@@ -222,6 +250,7 @@
 
 def ProcessFileForUnifiedSourceGeneration(sourceFile)
     path = sourceFile.path
+    $inputSources << sourceFile.to_s
     if (TopLevelDirectoryForPath($currentDirectory) != TopLevelDirectoryForPath(path.dirname))
         log("Flushing because new top level directory; old: #{$currentDirectory}, new: #{path.dirname}")
         $bundleManagers.each_value { |x| x.flush }
@@ -273,8 +302,10 @@
             raise "malformed #if" unless line =~ /\A#if\s+(\S+)/
             inDisabledLines = !$featureFlags[$1]
         else
-            raise "malformed preprocessor directive: #{line}" if line =~ /^#/
-            raise "duplicate line: #{line} in #{path}" if seen[line]
+            if seen[line]
+                next if $mode == :GenerateXCFilelists
+                raise "duplicate line: #{line} in #{path}"
+            end
             seen[line] = true
             result << SourceFile.new(line, sourceFileIndex)
         end
@@ -290,7 +321,7 @@
 sourceFiles.sort.each {
     | sourceFile |
     case $mode
-    when :GenerateBundles
+    when :GenerateBundles, :GenerateXCFilelists
         ProcessFileForUnifiedSourceGeneration(sourceFile)
     when :PrintBundledSources
         $generatedSources << sourceFile if $bundleManagers[sourceFile.path.extname] && sourceFile.unifiable
@@ -313,6 +344,11 @@
     end
 }
 
+if $mode == :GenerateXCFilelists
+    IO::write($inputXCFilelistPath, $inputSources.sort.join("\n") + "\n")
+    IO::write($outputXCFilelistPath, $outputSources.sort.join("\n") + "\n")
+end
+
 # We use stdout to report our unified source list to CMake.
 # Add trailing semicolon and avoid a trailing newline for CMake's sake.
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to