diff --git a/config/config.mk b/config/config.mk index 6f65244ac6d5..62f8e30d260d 100644 --- a/config/config.mk +++ b/config/config.mk @@ -818,4 +818,8 @@ DEFINES += -DNO_NSPR_10_SUPPORT # # libs:: # $(call py_action,purge_manifests,_build_manifests/purge/foo.manifest) +ifdef .PYMAKE +py_action = %mozbuild.action.$(1) main $(2) +else py_action = $(PYTHON) -m mozbuild.action.$(1) $(2) +endif diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 6f65244ac6d5..62f8e30d260d 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -818,4 +818,8 @@ DEFINES += -DNO_NSPR_10_SUPPORT # # libs:: # $(call py_action,purge_manifests,_build_manifests/purge/foo.manifest) +ifdef .PYMAKE +py_action = %mozbuild.action.$(1) main $(2) +else py_action = $(PYTHON) -m mozbuild.action.$(1) $(2) +endif diff --git a/python/mozbuild/mozbuild/action/process_install_manifest.py b/python/mozbuild/mozbuild/action/process_install_manifest.py index 9c5aec14196e..a72c697c1873 100644 --- a/python/mozbuild/mozbuild/action/process_install_manifest.py +++ b/python/mozbuild/mozbuild/action/process_install_manifest.py @@ -5,6 +5,7 @@ from __future__ import print_function, unicode_literals import argparse +import sys from mozpack.copier import FileCopier from mozpack.manifests import InstallManifest @@ -23,7 +24,7 @@ def process_manifest(destdir, paths, remove_unaccounted=True): return copier.copy(destdir, remove_unaccounted=remove_unaccounted) -if __name__ == '__main__': +def main(argv): parser = argparse.ArgumentParser( description='Process install manifest files.') @@ -32,7 +33,7 @@ if __name__ == '__main__': parser.add_argument('--no-remove', action='store_true', help='Do not remove unaccounted files from destination.') - args = parser.parse_args() + args = parser.parse_args(argv) result = process_manifest(args.destdir, args.manifests, remove_unaccounted=not args.no_remove) @@ -42,3 +43,6 @@ if __name__ == '__main__': updated=result.updated_files_count, rm_files=result.removed_files_count, rm_dirs=result.removed_directories_count)) + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/python/mozbuild/mozbuild/action/xpccheck.py b/python/mozbuild/mozbuild/action/xpccheck.py index 7183439824ef..ed9ee0a3524e 100644 --- a/python/mozbuild/mozbuild/action/xpccheck.py +++ b/python/mozbuild/mozbuild/action/xpccheck.py @@ -61,13 +61,13 @@ def verifyIniFile(initests, directory): print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory) sys.exit(1) -if __name__ == '__main__': - if len(sys.argv) < 3: +def main(argv): + if len(argv) < 2: print >>sys.stderr, "Usage: xpccheck.py [ ...]" sys.exit(1) - topsrcdir = sys.argv[1] - for d in sys.argv[2:]: + topsrcdir = argv[0] + for d in argv[1:]: # xpcshell-unpack is a copy of xpcshell sibling directory and in the Makefile # we copy all files (including xpcshell.ini from the sibling directory. if d.endswith('toolkit/mozapps/extensions/test/xpcshell-unpack'): @@ -76,3 +76,6 @@ if __name__ == '__main__': initests = getIniTests(d) verifyDirectory(initests, d) verifyIniFile(initests, d) + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/python/mozbuild/mozbuild/action/xpidl-process.py b/python/mozbuild/mozbuild/action/xpidl-process.py index 2396f34bfa90..2cf7d986dbca 100755 --- a/python/mozbuild/mozbuild/action/xpidl-process.py +++ b/python/mozbuild/mozbuild/action/xpidl-process.py @@ -65,7 +65,7 @@ def process(input_dir, cache_dir, header_dir, xpt_dir, deps_dir, module, stems): mk.dump(fh) -if __name__ == '__main__': +def main(argv): parser = argparse.ArgumentParser() parser.add_argument('--cache-dir', help='Directory in which to find or write cached lexer data.') @@ -82,6 +82,9 @@ if __name__ == '__main__': parser.add_argument('idls', nargs='+', help='Source .idl file(s). Specified as stems only.') - args = parser.parse_args() + args = parser.parse_args(argv) process(args.inputdir, args.cache_dir, args.headerdir, args.xptdir, args.depsdir, args.module, args.idls) + +if __name__ == '__main__': + main(sys.argv[1:])