Once gtest's sconfile is imported, build flags are propagated.
Deeper cleanup and effort to make tests less linux specific
by avoiding to add gtest's pthread dependencies
in sub scons files.
Bug: https://jira.iotivity.org/browse/IOT-863
Bug-AGL: https://jira.automotivelinux.org/browse/SPEC-158
Change-Id: I4ddbf3e1eef8648ceaeae6c62175308cb6f3fec1
Origin: https://github.com/tizenteam/iotivity/
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/249
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: David Antler <david.a.antler@intel.com>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__linux__'])
env.AppendUnique(CFLAGS = ['-std=gnu99'])
env.AppendUnique(CCFLAGS = ['-Wall', '-Wextra', '-fPIC'])
-env.AppendUnique(LIBS = ['dl', 'pthread'])
-env.AppendUnique(LIBS = ['uuid'])
+env.AppendUnique(LIBS = ['dl', 'uuid'])
# Set arch flags that match best TARGET_ARCH variable
target_arch = env.get('TARGET_ARCH')
gtest_env.AppendUnique(LIBPATH = [gtest_dotlib_dir])
gtest_env.PrependUnique(CPPPATH = [os.path.join(gtest_dir, 'include')])
gtest_env.AppendENVPath('LD_LIBRARY_PATH', gtest_dotlib_dir)
- compiler = gtest_env.get('CXX')
- if 'g++' in compiler:
+ if 'g++' in gtest_env.get('CXX'):
gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
gtest_env.AppendUnique(CXXFLAGS = ['-Wall'])
# Note: 'pthread' for android is in bionic
# On other platform, if use new gcc(>4.9?) it isn't required, otherwise, it's required
if target_os not in ['android']:
gtest_env.AppendUnique(CXXFLAGS = ['-pthread'])
+ gtest_env.PrependUnique(LIBS = ['pthread'])
+ gtest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
Return('gtest_env')
os.path.join(pi_dir, 'include'),
])
-if target_os not in ['windows']:
- unittests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- unittests_env.PrependUnique(LIBS = ['pthread'])
unittests_env.AppendUnique(LIBPATH = [unittests_env.get('BUILD_DIR')])
unittests_env.PrependUnique(LIBS = [
'plugin_interface',
'octbstack',
'oc_logger',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main'
+ 'coap'
])
if unittests_env.get('LOGGING'):
'../../../oc_logger/include',
])
-if target_os not in ['windows']:
- randomtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- randomtest_env.AppendUnique(LIBS = ['pthread'])
-
randomtest_env.AppendUnique(LIBPATH = [randomtest_env.get('BUILD_DIR')])
randomtest_env.PrependUnique(LIBS = ['octbstack',
- 'uuid',
- 'gtest',
- 'gtest_main'])
+ 'uuid'])
if target_os in ['linux']:
randomtest_env.AppendUnique(LIBS = ['m'])
malloctest_env.PrependUnique(CPPPATH = [
'../include'])
-if target_os not in ['windows']:
- malloctest_env.PrependUnique(LIBS = ['pthread'])
-
malloctest_env.AppendUnique(LIBPATH = [os.path.join(malloctest_env.get('BUILD_DIR'), 'resource', 'c_common')])
-malloctest_env.PrependUnique(LIBS = ['c_common', 'gtest', 'gtest_main'])
+malloctest_env.PrependUnique(LIBS = ['c_common'])
if malloctest_env.get('LOGGING'):
malloctest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
stringtest_env.AppendUnique(LIBPATH = [os.path.join(stringtest_env.get('BUILD_DIR'), 'resource', 'c_common')])
stringtest_env.PrependUnique(LIBS = ['c_common'])
-if target_os not in ['windows']:
- stringtest_env.PrependUnique(LIBS = ['pthread'])
-stringtest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
+
if stringtest_env.get('LOGGING'):
stringtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
#
'../include'])
timetest_env.AppendUnique(LIBPATH = [os.path.join(timetest_env.get('BUILD_DIR'), 'resource', 'c_common')])
-if target_os not in ['windows']:
- timetest_env.PrependUnique(LIBS = ['pthread'])
-timetest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
timetest_env.PrependUnique(LIBS = ['c_common'])
timetest_env.Append(LIBS = ['rt']);
if target_os in ['tizen', 'linux']:
liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
-if target_os not in ['android', 'arduino', 'windows', 'msys_nt']:
- liboctbstack_env.AppendUnique(LIBS = ['pthread'])
-
if target_os == 'arduino':
liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
elif target_os not in ['darwin','ios', 'msys_nt', 'windows']:
'../../../oc_logger/include',
])
-tmplist = catest_env['LINKFLAGS'][:]
-if '-lpthread' in tmplist:
- tmplist.remove('-lpthread')
- catest_env.Replace(LINKFLAGS = tmplist)
-
-if target_os not in ['windows']:
- catest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
catest_env.AppendUnique(LIBPATH = [catest_env.get('BUILD_DIR')])
catest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
catest_env.PrependUnique(LIBS = ['octbstack',
'iphlpapi'])
else:
catest_env.AppendUnique(LIBS = ['m'])
- catest_env.PrependUnique(LIBS = ['pthread'])
######################################################################
# Source files and Targets
'../../../../../../extlibs/tinydtls/ecc',
'../../../../../../extlibs/tinydtls/sha2'
])
-if target_os not in ['windows']:
- pki_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- pki_test_env.AppendUnique(LIBS = ['pthread'])
+
pki_test_env.AppendUnique(LIBPATH = [pki_test_env.get('BUILD_DIR')])
pki_test_env.AppendUnique(LIBS = ['octbstack'])
pki_test_env.AppendUnique(LIBS = ['CKManager'])
pki_test_env.AppendUnique(LIBS = ['asn1'])
-pki_test_env.AppendUnique(LIBS = ['gtest'])
-pki_test_env.AppendUnique(LIBS = ['gtest_main'])
if pki_test_env.get('SECURED') == '1':
pki_test_env.AppendUnique(LIBS = ['tinydtls'])
'octbstack',
'oc_logger',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main'])
+ 'coap'])
if sptest_env.get('SECURED') == '1':
sptest_env.AppendUnique(LIBS = ['timer'])
sptest_env.AppendUnique(LIBS = ['ws2_32',
'advapi32',
'iphlpapi'])
-else:
- sptest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- sptest_env.AppendUnique(LIBS = ['dl', 'pthread'])
######################################################################
# Source files and Targets
'../include'
])
-if target_os not in ['windows']:
- srmtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- srmtest_env.AppendUnique(LIBS = ['pthread'])
srmtest_env.AppendUnique(LIBPATH = [srmtest_env.get('BUILD_DIR')])
srmtest_env.PrependUnique(LIBS = ['ocsrm',
'octbstack',
'oc_logger',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main'])
+ 'coap'])
if srmtest_env.get('SECURED') == '1':
srmtest_env.AppendUnique(LIBS = ['tinydtls', 'timer'])
'../../extlibs/cjson',
'../../../oc_logger/include',
])
-if target_os not in ['windows']:
- stacktest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+
stacktest_env.AppendUnique(LIBPATH = [stacktest_env.get('BUILD_DIR')])
stacktest_env.PrependUnique(LIBS = ['octbstack',
'ocsrm',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main'])
-
+ 'coap'])
if target_os != 'darwin':
stacktest_env.PrependUnique(LIBS = ['oc_logger'])
stacktest_env.AppendUnique(LIBS = ['ws2_32', 'iphlpapi', 'kernel32'])
else:
stacktest_env.PrependUnique(LIBS = ['m'])
- stacktest_env.PrependUnique(LIBS = ['pthread'])
######################################################################
# Source files and Targets
'../../../extlibs/hippomocks-master/HippoMocksTest'
])
-if target_os not in ['windows']:
- provisiontests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- provisiontests_env.AppendUnique(LIBS = ['-lpthread', '-ldl'])
-
provisiontests_env.AppendUnique(LIBPATH = [provisiontests_env.get('BUILD_DIR')])
provisiontests_env.PrependUnique(LIBS = [
'ocprovision',
'octbstack',
'oc_logger',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main',
+ 'coap'
])
if with_ra_ibb:
'#extlibs/hippomocks-master/HippoMocksTest'
])
-if target_os not in ['windows']:
- unittests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- unittests_env.AppendUnique(LIBS = ['pthread'])
unittests_env.AppendUnique(LIBPATH = [unittests_env.get('BUILD_DIR')])
unittests_env.PrependUnique(LIBS = [
'oc',
'octbstack',
'oc_logger',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main'
+ 'coap'
])
if unittests_env.get('SECURED') == '1':
enrollee_test_env.get('SRC_DIR') + '/service/easy-setup/enrollee/inc',
enrollee_test_env.get('SRC_DIR') + '/service/easy-setup/enrollee/src'])
-if target_os not in ['windows']:
- enrollee_test_env.PrependUnique(LIBS = ['m'])
- enrollee_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
- enrollee_test_env.AppendUnique(LIBS = ['pthread'])
enrollee_test_env.AppendUnique(LIBPATH = [enrollee_test_env.get('BUILD_DIR')])
enrollee_test_env.PrependUnique(LIBS = [ 'octbstack',
'ocsrm',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main'])
+ 'coap'])
+if target_os not in ['windows']:
+ enrollee_test_env.AppendUnique(LIBS = ['m'])
if target_os != 'darwin':
enrollee_test_env.PrependUnique(LIBS = ['oc_logger'])
'../../../inc',
])
-if target_os not in ['windows']:
- mediator_csdk_test_env.AppendUnique(LIBS = ['dl'])
- mediator_csdk_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
- if target_os != 'android':
- mediator_csdk_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
- mediator_csdk_test_env.AppendUnique(LIBS = ['pthread'])
-
mediator_csdk_test_env.PrependUnique(LIBS = [
'ESMediatorCSDK',
'oc',
'octbstack',
'oc_logger',
'oc_logger_core',
- 'connectivity_abstraction',
- 'gtest',
- 'gtest_main'])
+ 'connectivity_abstraction'])
######################################################################
# Build Test
'../../../inc',
])
-if target_os not in ['windows']:
- mediator_rich_test_env.AppendUnique(LIBS = ['dl'])
- mediator_rich_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
- if target_os not in ['android']:
- mediator_rich_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
- mediator_rich_test_env.AppendUnique(LIBS = ['pthread'])
-
if mediator_rich_test_env.get('SECURED') == '1':
mediator_rich_test_env.PrependUnique(LIBS = ['tinydtls','ocprovision', 'ocpmapi', 'timer'])
'ESMediatorRich',
'oc',
'octbstack',
- 'oc_logger',
- 'gtest',
- 'gtest_main'])
+ 'oc_logger'])
######################################################################
# Build Test
if target_os not in ['windows']:
container_gtest_env.AppendUnique(LIBS = ['dl'])
- container_gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
container_gtest_env.AppendUnique(CCFLAGS = ['-Wnoexcept'])
- if target_os != 'android':
- container_gtest_env.AppendUnique(CXXFLAGS = ['-pthread'])
- container_gtest_env.AppendUnique(LIBS = ['pthread'])
+
+container_gtest_env.PrependUnique(LIBS = ['rcs_container', 'rcs_client', 'rcs_server', 'rcs_common',
+ 'oc','octbstack', 'oc_logger', 'oc_logger_core',
+ 'connectivity_abstraction'])
if target_os in ['android']:
container_gtest_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
if target_os not in ['windows']:
rcs_common_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
- if target_os not in ['android']:
- rcs_common_env.AppendUnique(CXXFLAGS = ['-pthread'])
- rcs_common_env.AppendUnique(LIBS = ['pthread'])
if target_os not in ['darwin', 'ios', 'windows']:
rcs_common_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
'oc_logger',
'connectivity_abstraction',
'coap',
- 'rcs_common',
- 'gtest',
- 'gtest_main',
- 'pthread'
- ])
+ 'rcs_common'])
rcs_common_test_src = [
rcs_common_test_env.Glob('primitiveResource/unittests/*.cpp'),
broker_test_env.AppendUnique(LIBS = ['oc'])
broker_test_env.AppendUnique(LIBS = ['rcs_client'])
broker_test_env.AppendUnique(LIBS = ['rcs_common'])
-broker_test_env.AppendUnique(LIBS = ['gtest'])
-broker_test_env.AppendUnique(LIBS = ['gtest_main'])
compiler = broker_test_env.get('CXX')
if 'g++' in compiler:
broker_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
-if target_os not in ['windows']:
- broker_test_env.AppendUnique(LIBS = ['pthread'])
-
######################################################################
# Build Test
######################################################################
cache_test_env.AppendUnique(LIBPATH = [cache_test_env.get('BUILD_DIR')])
cache_test_env.PrependUnique(LIBS = ['rcs_client', 'rcs_common',
'oc', 'octbstack', 'oc_logger',
- 'connectivity_abstraction', 'coap',
- 'gtest', 'gtest_main'])
+ 'connectivity_abstraction', 'coap'])
compiler = cache_test_env.get('CXX')
if 'g++' in compiler:
cache_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
-if target_os not in ['windows']:
- cache_test_env.AppendUnique(LIBS = ['pthread'])
-
######################################################################
# Build Test
######################################################################
server_builder_env.PrependUnique(LIBS = ['gcov'])
if target_os not in ['windows']:
server_builder_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
- if target_os not in ['android']:
- server_builder_env.AppendUnique(LIBS = ['dl'])
- server_builder_env.AppendUnique(CXXFLAGS = ['-pthread'])
if target_os not in ['darwin', 'ios', 'windows']:
server_builder_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
'octbstack',
'oc_logger',
'connectivity_abstraction',
- 'coap',
- 'gtest',
- 'gtest_main',
- 'pthread',
- ])
+ 'coap'])
server_builder_test_src = server_builder_test_env.Glob('unittests/*.cpp')
'../src/common/utils/include',
])
-if target_os not in ['windows']:
- rcs_test_env.AppendUnique(LIBS = ['dl'])
- rcs_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
- if target_os != 'android':
- rcs_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
- rcs_test_env.AppendUnique(LIBS = ['pthread'])
-
rcs_test_env.PrependUnique(LIBS = [
'connectivity_abstraction',
'oc_logger',
'oc',
'rcs_client',
'rcs_server',
- 'rcs_common',
- 'gtest',
- 'gtest_main'])
+ 'rcs_common'])
######################################################################
# Build Test
hosting_test_env.AppendUnique(LIBPATH = [hosting_test_env.get('BUILD_DIR')])
hosting_test_env.AppendUnique(LIBS = [
'resource_hosting', 'rcs_server', 'rcs_client','rcs_common',
- 'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap',
- 'gtest_main', 'gtest'])
+ 'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
if target_os not in ['windows']:
- hosting_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
-
-if target_os in ['linux']:
- hosting_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
- hosting_test_env.AppendUnique(LIBS = ['pthread'])
+ hosting_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0'])
hosting_test_env.PrependUnique(CPPPATH = [ src_dir + '/extlibs/hippomocks-master'])
hosting_test_env.AppendUnique(CPPPATH = ['../src'])
scene_test_env.AppendUnique(LIBPATH = [lib_env.get('BUILD_DIR')])
scene_test_env.AppendUnique(LIBS = [
'scene_manager', 'rcs_server', 'rcs_client','rcs_common',
- 'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap',
- 'gtest_main', 'gtest'])
+ 'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
if target_os not in ['windows']:
- scene_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
-
-if target_os in ['linux']:
- scene_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
- scene_test_env.AppendUnique(LIBS = ['pthread'])
+ scene_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0'])
if not scene_test_env.get('RELEASE'):
scene_test_env.PrependUnique(LIBS = ['gcov'])
'../../../extlibs/timer'
])
-if target_os not in ['windows']:
- ThingsManager_gtest_env.AppendUnique(LIBS = ['dl'])
- ThingsManager_gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
- if target_os != 'android':
- ThingsManager_gtest_env.AppendUnique(CXXFLAGS = ['-pthread'])
- ThingsManager_gtest_env.AppendUnique(LIBS = ['pthread'])
-
ThingsManager_gtest_env.PrependUnique(LIBS = [
'libTGMSDKLibrary',
'coap',
'oc_logger',
'oc_logger_core',
'oc',
- 'octbstack',
- 'gtest',
- 'gtest_main'])
+ 'octbstack'])
######################################################################
# Build Test