Bug 1319352 - Allow to run AccEventGen.py and xpild/header.py from any directory. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 22 Nov 2016 17:05:49 +0900
changeset 323946 1e0adeab3951ace3e93e94f91b475a3352940571
parent 323945 a61bb944172549590e01b811d426b4d8eef0dd78
child 323947 f6e90537b66f13f644e9fe96022537c1bd89cf84
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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):