|
@@ -0,0 +1,106 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Ricky Stewart <rstewart@mozilla.com>
|
|
|
+# Date 1577806210 0
|
|
|
+# Node ID 6e02a9956f57b0c32e8bad6b023a39d56343f7cb
|
|
|
+# Parent 84a9f1e261d3ac46e4675473755af9212e67e89c
|
|
|
+Bug 1606160 - mozbuild/base.py and mozbuild/mozconfig.py support Python 3 r=firefox-build-system-reviewers,mshal
|
|
|
+
|
|
|
+Differential Revision: https://phabricator.services.mozilla.com/D58323
|
|
|
+
|
|
|
+diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py
|
|
|
+--- a/python/mozbuild/mozbuild/base.py
|
|
|
++++ b/python/mozbuild/mozbuild/base.py
|
|
|
+@@ -44,17 +44,20 @@ def ancestors(path):
|
|
|
+ while path:
|
|
|
+ yield path
|
|
|
+ newpath = os.path.dirname(path)
|
|
|
+ if newpath == path:
|
|
|
+ break
|
|
|
+ path = newpath
|
|
|
+
|
|
|
+ def samepath(path1, path2):
|
|
|
+- if hasattr(os.path, 'samefile'):
|
|
|
++ # Under Python 3 (but NOT Python 2), MozillaBuild exposes the
|
|
|
++ # os.path.samefile function despite it not working, so only use it if we're
|
|
|
++ # not running under Windows.
|
|
|
++ if hasattr(os.path, 'samefile') and os.name != 'nt':
|
|
|
+ return os.path.samefile(path1, path2)
|
|
|
+ return os.path.normcase(os.path.realpath(path1)) == \
|
|
|
+ os.path.normcase(os.path.realpath(path2))
|
|
|
+
|
|
|
+ class BadEnvironmentException(Exception):
|
|
|
+ """Base class for errors raised when the build environment is not sane."""
|
|
|
+
|
|
|
+
|
|
|
+diff --git a/python/mozbuild/mozbuild/mozconfig.py b/python/mozbuild/mozbuild/mozconfig.py
|
|
|
+--- a/python/mozbuild/mozbuild/mozconfig.py
|
|
|
++++ b/python/mozbuild/mozbuild/mozconfig.py
|
|
|
+@@ -2,22 +2,23 @@
|
|
|
+ # 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/.
|
|
|
+
|
|
|
+ from __future__ import absolute_import, unicode_literals
|
|
|
+
|
|
|
+ import filecmp
|
|
|
+ import os
|
|
|
+ import re
|
|
|
+ import sys
|
|
|
+ import subprocess
|
|
|
+ import traceback
|
|
|
+
|
|
|
+ from collections import defaultdict
|
|
|
+ from mozpack import path as mozpath
|
|
|
++from mozbuild.util import ensure_subprocess_env
|
|
|
+
|
|
|
+
|
|
|
+ MOZ_MYCONFIG_ERROR = '''
|
|
|
+ The MOZ_MYCONFIG environment variable to define the location of mozconfigs
|
|
|
+ is deprecated. If you wish to define the mozconfig path via an environment
|
|
|
+ variable, use MOZCONFIG instead.
|
|
|
+ '''.strip()
|
|
|
+
|
|
|
+@@ -237,18 +239,19 @@ class MozconfigLoader(object):
|
|
|
+ command = [shell, mozpath.normsep(self._loader_script),
|
|
|
+ mozpath.normsep(self.topsrcdir), path, sys.executable,
|
|
|
+ mozpath.join(mozpath.dirname(self._loader_script),
|
|
|
+ 'action', 'dump_env.py')]
|
|
|
+
|
|
|
+ try:
|
|
|
+ # We need to capture stderr because that's where the shell sends
|
|
|
+ # errors if execution fails.
|
|
|
+- output = subprocess.check_output(command, stderr=subprocess.STDOUT,
|
|
|
+- cwd=self.topsrcdir, env=env)
|
|
|
++ output = subprocess.check_output(
|
|
|
++ command, stderr=subprocess.STDOUT, cwd=self.topsrcdir,
|
|
|
++ env=ensure_subprocess_env(os.environ), universal_newlines=True)
|
|
|
+ except subprocess.CalledProcessError as e:
|
|
|
+ lines = e.output.splitlines()
|
|
|
+
|
|
|
+ # Output before actual execution shouldn't be relevant.
|
|
|
+ try:
|
|
|
+ index = lines.index('------END_BEFORE_SOURCE')
|
|
|
+ lines = lines[index + 1:]
|
|
|
+ except ValueError:
|
|
|
+@@ -349,22 +352,16 @@ class MozconfigLoader(object):
|
|
|
+ env_after_source = {}
|
|
|
+
|
|
|
+ current = None
|
|
|
+ current_type = None
|
|
|
+ in_variable = None
|
|
|
+
|
|
|
+ for line in output.splitlines():
|
|
|
+
|
|
|
+- # XXX This is an ugly hack. Data may be lost from things
|
|
|
+- # like environment variable values.
|
|
|
+- # See https://bugzilla.mozilla.org/show_bug.cgi?id=831381
|
|
|
+- line = line.decode('mbcs' if sys.platform == 'win32' else 'utf-8',
|
|
|
+- 'ignore')
|
|
|
+-
|
|
|
+ if not line:
|
|
|
+ continue
|
|
|
+
|
|
|
+ if line.startswith('------BEGIN_'):
|
|
|
+ assert current_type is None
|
|
|
+ assert current is None
|
|
|
+ assert not in_variable
|
|
|
+ current_type = line[len('------BEGIN_'):]
|