Simplify scons stuff:
- instead of doing Import() and Export() for subdirs, just Return() the files in the subdirectories' SConscripts and add that to the top-level file list - remove the manual handling of sdl-config output, as scons will do it for us - remove the manual addition of libz to LIBS, as scons seems to automatically do it if you do a CheckLib() - properly read and use $CC, $CFLAGS, and $LDFLAGS environment variables, if they exist
This commit is contained in:
parent
0474a05ac3
commit
ebab58016c
32
SConstruct
32
SConstruct
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
|
||||
# XXX path separator fixed right now
|
||||
opts = Options()
|
||||
opts.Add('PSS_STYLE', 'Path separator style', 1)
|
||||
|
@ -7,34 +9,38 @@ env = Environment(options = opts,
|
|||
CPPDEFINES={'PSS_STYLE' : '${PSS_STYLE}',
|
||||
'LSB_FIRST' : '${LSB_FIRST}'})
|
||||
|
||||
#bring in environment CCFLAGS and LINKFLAGS
|
||||
import os
|
||||
if os.environ.has_key('CCFLAGS'):
|
||||
env['CCFLAGS'] = os.environ['CCFLAGS'];
|
||||
if os.environ.has_key('LINKFLAGS'):
|
||||
env['LINKFLAGS'] = os.environ['LINKFLAGS'];
|
||||
if os.environ.has_key('CC'):
|
||||
env.Replace(CC = os.environ['CC'])
|
||||
if os.environ.has_key('CFLAGS'):
|
||||
env.Append(CCFLAGS = os.environ['CFLAGS'])
|
||||
if os.environ.has_key('LDFLAGS'):
|
||||
env.Append(LINKFLAGS = os.environ['LDFLAGS'])
|
||||
|
||||
print "platform: ", env['PLATFORM']
|
||||
|
||||
# special flags for cygwin
|
||||
#we have to do this here so that the function and lib checks will go through mingw
|
||||
# we have to do this here so that the function and lib checks will go through
|
||||
# mingw
|
||||
if env['PLATFORM'] == 'cygwin':
|
||||
env['CCFLAGS'] += "-mno-cygwin";
|
||||
env['LINKFLAGS'] += "-mno-cygwin";
|
||||
env.Append(CCFLAGS = " -mno-cygwin")
|
||||
env.Append(LINKFLAGS = " -mno-cygwin")
|
||||
env['LIBS'] = ['ddraw','dinput','dsound','gdi32','dxguid','winmm','shell32','wsock32','comdlg32','ole32'];
|
||||
|
||||
conf = Configure(env)
|
||||
if not conf.CheckLib('SDL'):
|
||||
print 'Did not find libSDL.a or SDL.lib, exiting!'
|
||||
print 'Did not find libSDL or SDL.lib, exiting!'
|
||||
Exit(1)
|
||||
if not conf.CheckLib('z'):
|
||||
print 'Did not find libz.a or z.lib, exiting!'
|
||||
print 'Did not find libz or z.lib, exiting!'
|
||||
Exit(1)
|
||||
if conf.CheckFunc('asprintf'):
|
||||
conf.env['CCFLAGS'] += " -DHAVE_ASPRINTF";
|
||||
|
||||
conf.env.Append(CCFLAGS = " -DHAVE_ASPRINTF")
|
||||
|
||||
env = conf.Finish()
|
||||
|
||||
# parse SDL cflags/libs
|
||||
env.ParseConfig('sdl-config --cflags --libs')
|
||||
|
||||
Export('env')
|
||||
|
||||
SConscript(['src/SConscript'])
|
||||
|
|
|
@ -28,51 +28,21 @@ x6502.cpp
|
|||
movie.cpp
|
||||
unzip.c""")
|
||||
|
||||
Export('file_list')
|
||||
subdirs = Split("""
|
||||
boards
|
||||
drivers/common
|
||||
drivers/sdl
|
||||
fir
|
||||
input
|
||||
mappers""")
|
||||
#palettes
|
||||
|
||||
SConscript(Split("""
|
||||
boards/SConscript
|
||||
input/SConscript
|
||||
fir/SConscript
|
||||
mappers/SConscript
|
||||
drivers/common/SConscript
|
||||
drivers/sdl/SConscript
|
||||
"""))
|
||||
#palettes/SConscript
|
||||
Import('file_list')
|
||||
for dir in subdirs:
|
||||
subdir_files = SConscript('%s/SConscript' % dir)
|
||||
file_list.append(subdir_files)
|
||||
|
||||
Import('env')
|
||||
|
||||
# use sdl-config to get the cflags and libpath
|
||||
import os;
|
||||
sdl_cflags_pipe = os.popen("sdl-config --cflags");
|
||||
sdl_cflags = sdl_cflags_pipe.read();
|
||||
sdl_cflags = sdl_cflags.rstrip(os.linesep);
|
||||
sdl_cflags_pipe.close();
|
||||
|
||||
sdl_libpath = [];
|
||||
sdl_libs = [];
|
||||
|
||||
sdl_libflags_pipe = os.popen("sdl-config --libs");
|
||||
sdl_libflags = sdl_libflags_pipe.read();
|
||||
for flag in sdl_libflags.split(' '):
|
||||
if flag.find("-L") == 0:
|
||||
sdl_libpath.append(flag.strip("-L"));
|
||||
elif flag.find("-l") == 0:
|
||||
sdl_libs.append(flag.strip("-l"));
|
||||
else:
|
||||
print "extra link flag: ", flag;
|
||||
env['LINKFLAGS'] += " " + flag;
|
||||
|
||||
sdl_libflags_pipe.close();
|
||||
|
||||
# add zlib and sdl libs
|
||||
env['LIBS'].append('z');
|
||||
env['LIBS'].extend(sdl_libs);
|
||||
|
||||
# include sdl cflags
|
||||
env['CCFLAGS'] += " " + sdl_cflags;
|
||||
|
||||
print env['LINKFLAGS']
|
||||
|
||||
env.Program('fceu', file_list, LIBPATH=sdl_libpath)
|
||||
env.Program('fceu', file_list)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
Import('file_list')
|
||||
my_list = Split("""
|
||||
01-222.cpp
|
||||
112.cpp
|
||||
|
@ -54,8 +53,7 @@ supervision.cpp
|
|||
t-262.cpp
|
||||
tengen.cpp
|
||||
""")
|
||||
|
||||
for x in range(len(my_list)):
|
||||
my_list[x] = 'boards/' + my_list[x]
|
||||
file_list = my_list + file_list
|
||||
|
||||
Export('file_list')
|
||||
Return('my_list')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
Import('file_list')
|
||||
my_list = Split("""
|
||||
args.cpp
|
||||
cheat.cpp
|
||||
|
@ -10,7 +9,7 @@ scale3x.cpp
|
|||
scalebit.cpp
|
||||
vidblit.cpp
|
||||
""")
|
||||
|
||||
for x in range(len(my_list)):
|
||||
my_list[x] = 'drivers/common/' + my_list[x]
|
||||
file_list = my_list + file_list
|
||||
Export('file_list')
|
||||
Return('my_list')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
Import('file_list')
|
||||
my_list = Split("""
|
||||
input.cpp
|
||||
main.cpp
|
||||
|
@ -14,8 +13,6 @@ unix-netplay.cpp
|
|||
#sdl-opengl.cpp
|
||||
#sdl-opengl.h
|
||||
|
||||
|
||||
for x in range(len(my_list)):
|
||||
my_list[x] = 'drivers/sdl/' + my_list[x]
|
||||
file_list = my_list + file_list
|
||||
Export('file_list')
|
||||
Return('my_list')
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
Import('file_list')
|
||||
my_list = Split("""
|
||||
""")
|
||||
|
||||
for x in range(len(my_list)):
|
||||
my_list[x] = 'fir/' + my_list[x]
|
||||
file_list = my_list + file_list
|
||||
Export('file_list')
|
||||
Return('my_list')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
Import('file_list')
|
||||
my_list = Split("""
|
||||
arkanoid.cpp
|
||||
bworld.cpp
|
||||
|
@ -16,7 +15,7 @@ suborkb.cpp
|
|||
toprider.cpp
|
||||
zapper.cpp
|
||||
""")
|
||||
|
||||
for x in range(len(my_list)):
|
||||
my_list[x] = 'input/' + my_list[x]
|
||||
file_list = my_list + file_list
|
||||
Export('file_list')
|
||||
Return('my_list')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
Import('file_list')
|
||||
my_list = Split("""
|
||||
151.cpp
|
||||
15.cpp
|
||||
|
@ -77,7 +76,7 @@ emu2413.c
|
|||
mmc2and4.cpp
|
||||
simple.cpp
|
||||
""")
|
||||
|
||||
for x in range(len(my_list)):
|
||||
my_list[x] = 'mappers/' + my_list[x]
|
||||
file_list = my_list + file_list
|
||||
Export('file_list')
|
||||
Return('my_list')
|
||||
|
|
Loading…
Reference in New Issue