зеркало из https://github.com/mozilla/gecko-dev.git
Bug 648681 - Print useful information after building the tree; r=ted
This commit is contained in:
Родитель
e00e146a30
Коммит
9063db9bf5
|
@ -13,10 +13,11 @@ SEARCH_PATHS = [
|
|||
'python/mach',
|
||||
'python/mozboot',
|
||||
'python/mozbuild',
|
||||
'build/pymake',
|
||||
'python/blessings',
|
||||
'python/psutil',
|
||||
'python/which',
|
||||
'build/pymake',
|
||||
'config',
|
||||
'other-licenses/ply',
|
||||
'xpcom/idl-parser',
|
||||
'testing',
|
||||
|
|
|
@ -17,6 +17,7 @@ from mach.mixin.process import ProcessExecutionMixin
|
|||
|
||||
from mozfile.mozfile import rmtree
|
||||
|
||||
from .backend.configenvironment import ConfigEnvironment
|
||||
from .config import BuildConfig
|
||||
from .mozconfig import (
|
||||
MozconfigFindException,
|
||||
|
@ -51,6 +52,7 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
self._topobjdir = topobjdir
|
||||
self._mozconfig = None
|
||||
self._config_guess_output = None
|
||||
self._config_environment = None
|
||||
|
||||
@property
|
||||
def topobjdir(self):
|
||||
|
@ -72,6 +74,35 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
|
||||
return self._mozconfig
|
||||
|
||||
@property
|
||||
def config_environment(self):
|
||||
"""Returns the ConfigEnvironment for the current build configuration.
|
||||
|
||||
This property is only available once configure has executed.
|
||||
|
||||
If configure's output is not available, this will raise.
|
||||
"""
|
||||
if self._config_environment:
|
||||
return self._config_environment
|
||||
|
||||
config_status = os.path.join(self.topobjdir, 'config.status')
|
||||
|
||||
if not os.path.exists(config_status):
|
||||
raise Exception('config.status not available. Run configure.')
|
||||
|
||||
self._config_environment = \
|
||||
ConfigEnvironment.from_config_status(config_status)
|
||||
|
||||
return self._config_environment
|
||||
|
||||
@property
|
||||
def defines(self):
|
||||
return self.config_environment.defines
|
||||
|
||||
@property
|
||||
def substs(self):
|
||||
return self.config_environment.substs
|
||||
|
||||
@property
|
||||
def distdir(self):
|
||||
return os.path.join(self.topobjdir, 'dist')
|
||||
|
@ -91,6 +122,42 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
# mozfile doesn't like unicode arguments (bug 818783).
|
||||
rmtree(self.topobjdir.encode('utf-8'))
|
||||
|
||||
def get_binary_path(self, what='app', validate_exists=True):
|
||||
"""Obtain the path to a compiled binary for this build configuration.
|
||||
|
||||
The what argument is the program or tool being sought after. See the
|
||||
code implementation for supported values.
|
||||
|
||||
If validate_exists is True (the default), we will ensure the found path
|
||||
exists before returning, raising an exception if it doesn't.
|
||||
|
||||
If no arguments are specified, we will return the main binary for the
|
||||
configured XUL application.
|
||||
"""
|
||||
|
||||
substs = self.substs
|
||||
|
||||
stem = self.distdir
|
||||
if substs['OS_ARCH'] == 'Darwin':
|
||||
stem = os.path.join(stem, substs['MOZ_MACBUNDLE_NAME'], 'Contents',
|
||||
'MacOS')
|
||||
|
||||
leaf = None
|
||||
|
||||
if what == 'app':
|
||||
leaf = substs['MOZ_APP_NAME'] + substs['BIN_SUFFIX']
|
||||
elif what == 'xpcshell':
|
||||
leaf = 'xpcshell'
|
||||
else:
|
||||
raise Exception("Don't know how to locate binary: %s" % what)
|
||||
|
||||
path = os.path.join(stem, leaf)
|
||||
|
||||
if validate_exists and not os.path.exists(path):
|
||||
raise Exception('Binary expected at %s does not exist.' % path)
|
||||
|
||||
return path
|
||||
|
||||
@property
|
||||
def _config_guess(self):
|
||||
if self._config_guess_output is None:
|
||||
|
|
|
@ -115,9 +115,29 @@ class Build(MachCommandBase):
|
|||
warnings_database.save_to_file(warnings_path)
|
||||
|
||||
time_end = time.time()
|
||||
self._handle_finder_cpu_usage(time_end - time_start, finder_start_cpu)
|
||||
time_elapsed = time_end - time_start
|
||||
self._handle_finder_cpu_usage(time_elapsed, finder_start_cpu)
|
||||
|
||||
print('Finished building. Built files are in %s' % self.topobjdir)
|
||||
long_build = time_elapsed > 600
|
||||
|
||||
if status:
|
||||
return status
|
||||
|
||||
if long_build:
|
||||
print('We know it took a while, but your build finally finished successfully!')
|
||||
else:
|
||||
print('Your build was successful!')
|
||||
|
||||
app_path = self.get_binary_path('app')
|
||||
print('To take your build for a test drive, run: %s' % app_path)
|
||||
|
||||
# Only for full builds because incremental builders likely don't
|
||||
# need to be burdened with this.
|
||||
if not what:
|
||||
app = self.substs['MOZ_BUILD_APP']
|
||||
if app in ('browser', 'mobile/android'):
|
||||
print('For more information on what to do now, see '
|
||||
'https://developer.mozilla.org/docs/Developer_Guide/So_You_Just_Built_Firefox')
|
||||
|
||||
return status
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from mozfile.mozfile import NamedTemporaryFile
|
||||
|
@ -19,6 +20,8 @@ from mozbuild.base import (
|
|||
PathArgument,
|
||||
)
|
||||
|
||||
from mozbuild.backend.configenvironment import ConfigEnvironment
|
||||
|
||||
|
||||
|
||||
curdir = os.path.dirname(__file__)
|
||||
|
@ -51,6 +54,51 @@ class TestMozbuildObject(unittest.TestCase):
|
|||
self.assertIsNotNone(result)
|
||||
self.assertGreater(len(result), 0)
|
||||
|
||||
def test_config_environment(self):
|
||||
base = self.get_base()
|
||||
|
||||
# We need a valid config.status to test config environment creation.
|
||||
# However, this isn't working on the builders.
|
||||
# TODO Remove this and close bug 853954.
|
||||
config_status = os.path.join(base.topobjdir, 'config.status')
|
||||
if not os.path.exists(config_status):
|
||||
self.skipTest('config.status not available')
|
||||
return
|
||||
|
||||
ce = base.config_environment
|
||||
self.assertIsInstance(ce, ConfigEnvironment)
|
||||
|
||||
self.assertEqual(base.defines, ce.defines)
|
||||
self.assertEqual(base.substs, ce.substs)
|
||||
|
||||
self.assertIsInstance(base.defines, dict)
|
||||
self.assertIsInstance(base.substs, dict)
|
||||
|
||||
def test_get_binary_path(self):
|
||||
base = self.get_base()
|
||||
|
||||
platform = sys.platform
|
||||
|
||||
# We should ideally use the config.status from the build. Let's install
|
||||
# a fake one.
|
||||
substs = []
|
||||
if sys.platform.startswith('darwin'):
|
||||
substs.append(('OS_ARCH', 'Darwin'))
|
||||
substs.append(('MOZ_MACBUNDLE_NAME', 'Nightly.app'))
|
||||
elif sys.platform.startswith('win32', 'cygwin'):
|
||||
substs.append(('BIN_SUFFIX', '.exe'))
|
||||
|
||||
base._config_environment = ConfigEnvironment(base.topsrcdir,
|
||||
base.topobjdir, substs=substs)
|
||||
|
||||
p = base.get_binary_path('xpcshell', False)
|
||||
if platform.startswith('darwin'):
|
||||
self.assertTrue(p.endswith('Contents/MacOS/xpcshell'))
|
||||
elif platform.startswith('win32', 'cygwin'):
|
||||
self.assertTrue(p.endswith('xpcshell.exe'))
|
||||
else:
|
||||
self.assertTrue(p.endswith('dist/bin/xpcshell'))
|
||||
|
||||
|
||||
class TestPathArgument(unittest.TestCase):
|
||||
def test_path_argument(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче