bksys - proposal for optimising the unix debug option behavior

Ralf Habacker ralf.habacker at freenet.de
Tue Oct 4 21:36:05 BST 2005


Hi, 
while implementing some win32 related stuff for bksys I found some 
problems in the unix related implementation of the debug option. 

The original 
	if env['ARGS'].get('debug', None):
		env['BKS_DEBUG'] = env['ARGS'].get('debug', None)
		env.pprint('CYAN','** Enabling debug for the project **')
		env['GENCXXFLAGS'] = ['-g']
	else:
		if os.environ.has_key('CXXFLAGS'):
			# user-defined flags (gentooers will be elighted)
			env['GENCXXFLAGS'] = 
SCons.Util.CLVar( os.environ['CXXFLAGS'] )+['-DNDEBUG', '-DNO_DEBUG']
		else:
			env['GENCXXFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG']

- sets only the -g flag for compiling c++ files not for compiling c files and 
linking, which is  required to get debug informations in shared libraries or 
applications (at least under win32 gcc )

- does not allow setting additional c++/c/linker  flags if using the debug 
option. 

The implementation below fixes this problem. 

	if env['ARGS'].get('debug', None):
		env['BKS_DEBUG'] = env['ARGS'].get('debug', None)
		env.pprint('CYAN','** Enabling debug for the project **')
		env['GENCXXFLAGS'] = ['-g']
		env['GENCCFLAGS'] = ['-g']
		env['GENLINKFLAGS'] = ['-g']
	else:
		env['GENCXXFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG']
		env['GENCCFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG']
		env['GENLINKFLAGS'] = []
	
	if os.environ.has_key('CXXFLAGS'):  env['GENCXXFLAGS']  += 
SCons.Util.CLVar( os.environ['CXXFLAGS'] )
	if os.environ.has_key('CFLAGS'): env['GENCCFLAGS'] = 
SCons.Util.CLVar( os.environ['CFLAGS'] )
	if os.environ.has_key('LINKFLAGS'): env['GENLINKFLAGS'] += 
SCons.Util.CLVar( os.environ['LINKFLAGS'] )
	# for make compatibility 
	if os.environ.has_key('LDFLAGS'):   env['GENLINKFLAGS'] += 
SCons.Util.CLVar( os.environ['LDFLAGS'] )

As I may oversee some issues for linux I like to ask is there may be any 
problems applying this for unix ? 

Ralf 


svn diff -r 467242:467248 win32/detect_generic.py
Index: win32/detect_generic.py
===================================================================
--- win32/detect_generic.py   (revision 467242)
+++ win32/detect_generic.py   (revision 467248)
@@ -3,18 +3,23 @@
 def detect(env):
        import os, sys
        import SCons.Util
+
        if env['ARGS'].get('debug', None):
                env['BKS_DEBUG'] = env['ARGS'].get('debug', None)
                env.pprint('CYAN','** Enabling debug for the project **')
                env['GENCXXFLAGS'] = ['-g']
+               env['GENCCFLAGS'] = ['-g']
+               env['GENLINKFLAGS'] = ['-g']
        else:
-               if os.environ.has_key('CXXFLAGS'):
-                       # user-defined flags (gentooers will be elighted)
-                       env['GENCXXFLAGS'] = 
SCons.Util.CLVar( os.environ['CXXFLAGS'] )+['-DNDEBUG', '-DNO_DEBUG']
-               else:
-                       env['GENCXXFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG']
-
+               env['GENCXXFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG']
+               env['GENCCFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG']
+               env['GENLINKFLAGS'] = []
+
+       if os.environ.has_key('CXXFLAGS'):  env['GENCXXFLAGS']  += 
SCons.Util.CLVar( os.environ['CXXFLAGS'] )
        if os.environ.has_key('CFLAGS'): env['GENCCFLAGS'] = 
SCons.Util.CLVar( os.environ['CFLAGS'] )
+       if os.environ.has_key('LINKFLAGS'): env['GENLINKFLAGS'] += 
SCons.Util.CLVar( os.environ['LINKFLAGS'] )
+       # for make compatibility
+       if os.environ.has_key('LDFLAGS'):   env['GENLINKFLAGS'] += 
SCons.Util.CLVar( os.environ['LDFLAGS'] )

        # User-specified prefix
        if env['ARGS'].has_key('prefix'):





More information about the kde-core-devel mailing list