aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2015-12-16 01:13:56 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2015-12-16 01:17:06 +0100
commit2522cfe53942421892aa2c4741e7e9237db7c828 (patch)
treea04c0b86622f42620915ff137922b2d89a517731
parent85b43ea31726776b5d9aafa58786850c12e2c852 (diff)
downloadservo-2522cfe53942421892aa2c4741e7e9237db7c828.tar.gz
servo-2522cfe53942421892aa2c4741e7e9237db7c828.zip
Do not create modules from files with nothing to codegen (fixes #8711)
-rw-r--r--components/script/dom/bindings/codegen/BindingGen.py6
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py20
2 files changed, 16 insertions, 10 deletions
diff --git a/components/script/dom/bindings/codegen/BindingGen.py b/components/script/dom/bindings/codegen/BindingGen.py
index 5debf3e1f0f..6b1f10c44e2 100644
--- a/components/script/dom/bindings/codegen/BindingGen.py
+++ b/components/script/dom/bindings/codegen/BindingGen.py
@@ -18,8 +18,10 @@ def generate_binding_rs(config, outputprefix, webidlfile):
"""
filename = outputprefix + ".rs"
- root = CGBindingRoot(config, outputprefix, webidlfile)
- if replaceFileIfChanged(filename, root.define()):
+ module = CGBindingRoot(config, outputprefix, webidlfile).define()
+ if not module:
+ print "Skipping empty module: %s" % (filename)
+ elif replaceFileIfChanged(filename, module):
print "Generating binding implementation: %s" % (filename)
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 75de595694c..481a431ff73 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -5280,17 +5280,23 @@ class CGBindingRoot(CGThing):
descriptors.extend(config.getDescriptors(webIDLFile=webIDLFile,
hasInterfaceObject=False,
isCallback=False))
- dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
- cgthings = []
+ dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
mainCallbacks = config.getCallbacks(webIDLFile=webIDLFile)
callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile,
isCallback=True)
- # Do codegen for all the enums
- cgthings = [CGEnum(e) for e in config.getEnums(webIDLFile)]
+ enums = 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())
for d in dictionaries])
@@ -5310,10 +5316,6 @@ class CGBindingRoot(CGThing):
# And make sure we have the right number of newlines at the end
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
curr = CGImports(curr, descriptors + callbackDescriptors, mainCallbacks, [
'js',
@@ -5412,6 +5414,8 @@ class CGBindingRoot(CGThing):
self.root = curr
def define(self):
+ if not self.root:
+ return None
return stripTrailingWhitespace(self.root.define())