wat
This commit is contained in:
		
							parent
							
								
									c9ff381f39
								
							
						
					
					
						commit
						921890e0b2
					
				
					 8 changed files with 95 additions and 10 deletions
				
			
		
							
								
								
									
										14
									
								
								SConstruct
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								SConstruct
									
										
									
									
									
								
							|  | @ -59,8 +59,22 @@ for mode in GetOption('modes'): | |||
|         env = MODES[mode] | ||||
|     except KeyError: | ||||
|         print 'Skipping invalid mode: {}'.format(mode) | ||||
| 
 | ||||
|     # Process libraries | ||||
|     env.SConscript(LIB_DIR.File('SConscript'), { | ||||
|         'env': env, | ||||
|     }, variant_dir=BUILD_DIR.Dir(env['MODE']).Dir('lib'), duplicate=0) | ||||
| 
 | ||||
|     # Process source | ||||
|     library, binary = env.SConscript(SRC_DIR.File('SConscript'), { | ||||
|         'env': env | ||||
|     }, variant_dir=BUILD_DIR.Dir(env['MODE']).Dir('src'), duplicate=0) | ||||
|     env.Alias('lib', library) | ||||
|     env.Alias('bin', binary) | ||||
| 
 | ||||
|     env.SConscript(TEST_DIR.File('SConscript'), { | ||||
|         'env': env, | ||||
|     }, variant_dir=BUILD_DIR.Dir(env['MODE']).Dir('test'), duplicate=0) | ||||
| 
 | ||||
| Import('LIBS') | ||||
| print LIBS | ||||
|  |  | |||
							
								
								
									
										24
									
								
								lib/SConscript
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								lib/SConscript
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,24 @@ | |||
| # SConscript | ||||
| # | ||||
| # SCons build script for libs in base. Aggregates static and shared libraries in | ||||
| # these directories and exports them in the 'LIBS' variable. | ||||
| # | ||||
| # Eryn Wells <eryn@erynwells.me> | ||||
| 
 | ||||
| 
 | ||||
| Import('env') | ||||
| 
 | ||||
| dirs = ( | ||||
|     'gtest', | ||||
| ) | ||||
| 
 | ||||
| env['LIBS'] = {} | ||||
| for d in dirs: | ||||
|     static, dynamic = env.SConscript(Dir(d).File('SConscript'), { | ||||
|         'env': env, | ||||
|     }) | ||||
|     env['LIBS'][d] = {} | ||||
|     if static: | ||||
|         env['LIBS'][d]['static'] = static | ||||
|     if dynamic: | ||||
|         env['LIBS'][d]['dynamic'] = dynamic | ||||
|  | @ -25,4 +25,6 @@ for f in files: | |||
| 
 | ||||
| env.Append(CPPPATH=[Dir('include').srcnode()]) | ||||
| 
 | ||||
| gtest = env.Library('gtest', objs) | ||||
| gtest_static = env.Library('gtest', [env.StaticObject(f) for f in files]) | ||||
| gtest_dynamic = None | ||||
| Return('gtest_static gtest_dynamic') | ||||
|  |  | |||
							
								
								
									
										9
									
								
								site_scons/dirs.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								site_scons/dirs.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| # dirs.py | ||||
| # Eryn Wells <eryn@erynwells.me> | ||||
| 
 | ||||
| from SCons.Script import Dir | ||||
| 
 | ||||
| BUILD_DIR = Dir('#build') | ||||
| LIB_DIR = Dir('#lib') | ||||
| SRC_DIR = Dir('#src') | ||||
| TEST_DIR = Dir('#test') | ||||
|  | @ -7,14 +7,9 @@ | |||
| 
 | ||||
| import os.path | ||||
| import SCons.Defaults | ||||
| import binaries | ||||
| from dirs import * | ||||
| 
 | ||||
| 
 | ||||
| BUILD_DIR = Dir('#build') | ||||
| LIB_DIR = Dir('#lib') | ||||
| SRC_DIR = Dir('#src') | ||||
| TEST_DIR = Dir('#test') | ||||
| 
 | ||||
| # | ||||
| # Environment Configuration | ||||
| # | ||||
|  | @ -22,11 +17,15 @@ TEST_DIR = Dir('#test') | |||
| def has_clang(env): | ||||
|     _, cc_tail = os.path.split(env['CC']) | ||||
|     _, cxx_tail = os.path.split(env['CXX']) | ||||
|     return any([cc_tail.startswith('clang'), cxx_tail.startswith('clang')]) | ||||
|     return all([cc_tail.startswith('clang'), cxx_tail.startswith('clang')]) | ||||
| 
 | ||||
| default_env = SCons.Defaults.DefaultEnvironment() | ||||
| default_env.Replace(CC=binaries.first(['clang', 'gcc']), | ||||
|                     CXX=binaries.first(['clang++', 'g++'])) | ||||
| default_env.Append(TOOLS=['gtest']) | ||||
| print default_env.Dump() | ||||
| 
 | ||||
| default_env.Replace( | ||||
|     CC=default_env.WhereIs('clang') or default_env.WhereIs('gcc'), | ||||
|     CXX=default_env.WhereIs('clang++') or default_env.WhereIs('gcc++')) | ||||
| 
 | ||||
| default_env.Append(CCFLAGS=['-Wall', '-Wextra', '-pedantic'], | ||||
|                    CFLAGS=['-std=c99'], | ||||
|  |  | |||
							
								
								
									
										28
									
								
								site_scons/site_tools/gtest/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								site_scons/site_tools/gtest/__init__.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| # gtestprogram.py | ||||
| # Eryn Wells <eryn@erynwells.me> | ||||
| 
 | ||||
| import SCons.Util | ||||
| import dirs | ||||
| 
 | ||||
| 
 | ||||
| def build_gtest_program(env, target, source=None, *args, **kwargs): | ||||
|     if not SCons.Util.is_List(source): | ||||
|         source = [source] | ||||
|     source.insert(0, dirs.LIB_DIR.Dir('gtest').File('gtest_main.cc')) | ||||
|     source.append(env['LIBS']['gtest']['static']) | ||||
|     return env.Program(target, source, *args, **kwargs) | ||||
| 
 | ||||
| 
 | ||||
| def generate(env): | ||||
|     print 'gtestprogram generate()' | ||||
|     try: | ||||
|         env.AddMethod(build_gtest_program, 'GTestProgram') | ||||
|     except AttributeError: | ||||
|         # Old version of SCons | ||||
|         from SCons.Script.SConscript import SConsEnvironment | ||||
|         SConsEnvironment.GTestProgram = build_gtest_program | ||||
| 
 | ||||
| 
 | ||||
| def exists(env): | ||||
|     print 'gtestprogram exists()' | ||||
|     return 'gtest' in env['LIBS'] | ||||
|  | @ -18,8 +18,15 @@ for d in subdirs: | |||
| 
 | ||||
| files = [ | ||||
|     # TODO: Put files here. | ||||
|     #'hello.cc', | ||||
| ] | ||||
| 
 | ||||
| objs = [] | ||||
| for f in files: | ||||
|     objs.append(env.Object(f)) | ||||
| 
 | ||||
| #lib = env.Library('hello', files) | ||||
| #prog = env.Program('hello', lib) | ||||
| lib = None | ||||
| prog = None | ||||
| Return('prog lib') | ||||
|  |  | |||
|  | @ -23,3 +23,5 @@ files = [ | |||
| objs = [] | ||||
| for f in files: | ||||
|     objs.append(env.Object(f)) | ||||
| 
 | ||||
| env.GTestProgram('test_hello', 'test_hello.cc') | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue