From 5284fb2959b3fdc6a78ccfe72ed87d4bd5a0d24e Mon Sep 17 00:00:00 2001 From: James Turk Date: Mon, 4 Jul 2005 06:33:06 +0000 Subject: [PATCH] major cleaning --- SConstruct | 94 +++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/SConstruct b/SConstruct index 8c2e4d1..04ec7e8 100644 --- a/SConstruct +++ b/SConstruct @@ -5,7 +5,7 @@ # James Turk (jpt2433@rit.edu) # # Version: -# $Id: SConstruct,v 1.15 2005/07/04 03:06:06 cozman Exp $ +# $Id: SConstruct,v 1.16 2005/07/04 06:33:06 cozman Exp $ import os,os.path import glob @@ -17,7 +17,7 @@ def getFilesMulti(paths, pat): for d in paths: filelist += glob.glob( os.path.join(d,pat) ) return filelist - + ## config variables ## LIBRARY = 'photon' SUB_DIRS = ['', 'audio', 'math', 'util', 'util/filesys', 'video'] @@ -26,8 +26,7 @@ INC_DIRS = ["include/%s" % d for d in SUB_DIRS] SRC_FILES = [f.replace('src','build') for f in getFilesMulti(SRC_DIRS, '*.cpp')] INC_FILES = getFilesMulti(INC_DIRS, '*.hpp') -libsMap = { - 'nt':('opengl32','glu32','openal32'), +libsMap = { 'nt':('opengl32','glu32','openal32'), 'posix':('GL','GLU','openal'), 'mac':('GL','GLU','openal')} try: @@ -38,40 +37,26 @@ except KeyError: support.""" Exit(1) +def BuildSuperHeader(target = None, source = None, env = None): + header = file('include/'+LIBRARY+'.hpp','w') + incGuard = LIBRARY.upper()+'_HPP' + header.write('#ifndef '+incGuard+'\n') + header.write('#define '+incGuard+'\n\n') + for inc in INC_FILES: + header.write('#include "'+inc.replace('include/','')+'"\n') + header.write('\n#endif // '+incGuard+'\n') + header.close() + print "Built 'SuperHeader' " + LIBRARY + ".hpp" + return 0 + +SuperHeaderAction = Action(BuildSuperHeader) + # Configure the environment (Check libraries): -env = Environment(ENV = os.environ, - LIBPATH=['/usr/lib', '/usr/local/lib'], - INCPATH=['/usr/include', '/usr/local/include'], - CPPFLAGS = ['`freetype-config --cflags`', '-Wall', - '-pedantic'] - ) - -# Define Builds: -BuildDir('build', 'src', duplicate=0) - -lib = env.Library(os.path.join('lib',LIBRARY), source=SRC_FILES, - CPPPATH = 'include') -env.Alias(LIBRARY,lib) -env.Default(LIBRARY) - -ndoc = env.Command('docs/index.html', './include', - """NaturalDocs -nag -i $SOURCES -o HTML ./docs -p ./ndoc""") -env.Alias("docs",ndoc) - - -# Tests: -tests = [] -test_srcs = glob.glob( os.path.join('test', '*_test.cpp') ) - -for test_src in test_srcs: - test_name = test_src.replace('_test.cpp','') - tests.append(env.Program(test_name, source=test_src, CPPPATH = INC_DIRS+['/usr/include/freetype2/'], - LIBPATH='./lib', CPPFLAGS = '-Wall -pedantic', - LIBS=['photon',OAL_LIB,'glfw',OGL_LIB,GLU_LIB,'physfs','corona','freetype'])) -env.Alias('test',tests) - - -if LIBRARY in BUILD_TARGETS: +env = Environment() +env.Append(CPPPATH='include', CPPFLAGS='-Wall') +env.ParseConfig('freetype-config --cflags') +# Configure +if not env.GetOption('clean'): conf = Configure(env) if not conf.CheckLibWithHeader(OGL_LIB, 'GL/gl.h', 'C++'): print 'OpenGL not found, exiting.' @@ -93,16 +78,31 @@ if LIBRARY in BUILD_TARGETS: else: print 'OpenAL not found, continuing without OpenAL support.' env = conf.Finish() +env.Append(CPPFLAGS='-pedantic') # tests fail pedantic, so add after tests - # Build the Super-Header (only if this is a normal build) - header = file('include/'+LIBRARY+'.hpp','w') - incGuard = LIBRARY.upper()+'_HPP' - header.write('#ifndef '+incGuard+'\n') - header.write('#define '+incGuard+'\n\n') - for inc in INC_FILES: - header.write('#include "'+inc.replace('include/','')+'"\n') - header.write('\n#endif // '+incGuard+'\n') - header.close() - print 'Built '+LIBRARY+'.hpp' +## Define Builds ## +BuildDir('build', 'src', duplicate=0) + +# Library +lib = env.Library(os.path.join('lib',LIBRARY), source=SRC_FILES) +env.AddPostAction(lib, SuperHeaderAction) +env.Alias(LIBRARY,lib) +env.Default(LIBRARY) + +# Documentation +ndoc = env.Command('docs/index.html', './include', + """NaturalDocs -nag -i $SOURCES -o HTML ./docs -p ./ndoc""") +env.Alias("docs",ndoc) +# Tests: +tests = [] +test_srcs = glob.glob( os.path.join('test', '*_test.cpp') ) + +for test_src in test_srcs: + test_name = test_src.replace('_test.cpp','') + tests.append(env.Program(test_name, source=test_src, LIBPATH='./lib', + LIBS=['photon',OAL_LIB,'glfw',OGL_LIB,GLU_LIB, + 'physfs','corona','freetype'])) +env.Alias('test',tests) +