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)
45 print 'Invoke cmake command to generate appropriate make files'
46 env.Configure(gtest_dir, './configure')
49 print 'Making google unit test'
50 env.Configure(gtest_dir, 'make')
52 # print 'Create a directory'
53 # os.mkdir(gtest_dotlib_dir)
55 print 'Change to a directory'
56 os.chdir(gtest_dotlib_dir)
58 ## print 'Change to a directory'
59 # os.chdir(gtest_lib_dir)
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'
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'])
75 env.Configure(gtest_dir, './configure')
78 print 'Making google unit test'
79 env.Configure(gtest_dir, 'make')