Changeset 245531 in webkit


Ignore:
Timestamp:
May 20, 2019 11:24:43 AM (5 years ago)
Author:
Keith Rollin
Message:

generate-xcfilelists is stranding temporary files
https://bugs.webkit.org/show_bug.cgi?id=198008
<rdar://problem/50893659>

Reviewed by Jonathan Bedard.

generate-xcfilelists makes use of temporary files on disk. These files
are opened with the OS's "temporary" bit set, causing them to get
deleted when closed or the process exists. However, these temporary
files actually end up persisting after the script exists. This is
because sed is used to process the files, and is done so in a way
that causes the "temporary" bit to get cleared.

Address this issue by no longer using sed and instead performing the
equivalent processing the file content in-memory.

  • Scripts/webkitpy/generate_xcfilelists_lib/generators.py:

(BaseGenerator._generate_derived):
(BaseGenerator._generate_unified):
(BaseGenerator._replace):
(BaseGenerator._unexpand):
(BaseGenerator._find_added_lines.get_lines):
(BaseGenerator._find_added_lines):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r245516 r245531  
     12019-05-20  Keith Rollin  <krollin@apple.com>
     2
     3        generate-xcfilelists is stranding temporary files
     4        https://bugs.webkit.org/show_bug.cgi?id=198008
     5        <rdar://problem/50893659>
     6
     7        Reviewed by Jonathan Bedard.
     8
     9        generate-xcfilelists makes use of temporary files on disk. These files
     10        are opened with the OS's "temporary" bit set, causing them to get
     11        deleted when closed or the process exists. However, these temporary
     12        files actually end up persisting after the script exists. This is
     13        because `sed` is used to process the files, and is done so in a way
     14        that causes the "temporary" bit to get cleared.
     15
     16        Address this issue by no longer using `sed` and instead performing the
     17        equivalent processing the file content in-memory.
     18
     19        * Scripts/webkitpy/generate_xcfilelists_lib/generators.py:
     20        (BaseGenerator._generate_derived):
     21        (BaseGenerator._generate_unified):
     22        (BaseGenerator._replace):
     23        (BaseGenerator._unexpand):
     24        (BaseGenerator._find_added_lines.get_lines):
     25        (BaseGenerator._find_added_lines):
     26
    1272019-05-20  Ludovico de Nittis  <ludovico.denittis@collabora.com>
    228
  • trunk/Tools/Scripts/webkitpy/generate_xcfilelists_lib/generators.py

    r245476 r245531  
    5858import os
    5959import pickle
     60import re
    6061import tempfile
    6162import traceback
     
    273274            # project).
    274275
    275             self._replace(input.name, "^JavaScriptCore/",               "$(PROJECT_DIR)/")
    276             self._replace(input.name, "^JavaScriptCorePrivateHeaders/", "$(JAVASCRIPTCORE_PRIVATE_HEADERS_DIR)/")
    277             self._replace(input.name, "^WebCore/",                      "$(PROJECT_DIR)/")
    278             self._replace(input.name, "^WebKit2PrivateHeaders/",        "$(WEBKIT2_PRIVATE_HEADERS_DIR)/")
    279 
    280             self._unexpand(input.name, "JAVASCRIPTCORE_PRIVATE_HEADERS_DIR")
    281             self._unexpand(input.name, "PROJECT_DIR")
    282             self._unexpand(input.name, "WEBCORE_PRIVATE_HEADERS_DIR")
    283             self._unexpand(input.name, "WEBKIT2_PRIVATE_HEADERS_DIR")
    284             self._unexpand(input.name, "WEBKITADDITIONS_HEADERS_FOLDER_PATH")
    285             self._unexpand(input.name, "BUILT_PRODUCTS_DIR")    # Do this last, since it's a prefix of some other variables and will "intercept" them if executed earlier than them.
    286 
    287             self._replace(output.name, "^", self._get_derived_sources_dir() + "/")
    288             self._unexpand(output.name, "BUILT_PRODUCTS_DIR")
    289 
    290             self.added_lines_input_derived = self._find_added_lines(input.name, self._get_input_derived_xcfilelist_project_path())
    291             self.added_lines_output_derived = self._find_added_lines(output.name, self._get_output_derived_xcfilelist_project_path())
     276            input_lines = self._get_file_lines(input.name)
     277            output_lines = self._get_file_lines(output.name)
     278
     279            input_lines = self._replace(input_lines, "^JavaScriptCore/",               "$(PROJECT_DIR)/")
     280            input_lines = self._replace(input_lines, "^JavaScriptCorePrivateHeaders/", "$(JAVASCRIPTCORE_PRIVATE_HEADERS_DIR)/")
     281            input_lines = self._replace(input_lines, "^WebCore/",                      "$(PROJECT_DIR)/")
     282            input_lines = self._replace(input_lines, "^WebKit2PrivateHeaders/",        "$(WEBKIT2_PRIVATE_HEADERS_DIR)/")
     283
     284            input_lines = self._unexpand(input_lines, "JAVASCRIPTCORE_PRIVATE_HEADERS_DIR")
     285            input_lines = self._unexpand(input_lines, "PROJECT_DIR")
     286            input_lines = self._unexpand(input_lines, "WEBCORE_PRIVATE_HEADERS_DIR")
     287            input_lines = self._unexpand(input_lines, "WEBKIT2_PRIVATE_HEADERS_DIR")
     288            input_lines = self._unexpand(input_lines, "WEBKITADDITIONS_HEADERS_FOLDER_PATH")
     289            input_lines = self._unexpand(input_lines, "BUILT_PRODUCTS_DIR")    # Do this last, since it's a prefix of some other variables and will "intercept" them if executed earlier than them.
     290
     291            output_lines = self._replace(output_lines, "^", self._get_derived_sources_dir() + "/")
     292            output_lines = self._unexpand(output_lines, "BUILT_PRODUCTS_DIR")
     293
     294            self.added_lines_input_derived = self._find_added_lines(input_lines, self._get_input_derived_xcfilelist_project_path())
     295            self.added_lines_output_derived = self._find_added_lines(output_lines, self._get_output_derived_xcfilelist_project_path())
    292296
    293297    @util.LogEntryExit
     
    322326                    env=env)
    323327
    324             self._unexpand(output.name, "BUILT_PRODUCTS_DIR")
    325 
    326             self.added_lines_input_unified = self._find_added_lines(None, self._get_input_unified_xcfilelist_project_path())
    327             self.added_lines_output_unified = self._find_added_lines(output.name, self._get_output_unified_xcfilelist_project_path())
     328            input_lines = None
     329            output_lines = self._get_file_lines(output.name)
     330
     331            output_lines = self._unexpand(output_lines, "BUILT_PRODUCTS_DIR")
     332
     333            self.added_lines_input_unified = self._find_added_lines(input_lines, self._get_input_unified_xcfilelist_project_path())
     334            self.added_lines_output_unified = self._find_added_lines(output_lines, self._get_output_unified_xcfilelist_project_path())
    328335
    329336    @util.LogEntryExit
     
    336343
    337344    @util.LogEntryExit
    338     def _replace(self, file_name, to_replace, replace_with):
    339         util.subprocess_run([
    340             "sed", "-E", "-e",
    341             "s|{}|{}|".format(to_replace, replace_with),
    342             "-i", "''", file_name])
     345    def _replace(self, lines, to_replace, replace_with):
     346        return set([re.sub(to_replace, replace_with, line) for line in lines])
    343347
    344348    # Utility for post-processing the initial .xcfilelist content. Used to
     
    347351
    348352    @util.LogEntryExit
    349     def _unexpand(self, file_name, variable_name):
     353    def _unexpand(self, lines, variable_name):
    350354        to_replace = self._getenv(variable_name)
    351355        if not to_replace:
    352             return
    353 
    354         self._replace(file_name, "^{}/".format(to_replace), "$({})/".format(variable_name))
     356            return lines
     357        return self._replace(lines, "^{}/".format(to_replace), "$({})/".format(variable_name))
    355358
    356359    # Given a source file with new .xcfilelist content and a dest file that
     
    363366        if not source:
    364367            return set()
    365         source_lines = set(source) if isinstance(source, list) else self._get_file_lines(source)
    366         dest_lines = set(dest) if isinstance(dest, list) else self._get_file_lines(dest)
     368
     369        def get_lines(source):
     370            return source if isinstance(source, set) else set(source) if isinstance(source, list) else self._get_file_lines(source)
     371
     372        source_lines = get_lines(source)
     373        dest_lines = get_lines(dest)
    367374        delta_lines = source_lines - dest_lines
    368375        return delta_lines
Note: See TracChangeset for help on using the changeset viewer.