diff options
author | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 17:55:17 +0000 |
---|---|---|
committer | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 17:55:17 +0000 |
commit | 55e1a70ba79c37b1c17bd3bce842e8f4788b2cc3 (patch) | |
tree | 86322da915d46c039c3e910a475e66f14fa0adaa /ppapi/generators | |
parent | 566dad760c5bdcc72376473861b729efc9e0ecc2 (diff) | |
download | chromium_src-55e1a70ba79c37b1c17bd3bce842e8f4788b2cc3.zip chromium_src-55e1a70ba79c37b1c17bd3bce842e8f4788b2cc3.tar.gz chromium_src-55e1a70ba79c37b1c17bd3bce842e8f4788b2cc3.tar.bz2 |
Fix single release generation
Fix several cases where generating a single release will fail because
the object was defined at a previous release, and the UniqueRelease
check was returning an empty set.
BUG= 109679
Review URL: http://codereview.chromium.org/9151022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/generators')
-rwxr-xr-x | ppapi/generators/idl_c_header.py | 22 | ||||
-rwxr-xr-x | ppapi/generators/idl_c_proto.py | 6 | ||||
-rwxr-xr-x | ppapi/generators/idl_generator.py | 10 | ||||
-rwxr-xr-x | ppapi/generators/idl_node.py | 49 |
4 files changed, 71 insertions, 16 deletions
diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py index 3cdf627..485a8ab 100755 --- a/ppapi/generators/idl_c_header.py +++ b/ppapi/generators/idl_c_header.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/python +# # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -109,6 +110,13 @@ class HGen(GeneratorByFile): def GenerateFile(self, filenode, releases, options): savename = GetOutFileName(filenode, GetOption('dstroot')) + unique_releases = filenode.GetUniqueReleases(releases) + if not unique_releases: + if os.path.isfile(savename): + print "Removing stale %s for this range." % filenode.GetName() + os.remove(os.path.realpath(savename)) + return False + out = IDLOutFile(savename) self.GenerateHead(out, filenode, releases, options) self.GenerateBody(out, filenode, releases, options) @@ -119,7 +127,6 @@ class HGen(GeneratorByFile): __pychecker__ = 'unusednames=options' cgen = CGen() gpath = GetOption('guard') - release = releases[0] def_guard = GetOutFileName(filenode, relpath=gpath) def_guard = def_guard.replace(os.sep,'_').replace('.','_').upper() + '_' @@ -171,7 +178,12 @@ class HGen(GeneratorByFile): for node in filenode.GetListOf('Interface'): idefs = '' macro = cgen.GetInterfaceMacro(node) - for rel in node.GetUniqueReleases(releases): + unique = node.GetUniqueReleases(releases) + + # Skip this interface if there are no matching versions + if not unique: continue + + for rel in unique: version = node.GetVersion(rel) name = cgen.GetInterfaceString(node, version) strver = str(version).replace('.', '_') @@ -229,4 +241,6 @@ def Main(args): return failed if __name__ == '__main__': - sys.exit(Main(sys.argv[1:])) + retval = Main(sys.argv[1:]) + sys.exit(retval) + diff --git a/ppapi/generators/idl_c_proto.py b/ppapi/generators/idl_c_proto.py index 7ec0f94..ec42a64 100755 --- a/ppapi/generators/idl_c_proto.py +++ b/ppapi/generators/idl_c_proto.py @@ -534,7 +534,10 @@ class CGen(object): # Define a top level object. def Define(self, node, releases, tabs=0, prefix='', comment=False): - if not node.InReleases(releases): + # If this request does not match unique release, or if the release is not + # available (possibly deprecated) then skip. + unique = node.GetUniqueReleases(releases) + if not unique or not node.InReleases(releases): return '' self.LogEnter('Define %s tab=%d prefix="%s"' % (node,tabs,prefix)) @@ -654,3 +657,4 @@ def Main(args): if __name__ == '__main__': sys.exit(Main(sys.argv[1:])) + diff --git a/ppapi/generators/idl_generator.py b/ppapi/generators/idl_generator.py index 81e8f6f..683593b 100755 --- a/ppapi/generators/idl_generator.py +++ b/ppapi/generators/idl_generator.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/python +# # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -95,7 +96,7 @@ class Generator(object): vmin = ast.releases.index(vmin) vmax = ast.releases.index(vmax) + 1 releases = ast.releases[vmin:vmax] - InfoOut.Log('Generate range %s of %s.' % (range, self.name)) + InfoOut.Log('Generate range %s of %s.' % (rangestr, self.name)) ret = self.GenerateRange(ast, releases, options) if ret < 0: self.Error('Failed to generate range %s : %s.' %(vmin, vmax)) @@ -103,6 +104,10 @@ class Generator(object): InfoOut.Log('%s wrote %d files.' % (self.name, ret)) # Otherwise this should be a single release generation else: + if releasestr == 'start': + releasestr = ast.releases[0] + if releasestr == 'end': + releasestr = ast.releases[-1] if releasestr: InfoOut.Log('Generate release %s of %s.' % (releasestr, self.name)) ret = self.GenerateRelease(ast, releasestr, options) @@ -261,3 +266,4 @@ def Main(args): if __name__ == '__main__': GeneratorReleaseTest('Test Gen', 'testgen', 'Generator Class Test.') sys.exit(Main(sys.argv[1:])) + diff --git a/ppapi/generators/idl_node.py b/ppapi/generators/idl_node.py index e86955c..267b152 100755 --- a/ppapi/generators/idl_node.py +++ b/ppapi/generators/idl_node.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/python +# # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -253,18 +254,48 @@ class IDLNode(IDLRelease): # Given a list of global release, return a subset of releases # for this object that change. last_hash = None - build_list = [] + builds = [] filenode = self.GetProperty('FILE') - my_releases = filenode.release_map.GetReleases() - for rel in releases: + file_releases = filenode.release_map.GetReleases() + + # Generate a set of unique releases for this object based on versions + # available in this file's release labels. + for rel in file_releases: + # Check if this object is valid for the release in question. if not self.IsRelease(rel): continue - # Only check releases used by this source file - if rel not in my_releases: continue + # Only add it if the hash is different. cur_hash = self.GetHash(rel) if last_hash != cur_hash: - build_list.append(rel) + builds.append(rel) last_hash = cur_hash - return build_list + + # Remap the requested releases to releases in the unique build set to + # use first available release names and remove duplicates. + # UNIQUE VERSION: 'M13', 'M14', 'M17' + # REQUESTED RANGE: 'M15', 'M16', 'M17', 'M18' + # REMAP RESULT: 'M14', 'M17' + out_list = [] + build_len = len(builds) + build_index = 0 + rel_len = len(releases) + rel_index = 0 + + while build_index < build_len and rel_index < rel_len: + while rel_index < rel_len and releases[rel_index] < builds[build_index]: + rel_index = rel_index + 1 + + # If we've reached the end of the request list, we must be done + if rel_index == rel_len: + break + + # Check this current request + cur = releases[rel_index] + while build_index < build_len and cur >= builds[build_index]: + build_index = build_index + 1 + + out_list.append(builds[build_index - 1]) + rel_index = rel_index + 1 + return out_list def SetProperty(self, name, val): self.property_node.SetProperty(name, val) @@ -357,6 +388,6 @@ def Main(): return -1 return 0 - if __name__ == '__main__': sys.exit(Main()) + |