07-12-2007, 02:18 PM,
|
|
bugsyv
Junior Member
 
|
Posts: 46
Threads: 6
Joined: May 2007
|
|
Mac fixes for scons build
Hi guys... the scons build for mac wasn't quite right. I have made some changes so that it will compile and run ( on my machine at least ).
I would like to note that these changes don't create a universal binary and the packaging targets don't create a nice and mac-like dmg, but since I had so much merging to do after the svn servers came back up, I would like to go ahead and get this committed before I go any further.
Hopefully, in the future, this will do whatever the xcode project does without the maintenance overhead of keeping it in sync.
Also, I don't have a linux or windows development machine to test against, so if I broke something there feel free to fix it, and I will retest on my machine. If you could log the need for the fix, that will help
Thanks.
Patch against 1756
Code: Index: include/settings.h
===================================================================
--- include/settings.h (revision 1765)
+++ include/settings.h (working copy)
@@ -4,6 +4,10 @@
#include "configfile.h"
#include "definitions.h"
+#ifdef _DEFINE_OSX_HELPERS
+char* get_mac_data_dir();
+#endif
+
using namespace std;
class VIDEOMODES
Index: src/SConscript
===================================================================
--- src/SConscript (revision 1765)
+++ src/SConscript (working copy)
@@ -65,12 +65,43 @@
#--------------------------#
# Modify Build Environment #
#--------------------------#
-if sys.platform != 'win32':
+appdir = ""
+common_libs = ['SDL_image', 'SDL_net', 'SDL_gfx', 'ode']
+if ( 'darwin' == env['PLATFORM'] ):
+ pkgbase = "${PRODUCT_NAME}.app/Contents"
+ appdir = "%s/MacOS/" % pkgbase
+ pkgsrc = "../tools/osx"
+
+ common_libs.append( 'SDL' )
+ common_libs.append( 'GLExtensionWrangler' )
+ def batch_copy( target, source, env):
+ for tgt, src in zip( target, source ):
+ env.Execute( Copy( str( tgt ), str( src ) ) )
+
+ def build_list( template, items ):
+ return [ template % x for x in items ]
+
+ Alias( 'vdrift', [
+ local_env.ProcessTemplate(
+ '%s/Info.plist' % pkgbase,
+ '%s/Info.plist' % pkgsrc ),
+ local_env.Command(
+ '%s/Resources/${PRODUCT_NAME}.icns' % pkgbase,
+ '%s/vdrift.icns' % pkgsrc,
+ Copy( '$TARGET', '$SOURCE') ),
+ local_env.Command(
+ build_list( '%s/Frameworks/%%s.framework' % pkgbase, common_libs ),
+ build_list( '%s/%%s.framework' % pkgsrc, common_libs ),
+ batch_copy ) ] )
+ libs_link = ['objc']
+ local_env.Append( FRAMEWORKS = [ common_libs, 'Foundation', 'AppKit'] )
+ src.append(['../tools/osx/SDLMain.m', '../tools/osx/config_mac.mm'])
+elif sys.platform != 'win32':
local_env.ParseConfig('sdl-config --cflags --libs')
local_env.Append(LIBPATH = ['/usr/X11R6/lib'])
- libs_link = ['GL', 'GLU', 'GLEW', 'SDL_image', 'SDL_net', 'SDL_gfx', 'ode']
+ libs_link = ['GL', 'GLU', 'GLEW', common_libs]
else:
- libs_link = ['opengl32', 'glu32', 'glew32', 'mingw32', 'SDLmain', 'SDL', 'SDL_image', 'SDL_net', 'SDL_gfx', 'ode']
+ libs_link = ['opengl32', 'glu32', 'glew32', 'mingw32', 'SDLmain', common_libs ]
local_env.Append(LIBS = libs_link)
@@ -87,8 +118,10 @@
#--------------------#
# Compile Executable #
#--------------------#
-vdrift = local_env.Program(target='vdrift', source=[src, vamosobjs, guiobjs])
-
+vdrift = Alias('vdrift',
+ local_env.Program(target='%s$EXECUTABLE_NAME' % appdir,
+ source=[src, vamosobjs, guiobjs])
+) # just in case
Default(vdrift)
#---------#
Index: SConstruct
===================================================================
--- SConstruct (revision 1765)
+++ SConstruct (working copy)
@@ -4,8 +4,8 @@
#---------------#
# Build Options #
#---------------#
+
opts = Options('vdrift.conf', ARGUMENTS)
-opts.Add('settings', 'Directory under user\'s home dir where settings will be stored', '.vdrift')
opts.Add('destdir', 'Staging area to install VDrift to. Useful for packagers. ', '')
opts.Add('prefix', 'Path prefix.', '/usr') # Can't be /usr/local, it is HARDCODED in default VDrift.config
opts.Add('datadir', 'Path suffix where where VDrift data will be installed', "share/games/vdrift/data") # in most case this dir doesn't exsist => do not use PathOption (Fails on build)
@@ -33,6 +33,9 @@
#--------------------------#
# Create Build Environment #
#--------------------------#
+# define a list of CPPDEFINES so they don't get mangled...
+cppdefines = []
+default_settingsdir = ".vdrift"
#---------------#
# FreeBSD build #
#---------------#
@@ -52,12 +55,18 @@
# OS X build #
#------------#
elif sys.platform == 'darwin':
- env = Environment(ENV = os.environ,
- CPPPATH = ['#include', '#tools/osx/', '#tools/osx/SDL.framework/Headers/'],
- CCFLAGS = ['-Wall', '-Wno-non-virtual-dtor'],
- LIBPATH = ['.'],
- options = opts)
- check_headers = ['OpenGL/gl.h', 'OpenGL/glu.h']
+ env = Environment(ENV = os.environ,
+ CPPPATH = ['#include', '#tools/osx/', '#tools/osx/SDL.framework/Headers/'],
+ CCFLAGS = ['-Wall', '-Wno-non-virtual-dtor'],
+ LIBPATH = ['.'],
+ FRAMEWORKPATH = ['tools/osx'],
+ FRAMEWORKS = [ 'OpenGL'],
+ options = opts)
+
+ check_headers = ['OpenGL/gl.h', 'OpenGL/glu.h', 'SDL/sdl.h']
+ default_settingsdir = 'Library/Preferences/VDrift'
+ cppdefines.append(("_DEFINE_OSX_HELPERS"))
+
#---------------#
# Windows build #
#---------------#
@@ -81,6 +90,17 @@
options = opts)
check_headers = ['GL/gl.h', 'GL/glu.h', 'SDL/SDL.h', 'SDL/SDL_image.h', 'SDL/SDL_net.h', 'SDL/SDL_rotozoom.h', 'ode/ode.h']
+
+#-------------------------------#
+# General configurarion options #
+#-------------------------------#
+
+opts.Add('settings', 'Directory under user\'s home dir where settings will be stored', default_settingsdir )
+
+# For the OSX package, but could be useful otherwise
+env['EXECUTABLE_NAME'] = 'vdrift'
+env['PRODUCT_NAME'] = 'vdrift'
+
#--------------#
# Save Options #
#--------------#
@@ -161,6 +181,17 @@
env.Append (BUILDERS = {'TarCopy' : copy_tar_dir})
+#------------------------------------------------------------------------#
+# Provide a utility for applying environment variables to template files #
+#------------------------------------------------------------------------#
+def process_template(target, source, env):
+ for tgt, src in zip( target, source ):
+ file( str( tgt ), "w+" ).write(
+ env.subst( file( str( src ) ).read(), raw=1 ) )
+
+env.Append (BUILDERS =
+ {'ProcessTemplate': Builder(action = process_template ) })
+
#------------#
# Build Help #
#------------#
@@ -235,12 +266,12 @@
env = conf.Finish()
-# define a list of CPPDEFINES so they don't get mangled...
-cppdefines = []
#-------------#
# directories #
#-------------#
+env['data_directory'] = env['destdir'] + env['prefix'] + '/' + env['datadir']
+cppdefines.append(("SETTINGS_DIR", '"%s"' % env['settings']))
if sys.platform == 'win32':
# -DWIN32 is already defined
env['use_binreloc'] = False
@@ -248,12 +279,11 @@
env['data_directory'] = "./data"
env['settings'] = "VDrift"
cppdefines.append(("DATA_DIR", '"%s"' % env['data_directory']))
- cppdefines.append(("SETTINGS_DIR", '"%s"' % env['settings']))
+elif ('darwin' == env['PLATFORM']):
+ cppdefines.append(("DATA_DIR", "get_mac_data_dir()"))
else:
- env['data_directory'] = env['destdir'] + env['prefix'] + '/' + env['datadir']
temp = env['prefix'] + '/' + env['datadir']
cppdefines.append(("DATA_DIR", '"%s"' % temp))
- cppdefines.append(("SETTINGS_DIR", '"%s"' % env['settings']))
if env['old_openal']:
cppdefines.append("OLD_OPENAL")
|
|
|