Bug 1059090 - Don't require SOURCES to be set for CPP_UNIT_TESTS and SIMPLE_PROGRAMS. r=mshal

This commit is contained in:
Mike Hommey 2014-09-03 14:16:37 +09:00
parent 8fd95ad480
commit c2a27deef9
42 changed files with 33 additions and 157 deletions

View File

@ -148,15 +148,24 @@ directory, in which case we can use the ``SimplePrograms`` template
'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

View File

@ -11,21 +11,23 @@ def 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
@ -41,12 +43,14 @@ def HostProgram(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

View File

@ -17,8 +17,6 @@ CppUnitTests([
'TestPlainTextSerializer',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
MOCHITEST_MANIFESTS += [
'chrome/mochitest.ini',
'csp/mochitest.ini',

View File

@ -9,8 +9,6 @@ CppUnitTests([
'TestAudioMixer'
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestAudioEventTimeline',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestAudioChannelService',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
if CONFIG['OS_ARCH'] == 'WINNT':
DEFINES['NOMINMAX'] = True

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestWebGLElementArrayCache',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestTXMgr',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
USE_LIBS += [

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestLineBreak',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
USE_LIBS += [
'mozalloc',
'nspr',

View File

@ -6,8 +6,4 @@
SimplePrograms([
'umaptable',
])
SOURCES += [
'%s.c' % s for s in SIMPLE_PROGRAMS
]
], ext='.c')

View File

@ -6,13 +6,9 @@
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

View File

@ -423,12 +423,8 @@ else:
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

View File

@ -4,12 +4,8 @@
# 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 += [

View File

@ -15,8 +15,6 @@ if CONFIG['OS_TARGET'] != 'Android':
'test_sanity'
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
LOCAL_INCLUDES += [
'../include'
]

View File

@ -23,8 +23,6 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
'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'):

View File

@ -12,8 +12,6 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
'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'):

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestVolatileBuffer',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
USE_LIBS += [
'mozalloc',
'nspr',

View File

@ -37,8 +37,6 @@ if not CONFIG['MOZ_ASAN']:
'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

View File

@ -6,9 +6,6 @@
NO_DIST_INSTALL = True
SOURCES += [
'TestZip.cpp',
]
SimplePrograms([
'TestZip',
])

View File

@ -6,10 +6,6 @@
DISABLE_STL_WRAPPING = True
SOURCES += [
'ShowSSEConfig.cpp',
]
CppUnitTests([
'ShowSSEConfig',
])

View File

@ -46,18 +46,12 @@ SimplePrograms([
# 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',

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestCertDB',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
USE_LIBS += [
'mozalloc',
'nspr',

View File

@ -13,10 +13,6 @@ SimplePrograms([
'OCSPStaplingServer',
])
SOURCES += [
'%s.cpp' % s for s in SIMPLE_PROGRAMS
]
LOCAL_INCLUDES += [
'../lib',
]

View File

@ -8,8 +8,6 @@ CppUnitTests([
'TestStartupCache',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
EXTRA_COMPONENTS += [
'TestStartupCacheTelemetry.js',
'TestStartupCacheTelemetry.manifest',

View File

@ -28,8 +28,6 @@ if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT', 'Darwin'):
'test_deadlock_detector',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
LOCAL_INCLUDES += [
'../src',
]

View File

@ -8,8 +8,6 @@ CppUnitTests([
'test_IHistory',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
USE_LIBS += [

View File

@ -9,9 +9,5 @@ SimplePrograms([
'GoodPlugin',
])
SOURCES += [
'%s.cpp' % s for s in SIMPLE_PROGRAMS
]
BROWSER_CHROME_MANIFESTS += ['browser.ini']
USE_STATIC_LIBS = True

View File

@ -18,10 +18,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
'TestAUSReadStrings',
])
SOURCES += [
'%s.cpp' % s for s in SIMPLE_PROGRAMS
]
LOCAL_INCLUDES += [
'/toolkit/mozapps/update',
'/toolkit/mozapps/update/common',

View File

@ -5,5 +5,4 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
SOURCES += ['TestWebappRT.cpp' ]
SimplePrograms(['TestWebappRT'])

View File

@ -8,18 +8,10 @@ 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 += [

View File

@ -15,30 +15,19 @@ if not CONFIG['MOZ_PROFILE_GENERATE']:
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'

View File

@ -20,10 +20,6 @@ SimplePrograms([
'WriteArgument',
])
SOURCES += [
'%s.cpp' % s for s in SIMPLE_PROGRAMS
]
USE_LIBS += [
'nspr',
]

View File

@ -24,8 +24,6 @@ FAIL_ON_WARNINGS = True
# is bug 652123.
# CPP_UNIT_TESTS += ['TestChromeMargin']
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
USE_LIBS += [
'mozalloc',
'nspr',

View File

@ -4,10 +4,6 @@
# 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',
])

View File

@ -8,10 +8,6 @@ SimplePrograms([
'TestXPTCInvoke',
])
SOURCES += [
'%s.cpp' % s for s in SIMPLE_PROGRAMS
]
USE_LIBS += [
'mozalloc',
'nspr',

View File

@ -4,10 +4,6 @@
# 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'
])

View File

@ -4,12 +4,6 @@
# 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'

View File

@ -8,10 +8,6 @@ SimplePrograms([
'TestMinStringAPI',
])
SOURCES += [
'%s.cpp' % s for s in SIMPLE_PROGRAMS
]
USE_LIBS += [
'mozalloc',
'nspr',

View File

@ -48,10 +48,6 @@ if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']:
'TestSTLWrappers',
])
SOURCES += [
'%s.cpp' % s for s in sorted(SIMPLE_PROGRAMS)
]
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
CppUnitTests([
@ -114,8 +110,6 @@ if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT'):
'TestDeadlockDetectorScalability',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
LOCAL_INCLUDES += [
'../ds',
]

View File

@ -9,8 +9,6 @@ CppUnitTests([
'TestNtPathToDosPath',
])
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
USE_LIBS += [
'mozalloc',
'nspr',

View File

@ -9,10 +9,6 @@ SimplePrograms([
'SimpleTypeLib',
])
SOURCES += [
'%s.cpp' % s for s in SIMPLE_PROGRAMS
]
FAIL_ON_WARNINGS = True
USE_LIBS += [

View File

@ -4,10 +4,6 @@
# 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'
])