mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 936555 - make mozinfo use MozconfigLoader to locate the mozconfig; r=gps
This commit is contained in:
parent
ae79938400
commit
3a2b40d1f8
2
CLOBBER
2
CLOBBER
@ -22,4 +22,4 @@
|
||||
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
|
||||
# don't change CLOBBER for WebIDL changes any more.
|
||||
|
||||
bug 960811 - clobber to rebuild preprocessed files when enabling synthetic APKs
|
||||
Bug 936555 - changes to mozconfig finding require clobbers, given that builds on try were green
|
||||
|
@ -75,7 +75,7 @@ class MozconfigLoader(ProcessExecutionMixin):
|
||||
|
||||
return os.path.join(our_dir, 'mozconfig_loader')
|
||||
|
||||
def find_mozconfig(self):
|
||||
def find_mozconfig(self, env=os.environ):
|
||||
"""Find the active mozconfig file for the current environment.
|
||||
|
||||
This emulates the logic in mozconfig-find.
|
||||
@ -91,10 +91,10 @@ class MozconfigLoader(ProcessExecutionMixin):
|
||||
"""
|
||||
# Check for legacy methods first.
|
||||
|
||||
if 'MOZ_MYCONFIG' in os.environ:
|
||||
if 'MOZ_MYCONFIG' in env:
|
||||
raise MozconfigFindException(MOZ_MYCONFIG_ERROR)
|
||||
|
||||
env_path = os.environ.get('MOZCONFIG', None)
|
||||
env_path = env.get('MOZCONFIG', None)
|
||||
if env_path is not None:
|
||||
if not os.path.exists(env_path):
|
||||
raise MozconfigFindException(
|
||||
@ -128,7 +128,7 @@ class MozconfigLoader(ProcessExecutionMixin):
|
||||
deprecated_paths = [os.path.join(self.topsrcdir, s) for s in
|
||||
self.DEPRECATED_TOPSRCDIR_PATHS]
|
||||
|
||||
home = os.environ.get('HOME', None)
|
||||
home = env.get('HOME', None)
|
||||
if home is not None:
|
||||
deprecated_paths.extend([os.path.join(home, s) for s in
|
||||
self.DEPRECATED_HOME_PATHS])
|
||||
|
@ -8,7 +8,7 @@
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
|
||||
import mozbuild.mozconfig as mozconfig
|
||||
|
||||
def build_dict(config, env=os.environ):
|
||||
"""
|
||||
@ -27,10 +27,9 @@ def build_dict(config, env=os.environ):
|
||||
d = {}
|
||||
d['topsrcdir'] = config.topsrcdir
|
||||
|
||||
if 'MOZCONFIG' in env:
|
||||
mozconfig = env["MOZCONFIG"]
|
||||
mozconfig = os.path.join(config.topsrcdir, mozconfig)
|
||||
d['mozconfig'] = os.path.normpath(mozconfig)
|
||||
the_mozconfig = mozconfig.MozconfigLoader(config.topsrcdir).find_mozconfig(env)
|
||||
if the_mozconfig:
|
||||
d['mozconfig'] = the_mozconfig
|
||||
|
||||
# os
|
||||
o = substs["OS_TARGET"]
|
||||
|
@ -19,6 +19,8 @@ from mozbuild.mozinfo import (
|
||||
write_mozinfo,
|
||||
)
|
||||
|
||||
from mozfile.mozfile import NamedTemporaryFile
|
||||
|
||||
|
||||
class Base(object):
|
||||
def _config(self, substs={}):
|
||||
@ -239,15 +241,18 @@ class TestWriteMozinfo(unittest.TestCase, Base):
|
||||
MOZ_WIDGET_TOOLKIT='windows',
|
||||
))
|
||||
c.topsrcdir = '/tmp'
|
||||
write_mozinfo(self.f, c, {'MOZCONFIG': 'foo'})
|
||||
with open(self.f) as f:
|
||||
d = json.load(f)
|
||||
self.assertEqual('win', d['os'])
|
||||
self.assertEqual('x86', d['processor'])
|
||||
self.assertEqual('windows', d['toolkit'])
|
||||
self.assertEqual('/tmp', d['topsrcdir'])
|
||||
self.assertEqual(os.path.normpath('/tmp/foo'), d['mozconfig'])
|
||||
self.assertEqual(32, d['bits'])
|
||||
with NamedTemporaryFile(dir=c.topsrcdir) as mozconfig:
|
||||
mozconfig.write('unused contents')
|
||||
mozconfig.flush()
|
||||
write_mozinfo(self.f, c, {'MOZCONFIG': mozconfig.name})
|
||||
with open(self.f) as f:
|
||||
d = json.load(f)
|
||||
self.assertEqual('win', d['os'])
|
||||
self.assertEqual('x86', d['processor'])
|
||||
self.assertEqual('windows', d['toolkit'])
|
||||
self.assertEqual('/tmp', d['topsrcdir'])
|
||||
self.assertEqual(os.path.normpath(mozconfig.name), d['mozconfig'])
|
||||
self.assertEqual(32, d['bits'])
|
||||
|
||||
def test_fileobj(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user