Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / extlibs / gtest / SConscript
1 ##
2 # 'googletest' script to check if Google Unit Test library is installed.  If not,
3 # get it and install it
4 #
5 ##
6
7 import os
8
9 Import('env')
10
11 target_os = env.get('TARGET_OS')
12 src_dir = env.get('SRC_DIR')
13
14 targets_need_gtest = ['darwin','linux']
15 gtest_dir      = src_dir + '/extlibs/gtest/gtest-1.7.0'
16 gtest_zip_file = src_dir + '/extlibs/gtest/gtest-1.7.0.zip'
17 gtest_url      = 'https://googletest.googlecode.com/files/gtest-1.7.0.zip'
18
19 if target_os in targets_need_gtest:
20         print '*** Checking for installation of google unit test 1.7.0 ***'
21
22         if not os.path.exists(gtest_dir):
23                 # If the gtest zip file is not already present, download it
24                 if not os.path.exists(gtest_zip_file):
25                         gtest_zip = env.Download(gtest_zip_file, gtest_url)
26                 else:
27                         gtest_zip = gtest_zip_file
28
29                 # Unzip gtest
30                 print 'Unzipping google unit test'
31                 env.UnpackAll(gtest_dir, gtest_zip)
32
33
34 if target_os == 'darwin':
35         if os.path.exists(gtest_dir):
36                 # Build gtest and store it at a temporary directory
37                 gtest_lib_dir = gtest_dir + '/lib'
38                 gtest_dotlib_dir = gtest_lib_dir + '/.libs'
39
40         if not os.path.exists(gtest_lib_dir):
41 #                       print 'Create a directory'
42 #                       os.mkdir(gtest_lib_dir)
43
44
45                         print 'Invoke cmake command to generate appropriate make files'
46                         env.Configure(gtest_dir, './configure')
47
48                         # Run make on gtest
49                         print 'Making google unit test'
50                         env.Configure(gtest_dir, 'make')
51
52 #                       print 'Create a directory'
53 #                       os.mkdir(gtest_dotlib_dir)
54
55                         print 'Change to a directory'
56                         os.chdir(gtest_dotlib_dir)
57
58 ##                      print 'Change to a directory'
59 #                       os.chdir(gtest_lib_dir)
60
61                         print 'Create hard links pointing to gtest libraries'
62                         os.link('libgtest.a', gtest_lib_dir + 'libgtest.a')
63                         os.link('libgtest_main.a', gtest_lib_dir +  'libgtest_main.a')
64                         print 'Create hard links pointing to gtest libraries - DONE'
65
66
67 elif target_os == 'linux':
68         if os.path.exists(gtest_dir):
69                 if not os.path.exists(gtest_dir + "/lib"):
70                         # Run configure on gtest
71                         print 'Configuring google unit test'
72                         if env.get('CROSS_COMPILE'):
73                                 env.Configure(gtest_dir, './configure --host=' + env['CROSS_COMPILE'])
74                         else:
75                                 env.Configure(gtest_dir, './configure')
76
77                         # Run make on gtest
78                         print 'Making google unit test'
79                         env.Configure(gtest_dir, 'make')
80
81