Bug 1273579 - Move GenerateCSS2PropertiesWebIDL.py invocation to moz.build; r?ted
MozReview-Commit-ID: 4OdSORktwis
--- a/dom/bindings/GenerateCSS2PropertiesWebIDL.py
+++ b/dom/bindings/GenerateCSS2PropertiesWebIDL.py
@@ -1,24 +1,30 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import sys
import string
import argparse
+import subprocess
+import buildconfig
# Generates a line of WebIDL with the given spelling of the property name
# (whether camelCase, _underscorePrefixed, etc.) and the given array of
# extended attributes.
def generateLine(propName, extendedAttrs):
return " [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs),
propName)
-def generate(output, idlFilename):
- propList = eval(sys.stdin.read())
+def generate(output, idlFilename, preprocessorHeader):
+ cpp = buildconfig.substs['CPP'].split()
+ cpp.append(preprocessorHeader)
+ preprocessed = subprocess.check_output(cpp)
+
+ propList = eval(preprocessed)
props = ""
for [name, prop, id, flags, pref, proptype] in propList:
if "CSS_PROPERTY_INTERNAL" in flags:
continue
# Unfortunately, even some of the getters here are fallible
# (e.g. on nsComputedDOMStyle).
extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
if pref is not "":
@@ -63,13 +69,14 @@ def generate(output, idlFilename):
idlFile.close()
output.write("/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n" +
string.Template(idlTemplate).substitute({"props": props}) + '\n')
def main():
parser = argparse.ArgumentParser()
parser.add_argument('idlFilename', help='IDL property file template')
+ parser.add_argument('preprocessorHeader', help='Header file to pass through the preprocessor')
args = parser.parse_args()
- generate(sys.stdout, args.idlFilename)
+ generate(sys.stdout, args.idlFilename, args.preprocessorHeader)
if __name__ == '__main__':
main()
--- a/dom/bindings/Makefile.in
+++ b/dom/bindings/Makefile.in
@@ -22,21 +22,16 @@ css2properties_dependencies = \
$(topsrcdir)/layout/style/nsCSSPropAliasList.h \
$(webidl_base)/CSS2Properties.webidl.in \
$(topsrcdir)/layout/style/PythonCSSProps.h \
$(srcdir)/GenerateCSS2PropertiesWebIDL.py \
$(GLOBAL_DEPS) \
$(NULL)
CSS2Properties.webidl: $(css2properties_dependencies)
- $(CPP) $(DEFINES) $(ACDEFINES) -I$(topsrcdir)/layout/style \
- $(topsrcdir)/layout/style/PythonCSSProps.h | \
- PYTHONDONTWRITEBYTECODE=1 $(PYTHON) \
- $(srcdir)/GenerateCSS2PropertiesWebIDL.py \
- $(webidl_base)/CSS2Properties.webidl.in > $@
# Most of the logic for dependencies lives inside Python so it can be
# used by multiple build backends. We simply have rules to generate
# and include the .pp file.
#
# The generated .pp file contains all the important dependencies such as
# changes to .webidl or .py files should result in code generation being
# performed. But we do pull in file-lists.jon to catch file additions.
--- a/dom/bindings/moz.build
+++ b/dom/bindings/moz.build
@@ -143,8 +143,17 @@ if CONFIG['MOZ_SIMPLEPUSH']:
DEFINES['MOZ_SIMPLEPUSH'] = True
PYTHON_UNIT_TESTS += [
'mozwebidlcodegen/test/test_mozwebidlcodegen.py',
]
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wno-error=shadow']
+
+if CONFIG['COMPILE_ENVIRONMENT']:
+ GENERATED_FILES += ['CSS2Properties.webidl']
+ css_props = GENERATED_FILES['CSS2Properties.webidl']
+ css_props.script = 'GenerateCSS2PropertiesWebIDL.py:generate'
+ css_props.inputs = [
+ '/dom/webidl/CSS2Properties.webidl.in',
+ '/layout/style/PythonCSSProps.h',
+ ]