major cleaning

This commit is contained in:
James Turk 2005-07-04 06:33:06 +00:00
parent 219db7e0f1
commit 5284fb2959

View File

@ -5,7 +5,7 @@
# James Turk (jpt2433@rit.edu) # James Turk (jpt2433@rit.edu)
# #
# Version: # 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 os,os.path
import glob import glob
@ -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')] SRC_FILES = [f.replace('src','build') for f in getFilesMulti(SRC_DIRS, '*.cpp')]
INC_FILES = getFilesMulti(INC_DIRS, '*.hpp') INC_FILES = getFilesMulti(INC_DIRS, '*.hpp')
libsMap = { libsMap = { 'nt':('opengl32','glu32','openal32'),
'nt':('opengl32','glu32','openal32'),
'posix':('GL','GLU','openal'), 'posix':('GL','GLU','openal'),
'mac':('GL','GLU','openal')} 'mac':('GL','GLU','openal')}
try: try:
@ -38,40 +37,26 @@ except KeyError:
support.""" support."""
Exit(1) 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): # Configure the environment (Check libraries):
env = Environment(ENV = os.environ, env = Environment()
LIBPATH=['/usr/lib', '/usr/local/lib'], env.Append(CPPPATH='include', CPPFLAGS='-Wall')
INCPATH=['/usr/include', '/usr/local/include'], env.ParseConfig('freetype-config --cflags')
CPPFLAGS = ['`freetype-config --cflags`', '-Wall', # Configure
'-pedantic'] if not env.GetOption('clean'):
)
# 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:
conf = Configure(env) conf = Configure(env)
if not conf.CheckLibWithHeader(OGL_LIB, 'GL/gl.h', 'C++'): if not conf.CheckLibWithHeader(OGL_LIB, 'GL/gl.h', 'C++'):
print 'OpenGL not found, exiting.' print 'OpenGL not found, exiting.'
@ -93,16 +78,31 @@ if LIBRARY in BUILD_TARGETS:
else: else:
print 'OpenAL not found, continuing without OpenAL support.' print 'OpenAL not found, continuing without OpenAL support.'
env = conf.Finish() 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) ## Define Builds ##
header = file('include/'+LIBRARY+'.hpp','w') BuildDir('build', 'src', duplicate=0)
incGuard = LIBRARY.upper()+'_HPP'
header.write('#ifndef '+incGuard+'\n') # Library
header.write('#define '+incGuard+'\n\n') lib = env.Library(os.path.join('lib',LIBRARY), source=SRC_FILES)
for inc in INC_FILES: env.AddPostAction(lib, SuperHeaderAction)
header.write('#include "'+inc.replace('include/','')+'"\n') env.Alias(LIBRARY,lib)
header.write('\n#endif // '+incGuard+'\n') env.Default(LIBRARY)
header.close()
print 'Built '+LIBRARY+'.hpp' # 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)