apply 2to3 conversions via patches rather than running during build

This commit is contained in:
sthen
2025-02-18 22:30:15 +00:00
parent 7cd6749e81
commit 31e5083865
4 changed files with 183 additions and 28 deletions
-3
View File
@@ -36,9 +36,6 @@ NO_TEST= Yes
DATA_DIR= campaigns graphics intro languages maps patches \
scripts sounds units
pre-patch:
2to3 -w ${WRKSRC}/SConstruct
# the shipped images are considered broken by newer libpng: use opting
# to fix them
pre-configure:
+51 -5
View File
@@ -1,3 +1,5 @@
2to3 and additional fixes
Index: SConstruct
--- SConstruct.orig
+++ SConstruct
@@ -27,6 +29,15 @@ Index: SConstruct
Help(opts.GenerateHelpText(env))
mingw = env.Clone()
optionsChanged = True
@@ -122,7 +125,7 @@ def ParseConfig(env, command, function=None):
flags['LINKFLAGS'].append(arg)
else:
flags['CCFLAGS'].append(arg)
- apply(env.Append, (), flags)
+ env.Append(*(), **flags)
return static_libs
if function is None:
@@ -144,6 +147,10 @@ def CheckOpenGL(env, conf):
'LIBS': ['GL'],
'LIBPATH': ['/usr/lib', '/usr/X11R6/lib'],
@@ -67,15 +78,16 @@ Index: SConstruct
return 0
# make sure we have lualib which is included in lua 5.1
if conf.CheckFunc('luaopen_base'):
@@ -189,13 +193,13 @@ def AutoConfigure(env):
@@ -189,30 +193,30 @@ def AutoConfigure(env):
conf = Configure(env)
## check for required libs ##
- if not conf.CheckLibWithHeader('png', 'png.h', 'c'):
- print('Did not find png library or headers, exiting!')
- print 'Did not find png library or headers, exiting!'
- Exit(1)
if not conf.CheckLibWithHeader('z', 'zlib.h', 'c'):
print('Did not find the zlib library or headers, exiting!')
- print 'Did not find the zlib library or headers, exiting!'
+ print('Did not find the zlib library or headers, exiting!')
Exit(1)
- if not 'USE_WIN32' in env['CPPDEFINES'] and not sys.platform.startswith('freebsd'):
+ if not conf.CheckLibWithHeader('png', 'png.h', 'c'):
@@ -83,9 +95,16 @@ Index: SConstruct
+ Exit(1)
+ if not 'USE_WIN32' in env['CPPDEFINES'] and not sys.platform.startswith('openbsd'):
if not conf.CheckLib('dl'):
print('Did not find dl library or header which is needed on some systems for lua. Exiting!')
- print 'Did not find dl library or header which is needed on some systems for lua. Exiting!'
+ print('Did not find dl library or header which is needed on some systems for lua. Exiting!')
Exit(1)
@@ -207,12 +211,12 @@ def AutoConfigure(env):
if not CheckLuaLib(env, conf):
- print 'Did not find required lua library. Exiting!'
+ print('Did not find required lua library. Exiting!')
Exit(1)
if not CheckOpenGL(env, conf):
- print 'Did not find required OpenGL library. Exiting!'
+ print('Did not find required OpenGL library. Exiting!')
Exit(1)
# Check for optional libraries #
@@ -100,6 +119,33 @@ Index: SConstruct
# check for optional functions
if conf.CheckFunc('strcasestr'):
@@ -232,7 +236,7 @@ def AutoConfigure(env):
env.ParseConfig('sdl-config --libs')
if sys.platform != "darwin" and not '-Dmain=SDL_main' in env['CCFLAGS']:
if not conf.CheckLibWithHeader('SDL', 'SDL.h', 'c'):
- print 'Did not find SDL library or headers, exiting!'
+ print('Did not find SDL library or headers, exiting!')
Exit(1)
env = conf.Finish()
@@ -245,14 +249,14 @@ def AutoConfigureIfNeeded(env, name):
# Remove outdated cache file
os.remove(cachename)
if optionsChanged or not os.path.exists(cachename):
- print cachename + " doesn't exist or out of date."
- print "Generating new build config cache ..."
+ print(cachename + " doesn't exist or out of date.")
+ print("Generating new build config cache ...")
cache = DefineOptions(cachename, {})
AutoConfigure(env)
cache.Save(cachename, env)
else:
cache = DefineOptions(cachename, {})
- print "Using " + cachename
+ print("Using " + cachename)
cache.Update(env)
AutoConfigureIfNeeded(env, '')
@@ -265,7 +269,7 @@ addBosWarsPaths(env)
# define the different build environments (variants)
-3
View File
@@ -44,9 +44,6 @@ MODSCONS_FLAGS = debug=1 \
datadir=${TRUEPREFIX}/share/dangerdeep \
installbindir=${PREFIX}/bin
pre-patch:
2to3 -w ${WRKSRC}/SConstruct
pre-configure:
${SUBST_CMD} ${WRKSRC}/SConstruct
+132 -17
View File
@@ -1,7 +1,27 @@
2to3 and additional fixes
Index: SConstruct
--- SConstruct.orig
+++ SConstruct
@@ -79,9 +79,9 @@ elif sys.platform == 'darwin':
@@ -49,7 +49,7 @@ if (env.GetOption('clean') or conf == '0'):
if sys.platform == 'win32':
checkconf = False
- print "Compiling for Win32 Environment"
+ print("Compiling for Win32 Environment")
env = Environment(ENV = os.environ)
env.Append(CPPDEFINES = ['WIN32','NOMINMAX','DEBUG'])
@@ -68,7 +68,7 @@ if sys.platform == 'win32':
build_dir = 'win32'
elif sys.platform == 'darwin':
- print "Compiling for MacOSX"
+ print("Compiling for MacOSX")
env = Environment(ENV = os.environ)
env.Append(CPPPATH = ['/System/Library/Frameworks/AGL.framework/Headers', '/System/Library/Frameworks/OpenGL.framework/Headers','/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/include' , './Mac'])
libpath = ['/System/Library/Frameworks/OpenGL.framework/Libraries', '/usr/local/lib', '/usr/lib']
@@ -79,11 +79,11 @@ elif sys.platform == 'darwin':
datadir = './data' # use slashes as separator always. C/C++ want it so.
build_dir = 'macosx'
osspecificsrc = Split("""Mac/SDLMain.m""")
@@ -12,9 +32,12 @@ Index: SConstruct
+ env.Append(CCFLAGS = '-g')
+ env.Append(CPPDEFINES = ['DEBUG'])
elif (sys.platform == 'freebsd5') or (sys.platform == 'freebsd6') or (sys.platform == 'freebsd7'):
print("Compiling for FreeBSD Environment")
- print "Compiling for FreeBSD Environment"
+ print("Compiling for FreeBSD Environment")
env = Environment(ENV = os.environ)
@@ -99,43 +99,43 @@ elif (sys.platform == 'freebsd5') or (sys.platform ==
LOCALBASE = os.environ['LOCALBASE']
X11BASE = os.environ['X11BASE']
@@ -99,45 +99,45 @@ elif (sys.platform == 'freebsd5') or (sys.platform ==
cpuinfol = cpuinfof.readlines()
mmxsupported = False
ssesupported = False
@@ -31,7 +54,7 @@ Index: SConstruct
env.Append(CCFLAGS = '-msse')
- env.Append(CPPDEFINES = ['USE_SSE'])
- osspecificsrc += []
- print('Using x86 SSE/MMX optimizations.')
- print 'Using x86 SSE/MMX optimizations.'
+ env.Append(CPPDEFINES = ['USE_SSE'])
+ osspecificsrc += []
+ print('Using x86 SSE/MMX optimizations.')
@@ -58,8 +81,14 @@ Index: SConstruct
- gllibdir = i
- break
- if (gllibdir == ''):
- print('ERROR: no libGL.so detected!')
- print 'ERROR: no libGL.so detected!'
- else:
- print 'Found GL library "'+gllibdir+'libGL.so"'
- if (os.system('grep glBindProgram '+gllibdir+'libGL.so > /dev/null') != 0):
- print 'GL headers declare glBindProgram, but libGL.so has no such symbol! Ignoring all undefined symbols...'
- # I'm not sure which option will hopefully fix the problem... so i use both...
- env.Append(LINKFLAGS = '--unresolved-symbols=ignore-all')
- env.Append(LINKFLAGS = '-Xlinker --unresolved-symbols -Xlinker ignore-all')
+ if (checkconf == True and os.system('grep glBindProgram ' + X11BASE + '/include/GL/gl*.h > /dev/null') == 0):
+ gllibdirs = [X11BASE + '/lib/', '/usr/lib/', LOCALBASE + '/lib/']
+ gllibdir = ''
@@ -70,20 +99,46 @@ Index: SConstruct
+ if (gllibdir == ''):
+ print('ERROR: no libGL.so detected!')
+ else:
print('Found GL library "'+gllibdir+'libGL.so"')
- if (os.system('grep glBindProgram '+gllibdir+'libGL.so > /dev/null') != 0):
- print('GL headers declare glBindProgram, but libGL.so has no such symbol! Ignoring all undefined symbols...')
- # I'm not sure which option will hopefully fix the problem... so i use both...
- env.Append(LINKFLAGS = '--unresolved-symbols=ignore-all')
- env.Append(LINKFLAGS = '-Xlinker --unresolved-symbols -Xlinker ignore-all')
+ print('Found GL library "'+gllibdir+'libGL.so"')
+ if (os.system('grep glBindProgram '+gllibdir+'libGL.so > /dev/null') != 0):
+ print('GL headers declare glBindProgram, but libGL.so has no such symbol! Ignoring all undefined symbols...')
+ # I'm not sure which option will hopefully fix the problem... so i use both...
+ env.Append(LINKFLAGS = '--unresolved-symbols=ignore-all')
+ env.Append(LINKFLAGS = '-Xlinker --unresolved-symbols -Xlinker ignore-all')
elif 0 != mingw32:
print("Compiling for mingw32 Environment")
- print "Compiling for mingw32 Environment"
+ print("Compiling for mingw32 Environment")
env = Environment(ENV = os.environ, tools = ['mingw'])
env.Append(CPPPATH = [ mingw32root + '/usr/include/', mingw32root + '/usr/include/GL/', mingw32root + '/usr/include/SDL/' ] )
@@ -171,12 +171,12 @@ elif 0 != mingw32:
osspecificsrc += []
env.Append(CCFLAGS = '-msse')
env.Append(CPPDEFINES = ['USE_SSE'])
- print 'Using x86 SSE/MMX optimizations with GCC intrinsics.'
+ print('Using x86 SSE/MMX optimizations with GCC intrinsics.')
datadir = './data' # use slashes as separator always. C/C++ want it so.
build_dir = 'mingw32'
else:
SConsignFile()
- print "Compiling for GNU/Linux Environment (" + sys.platform + ")"
+ print("Compiling for GNU/Linux Environment (" + sys.platform + ")")
env = Environment(ENV = os.environ)
env.Append(CPPPATH = ['/usr/include/SDL', '/usr/include/GL'])
@@ -192,10 +192,10 @@ else:
# allow arch to be over-ridden if need be.
if archflag != '':
- print 'Using architecture: ' + archflag + ' (Changed from ' + arch + ')'
+ print('Using architecture: ' + archflag + ' (Changed from ' + arch + ')')
arch = archflag
else:
- print 'Using architecture: ' + arch
+ print('Using architecture: ' + arch)
# Set libpath accordingly
if arch == 'x86_64':
@@ -207,8 +207,6 @@ else:
# Set libpath for real
libpath = [archlib, archlib + '/X11', '/usr/X11R6/lib']
@@ -101,7 +156,28 @@ Index: SConstruct
env.Append(CPPDEFINES = ['DEBUG'])
elif (debug == -1):
ccflags += ' -g -O3 -mfpmath=sse -mmmx -msse -m3dnow'
@@ -258,18 +255,18 @@ else:
@@ -239,10 +236,10 @@ else:
if (useefence >= 1):
extralibs += ['efence']
- print 'Linking to ElectricFence library!'
+ print('Linking to ElectricFence library!')
elif (useduma >= 1):
extralibs += ['duma']
- print 'Linking to DUMA (EletricFence successor) library!'
+ print('Linking to DUMA (EletricFence successor) library!')
if (cvedit == 1):
env.Append(CPPDEFINES = ['CVEDIT'])
@@ -252,25 +249,25 @@ else:
osspecificsrc += []
if (usex86sse >= 2):
env.Append(CPPDEFINES = ['USE_SSE_ALWAYS'])
- print 'Using x86 SSE/MMX optimizations with GCC intrinsics ALWAYS WITHOUT DETECTION!'
+ print('Using x86 SSE/MMX optimizations with GCC intrinsics ALWAYS WITHOUT DETECTION!')
else:
- print 'Using x86 SSE/MMX optimizations with GCC intrinsics.'
+ print('Using x86 SSE/MMX optimizations with GCC intrinsics.')
env.Append(CCFLAGS = ccflags)
# check for broken libGL, ignore undefined symbols then
@@ -115,15 +191,28 @@ Index: SConstruct
gllibdir = i
break
if (gllibdir == ''):
print('ERROR: no libGL.so detected!')
- print 'ERROR: no libGL.so detected!'
+ print('ERROR: no libGL.so detected!')
else:
print('Found GL library "'+gllibdir+'libGL.so"')
- print 'Found GL library "'+gllibdir+'libGL.so"'
- if (os.system('grep glBindProgram '+gllibdir+'libGL.so > /dev/null') != 0):
- print 'GL headers declare glBindProgram, but libGL.so has no such symbol! Ignoring all undefined symbols...'
+ print('Found GL library "'+gllibdir+'libGL.so"')
+ if (os.system('grep glBindProgram '+gllibdir+'libGL.so* > /dev/null') != 0):
print('GL headers declare glBindProgram, but libGL.so has no such symbol! Ignoring all undefined symbols...')
+ print('GL headers declare glBindProgram, but libGL.so has no such symbol! Ignoring all undefined symbols...')
# I'm not sure which option will hopefully fix the problem... so i use both...
env.Append(LINKFLAGS = '--unresolved-symbols=ignore-all')
@@ -289,6 +286,12 @@ target_dir = '#build' + os.sep + build_dir
env.Append(LINKFLAGS = '-Xlinker --unresolved-symbols -Xlinker ignore-all')
@@ -282,13 +279,19 @@ installbindir = '/usr/local/bin'
if ARGUMENTS.get('installbindir', 0):
installbindir = ARGUMENTS.get('installbindir', 0)
-print 'Install binary path: ' + installbindir
-print 'Using data dir: ' + datadir
+print('Install binary path: ' + installbindir)
+print('Using data dir: ' + datadir)
target_dir = '#build' + os.sep + build_dir
source_base_dir = 'src'
libpath = libpath + [target_dir]
env.Append(LIBPATH = libpath)
@@ -136,6 +225,32 @@ Index: SConstruct
################ configure
if(checkconf == True):
@@ -297,20 +300,20 @@ if(checkconf == True):
if (devel == 0):
for i in ['GL', 'GLU', 'SDL', 'SDL_image', 'SDL_mixer', 'fftw3', 'bz2']:
if not conf.CheckLib(i):
- print 'Library ' + i + ' is missing, it must be installed!'
+ print('Library ' + i + ' is missing, it must be installed!')
Exit(1)
for i in ['gl.h', 'glu.h', 'SDL.h', 'SDL_image.h', 'SDL_mixer.h', 'fftw3.h', 'bzlib.h']:
if not conf.CheckHeader(i):
- print 'Include file ' + i + ' is missing, install matching development library!'
+ print('Include file ' + i + ' is missing, install matching development library!')
Exit(1)
if conf.CheckLibWithHeader('fftw3f', 'fftw3.h', 'C'):
- print 'fftw3 library supports float type. Using it...'
+ print('fftw3 library supports float type. Using it...')
fftwlib = 'fftw3f'
conf.env.Append(CPPDEFINES = ['WITH_FLOAT_FFTW'])
else:
- print 'fftw3 library does not support float type.'
+ print('fftw3 library does not support float type.')
if conf.CheckLibWithHeader('avutil', 'ffmpeg/libavutil/avutil.h', 'C'):
- print 'libavutil found...'
+ print('libavutil found...')
ffmpeg_available = True
else:
fftwlib = 'fftw3f'
@@ -347,7 +350,7 @@ Export('env', 'gfxlibs', 'alllibs', 'installbindir', '
SConscript(source_base_dir + os.sep + 'SConscript', build_dir = target_dir, duplicate = 0)