add initial SConstruct file; no dist/install yet

This commit is contained in:
Josh Holtrop 2011-05-17 13:17:54 -04:00
parent 2257c664d6
commit 45ebca0650

79
SConstruct Normal file
View File

@ -0,0 +1,79 @@
# vim:filetype=python
import os
import re
from subprocess import *
target = 'anaglym'
DEBUG = False
if 'install_dir' in os.environ:
install_dir = os.environ['install_dir']
else:
install_dir = os.environ['HOME'] + '/local/' + target
if os.sep == '\\':
platform = 'PLATFORM_WINDOWS'
else:
platform = 'PLATFORM_LINUX'
subdirs = ['WFObj', 'PhyObj', 'TextureCache', 'OdeWorld']
env = Environment()
env.ParseConfig('pkg-config --cflags --libs lua5.1')
env.ParseConfig('pkg-config --cflags --libs ftgl')
env.ParseConfig('sdl-config --cflags --libs')
env.ParseConfig('ode-config --cflags --libs')
env.ParseConfig('smpeg-config --libs')
if platform == 'PLATFORM_WINDOWS':
env.Append(LIBS = ['opengl32', 'glu32', 'mingw32'])
if platform == 'PLATFORM_LINUX':
env.Append(LIBS = ['GL', 'GLU'])
env.Append(CPPFLAGS = ['-D'+platform, '-I.'])
env.Append(LIBS = ['SDL_image', 'SDL_sound', 'vorbisfile'])
cflags = ['-O2', '-Wall']
if DEBUG:
cflags += ['-g']
env.Append(CFLAGS = cflags, CXXFLAGS = cflags)
sources = [Glob('*.cc')]
if not os.path.exists('ag_lua.cc'):
sources.append('ag_lua.cc')
if not os.path.exists('sdl_keymap.cc'):
sources.append('sdl_keymap.cc')
for sd in subdirs:
sources += [Glob(sd + '/*.c'), Glob(sd + '/*.cc')]
def F2C(target, source, env):
f = open(str(target[0]), 'w')
for s in source:
c_name = re.sub(r'\W', '_', str(s))
f.write('unsigned char %s[] = {' % c_name)
src = open(str(s), 'r')
s_len = 0
while 1:
if s_len % 12 == 0:
f.write('\n ')
ch = src.read(1)
if len(ch) < 1:
break
s_len += 1
f.write('0x%02x, ' % ord(ch))
f.write('0x00\n')
src.close()
f.write('};\n')
f.write('unsigned int %s_len = %d;\n' % (c_name, s_len))
f.close()
return None
def SDLKeymap(target, source, env):
Popen(['perl', str(source[0])]).wait()
env.Append(BUILDERS = {'SDLKeymap' : Builder(action = SDLKeymap)})
env.Append(BUILDERS = {'F2C' : Builder(action = F2C)})
env.F2C('ag_lua.cc', 'ag.lua')
env.SDLKeymap('sdl_keymap.cc', 'gen-sdl-keymap.pl')
env.Program(target, sources)