Changeset 82030 in webkit


Ignore:
Timestamp:
Mar 26, 2011 7:38:43 AM (13 years ago)
Author:
abarth@webkit.org
Message:

2011-03-26 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

We shouldn't bother running GYP if the generated files are newer than the GYP files
https://bugs.webkit.org/show_bug.cgi?id=57146

In the common case, this check will avoid any overhead from processing
the GYP files. Another approach to doing this is to add the feature to
GYP directly, but GYP's approach to this problem is to compute the
output in its entirety and compare it byte-for-byte against the output
file. In the future, it might make sense to add this approach as an
alternative approach for GYP itself.

I also removed JavaScriptGlue from the script because we're not really
going to change JavaScriptGlue over to GYP. We were using
JavaScriptGlue as a learning experience.

  • Source/gyp/configure:
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r82018 r82030  
     12011-03-26  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        We shouldn't bother running GYP if the generated files are newer than the GYP files
     6        https://bugs.webkit.org/show_bug.cgi?id=57146
     7
     8        In the common case, this check will avoid any overhead from processing
     9        the GYP files.  Another approach to doing this is to add the feature to
     10        GYP directly, but GYP's approach to this problem is to compute the
     11        output in its entirety and compare it byte-for-byte against the output
     12        file.  In the future, it might make sense to add this approach as an
     13        alternative approach for GYP itself.
     14
     15        I also removed JavaScriptGlue from the script because we're not really
     16        going to change JavaScriptGlue over to GYP.  We were using
     17        JavaScriptGlue as a learning experience.
     18
     19        * Source/gyp/configure:
     20
    1212011-03-25  Kevin Ollivier  <kevino@theolliviers.com>
    222
  • trunk/Source/gyp/configure

    r81712 r82030  
    3232import subprocess
    3333
     34from optparse import OptionParser
     35
     36def chdir_to_source():
     37    source_directory = os.path.abspath(os.path.join(__file__, '..', '..'))
     38    os.chdir(source_directory)
     39
     40def gyp():
     41    return os.path.join('ThirdParty', 'gyp', 'gyp')
     42
     43class Project:
     44    def __init__(self, name):
     45        self._name = name
     46
     47    def name(self):
     48        return self._name
     49
     50    def inputs(self):
     51        return [
     52            os.path.join(self._name, 'gyp', self._name + '.gyp'),
     53            os.path.join(self._name, self._name + '.gypi'),
     54            os.path.join('gyp', 'common.gypi'),
     55        ]
     56
     57    def output(self):
     58        return os.path.join(self._name, 'gyp', self._name + '.xcodeproj', 'project.pbxproj')
     59
     60    def should_generate(self):
     61        if not os.path.exists(self.output()):
     62            return True
     63        return os.path.getmtime(self.output()) < self._newest(self.inputs())
     64
     65    def generate(self):
     66        subprocess.call([
     67            gyp(),
     68            self.inputs()[0],
     69            '-G',
     70            'xcode_list_excluded_files=0',
     71            '--depth=.',
     72        ])
     73        # GYP doesn't always touch the output file, but we want to touch the
     74        # file so that we don't keep trying to regenerate it.
     75        os.utime(self.output(), None)
     76
     77    @staticmethod
     78    def _newest(paths):
     79        return max([os.path.getmtime(path) for path in paths])
    3480
    3581PROJECTS = [
    36     "JavaScriptGlue",
    37     "JavaScriptCore",
    38     "WebCore",
     82    Project("JavaScriptCore"),
     83    Project("WebCore"),
    3984]
    4085
     86def projects_to_generate():
     87    should_generate = [project for project in PROJECTS if project.should_generate()]
     88    already_generated = [project.name() for project in set(PROJECTS) - set(should_generate)]
    4189
    42 def create_project(project):
    43     subprocess.call([
    44         os.path.join('ThirdParty', 'gyp', 'gyp'),
    45         os.path.join(project, 'gyp', project + '.gyp'),
    46         '-G',
    47         'xcode_list_excluded_files=0',
    48         '--depth=.',
    49     ])
     90    if already_generated:
     91        print "Not generating %s because the generated files exist and are newer than the GYP files." % ', '.join(already_generated)
     92        print "Pass --regenerate-projects to override."
    5093
    51 
    52 def create_all_projects():
    53     for project in PROJECTS:
    54         create_project(project)
    55 
     94    return should_generate
    5695
    5796def main():
    58     source_directory = os.path.abspath(os.path.join(__file__, '..', '..'))
    59     os.chdir(source_directory)
     97    chdir_to_source()
     98
     99    parser = OptionParser()
    60100    # FIXME: The user should be able to pass which port on the command line.
    61     create_all_projects()
     101    parser.add_option("--regenerate-projects", dest="regenerate_projects",
     102                      default=False, action="store_true",
     103                      help="Generate all project files even if they appear to be up to date.")
     104    (options, args) = parser.parse_args()
    62105
     106    projects = PROJECTS
     107    if not options.regenerate_projects:
     108        projects = projects_to_generate()
     109
     110    for project in projects:
     111        print "Generating %s." % project.name()
     112        project.generate()
    63113
    64114if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.