Bug 1059090 - Don't require SOURCES to be set for CPP_UNIT_TESTS and SIMPLE_PROGRAMS. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 03 Sep 2014 14:16:37 +0900
changeset 226687 17bee965226aac3bfc80ac19b513467ae61c8609
parent 226686 01a0e2c9c595e983605cb0aa5c12c9eceeb8ae7f
child 226688 344599c26cd3ca2c14cb042dfc82434207d36ceb
push idunknown
push userunknown
push dateunknown
reviewersmshal
bugs1059090
milestone35.0a1
Bug 1059090 - Don't require SOURCES to be set for CPP_UNIT_TESTS and SIMPLE_PROGRAMS. r=mshal
build/docs/defining-binaries.rst
build/templates.mozbuild
content/base/test/moz.build
content/media/compiledtest/moz.build
content/media/webaudio/compiledtest/moz.build
dom/audiochannel/tests/moz.build
dom/canvas/compiledtest/moz.build
editor/txmgr/tests/moz.build
intl/lwbrk/tests/moz.build
intl/uconv/tools/moz.build
intl/unicharutil/tests/moz.build
js/src/moz.build
layout/style/test/moz.build
media/libcubeb/tests/moz.build
media/mtransport/test/moz.build
media/webrtc/signaling/test/moz.build
memory/mozalloc/tests/moz.build
mfbt/tests/moz.build
mozglue/linker/tests/moz.build
mozglue/tests/moz.build
netwerk/test/moz.build
security/manager/ssl/tests/compiled/moz.build
security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
startupcache/test/moz.build
storage/test/moz.build
toolkit/components/places/tests/cpp/moz.build
toolkit/mozapps/plugins/tests/moz.build
toolkit/mozapps/update/tests/moz.build
toolkit/webapps/tests/moz.build
toolkit/xre/test/win/moz.build
tools/trace-malloc/moz.build
uriloader/exthandler/tests/moz.build
widget/tests/moz.build
xpcom/reflect/xptcall/md/test/moz.build
xpcom/reflect/xptcall/tests/moz.build
xpcom/reflect/xptinfo/tests/moz.build
xpcom/sample/program/moz.build
xpcom/tests/external/moz.build
xpcom/tests/moz.build
xpcom/tests/windows/moz.build
xpcom/typelib/xpt/tests/moz.build
xpcom/windbgdlg/moz.build
--- a/build/docs/defining-binaries.rst
+++ b/build/docs/defining-binaries.rst
@@ -143,25 +143,34 @@ names.
 In some cases, we want to create an executable per source file in the current
 directory, in which case we can use the ``SimplePrograms`` template
 
    SimplePrograms([
        'FirstProgram',
        'SecondProgram',
    ])
 
-The corresponding ``SOURCES`` must match:
+Contrary to ``Program``, which requires corresponding ``SOURCES``, when using
+``SimplePrograms``, the corresponding ``SOURCES`` are implied. If the
+corresponding ``sources`` have an extension different from ``.cpp``, it is
+possible to specify the proper extension:
 
-   SOURCES += [
-       'FirstProgram.cpp',
-       'SecondProgram.c',
-   ]
+   SimplePrograms([
+       'ThirdProgram',
+       'FourthProgram',
+   ], ext='.c')
+
+Please note this construct was added for compatibility with what already lives
+in the mozilla tree ; it is recommended not to add new simple programs with
+sources with a different extension than ``.cpp``.
 
 Similar to ``SimplePrograms``, is the ``CppUnitTests`` template, which defines,
-with the same rules, C++ unit tests programs.
+with the same rules, C++ unit tests programs. Like ``SimplePrograms``, it takes
+an ``ext`` argument to specify the extension for the corresponding ``SOURCES``,
+if it's different from ``.cpp``.
 
 
 Linking with system libraries
 =============================
 
 Programs and libraries usually need to link with system libraries, such as a
 widget toolkit, etc. Those required dependencies can be given with the
 ``OS_LIBS`` variable.
