Changeset 239813 in webkit


Ignore:
Timestamp:
Jan 9, 2019 6:20:13 PM (5 years ago)
Author:
Fujii Hironori
Message:

Use directory local sequential numbers for Unified Sources filenames instead of global sequential numbers for CMake
https://bugs.webkit.org/show_bug.cgi?id=192391

Reviewed by Don Olmstead.

Unified Source Builds are using global sequential numbers for
bundle filenames UnifiedSource{sequential-number}.cpp. As the
result, every new source file added would shift the next ones and
prevent compiler caches from speeding up consecutive builds e.g.
in git-bisect sessions.

Changed it to directory local sequential numbers,
UnifiedSource-{hash-of-dir-name}-{sequential-number-within-the-dir}.cpp.

This is affecting only CMake builds which is where no
'--max-cpp-bundle-count' nor '--max-obj-c-bundle-count' options
are set. Xcode builds still use the old convention.

  • Scripts/generate-unified-source-bundles.rb: Add new instance

variables @currentDirectory and @extraFiles to BundleManager.
Still use global sequential numbers if --max-cpp-bundle-count or
--max-obj-c-bundle-count is given.

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r239792 r239813  
     12019-01-09  Carlos Eduardo Ramalho  <cadubentzen@gmail.com> and Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        Use directory local sequential numbers for Unified Sources filenames instead of global sequential numbers for CMake
     4        https://bugs.webkit.org/show_bug.cgi?id=192391
     5
     6        Reviewed by Don Olmstead.
     7
     8        Unified Source Builds are using global sequential numbers for
     9        bundle filenames UnifiedSource{sequential-number}.cpp. As the
     10        result, every new source file added would shift the next ones and
     11        prevent compiler caches from speeding up consecutive builds e.g.
     12        in git-bisect sessions.
     13
     14        Changed it to directory local sequential numbers,
     15        UnifiedSource-{hash-of-dir-name}-{sequential-number-within-the-dir}.cpp.
     16
     17        This is affecting only CMake builds which is where no
     18        '--max-cpp-bundle-count' nor '--max-obj-c-bundle-count' options
     19        are set. Xcode builds still use the old convention.
     20
     21        * Scripts/generate-unified-source-bundles.rb: Add new instance
     22        variables @currentDirectory and @extraFiles to BundleManager.
     23        Still use global sequential numbers if --max-cpp-bundle-count or
     24        --max-obj-c-bundle-count is given.
     25
    1262019-01-09  Alex Christensen  <achristensen@webkit.org>
    227
  • trunk/Source/WTF/Scripts/generate-unified-source-bundles.rb

    r239561 r239813  
    2222# THE POSSIBILITY OF SUCH DAMAGE.
    2323
     24require 'digest'
    2425require 'fileutils'
    2526require 'pathname'
     
    5354    puts
    5455    puts "Generation options:"
    55     puts "--max-cpp-bundle-count               Sets the limit on the number of cpp bundles that can be generated"
    56     puts "--max-obj-c-bundle-count             Sets the limit on the number of Obj-C bundles that can be generated"
     56    puts "--max-cpp-bundle-count               Use global sequential numbers for cpp bundle filenames and set the limit on the number"
     57    puts "--max-obj-c-bundle-count             Use global sequential numbers for Obj-C bundle filenames and set the limit on the number"
    5758    exit 1
    5859end
     
    184185
    185186class BundleManager
    186     attr_reader :bundleCount, :extension, :fileCount, :currentBundleText, :maxCount
     187    attr_reader :bundleCount, :extension, :fileCount, :currentBundleText, :maxCount, :extraFiles
    187188
    188189    def initialize(extension, max)
     
    192193        @currentBundleText = ""
    193194        @maxCount = max
     195        @extraFiles = []
     196        @currentDirectory = nil
    194197    end
    195198
     
    206209    end
    207210
    208     def bundleFileName(number)
    209         @extension == "cpp" ? "UnifiedSource#{number}.#{extension}" : "UnifiedSource#{number}-#{extension}.#{extension}"
     211    def bundleFileName()
     212        id =
     213            if @maxCount
     214                @bundleCount.to_s
     215            else
     216                # The dash makes the filenames more clear when using a hash.
     217                hash = Digest::SHA1.hexdigest(@currentDirectory.to_s)[0..7]
     218                "-#{hash}-#{@bundleCount}"
     219            end
     220        @extension == "cpp" ? "UnifiedSource#{id}.#{extension}" : "UnifiedSource#{id}-#{extension}.#{extension}"
    210221    end
    211222
    212223    def flush
    213         # No point in writing an empty bundle file
    214         return if @currentBundleText == ""
    215 
    216224        @bundleCount += 1
    217         bundleFile = bundleFileName(@bundleCount)
     225        bundleFile = bundleFileName
    218226        $generatedSources << $unifiedSourceOutputPath + bundleFile
     227        @extraFiles << bundleFile if @maxCount and @bundleCount > @maxCount
    219228
    220229        writeFile(bundleFile, @currentBundleText)
     
    225234    def flushToMax
    226235        raise if !@maxCount
    227         ((@bundleCount+1)..@maxCount).each {
    228             | index |
    229             writeFile(bundleFileName(index), "")
    230         }
     236        while @bundleCount < @maxCount
     237            flush
     238        end
    231239    end
    232240
     
    234242        path = sourceFile.path
    235243        raise "wrong extension: #{path.extname} expected #{@extension}" unless path.extname == ".#{@extension}"
     244        if (TopLevelDirectoryForPath(@currentDirectory) != TopLevelDirectoryForPath(path.dirname))
     245            log("Flushing because new top level directory; old: #{@currentDirectory}, new: #{path.dirname}")
     246            flush
     247            @currentDirectory = path.dirname
     248            @bundleCount = 0 unless @maxCount
     249        end
    236250        if @fileCount == MAX_BUNDLE_SIZE
    237251            log("Flushing because new bundle is full (#{@fileCount} sources)")
     
    256270    path = sourceFile.path
    257271    $inputSources << sourceFile.to_s
    258     if (TopLevelDirectoryForPath($currentDirectory) != TopLevelDirectoryForPath(path.dirname))
    259         log("Flushing because new top level directory; old: #{$currentDirectory}, new: #{path.dirname}")
    260         $bundleManagers.each_value { |x| x.flush }
    261         $currentDirectory = path.dirname
    262     end
    263272
    264273    bundle = $bundleManagers[path.extname]
     
    343352
    344353    manager.flushToMax
    345     bundleCount = manager.bundleCount
    346     extension = manager.extension
    347     if bundleCount > maxCount
    348         filesToAdd = ((maxCount+1)..bundleCount).map { |x| manager.bundleFileName(x) }.join(", ")
     354
     355    unless manager.extraFiles.empty?
     356        extension = manager.extension
     357        bundleCount = manager.bundleCount
     358        filesToAdd = manager.extraFiles.join(", ")
    349359        raise "number of bundles for #{extension} sources, #{bundleCount}, exceeded limit, #{maxCount}. Please add #{filesToAdd} to Xcode then update UnifiedSource#{extension.capitalize}FileCount"
    350360    end
Note: See TracChangeset for help on using the changeset viewer.