2 # 'googletest' script to check if Google Unit Test library is installed. If not,
3 # get it and install it
11 target_os = env.get('TARGET_OS')
12 src_dir = env.get('SRC_DIR')
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'
19 if target_os in targets_need_gtest:
20 print '*** Checking for installation of google unit test 1.7.0 ***'
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)
27 gtest_zip = gtest_zip_file
30 print 'Unzipping google unit test'
31 env.UnpackAll(gtest_dir, gtest_zip)
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'
40 if not os.path.exists(gtest_lib_dir):
41 print 'Create a directory'
42 os.mkdir(gtest_lib_dir)
44 print 'Change to a directory'
45 os.chdir(gtest_lib_dir)
47 print 'Invoke cmake command to generate appropriate make files'
48 env.Configure(gtest_lib_dir, 'cmake -G"Unix Makefiles" ..')
51 print 'Making google unit test'
52 env.Configure(gtest_lib_dir, 'make')
54 print 'Create a directory'
55 os.mkdir(gtest_dotlib_dir)
57 print 'Change to a directory'
58 os.chdir(gtest_dotlib_dir)
60 print 'Create hard links pointing to gtest libraries'
61 os.link('../' + 'libgtest.a', 'libgtest.a')
62 os.link('../' + 'libgtest_main.a', 'libgtest_main.a')
63 print 'Create hard links pointing to gtest libraries - DONE'
66 elif target_os == 'linux':
67 if os.path.exists(gtest_dir):
68 if not os.path.exists(gtest_dir + "/lib"):
69 # Run configure on gtest
70 print 'Configuring google unit test'
71 if env.get('CROSS_COMPILE'):
72 env.Configure(gtest_dir, './configure --host=' + env['CROSS_COMPILE'])
74 env.Configure(gtest_dir, './configure')
77 print 'Making google unit test'
78 env.Configure(gtest_dir, 'make')