--- a/build/templates.mozbuild
+++ b/build/templates.mozbuild
@@ -6,52 +6,56 @@
 
 @template
 def Program(name):
     '''Template for program executables.'''
     PROGRAM = name
 
 
 @template
-def SimplePrograms(names):
+def SimplePrograms(names, ext='.cpp'):
     '''Template for simple program executables.
 
     Those have a single source with the same base name as the executable.
     '''
     SIMPLE_PROGRAMS += names
+    SOURCES += ['%s%s' % (name, ext) for name in names]
 
 
 @template
-def CppUnitTests(names):
+def CppUnitTests(names, ext='.cpp'):
     '''Template for C++ unit tests.
 
     Those have a single source with the same base name as the executable.
     '''
     CPP_UNIT_TESTS += names
+    SOURCES += ['%s%s' % (name, ext) for name in names]
 
 
 @template
 def Library(name):
     '''Template for libraries.'''
     LIBRARY_NAME = name
 
 
 @template
 def HostProgram(name):
     '''Template for build tools executables.'''
     HOST_PROGRAM = name
 
 
 @template
-def HostSimplePrograms(names):
+def HostSimplePrograms(names, ext='.cpp'):
     '''Template for simple build tools executables.
 
     Those have a single source with the same base name as the executable.
     '''
     HOST_SIMPLE_PROGRAMS += names
+    HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext)
+        for name in names]
 
 
 @template
 def HostLibrary(name):
     '''Template for build tools libraries.'''
     HOST_LIBRARY_NAME = name
 
 
