Bug 1319352 - Allow to run AccEventGen.py and xpild/header.py from any directory. r?mshal draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 22 Nov 2016 17:05:49 +0900
changeset 442610 1651f57ec3ca143f8bf4e3b0a0b9f1807f0e1dc7
parent 442609 36a642ecd5ed5638f54dbba816a7ad5872bdd80d
child 537843 cd253a6a41bb8dfd96f6ae02e606999b66e6b636
push id36757
push userbmo:mh+mozilla@glandium.org
push dateTue, 22 Nov 2016 22:28:41 +0000
reviewersmshal
bugs1319352
milestone53.0a1
Bug 1319352 - Allow to run AccEventGen.py and xpild/header.py from any directory. r?mshal
accessible/xpcom/AccEventGen.py
xpcom/idl-parser/xpidl/header.py
--- a/accessible/xpcom/AccEventGen.py
+++ b/accessible/xpcom/AccEventGen.py
@@ -218,11 +218,11 @@ def get_conf(conf_file):
         mozpath.join(buildconfig.topsrcdir, 'xpcom', 'base'),
     ]
     return conf, inc_dir
 
 def gen_files(fd, conf_file, xpidllex, xpidlyacc):
     deps = set()
     conf, inc_dir = get_conf(conf_file)
     deps.update(print_header_file(fd, conf, inc_dir))
-    with open('xpcAccEvents.cpp', 'w') as cpp_fd:
+    with open(os.path.join(os.path.dirname(fd.name), 'xpcAccEvents.cpp'), 'w') as cpp_fd:
         deps.update(print_cpp_file(cpp_fd, conf, inc_dir))
     return deps
--- a/xpcom/idl-parser/xpidl/header.py
+++ b/xpcom/idl-parser/xpidl/header.py
@@ -543,17 +543,17 @@ def write_interface(iface, fd):
                                      'nativeName': methodNativeName(member),
                                      'paramList': paramlistAsNative(member, empty='')})
         fd.write('\n')
 
     fd.write(iface_template_epilog)
 
 
 def main(outputfile):
-    cachedir = '.'
+    cachedir = os.path.dirname(outputfile.name if outputfile else '') or '.'
     if not os.path.isdir(cachedir):
         os.mkdir(cachedir)
     sys.path.append(cachedir)
 
     # Delete the lex/yacc files.  Ply is too stupid to regenerate them
     # properly
     for fileglobs in [os.path.join(cachedir, f) for f in ["xpidllex.py*", "xpidlyacc.py*"]]:
         for filename in glob.glob(fileglobs):