Skip to content
  • thakis's avatar
    Add missing .h files to .gn files that have a .cc file next to it in the gn file already. · b8590c94
    thakis authored
    I downloaded https://docs.google.com/spreadsheets/d/15az3FMl-jAS0mx4E9XVSBVHVpmEzo-9EAGY0ywe7bZs/edit#gid=0
    as a csv file, and removed the header line and all columns except the filename.
    Then i ran this script to create this CL:
    
        import os, re, subprocess
        edits = {}
        for filename in open('/Users/thakis/Downloads/files.txt'):
          filename = filename.strip()
          if not filename.endswith('.h'):
    	continue
          basename = os.path.basename(filename)
          cc = r'\b' + os.path.splitext(basename)[0] + r'\.(cc|cpp|mm)\b'
          p = subprocess.Popen(['git', 'grep', '-En', cc, '--', '*.gn', '*.gni'],
    			   stdout = subprocess.PIPE)
          out, _ = p.communicate()
          if p.returncode != 0 or not out:
    	continue
    
          for gnline in out.splitlines():
    	gnfile, linenr, contents = gnline.split(':')
    	linenr = int(linenr)
    	new = re.sub(cc, basename, contents)
    	print gnfile, linenr, new
    	edits.setdefault(gnfile, {})[linenr] = new
    
        for gnfile in edits:
          lines = open(gnfile).read().splitlines()
          for l in reversed(edits[gnfile].keys()):
    	lines.insert(l, edits[gnfile][l])
          open(gnfile, 'w').write('\n'.join(lines))
    
    (It has off-by-a-few errors in the insertion code, so I manually cleaned up
    the output a little bit. Since it was only needed in two files, I didn't
    debug the script.)
    
    I then removed the editing part of the script and made it just do `if out: print filename` at the end of the
    first loop, and used this Apps Script to updated the spreadsheet:
    
        var covered = [ /* filenames printed by script */ ];
        function thakisAutoScript() {
          var spreadsheet = SpreadsheetApp.getActive();
          var sheet = spreadsheet.getActiveSheet();
          var dataRange = sheet.getRange("A2:E898");
          var data = dataRange.getValues();
          for (var i = 0; i < data.length; ++i) {
            var row = data[i];
            var file = row[0];
            if (covered.indexOf(file) == -1)
              continue;
            row[1] = '.h';
            row[2] = 'FALSE';
            row[3] = 'thakis';
            row[4] = 'https://codereview.chromium.org/2770693003/';
            sheet.getRange(2 + i, 1, 1, 5).setValues([row]);
          }
        }
    
    No intended behavior change, see "[chromium-dev] Unlisted source files in BUILD.gn"
    
    BUG=none
    CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win10_chromium_x64_rel_ng;master.tryserver.chromium.win:win_optional_gpu_tests_rel
    NOTRY=true
    
    Review-Url: https://codereview.chromium.org/2770693003
    Cr-Commit-Position: refs/heads/master@{#459147}
    b8590c94