--- a/content/base/test/moz.build
+++ b/content/base/test/moz.build
@@ -12,18 +12,16 @@ if CONFIG['OS_ARCH'] != 'Darwin':
 
 CppUnitTests([
     'TestCSPParser',
     'TestGetURL',
     'TestNativeXMLHttpRequest',
     'TestPlainTextSerializer',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 MOCHITEST_MANIFESTS += [
     'chrome/mochitest.ini',
     'csp/mochitest.ini',
     'mochitest.ini',
     'websocket_hybi/mochitest.ini',
 ]
 # OOP tests don't work on Windows (bug 763081) or native-fennec
 # (see Bug 774939). App permission checks are also disabled on
--- a/content/media/compiledtest/moz.build
+++ b/content/media/compiledtest/moz.build
@@ -4,18 +4,16 @@
 # 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/.
 
 CppUnitTests([
     'TestAudioBuffers',
     'TestAudioMixer'
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '..',
 ]
 
 USE_LIBS += [
     'mozalloc',
--- a/content/media/webaudio/compiledtest/moz.build
+++ b/content/media/webaudio/compiledtest/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 CppUnitTests([
     'TestAudioEventTimeline',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '..',
 ]
 
 USE_LIBS += [
     'mozalloc',
--- a/dom/audiochannel/tests/moz.build
+++ b/dom/audiochannel/tests/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 CppUnitTests([
     'TestAudioChannelService',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 if CONFIG['OS_ARCH'] == 'WINNT':
     DEFINES['NOMINMAX'] = True
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
--- a/dom/canvas/compiledtest/moz.build
+++ b/dom/canvas/compiledtest/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 CppUnitTests([
     'TestWebGLElementArrayCache',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '../',
 ]
 
 USE_LIBS += [
     'mozalloc',
--- a/editor/txmgr/tests/moz.build
+++ b/editor/txmgr/tests/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 CppUnitTests([
     'TestTXMgr',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/intl/lwbrk/tests/moz.build
+++ b/intl/lwbrk/tests/moz.build
@@ -3,16 +3,14 @@
 # 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/.
 
 CppUnitTests([
     'TestLineBreak',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/intl/uconv/tools/moz.build
+++ b/intl/uconv/tools/moz.build
@@ -1,13 +1,9 @@
 # -*- 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/.
 
 SimplePrograms([
     'umaptable',
-])
-
-SOURCES += [
-    '%s.c' % s for s in SIMPLE_PROGRAMS
-]
+], ext='.c')
--- a/intl/unicharutil/tests/moz.build
+++ b/intl/unicharutil/tests/moz.build
@@ -1,23 +1,19 @@
 # -*- 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/.
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
-SOURCES += [
-    'NormalizationTest.cpp',
-    'UnicharSelfTest.cpp',
-]
-
 SimplePrograms([
-    "%s" % (fyl[0:-4]) for fyl in SOURCES
+    'NormalizationTest',
+    'UnicharSelfTest',
 ])
 
 USE_STATIC_LIBS = True
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'unicharutil_external_s',
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -418,22 +418,18 @@ else:
         'perf/pm_stub.cpp'
     ]
 
 # Disable PGO for MSVC 2010 due to unpredictable performance, see
 # bug 1030706.
 if CONFIG['_MSC_VER'] != '1600':
     MSVC_ENABLE_PGO = True
 
-HOST_SOURCES += [
-    'jskwgen.cpp',
-]
-
 HostSimplePrograms([
-    'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES
+    'host_jskwgen',
 ])
 
 # JavaScript must be built shared, even for static builds, as it is used by
 # other modules which are always built shared. Failure to do so results in
 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
 # and then the static data cells used for locking no longer work.
 #
 # In fact, we now build both a static and a shared library, as the
--- a/layout/style/test/moz.build
+++ b/layout/style/test/moz.build
@@ -1,20 +1,16 @@
 # -*- 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/.
 
-HOST_SOURCES += [
-    'ListCSSProperties.cpp',
-]
-
 HostSimplePrograms([
-    'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES
+    'host_ListCSSProperties',
 ])
 
 MOCHITEST_MANIFESTS += [
     'chrome/mochitest.ini',
     'css-visited/mochitest.ini',
     'mochitest.ini',
 ]
 BROWSER_CHROME_MANIFESTS += ['browser.ini']
--- a/media/libcubeb/tests/moz.build
+++ b/media/libcubeb/tests/moz.build
@@ -10,18 +10,16 @@ CppUnitTests([
 
 if CONFIG['OS_TARGET'] != 'Android':
   CppUnitTests([
     'test_audio',
     'test_latency',
     'test_sanity'
   ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 LOCAL_INCLUDES += [
     '../include'
 ]
 
 FAIL_ON_WARNINGS = True
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     # On windows, the WASAPI backend needs the resampler we have in
--- a/media/mtransport/test/moz.build
+++ b/media/mtransport/test/moz.build
@@ -18,18 +18,16 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CO
         'turn_unittest',
     ])
 
     if CONFIG['MOZ_SCTP']:
         CppUnitTests([
             'sctp_unittest',
         ])
 
-    SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 FAIL_ON_WARNINGS = True
 
 for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR', 'SCTP_DEBUG', 'INET'):
     DEFINES[var] = True
 
 if CONFIG['OS_TARGET'] == 'Android':
     LOCAL_INCLUDES += [
         '/media/mtransport/third_party/nrappkit/src/port/android/include',
--- a/media/webrtc/signaling/test/moz.build
+++ b/media/webrtc/signaling/test/moz.build
@@ -7,18 +7,16 @@
 if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     CppUnitTests([
         'mediaconduit_unittests',
         'mediapipeline_unittest',
         'sdp_unittests',
         'signaling_unittests',
     ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
 if CONFIG['OS_TARGET'] in ('Darwin', 'Android'):
     DEFINES['GTEST_USE_OWN_TR1_TUPLE'] = 1
 
 for var in ('USE_FAKE_MEDIA_STREAMS', 'USE_FAKE_PCOBSERVER',
             'NR_SOCKET_IS_VOID_PTR', 'HAVE_STRDUP'):
     DEFINES[var] = True
--- a/memory/mozalloc/tests/moz.build
+++ b/memory/mozalloc/tests/moz.build
@@ -3,16 +3,14 @@
 # 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/.
 
 CppUnitTests([
     'TestVolatileBuffer',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/mfbt/tests/moz.build
+++ b/mfbt/tests/moz.build
@@ -32,18 +32,16 @@ CppUnitTests([
     'TestWeakPtr',
 ])
 
 if not CONFIG['MOZ_ASAN']:
     CppUnitTests([
         'TestPoisonArea',
     ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 # Since we link directly with MFBT object files, define IMPL_MFBT
 DEFINES['IMPL_MFBT'] = True
 
 DISABLE_STL_WRAPPING = True
 
 if CONFIG['_MSC_VER']:
   CXXFLAGS += [
     '-wd4275', # non dll-interface class used as base for dll-interface class
--- a/mozglue/linker/tests/moz.build
+++ b/mozglue/linker/tests/moz.build
@@ -1,19 +1,16 @@
 # -*- 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/.
 
 NO_DIST_INSTALL = True
 
-SOURCES += [
-    'TestZip.cpp',
-]
 SimplePrograms([
     'TestZip',
 ])
 LOCAL_INCLUDES += ['..']
 USE_LIBS += [
     'linker',
 ]
 DISABLE_STL_WRAPPING = True
--- a/mozglue/tests/moz.build
+++ b/mozglue/tests/moz.build
@@ -1,15 +1,11 @@
 # -*- 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/.
 
 DISABLE_STL_WRAPPING = True
 
-SOURCES += [
-    'ShowSSEConfig.cpp',
-]
-
 CppUnitTests([
     'ShowSSEConfig',
 ])
--- a/netwerk/test/moz.build
+++ b/netwerk/test/moz.build
@@ -41,28 +41,22 @@ SimplePrograms([
 #    TestPerf',
 #    TestSocketTransport',
 #    TestStreamChannel',
 #    TestStreamPump',
 #    TestStreamTransport',
 #    TestUDPSocketProvider',
 #]
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 CppUnitTests([
     'TestCookie',
     'TestSTSParser',
     'TestUDPSocket',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 RESOURCE_FILES += [
     'urlparse.dat',
     'urlparse_unx.dat',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/security/manager/ssl/tests/compiled/moz.build
+++ b/security/manager/ssl/tests/compiled/moz.build
@@ -3,16 +3,14 @@
 # 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/.
 
 CppUnitTests([
   'TestCertDB',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
@@ -8,20 +8,16 @@ FAIL_ON_WARNINGS = True
 
 SimplePrograms([
     'BadCertServer',
     'ClientAuthServer',
     'GenerateOCSPResponse',
     'OCSPStaplingServer',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 LOCAL_INCLUDES += [
     '../lib',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'mozillapkix',
     'nspr',
--- a/startupcache/test/moz.build
+++ b/startupcache/test/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 CppUnitTests([
     'TestStartupCache',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 EXTRA_COMPONENTS += [
     'TestStartupCacheTelemetry.js',
     'TestStartupCacheTelemetry.manifest',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/storage/test/moz.build
+++ b/storage/test/moz.build
@@ -23,18 +23,16 @@ CppUnitTests([
 
 if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT', 'Darwin'):
     # FIXME bug 523392: test_deadlock_detector doesn't like Windows
     # FIXME bug 523378: also fails on OS X
     CppUnitTests([
         'test_deadlock_detector',
     ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 LOCAL_INCLUDES += [
     '../src',
 ]
 
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
     'mozalloc',
--- a/toolkit/components/places/tests/cpp/moz.build
+++ b/toolkit/components/places/tests/cpp/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 CppUnitTests([
     'test_IHistory',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/toolkit/mozapps/plugins/tests/moz.build
+++ b/toolkit/mozapps/plugins/tests/moz.build
@@ -4,14 +4,10 @@
 # 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/.
 
 SimplePrograms([
     'BadPlugin',
     'GoodPlugin',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 BROWSER_CHROME_MANIFESTS += ['browser.ini']
 USE_STATIC_LIBS = True
--- a/toolkit/mozapps/update/tests/moz.build
+++ b/toolkit/mozapps/update/tests/moz.build
@@ -13,20 +13,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'andr
     if CONFIG['MOZ_MAINTENANCE_SERVICE'] and not CONFIG['HAVE_64BIT_BUILD']:
         XPCSHELL_TESTS_MANIFESTS += ['unit_service_updater/xpcshell.ini']
 
     SimplePrograms([
         'TestAUSHelper',
         'TestAUSReadStrings',
     ])
 
-    SOURCES += [
-        '%s.cpp' % s for s in SIMPLE_PROGRAMS
-    ]
-
     LOCAL_INCLUDES += [
         '/toolkit/mozapps/update',
         '/toolkit/mozapps/update/common',
     ]
 
     if CONFIG['OS_ARCH'] == 'WINNT':
         USE_LIBS += [
             'updatecommon-standalone',
--- a/toolkit/webapps/tests/moz.build
+++ b/toolkit/webapps/tests/moz.build
@@ -1,9 +1,8 @@
 # -*- 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/.
 
 MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
-SOURCES += ['TestWebappRT.cpp' ]
 SimplePrograms(['TestWebappRT'])
--- a/toolkit/xre/test/win/moz.build
+++ b/toolkit/xre/test/win/moz.build
@@ -3,28 +3,20 @@
 # 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/.
 
 SimplePrograms([
     'TestXREMakeCommandLineWin',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 CppUnitTests([
     'TestDllInterceptor',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in CPP_UNIT_TESTS
-]
-
 DEFINES['NS_NO_XPCOM'] = True
 
 LOCAL_INCLUDES += [
     '/config',
     '/toolkit/xre',
 ]
 
 
--- a/tools/trace-malloc/moz.build
+++ b/tools/trace-malloc/moz.build
@@ -10,40 +10,29 @@ if not CONFIG['MOZ_PROFILE_GENERATE']:
         'formdata.c',
         'spacecategory.c',
         'spacetrace.c',
     ]
 
 bin_suffix = CONFIG['BIN_SUFFIX']
 
 
-simple_c_sources = [
-    'leakstats',
-    'tmstats',
-]
-
-SOURCES += [
-    '%s.c' % s for s in simple_c_sources
-]
 SOURCES += [
     'tmreader.c',
 ]
 
-SimplePrograms(simple_c_sources)
+SimplePrograms([
+    'leakstats',
+    'tmstats',
+], ext='.c')
 
-simple_cpp_sources = [
+SimplePrograms([
     'bloatblame',
     'leaksoup',
-]
-
-SOURCES += [
-    '%s.cpp' % s for s in simple_cpp_sources
-]
-
-SimplePrograms(simple_cpp_sources)
+])
 
 RESOURCE_FILES += [
     'spacetrace.css'
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/uriloader/exthandler/tests/moz.build
+++ b/uriloader/exthandler/tests/moz.build
@@ -15,15 +15,11 @@ if CONFIG['OS_ARCH'] != 'Darwin':
     # test cases with the string "content_encoding" in their names.
     if not CONFIG['MOZ_JSDOWNLOADS']:
         XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
 SimplePrograms([
     'WriteArgument',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 USE_LIBS += [
     'nspr',
 ]
--- a/widget/tests/moz.build
+++ b/widget/tests/moz.build
@@ -19,16 +19,14 @@ FAIL_ON_WARNINGS = True
 #         Test disabled because it uses the internal string APIs incorrectly
 #         (see bug 582863)
 #         CPP_UNIT_TESTS += ['TestWinTSF']
 #
 #     Test disabled because it requires the internal API. Re-enabling this test
 #     is bug 652123.
 #     CPP_UNIT_TESTS += ['TestChromeMargin']
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/xpcom/reflect/xptcall/md/test/moz.build
+++ b/xpcom/reflect/xptcall/md/test/moz.build
@@ -1,13 +1,9 @@
 # -*- 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/.
 
-SOURCES += [
-    'stub_test.cpp',
-]
-
 SimplePrograms([
     'stub_test',
 ])
--- a/xpcom/reflect/xptcall/tests/moz.build
+++ b/xpcom/reflect/xptcall/tests/moz.build
@@ -3,18 +3,14 @@
 # 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/.
 
 SimplePrograms([
     'TestXPTCInvoke',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/xpcom/reflect/xptinfo/tests/moz.build
+++ b/xpcom/reflect/xptinfo/tests/moz.build
@@ -1,18 +1,14 @@
 # -*- 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/.
 
-SOURCES += [
-    'TestInterfaceInfo.cpp',
-]
-
 SimplePrograms([
     'TestInterfaceInfo'
 ])
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
--- a/xpcom/sample/program/moz.build
+++ b/xpcom/sample/program/moz.build
@@ -1,20 +1,14 @@
 # -*- 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/.
 
-# We must specify CPP_SOURCES in order to link using the proper c++ linker
-# on certain platforms.
-SOURCES += [
-    'nsTestSample.cpp',
-]
-
 # SIMPLE_PROGRAMS compiles a single .cpp file into an executable
 SimplePrograms([
     'nsTestSample'
 ])
 
 # Whatever code is going to be linked with the *standalone* glue must be
 # built with the XPCOM_GLUE define set.
 DEFINES['XPCOM_GLUE'] = True
--- a/xpcom/tests/external/moz.build
+++ b/xpcom/tests/external/moz.build
@@ -3,18 +3,14 @@
 # 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/.
 
 SimplePrograms([
     'TestMinStringAPI',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/xpcom/tests/moz.build
+++ b/xpcom/tests/moz.build
@@ -43,20 +43,16 @@ if CONFIG['OS_TARGET'] == 'WINNT':
         'TestBase64',
     ])
 
 if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']:
     SimplePrograms([
         'TestSTLWrappers',
     ])
 
-SOURCES += [
-    '%s.cpp' % s for s in sorted(SIMPLE_PROGRAMS)
-]
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 CppUnitTests([
     'ShowAlignments',
     'TestAutoPtr',
     'TestAutoRef',
     'TestCOMArray',
     'TestCOMPtr',
@@ -109,18 +105,16 @@ if CONFIG['MOZ_MEMORY']:
 if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT'):
     # FIXME bug 523392: TestDeadlockDetector doesn't like Windows
     # FIXME bug 523378: also fails on OS X
     CppUnitTests([
         'TestDeadlockDetector',
         'TestDeadlockDetectorScalability',
     ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 LOCAL_INCLUDES += [
     '../ds',
 ]
 
 RESOURCE_FILES += [
     'test.properties',
 ]
 
--- a/xpcom/tests/windows/moz.build
+++ b/xpcom/tests/windows/moz.build
@@ -4,18 +4,16 @@
 # 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/.
 
 CppUnitTests([
     'TestCOM',
     'TestNtPathToDosPath',
 ])
 
-SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
-
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
 
 OS_LIBS += [
--- a/xpcom/typelib/xpt/tests/moz.build
+++ b/xpcom/typelib/xpt/tests/moz.build
@@ -4,19 +4,15 @@
 # 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/.
 
 SimplePrograms([
     'PrimitiveTest',
     'SimpleTypeLib',
 ])
 
-SOURCES += [
-    '%s.cpp' % s for s in SIMPLE_PROGRAMS
-]
-
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
     'mozalloc',
     'xpt',
     'xul',
 ]
--- a/xpcom/windbgdlg/moz.build
+++ b/xpcom/windbgdlg/moz.build
@@ -1,13 +1,9 @@
 # -*- 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/.
 
-SOURCES += [
-    'windbgdlg.cpp',
-]
-
 SimplePrograms([
     'windbgdlg'
 ])