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")
|
|
07-12-2007, 05:30 PM,
|
|
abs1nth
Senior Member
|
Posts: 358
Threads: 5
Joined: Sep 2005
|
|
Re: Mac fixes for scons build
bugsyv Wrote: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 ).
thats great! it "wasn't quite right" because it never worked in the first place and i only spent some few minutes trying to get it to work. i will look_at/commit your change tomorrow.
edit: it would be great if someone with more knowledge of scons than me could also give it a look.
|
|
07-13-2007, 01:22 AM,
|
|
thelusiv
Administrator
|
Posts: 2,346
Threads: 223
Joined: Jun 2005
|
|
Alright I've read through the patch a good bit, and understand what you're doing and it looks like it's a good one. Tell you what, rather than make abs1nth apply all that by hand, I'll just give you checkin privileges (the output of svn diff won't usually go through patch, at least for me). Since you seem to understand SCons and building on OS X, I think it would be good to have you on the team.
Please send me a private message or email with your desired username and password, and I'll set it up for you.
Please keep us up to date on any changes you make, so they can be tested on other systems, don't forget to include a log message when you check in too (as descriptive as possible, but doesn't have to include details, those can be discussed here). Also it doesn't hurt to stop by the IRC channel occasionally. Other than that just write good code...and if you don't know how to do something check the SVN book or ask us.
|
|
07-13-2007, 05:51 AM,
|
|
bugsyv
Junior Member
|
Posts: 46
Threads: 6
Joined: May 2007
|
|
thelusiv Wrote:the output of svn diff won't usually go through patch, at least for me.
Yeah, I think I read that on the wiki. So, I tried to find out if there was any trick to it. However, Code: patch -p0 < patchfile
(from the proper directory) works just like the man page says it should.
Of course I have the mac build of patch, if that makes any difference... and it reports version 2.5.8.
|
|
07-13-2007, 04:14 PM,
|
|
bugsyv
Junior Member
|
Posts: 46
Threads: 6
Joined: May 2007
|
|
Okiedokie... committed to svn with my spanking new privs. Let me know if anything goes wrong.
|
|
07-13-2007, 06:18 PM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
bugsyv Wrote:Okiedokie... committed to svn with my spanking new privs. Let me know if anything goes wrong.
don't know if this is the cause, but 'scons install' doesn't work for me anymore:
Code: scons: *** [/usr/local/bin/vdrift] Exception
Traceback (most recent call last):
File "/usr/lib/scons/SCons/Taskmaster.py", line 194, in execute
self.targets[0].build()
File "/usr/lib/scons/SCons/Node/__init__.py", line 301, in build
apply(executor, (self, exitstatfunc), kw)
File "/usr/lib/scons/SCons/Executor.py", line 129, in __call__
self.do_execute(target, exitstatfunc, kw)
File "/usr/lib/scons/SCons/Executor.py", line 122, in do_execute
kw)
File "/usr/lib/scons/SCons/Action.py", line 313, in __call__
s = self.strfunction(target, source, env)
File "/usr/lib/scons/SCons/Environment.py", line 87, in installString
return s(target[0].path, source[0].path, env)
AttributeError: Alias instance has no attribute 'path'
scons: building terminated because of errors.
--alex--
|
|
07-13-2007, 09:32 PM,
|
|
bugsyv
Junior Member
|
Posts: 46
Threads: 6
Joined: May 2007
|
|
nice. big problem wiyh my first submit. investigating.
|
|
07-13-2007, 11:13 PM,
|
|
bugsyv
Junior Member
|
Posts: 46
Threads: 6
Joined: May 2007
|
|
The install target flat-out hangs on my mac, but I think I know the cause of the problem that you are seeing. Since I can't test, can you verify this patch Code: Index: src/SConscript
===================================================================
--- src/SConscript (revision 1767)
+++ src/SConscript (working copy)
@@ -1,5 +1,6 @@
import os, sys
+
#-------------#
# Import Vars #
#-------------#
@@ -118,16 +119,16 @@
#--------------------#
# Compile Executable #
#--------------------#
-vdrift = Alias('vdrift',
- local_env.Program(target='%s$EXECUTABLE_NAME' % appdir,
- source=[src, vamosobjs, guiobjs])
+vdrift_prog= local_env.Program(target='%s$EXECUTABLE_NAME' % appdir,
+ source=[src, vamosobjs, guiobjs]
+vdrift = Alias('vdrift', vdrift_prog)
) # just in case
Default(vdrift)
#---------#
# Install #
#---------#
-install = env.Install(Dir(env.subst("$destdir$prefix/$bindir")), vdrift)
+install = env.Install(Dir(env.subst("$destdir$prefix/$bindir")), vdrift_prog )
env.Alias("install", install)
#---------------#
It doesn't make sense for me, but I'll worry about that later.
try to apply the patch with Code: patch -p0 < patchfile
from the root of your working copy. if that doesn't work, I'll have to ask you to apply it by hand.
Thanks.
|
|
07-14-2007, 12:18 AM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
bugsyv Wrote:The install target flat-out hangs on my mac, but I think I know the cause of the problem that you are seeing. Since I can't test, can you verify this patch
doesn't work:
Code: File "/home/romosan/cvs/vdrift/src/SConscript", line 124
vdrift = Alias('vdrift', vdrift_prog)
^
SyntaxError: invalid syntax
--alex--
|
|
07-14-2007, 12:34 AM,
|
|
bugsyv
Junior Member
|
Posts: 46
Threads: 6
Joined: May 2007
|
|
alex25 Wrote:doesn't work
Oops.. that patch has a mistake I caught later.. add a paren to the end of the previous line and remove the paren on the following line:
") # just in case"
Sory for the inconvenience
|
|
07-14-2007, 12:41 PM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
bugsyv Wrote:Oops.. that patch has a mistake I caught later.. add a paren to the end of the previous line and remove the paren on the following line:
that worked.
--alex--
|
|
07-14-2007, 03:21 PM,
|
|
bugsyv
Junior Member
|
Posts: 46
Threads: 6
Joined: May 2007
|
|
good. thanks for the feedback
|
|
|