Bug 1257049 - Stop spawning a separate process for config.status from configure.py draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 15 Mar 2016 18:34:30 +0900
changeset 340841 82a244c692d91af2fa516ea36f6909069b4d12be
parent 340840 c916fde5ebb3819a051a96c2f25366764c5900e7
child 340842 5ee487a0c8feb84a9bd9f052a005ba8a2b49399b
push id13075
push userbmo:mh+mozilla@glandium.org
push dateWed, 16 Mar 2016 01:22:38 +0000
bugs1257049
milestone48.0a1
Bug 1257049 - Stop spawning a separate process for config.status from configure.py
configure.py
python/mozbuild/mozbuild/config_status.py
--- a/configure.py
+++ b/configure.py
@@ -67,16 +67,15 @@ if __name__ == '__main__':
 ''')
 
     # Other things than us are going to run this file, so we need to give it
     # executable permissions.
     os.chmod('config.status', 0755)
     if not config.get('BUILDING_JS') or config.get('JS_STANDALONE'):
         if not config.get('JS_STANDALONE'):
             os.environ['WRITE_MOZINFO'] = '1'
-        # Until we have access to the virtualenv from this script, execute
-        # config.status externally, with the virtualenv python.
-        return subprocess.call([config['PYTHON'], 'config.status'])
+        from mozbuild.config_status import config_status
+        return config_status(args=[], **sanitized_config)
     return 0
 
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv))
--- a/python/mozbuild/mozbuild/config_status.py
+++ b/python/mozbuild/mozbuild/config_status.py
@@ -58,17 +58,18 @@ following:
 
    mach build-backend --backend=VisualStudio
 
 ===============================
 '''.strip()
 
 
 def config_status(topobjdir='.', topsrcdir='.', defines=None,
-                  non_global_defines=None, substs=None, source=None):
+                  non_global_defines=None, substs=None, source=None,
+                  args=sys.argv[1:]):
     '''Main function, providing config.status functionality.
 
     Contrary to config.status, it doesn't use CONFIG_FILES or CONFIG_HEADERS
     variables.
 
     Without the -n option, this program acts as config.status and considers
     the current directory as the top object directory, even when config.status
     is in a different directory. It will, however, treat the directory
@@ -107,17 +108,17 @@ def config_status(topobjdir='.', topsrcd
     parser.add_argument('-d', '--diff', action='store_true',
                         help='print diffs of changed files.')
     parser.add_argument('-b', '--backend', nargs='+', choices=sorted(backends),
                         default=default_backends,
                         help='what backend to build (default: %s).' %
                         ' '.join(default_backends))
     parser.add_argument('--dry-run', action='store_true',
                         help='do everything except writing files out.')
-    options = parser.parse_args()
+    options = parser.parse_args(args)
 
     # Without -n, the current directory is meant to be the top object directory
     if not options.not_topobjdir:
         topobjdir = os.path.abspath('.')
 
     env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
             non_global_defines=non_global_defines, substs=substs, source=source)