--opengl works now, had to fix dep issues in linux. TODO: --opengl-renderer

This commit is contained in:
Bryan Hoyle 2012-08-12 13:52:22 -04:00
parent 7084c8be28
commit 859aa0cf14

View File

@ -2,26 +2,26 @@ import os, sys, subprocess, time
##Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32 ##Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32
class ourSpawn: class ourSpawn:
def ourspawn(self, sh, escape, cmd, args, env): def ourspawn(self, sh, escape, cmd, args, env):
newargs = ' '.join(args[1:]) newargs = ' '.join(args[1:])
cmdline = cmd + " " + newargs cmdline = cmd + " " + newargs
startupinfo = subprocess.STARTUPINFO() startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env) stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
data, err = proc.communicate() data, err = proc.communicate()
rv = proc.wait() rv = proc.wait()
if rv: if rv:
print "=====" print "====="
print err print err
print "=====" print "====="
return rv return rv
def SetupSpawn( env ): def SetupSpawn( env ):
if sys.platform == 'win32': if sys.platform == 'win32':
buf = ourSpawn() buf = ourSpawn()
buf.ourenv = env buf.ourenv = env
env['SPAWN'] = buf.ourspawn env['SPAWN'] = buf.ourspawn
AddOption('--opengl',dest="opengl",action='store_true',default=False,help="Build with OpenGL interface support.") AddOption('--opengl',dest="opengl",action='store_true',default=False,help="Build with OpenGL interface support.")
AddOption('--opengl-renderer',dest="opengl-renderer",action='store_true',default=False,help="Build with OpenGL renderer support. (requires --opengl)") AddOption('--opengl-renderer',dest="opengl-renderer",action='store_true',default=False,help="Build with OpenGL renderer support. (requires --opengl)")
@ -48,68 +48,68 @@ AddOption('--build-number',dest="build-number",default=False,help="Build number.
AddOption('--snapshot',dest="snapshot",default=False,help="Snapshot build.") AddOption('--snapshot',dest="snapshot",default=False,help="Snapshot build.")
if((not GetOption('lin')) and (not GetOption('win')) and (not GetOption('macosx'))): if((not GetOption('lin')) and (not GetOption('win')) and (not GetOption('macosx'))):
print "You must specify a platform to target" print "You must specify a platform to target"
raise SystemExit(1) raise SystemExit(1)
if(GetOption('win')): if(GetOption('win')):
env = Environment(tools = ['mingw'], ENV = os.environ) env = Environment(tools = ['mingw'], ENV = os.environ)
else: else:
env = Environment(ENV = os.environ) env = Environment(ENV = os.environ)
if GetOption("toolprefix"): if GetOption("toolprefix"):
env['CC'] = GetOption("toolprefix")+env['CC'] env['CC'] = GetOption("toolprefix")+env['CC']
env['CXX'] = GetOption("toolprefix")+env['CXX'] env['CXX'] = GetOption("toolprefix")+env['CXX']
env['RC'] = GetOption("toolprefix")+env['RC'] env['RC'] = GetOption("toolprefix")+env['RC']
#Check for headers and libraries #Check for headers and libraries
conf = Configure(env) conf = Configure(env)
try: try:
env.ParseConfig('sdl-config --cflags') env.ParseConfig('sdl-config --cflags')
env.ParseConfig('sdl-config --libs') env.ParseConfig('sdl-config --libs')
except: except:
conf.CheckLib("SDL") conf.CheckLib("SDL")
if(GetOption("sdl-dir")): if(GetOption("sdl-dir")):
if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'): if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'):
print "sdl headers not found or not installed" print "sdl headers not found or not installed"
raise SystemExit(1) raise SystemExit(1)
else: else:
env.Append(CPPPATH=GetOption("sdl-dir")) env.Append(CPPPATH=GetOption("sdl-dir"))
#Find correct lua include dir #Find correct lua include dir
try: try:
env.ParseConfig('pkg-config --cflags lua5.1') env.ParseConfig('pkg-config --cflags lua5.1')
except: except:
if(GetOption("lua-dir")): if(GetOption("lua-dir")):
if not conf.CheckCHeader(GetOption("lua-dir") + '/lua.h'): if not conf.CheckCHeader(GetOption("lua-dir") + '/lua.h'):
print "lua5.1 headers not found or not installed" print "lua5.1 headers not found or not installed"
raise SystemExit(1) raise SystemExit(1)
else: else:
env.Append(CPPPATH=GetOption("lua-dir")) env.Append(CPPPATH=GetOption("lua-dir"))
#Check for FFT lib #Check for FFT lib
if not conf.CheckLib('fftw3f') and not conf.CheckLib('fftw3f-3'): if not conf.CheckLib('fftw3f') and not conf.CheckLib('fftw3f-3'):
print "libfftw3f not found or not installed" print "libfftw3f not found or not installed"
raise SystemExit(1) raise SystemExit(1)
#Check for Bzip lib #Check for Bzip lib
if not conf.CheckLib('bz2'): if not conf.CheckLib('bz2'):
print "libbz2 not found or not installed" print "libbz2 not found or not installed"
raise SystemExit(1) raise SystemExit(1)
#Check for zlib #Check for zlib
if not conf.CheckLib('z'): if not conf.CheckLib('z'):
print "libz not found or not installed" print "libz not found or not installed"
raise SystemExit(1) raise SystemExit(1)
if not conf.CheckCHeader("bzlib.h"): if not conf.CheckCHeader("bzlib.h"):
print "bzip2 headers not found" print "bzip2 headers not found"
raise SystemExit(1) raise SystemExit(1)
#Check for Lua lib #Check for Lua lib
if not conf.CheckLib('lua') and not conf.CheckLib('lua5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua-5.1'): if not conf.CheckLib('lua') and not conf.CheckLib('lua5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua-5.1'):
print "liblua not found or not installed" print "liblua not found or not installed"
raise SystemExit(1) raise SystemExit(1)
env = conf.Finish(); env = conf.Finish();
@ -119,84 +119,86 @@ env.Append(LIBS=['pthread', 'm'])
env.Append(CPPDEFINES=["USE_SDL", "LUACONSOLE", "GRAVFFT", "_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"]) env.Append(CPPDEFINES=["USE_SDL", "LUACONSOLE", "GRAVFFT", "_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"])
if GetOption("ptw32-static"): if GetOption("ptw32-static"):
env.Append(CPPDEFINES=['PTW32_STATIC_LIB']); env.Append(CPPDEFINES=['PTW32_STATIC_LIB']);
if(GetOption('static')): if(GetOption('static')):
env.Append(LINKFLAGS=['-static-libgcc']) env.Append(LINKFLAGS=['-static-libgcc'])
if(GetOption('win')): if(GetOption('win')):
openGLLibs = ['opengl32', 'glew32'] openGLLibs = ['opengl32', 'glew32']
env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'regex']) env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'regex'])
env.Append(LIBS=['winmm', 'gdi32']) env.Append(LIBS=['winmm', 'gdi32'])
env.Append(CPPDEFINES=["WIN"]) env.Append(CPPDEFINES=["WIN"])
env.Append(LINKFLAGS=['-mwindows']) env.Append(LINKFLAGS=['-mwindows'])
if(GetOption('_64bit')): if(GetOption('_64bit')):
env.Append(CPPDEFINES=['__CRT__NO_INLINE']) env.Append(CPPDEFINES=['__CRT__NO_INLINE'])
env.Append(LINKFLAGS=['-Wl,--stack=16777216']) env.Append(LINKFLAGS=['-Wl,--stack=16777216'])
if(GetOption('lin')): if(GetOption('lin')):
openGLLibs = ['GL'] if(GetOption('opengl')):
env.Append(LIBS=['X11', 'rt']) env.ParseConfig('pkg-config --libs glew gl glu')
env.Append(CPPDEFINES=["LIN"]) openGLLibs = ['GL']
if GetOption('_64bit'): env.Append(LIBS=['X11', 'rt'])
env.Append(LINKFAGS=['-m64']) env.Append(CPPDEFINES=["LIN"])
env.Append(CCFLAGS=['-m64']) if GetOption('_64bit'):
else: env.Append(LINKFAGS=['-m64'])
env.Append(LINKFLAGS=['-m32']) env.Append(CCFLAGS=['-m64'])
env.Append(CCFLAGS=['-m32']) else:
env.Append(LINKFLAGS=['-m32'])
env.Append(CCFLAGS=['-m32'])
if GetOption('_64bit'): if GetOption('_64bit'):
env.Append(CPPDEFINES=["_64BIT"]) env.Append(CPPDEFINES=["_64BIT"])
if(GetOption('beta')): if(GetOption('beta')):
env.Append(CPPDEFINES='BETA') env.Append(CPPDEFINES='BETA')
if(GetOption('snapshot')): if(GetOption('snapshot')):
env.Append(CPPDEFINES=['SNAPSHOT_ID=' + GetOption('snapshot')]) env.Append(CPPDEFINES=['SNAPSHOT_ID=' + GetOption('snapshot')])
env.Append(CPPDEFINES='SNAPSHOT') env.Append(CPPDEFINES='SNAPSHOT')
else: else:
env.Append(CPPDEFINES=["SNAPSHOT_ID=" + str(int(time.time()))]) env.Append(CPPDEFINES=["SNAPSHOT_ID=" + str(int(time.time()))])
if(GetOption('save-version')): if(GetOption('save-version')):
env.Append(CPPDEFINES=['SAVE_VERSION=' + GetOption('major-version')]) env.Append(CPPDEFINES=['SAVE_VERSION=' + GetOption('major-version')])
if(GetOption('minor-version')): if(GetOption('minor-version')):
env.Append(CPPDEFINES=['MINOR_VERSION=' + GetOption('minor-version')]) env.Append(CPPDEFINES=['MINOR_VERSION=' + GetOption('minor-version')])
if(GetOption('release')): if(GetOption('release')):
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer', '-funsafe-loop-optimizations', '-Wunsafe-loop-optimizations']) env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer', '-funsafe-loop-optimizations', '-Wunsafe-loop-optimizations'])
if(GetOption('x86')): if(GetOption('x86')):
env.Append(CPPDEFINES='X86') env.Append(CPPDEFINES='X86')
if(GetOption('debug')): if(GetOption('debug')):
env.Append(CPPDEFINES='DEBUG') env.Append(CPPDEFINES='DEBUG')
env.Append(CCFLAGS='-g') env.Append(CCFLAGS='-g')
if(GetOption('sse')): if(GetOption('sse')):
env.Append(CCFLAGS='-msse') env.Append(CCFLAGS='-msse')
env.Append(CPPDEFINES='X86_SSE') env.Append(CPPDEFINES='X86_SSE')
if(GetOption('sse2')): if(GetOption('sse2')):
env.Append(CCFLAGS='-msse2') env.Append(CCFLAGS='-msse2')
env.Append(CPPDEFINES='X86_SSE2') env.Append(CPPDEFINES='X86_SSE2')
if(GetOption('sse3')): if(GetOption('sse3')):
env.Append(CCFLAGS='-msse3') env.Append(CCFLAGS='-msse3')
env.Append(CPPDEFINES='X86_SSE3') env.Append(CPPDEFINES='X86_SSE3')
if(GetOption('opengl')): if(GetOption('opengl')):
env.Append(CPPDEFINES=["OGLI", "PIX32OGL"]) env.Append(CPPDEFINES=["OGLI", "PIX32OGL"])
env.Append(LIBS=openGLLibs) env.Append(LIBS=openGLLibs)
if(GetOption('opengl') and GetOption('opengl-renderer')): if(GetOption('opengl') and GetOption('opengl-renderer')):
env.Append(CPPDEFINES=["OGLR"]) env.Append(CPPDEFINES=["OGLR"])
elif(GetOption('opengl-renderer')): elif(GetOption('opengl-renderer')):
print "opengl-renderer requires opengl" print "opengl-renderer requires opengl"
raise SystemExit(1) raise SystemExit(1)
sources=Glob("src/*.cpp") sources=Glob("src/*.cpp")
if(GetOption('win')): if(GetOption('win')):
sources += env.RES('resources/powder-res.rc') sources += env.RES('resources/powder-res.rc')
sources+=Glob("src/*/*.cpp") sources+=Glob("src/*/*.cpp")
sources+=Glob("src/simulation/elements/*.cpp") sources+=Glob("src/simulation/elements/*.cpp")
sources+=Glob("src/simulation/tools/*.cpp") sources+=Glob("src/simulation/tools/*.cpp")
@ -209,19 +211,19 @@ SetupSpawn(env)
programName = "powder" programName = "powder"
if(GetOption('win')): if(GetOption('win')):
programName = "Powder" programName = "Powder"
if(GetOption('_64bit')): if(GetOption('_64bit')):
programName += "64" programName += "64"
if(not (GetOption('sse2') or GetOption('sse3'))): if(not (GetOption('sse2') or GetOption('sse3'))):
programName += "-legacy" programName += "-legacy"
if(GetOption('macosx')): if(GetOption('macosx')):
programName += "-x" programName += "-x"
if(GetOption('win')): if(GetOption('win')):
programName += ".exe" programName += ".exe"
env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), "python generator.py elements $TARGETS $SOURCES") env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), "python generator.py elements $TARGETS $SOURCES")
env.Command(['generated/ToolClasses.cpp', 'generated/ToolClasses.h'], Glob('src/simulation/tools/*.cpp'), "python generator.py tools $TARGETS $SOURCES") env.Command(['generated/ToolClasses.cpp', 'generated/ToolClasses.h'], Glob('src/simulation/tools/*.cpp'), "python generator.py tools $TARGETS $SOURCES")
@ -230,5 +232,5 @@ Decider('MD5')
Default(t) Default(t)
#if(GetOption('release')): #if(GetOption('release')):
# StripExecutable(t); # StripExecutable(t);