3 # TTimo <ttimo@idsoftware.com>
4 # http://scons.sourceforge.net
6 # various GL-related code:
7 # GL logging functions (used on all platforms)
8 # GLimp code (Linux only)
9 # The C code is generated using M4 macros from a description of the GL API
10 # on win32, the logging functions are generated ones and kept in the source
11 # on other platforms, scons generates on the fly at build time
17 # NOTE: make sure the .api files are in LF line endings, CRLF isn't working so well
18 def build_logfuncs(env, target, source):
20 # search for the module - source repository might make things harder
21 gllog_path = 'sys/gllog'
22 if ( not os.path.exists( gllog_path + '/logfunc.py' ) ):
23 gllog_path = '/var/local/Doom/neo/sys/gllog'
24 sys.path.append( gllog_path )
25 from logfunc import do_logfunc
26 f_out = open('%s' % target[0], 'w')
27 f_out.write('// generated file, do not modify!\n')
28 f_out.write('// ' + time.asctime() + '\n')
29 f_out.write('// see SConscript.gl and sys/gllog/\n\n')
31 f_in = open( gllog_path + '/gl.api', 'r')
32 do_logfunc(f_in, f_out)
35 f_out.write('\n#ifdef __linux__\n\n')
36 f_in = open( gllog_path + '/glX.api', 'r')
37 do_logfunc(f_in, f_out)
39 f_out.write('\n#endif\n\n')
41 f_out.write('\n#ifdef WIN32\n\n')
42 f_in = open( gllog_path + '/wgl.api', 'r')
43 do_logfunc(f_in, f_out)
45 f_out.write('\n#endif\n\n')
49 print 'Generated %s' % target[0]
51 gl_env = g_env.Clone()
52 gl_env.Append( CPPPATH = '#' )
53 gl_env.Append( CPPFLAGS = '-DGLIMP' )
55 if ( local_dedicated == 1 ):
56 gl_env.Append( CPPFLAGS = '-DID_DEDICATED' )
58 # general M4 builder setup
59 # files we are going to generate from their M4 counterparts
62 '../gllog/gl_extensions.cpp',
63 '../linux/glimp_dlopen.cpp',
64 '../linux/glimp_logging.cpp',
65 '../linux/glimp_stub.cpp',
66 '../linux/glimp_local.h' )
69 gl_env.M4( i_m4, i_m4 + '.m4' )
70 gl_env.Depends( i_m4, '../gllog/gl_def.m4' )
72 # enable if you need to generate again
73 # FIXME: conflicts when several environements are used. move that to seperate script
74 #enforce = gl_env.M4( '#sys/linux/qgl_enforce.h', '../linux/qgl_enforce.h.m4' )
75 #gl_env.Depends( enforce, '../gllog/gl_def.m4' )
77 # logging functions, python generated ( that's beyond my m4-fu )
79 gl_env.Depends( '../linux/glimp_logging.cpp', '../linux/glimp_logfuncs.cpp' )
81 logfuncs = gl_env.Command( '../linux/glimp_logfuncs.cpp', '../gllog/logfunc.py', build_logfuncs )
82 gl_env.Depends( logfuncs, '../gllog/gl_def.m4' )
85 sources.append( '../gllog/gl_extensions.cpp' )
87 if ( local_dedicated == 1 ):
88 sources.append( '../linux/glimp_stub.cpp' )
90 sources.append( '../linux/glimp_dlopen.cpp' )
91 sources.append( '../linux/glimp_logging.cpp' )
93 #if ( DEDICATED != '0' ):
94 # sources.append( '../linux/glimp_stub.cpp' )
96 #if ( GL_HARDLINK == '0' ):
97 # sources.append( '../linux/glimp_dlopen.cpp' )
98 # sources.append( '../linux/glimp_logging.cpp' )
100 lib = gl_env.StaticLibrary( 'glimp', sources )
101 #gl_env.Install( '../..', lib )