Bug 1393454 Do not compile rust gtest crate if --disable-tests is set draft
authorTom Ritter <tom@mozilla.com>
Mon, 28 Aug 2017 13:12:24 -0500
changeset 654385 bea8622474de5d58bac8901d638851cd5c1ee824
parent 654384 b06e9c7d1f72216d3cca7b7ed1933869e8314881
child 728555 b6c22dc256536e75e1dd00f5e7277859eefec4c0
push id76562
push userbmo:tom@mozilla.com
push dateMon, 28 Aug 2017 18:14:51 +0000
bugs1393454
milestone57.0a1
Bug 1393454 Do not compile rust gtest crate if --disable-tests is set MozReview-Commit-ID: 1HgK0D1kGNu
moz.configure
toolkit/library/gtest/moz.build
toolkit/toolkit.mozbuild
--- a/moz.configure
+++ b/moz.configure
@@ -265,19 +265,19 @@ set_config('BUILD_BACKENDS', build_backe
 option('--disable-gtest-in-build',
        help='Force disable building the gtest libxul during the build.',
        when='--enable-compile-environment')
 
 # Determine whether to build the gtest xul. This happens in automation
 # on Desktop platforms with the exception of Windows PGO, where linking
 # xul-gtest.dll takes too long.
 @depends('MOZ_PGO', build_project, target, 'MOZ_AUTOMATION', '--disable-gtest-in-build',
-         when='--enable-compile-environment')
-def build_gtest(pgo, build_project, target, automation, enabled):
-    if not enabled:
+         enable_tests, when='--enable-compile-environment')
+def build_gtest(pgo, build_project, target, automation, enabled, enable_tests):
+    if not enable_tests or not enabled:
         return None
     if (automation and build_project == 'browser' and
         not (pgo and target.os == 'WINNT')):
         return True
 
 set_config('LINK_GTEST_DURING_COMPILE', build_gtest)
 
 # Awk detection
--- a/toolkit/library/gtest/moz.build
+++ b/toolkit/library/gtest/moz.build
@@ -1,18 +1,22 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 FINAL_TARGET = 'dist/bin/gtest'
 
+if CONFIG['ENABLE_TESTS']:
+	USE_LIBS += [
+	    'gkrust-gtest',
+	]
+
 USE_LIBS += [
-    'gkrust-gtest',
     'static:xul',
     # xul-gtest is an intermediate static library. It is used as FINAL_TARGET
     # for gtest code.
     # If the FINAL_TARGET were the library in this directory, then the gtest
     # code would end up before static:xul, and before StaticXULComponentStart,
     # which needs to stay first.
     'xul-gtest',
 ]
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -1,16 +1,20 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
+if CONFIG['ENABLE_TESTS']:
+    DIRS += [
+        '/toolkit/library/gtest/rust',
+    ]
+
 DIRS += [
-    '/toolkit/library/gtest/rust',
     '/toolkit/library/rust',
 ]
 
 if CONFIG['MOZ_SANDBOX']:
     DIRS += ['/security/sandbox']
 
 DIRS += [
     # Depends on NSS and NSPR, and must be built after sandbox or else B2G emulator