Bug 1468547 - Re-factor gtest mach command to not invoke make when not necessary. r=mshal

MozReview-Commit-ID: 6j7t0YIZc8n

--HG--
extra : rebase_source : e4478904d4f4e54ead473435df2c9e9a47a9294c
This commit is contained in:
Chris Manchester 2018-07-09 14:28:59 -07:00
parent 1d6bf9c8d4
commit dc4c4637b0
3 changed files with 28 additions and 24 deletions

View File

@ -593,8 +593,34 @@ class GTestCommands(MachCommandBase):
debugger_args):
# We lazy build gtest because it's slow to link
self._run_make(directory="testing/gtest", target='gtest',
print_directory=False, ensure_exit_code=True)
try:
config = self.config_environment
except Exception:
print("Please run |./mach build| before |./mach gtest|.")
return 1
active_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
if 'Tup' in active_backend:
gtest_build_path = mozpath.join(self.topobjdir, '<gtest>')
else:
# This path happens build the necessary parts of the tree in the
# Make backend due to the odd nature of partial tree builds.
gtest_build_path = mozpath.relpath(mozpath.join(self.topobjdir,
'toolkit', 'library',
'gtest', 'rust'),
self.topsrcdir)
os.environ[b'LINK_GTEST_DURING_COMPILE'] = b'1'
res = self._mach_context.commands.dispatch('build', self._mach_context,
what=[gtest_build_path])
del os.environ[b'LINK_GTEST_DURING_COMPILE']
if res:
print("Could not build xul-gtest")
return res
if self.substs.get('MOZ_WIDGET_TOOLKIT') == 'cocoa':
self._run_make(directory='browser/app', target='repackage',
ensure_exit_code=True)
app_path = self.get_binary_path('app')
args = [app_path, '-unittest', '--gtest_death_test_style=threadsafe'];

View File

@ -1,18 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
# Avoid recursive make to avoid having to add files to the gtest/ subdirectory
# (which is third-party code), and to make the build faster.
include $(topsrcdir)/config/rules.mk
ifeq (browser,$(MOZ_BUILD_APP))
ifdef COMPILE_ENVIRONMENT
gtest::
$(MAKE) -C $(DEPTH)/toolkit/library gtestxul
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
$(MAKE) -C $(DEPTH)/browser/app repackage
endif
endif
endif

View File

@ -8,8 +8,4 @@ include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk
.PHONY: gtestxul
gtestxul:
$(MAKE) -C $(DEPTH) toolkit/library/gtest/target LINK_GTEST_DURING_COMPILE=1
DUMP_SYMBOLS_FLAGS = --count-ctors