+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
# Ignore output dirs
/release
resource/release
platform
# Ignore downloaded dependencies
-extlibs/gtest*
+extlibs/gtest/gtest-*
extlibs/hippomocks-master/
extlibs/master.zip
extlibs/cereal/cereal
target_os = env.get('TARGET_OS')
src_dir = env.get('SRC_DIR')
+targets_need_gtest = ['darwin','linux']
+gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
+gtest_zip_file = src_dir + '/extlibs/gtest/gtest-1.7.0.zip'
+gtest_url = 'https://googletest.googlecode.com/files/gtest-1.7.0.zip'
-if target_os == 'linux':
- print '*** Checking for installation of google unit test 1.7.0 ***'
-
- gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
- gtest_zip_file = src_dir + '/extlibs/gtest/gtest-1.7.0.zip'
- gtest_url = 'https://googletest.googlecode.com/files/gtest-1.7.0.zip'
+if target_os in targets_need_gtest:
+ print '*** Checking for installation of google unit test 1.7.0 ***'
if not os.path.exists(gtest_dir):
# If the gtest zip file is not already present, download it
print 'Unzipping google unit test'
env.UnpackAll(gtest_dir, gtest_zip)
+
+if target_os == 'darwin':
+ if os.path.exists(gtest_dir):
+ # Build gtest and store it at a temporary directory
+ gtest_lib_dir = gtest_dir + '/lib'
+ gtest_dotlib_dir = gtest_lib_dir + '/.libs'
+
+ if not os.path.exists(gtest_lib_dir):
+ print 'Create a directory'
+ os.mkdir(gtest_lib_dir)
+
+ print 'Change to a directory'
+ os.chdir(gtest_lib_dir)
+
+ print 'Invoke cmake command to generate appropriate make files'
+ env.Configure(gtest_lib_dir, 'cmake -G"Unix Makefiles" ..')
+
+ # Run make on gtest
+ print 'Making google unit test'
+ env.Configure(gtest_lib_dir, 'make')
+
+ print 'Create a directory'
+ os.mkdir(gtest_dotlib_dir)
+
+ print 'Change to a directory'
+ os.chdir(gtest_dotlib_dir)
+
+ print 'Create hard links pointing to gtest libraries'
+ os.link('../' + 'libgtest.a', 'libgtest.a')
+ os.link('../' + 'libgtest_main.a', 'libgtest_main.a')
+ print 'Create hard links pointing to gtest libraries - DONE'
+
+
+elif target_os == 'linux':
+ if not os.path.exists(gtest_dir):
# Run configure on gtest
print 'Configuring google unit test'
env.Configure(gtest_dir, './configure')
# Build C/C++ unit tests
SConscript('unit_tests.scons')
+
elif target_os == 'darwin':
- # Build linux samples for now
+ # Build linux samples for now.
SConscript('csdk/stack/samples/linux/SimpleClientServer/SConscript')
+
+ # Build C stack's unit tests.
+ SConscript('unit_tests.scons')
+
elif target_os == 'arduino':
SConscript('csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript')
-
catest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
catest_env.PrependUnique(LIBS = ['m',
'octbstack',
- 'oc_logger',
'connectivity_abstraction',
'coap',
'gtest',
'gtest_main'])
+target_os = env.get('TARGET_OS')
+if target_os != 'darwin':
+ catest_env.PrependUnique(LIBS = ['oc_logger'])
+
if env.get('SECURED') == '1':
catest_env.AppendUnique(LIBS = ['tinydtls'])
catest_env.ParseConfig('pkg-config --libs glib-2.0');
stacktest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
stacktest_env.PrependUnique(LIBS = ['m',
'octbstack',
- 'oc_logger',
'connectivity_abstraction',
'coap',
'gtest',
'gtest_main'])
+target_os = env.get('TARGET_OS')
+if target_os != 'darwin':
+ stacktest_env.PrependUnique(LIBS = ['oc_logger'])
+
+
if env.get('SECURED') == '1':
stacktest_env.AppendUnique(LIBS = ['tinydtls'])
stacktest_env.ParseConfig('pkg-config --libs glib-2.0');
# Build C++ unit tests
SConscript('unittests/SConscript')
+elif target_os == 'darwin':
+ # Verify that 'google unit test' library is installed. If not,
+ # get it and install it
+ SConscript(src_dir + '/extlibs/gtest/SConscript')
+ # Build C stack's unit tests.
+ SConscript('csdk/stack/test/SConscript')
+ SConscript('csdk/connectivity/test/SConscript')