Bug 1217015 - Convert AccEventGen.py to GENERATED_FILES and get rid of most of accessible/xpcom/Makefile.in r=glandium,tbsaunde

This commit is contained in:
Chris Manchester 2015-11-16 16:51:51 -08:00
parent fa1b4b0db7
commit cace689ddb
3 changed files with 42 additions and 67 deletions

View File

@ -4,16 +4,24 @@
# 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, os, xpidl
import sys
import os
from mozbuild.makeutil import write_dep_makefile
from mozbuild.util import FileAvoidWrite
import buildconfig
import mozpack.path as mozpath
# The xpidl parser is not incorporated in the in-tree virtualenv.
xpidl_dir = mozpath.join(buildconfig.topsrcdir, 'xpcom', 'idl-parser',
'xpidl')
sys.path.append(xpidl_dir)
import xpidl
# Instantiate the parser.
p = xpidl.IDLParser()
def findIDL(includePath, interfaceFileName):
for d in includePath:
# Not os.path.join: we need a forward slash even on Windows because
# this filename ends up in makedepend output.
path = d + '/' + interfaceFileName
path = mozpath.join(d, interfaceFileName)
if os.path.exists(path):
return path
raise BaseException("No IDL file found for interface %s "
@ -33,16 +41,13 @@ class Configuration:
execfile(filename, config)
self.simple_events = config.get('simple_events', [])
def readConfigFile(filename):
return Configuration(filename)
def firstCap(str):
return str[0].upper() + str[1:]
def writeAttributeParams(a):
return ("%s a%s" % (a.realtype.nativeType('in'), firstCap(a.name)))
def print_header_file(fd, conf):
def print_header_file(fd, conf, incdirs):
idl_paths = set()
fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n")
@ -55,7 +60,7 @@ def print_header_file(fd, conf):
for e in conf.simple_events:
fd.write("#include \"nsIAccessible%s.h\"\n" % e)
for e in conf.simple_events:
idl, idl_path = loadEventIDL(p, options.incdirs, e)
idl, idl_path = loadEventIDL(p, incdirs, e)
idl_paths.add(idl_path)
for iface in filter(lambda p: p.kind == "interface", idl.productions):
classname = ("xpcAcc%s" % e)
@ -103,7 +108,7 @@ def print_cpp(idl, fd, conf, eventname):
if p.kind == 'interface':
write_cpp(eventname, p, fd)
def print_cpp_file(fd, conf):
def print_cpp_file(fd, conf, incdirs):
idl_paths = set()
fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n")
fd.write('#include "xpcAccEvents.h"\n')
@ -115,7 +120,7 @@ def print_cpp_file(fd, conf):
types = []
for e in conf.simple_events:
idl, idl_path = loadEventIDL(p, options.incdirs, e)
idl, idl_path = loadEventIDL(p, incdirs, e)
idl_paths.add(idl_path)
types.extend(interfaceAttributeTypes(idl))
@ -124,7 +129,7 @@ def print_cpp_file(fd, conf):
fd.write("\n")
for e in conf.simple_events:
idl, idl_path = loadEventIDL(p, options.incdirs, e)
idl, idl_path = loadEventIDL(p, incdirs, e)
idl_paths.add(idl_path)
print_cpp(idl, fd, conf, e)
@ -204,35 +209,14 @@ def write_cpp(eventname, iface, fd):
for a in attributes:
writeAttributeGetter(fd, classname, a)
def gen_header_file(fd, conf_file):
conf = Configuration(conf_file)
inc_dir = mozpath.join(buildconfig.topobjdir, 'dist', 'idl')
def main():
from argparse import ArgumentParser
o = ArgumentParser()
o.add_argument('-I', action='append', dest='incdirs', default=['.'],
help="Directory to search for imported files")
o.add_argument('config',
help='Config file to load')
o.add_argument('header_output', metavar='FILE',
help="Quick stub header output file")
o.add_argument('stub_output', metavar='FILE',
help="C++ source output file")
o.add_argument('makedepend_output', metavar='FILE',
help="gnumake dependencies output file")
global options
options = o.parse_args()
return print_header_file(fd, conf, [inc_dir])
# Instantiate the parser.
global p
p = xpidl.IDLParser()
def gen_cpp_file(fd, conf_file):
conf = Configuration(conf_file)
inc_dir = mozpath.join(buildconfig.topobjdir, 'dist', 'idl')
conf = readConfigFile(options.config)
with FileAvoidWrite(options.header_output) as fh:
idl_paths = print_header_file(fh, conf)
with FileAvoidWrite(options.stub_output) as fh:
idl_paths |= print_cpp_file(fh, conf)
with FileAvoidWrite(options.makedepend_output) as fh:
write_dep_makefile(fh, options.stub_output, idl_paths)
if __name__ == '__main__':
main()
return print_cpp_file(fd, conf, [inc_dir])

View File

@ -2,31 +2,9 @@
# 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/.
EXTRA_MDDEPEND_FILES = xpcAccEvents.pp
# We'd like this to be defined in a future GENERATED_EXPORTS list.
# Bug 1160185 has a few proposals for this.
INSTALL_TARGETS += xpcaccevents
xpcaccevents_FILES := xpcAccEvents.h
xpcaccevents_DEST = $(DIST)/include
xpcaccevents_TARGET := export
include $(topsrcdir)/config/rules.mk
xpcAccEvents.cpp: $(srcdir)/AccEvents.conf \
$(srcdir)/AccEventGen.py \
$(LIBXUL_DIST)/sdk/bin/header.py \
$(LIBXUL_DIST)/sdk/bin/xpidl.py
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-I$(LIBXUL_DIST)/sdk/bin \
$(srcdir)/AccEventGen.py \
-I $(DEPTH)/dist/idl \
$(srcdir)/AccEvents.conf \
xpcAccEvents.h \
xpcAccEvents.cpp \
$(MDDEPDIR)/xpcAccEvents.pp
xpcAccEvents.h: xpcAccEvents.cpp
GARBAGE += \
xpcAccEvents.cpp \
xpcAccEvents.h \
$(null)

View File

@ -46,4 +46,17 @@ else:
'/accessible/other',
]
GENERATED_FILES += [
'xpcAccEvents.cpp',
'xpcAccEvents.h',
]
xpc_acc_events_h = GENERATED_FILES['xpcAccEvents.h']
xpc_acc_events_h.script = 'AccEventGen.py:gen_header_file'
xpc_acc_events_h.inputs += ['AccEvents.conf']
xpc_acc_events_cpp = GENERATED_FILES['xpcAccEvents.cpp']
xpc_acc_events_cpp.script = 'AccEventGen.py:gen_cpp_file'
xpc_acc_events_cpp.inputs += ['AccEvents.conf']
FINAL_LIBRARY = 'xul'