mirror of
https://github.com/servo/servo.git
synced 2025-07-29 18:20:24 +01:00
Auto merge of #8996 - nox:rm-empty-modules, r=frewsxcv
Do not create modules from files with nothing to codegen (fixes #8711) Fixes #8711. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8996) <!-- Reviewable:end -->
This commit is contained in:
commit
d1ea209f0f
2 changed files with 16 additions and 10 deletions
|
@ -18,8 +18,10 @@ def generate_binding_rs(config, outputprefix, webidlfile):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filename = outputprefix + ".rs"
|
filename = outputprefix + ".rs"
|
||||||
root = CGBindingRoot(config, outputprefix, webidlfile)
|
module = CGBindingRoot(config, outputprefix, webidlfile).define()
|
||||||
if replaceFileIfChanged(filename, root.define()):
|
if not module:
|
||||||
|
print "Skipping empty module: %s" % (filename)
|
||||||
|
elif replaceFileIfChanged(filename, module):
|
||||||
print "Generating binding implementation: %s" % (filename)
|
print "Generating binding implementation: %s" % (filename)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5258,17 +5258,23 @@ class CGBindingRoot(CGThing):
|
||||||
descriptors.extend(config.getDescriptors(webIDLFile=webIDLFile,
|
descriptors.extend(config.getDescriptors(webIDLFile=webIDLFile,
|
||||||
hasInterfaceObject=False,
|
hasInterfaceObject=False,
|
||||||
isCallback=False))
|
isCallback=False))
|
||||||
dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
|
|
||||||
|
|
||||||
cgthings = []
|
dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
|
||||||
|
|
||||||
mainCallbacks = config.getCallbacks(webIDLFile=webIDLFile)
|
mainCallbacks = config.getCallbacks(webIDLFile=webIDLFile)
|
||||||
callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile,
|
callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile,
|
||||||
isCallback=True)
|
isCallback=True)
|
||||||
|
|
||||||
# Do codegen for all the enums
|
enums = config.getEnums(webIDLFile)
|
||||||
cgthings = [CGEnum(e) for e in config.getEnums(webIDLFile)]
|
|
||||||
|
|
||||||
|
if not (descriptors or dictionaries or mainCallbacks or callbackDescriptors or enums):
|
||||||
|
self.root = None
|
||||||
|
return
|
||||||
|
|
||||||
|
# Do codegen for all the enums.
|
||||||
|
cgthings = [CGEnum(e) for e in enums]
|
||||||
|
|
||||||
|
# Do codegen for all the dictionaries.
|
||||||
cgthings.extend([CGDictionary(d, config.getDescriptorProvider())
|
cgthings.extend([CGDictionary(d, config.getDescriptorProvider())
|
||||||
for d in dictionaries])
|
for d in dictionaries])
|
||||||
|
|
||||||
|
@ -5288,10 +5294,6 @@ class CGBindingRoot(CGThing):
|
||||||
# And make sure we have the right number of newlines at the end
|
# And make sure we have the right number of newlines at the end
|
||||||
curr = CGWrapper(CGList(cgthings, "\n\n"), post="\n\n")
|
curr = CGWrapper(CGList(cgthings, "\n\n"), post="\n\n")
|
||||||
|
|
||||||
# Wrap all of that in our namespaces.
|
|
||||||
# curr = CGNamespace.build(['dom'],
|
|
||||||
# CGWrapper(curr, pre="\n"))
|
|
||||||
|
|
||||||
# Add imports
|
# Add imports
|
||||||
curr = CGImports(curr, descriptors + callbackDescriptors, mainCallbacks, [
|
curr = CGImports(curr, descriptors + callbackDescriptors, mainCallbacks, [
|
||||||
'js',
|
'js',
|
||||||
|
@ -5390,6 +5392,8 @@ class CGBindingRoot(CGThing):
|
||||||
self.root = curr
|
self.root = curr
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
|
if not self.root:
|
||||||
|
return None
|
||||||
return stripTrailingWhitespace(self.root.define())
|
return stripTrailingWhitespace(self.root.define())
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue