diff options
author | Damien Plisson <damien.plisson@yahoo.fr> | 2009-10-27 16:40:41 +0300 |
---|---|---|
committer | Damien Plisson <damien.plisson@yahoo.fr> | 2009-10-27 16:40:41 +0300 |
commit | b8a7f844ca2bf07a70b4e33ca6b28bb7312df11d (patch) | |
tree | b832df93007e65df862fb16a0626ccbdd4cca0f1 | |
parent | 54facb5cfe2134d17790a1c24f910bbaaab4e272 (diff) |
Mac:
Fixed gcc-4.0 compile error (cocoa)
Updated scons to build cocoa (32bit & 64bit) (Thx Jens Verwiebe for the patch):
- make sure right python is unzipped to app-bundle ( printing information at the end of compiling )
- make sure arch-setting appends needed flags ( depending on OSX-version obsolete sometimes but harmless )
- link correct frameworks depending on gfx-api ( cocoa/carbon)
- conscript prepared for cocoa objC-files
- link to openAL-framework, using the headers from blender-lib + the symbols in framework
Usage instruction:
The default build is Cocoa 32bit.
To change it, copy config/darwin-config.py to user-config.py in the blender folder, and edit:
- WITH_GHOST_COCOA & MACOSX_ARCHITECTURE variables to select cocoa/carbon, and the arch (i386, X86_64, ppc, ..)
- the libs options as usual
-rw-r--r-- | config/darwin-config.py | 112 | ||||
-rw-r--r-- | intern/ghost/SConscript | 27 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 2 | ||||
-rw-r--r-- | tools/Blender.py | 14 | ||||
-rwxr-xr-x | tools/btools.py | 5 |
5 files changed, 123 insertions, 37 deletions
diff --git a/config/darwin-config.py b/config/darwin-config.py index 981f321e5bc..6dd65aeb40f 100644 --- a/config/darwin-config.py +++ b/config/darwin-config.py @@ -1,8 +1,23 @@ +# +# Note : if you want to alter this file +# copy it as a whole in the upper folder +# as user-config.py +# dont create a new file with only some +# vars changed. + import commands # IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs USE_SDK=True +############################################################################# +################### Cocoa & architecture settings ################## +############################################################################# + +WITH_GHOST_COCOA=True +MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64 + + cmd = 'uname -p' MAC_PROC=commands.getoutput(cmd) cmd = 'uname -r' @@ -11,28 +26,42 @@ if cmd_res[0]=='7': MAC_CUR_VER='10.3' elif cmd_res[0]=='8': MAC_CUR_VER='10.4' -else: +elif cmd_res[0]=='9': MAC_CUR_VER='10.5' +elif cmd_res[0]=='10': + MAC_CUR_VER='10.6' if MAC_PROC == 'powerpc': LCGDIR = '#../lib/darwin-6.1-powerpc' else : - LCGDIR = '#../lib/darwin-8.x.i386' + LCGDIR = '#../lib/darwin-9.x.universal' LIBDIR = '${LCGDIR}' BF_PYTHON_VERSION = '3.1' -if MAC_PROC== 'powerpc' and BF_PYTHON_VERSION == '2.3': +if MAC_PROC == 'powerpc' and BF_PYTHON_VERSION == '2.3': MAC_MIN_VERS = '10.3' MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk' -else: + CC = 'gcc' + CXX = 'g++' +elif MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'ppc': MAC_MIN_VERS = '10.4' MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' + CC = 'gcc-4.0' + CXX = 'g++-4.0' +else : + MAC_MIN_VERS = '10.5' + MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' + CC = 'gcc-4.2' + CXX = 'g++-4.2' +############################################################################# +################### Dependency settings ################## +############################################################################# # enable ffmpeg support WITH_BF_FFMPEG = True # -DWITH_FFMPEG -FFMPEG_PRECOMPILED = False +FFMPEG_PRECOMPILED = True if FFMPEG_PRECOMPILED: # use precompiled ffmpeg in /lib BF_FFMPEG = LIBDIR + '/ffmpeg' @@ -45,8 +74,8 @@ else: BF_FFMPEG_INC = '${BF_FFMPEG}' if USE_SDK==True: BF_FFMPEG_EXTRA = '-isysroot '+MACOSX_SDK+' -mmacosx-version-min='+MAC_MIN_VERS - BF_XVIDCORE_CONFIG = '--disable-assembly' # currently causes errors, even with yasm installed - BF_X264_CONFIG = '--disable-pthread' + BF_XVIDCORE_CONFIG = '--disable-assembly --disable-mmx' # currently causes errors, even with yasm installed + BF_X264_CONFIG = '--disable-pthread --disable-asm' if BF_PYTHON_VERSION=='3.1': # python 3.1 uses precompiled libraries in bf svn /lib by default @@ -75,10 +104,11 @@ else: BF_PYTHON_LINKFLAGS = ['-u','_PyMac_Error','-framework','System','-framework','Python'] if MAC_CUR_VER=='10.3' or MAC_CUR_VER=='10.4': BF_PYTHON_LINKFLAGS = ['-u', '__dummy']+BF_PYTHON_LINKFLAGS + -BF_QUIET = '1' -WITH_BF_OPENMP = '0' +WITH_BF_OPENMP = '0' # multithreading for fluids, cloth and smoke ( only works with ICC atm ) +WITH_BF_OPENAL = True #different lib must be used following version of gcc # for gcc 3.3 #BF_OPENAL = LIBDIR + '/openal' @@ -89,11 +119,11 @@ else : BF_OPENAL = LIBDIR + '/openal' WITH_BF_STATICOPENAL = False -BF_OPENAL_INC = '${BF_OPENAL}/include' -BF_OPENAL_LIB = 'openal' -BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' +BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!! +#BF_OPENAL_LIB = 'openal' +#BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' # Warning, this static lib configuration is untested! users of this OS please confirm. -BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' +#BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' # Warning, this static lib configuration is untested! users of this OS please confirm. BF_CXX = '/usr' @@ -199,10 +229,13 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' BF_FREETYPE_LIB = 'freetype' BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' -WITH_BF_QUICKTIME = True # -DWITH_QUICKTIME +if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': + WITH_BF_QUICKTIME = False # -DWITH_QUICKTIME ( disable for 64bit atm ) +else: + WITH_BF_QUICKTIME = True WITH_BF_ICONV = True -BF_ICONV = LIBDIR + "/iconv" +BF_ICONV = '/usr' BF_ICONV_INC = '${BF_ICONV}/include' BF_ICONV_LIB = 'iconv' #BF_ICONV_LIBPATH = '${BF_ICONV}/lib' @@ -213,12 +246,30 @@ BF_OPENGL_LIB = 'GL GLU' BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries' BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL'] -CFLAGS = ['-pipe','-fPIC','-funsigned-char'] +############################################################################# +################### various compile settings and flags ################## +############################################################################# -CPPFLAGS = ['-fpascal-strings'] -CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fpascal-strings'] -CXXFLAGS = [ '-pipe','-fPIC','-funsigned-char', '-fpascal-strings'] -PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','QuickTime'] +BF_QUIET = '1' # suppress verbose output + +if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': + ARCH_FLAGS = ['-m64'] +else: + ARCH_FLAGS = ['-m32'] + +CFLAGS = ['-pipe','-funsigned-char']+ARCH_FLAGS + +CPPFLAGS = ['-fpascal-strings']+ARCH_FLAGS +CCFLAGS = ['-pipe','-funsigned-char','-fpascal-strings']+ARCH_FLAGS +CXXFLAGS = ['-pipe','-funsigned-char', '-fpascal-strings']+ARCH_FLAGS + +if WITH_GHOST_COCOA==True: + PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS +else: + PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS + +if WITH_BF_QUICKTIME == True: + PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime'] #note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4 LLIBS = ['stdc++', 'SystemStubs'] @@ -232,33 +283,34 @@ if MAC_MIN_VERS == '10.3': if USE_SDK==True: SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS] - PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS, '-Wl,-syslibroot,' + MACOSX_SDK]+PLATFORM_LINKFLAGS + PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-syslibroot '+MACOSX_SDK]+PLATFORM_LINKFLAGS CCFLAGS=SDK_FLAGS+CCFLAGS CXXFLAGS=SDK_FLAGS+CXXFLAGS -# you can add -mssse3 if gcc >= 4.2 -if MAC_PROC == 'i386': +if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64': REL_CFLAGS = ['-O2','-ftree-vectorize','-msse','-msse2','-msse3'] REL_CCFLAGS = ['-O2','-ftree-vectorize','-msse','-msse2','-msse3'] else: CFLAGS = CFLAGS+['-fno-strict-aliasing'] CCFLAGS = CCFLAGS+['-fno-strict-aliasing'] CXXFLAGS = CXXFLAGS+['-fno-strict-aliasing'] - REL_CFLAGS = ['-O2'] REL_CCFLAGS = ['-O2'] +# add -mssse3 for intel 64bit archs +if MACOSX_ARCHITECTURE == 'x86_64': + REL_CFLAGS = REL_CFLAGS+['-mssse3'] + REL_CCFLAGS = REL_CCFLAGS+['-mssse3'] + ##BF_DEPEND = True ## ##AR = ar ##ARFLAGS = ruv ##ARFLAGSQUIET = ru ## -CC = 'gcc' -CXX = 'g++' -C_WARN = ['-Wdeclaration-after-statement'] +#C_WARN = ['-Wdeclaration-after-statement'] -CC_WARN = ['-Wall', '-Wno-long-double'] +CC_WARN = ['-Wall'] ##FIX_STUBS_WARNINGS = -Wno-unused @@ -272,5 +324,9 @@ BF_PROFILE = False BF_DEBUG = False BF_DEBUG_CCFLAGS = ['-g'] +############################################################################# +################### Output directories ################## +############################################################################# + BF_BUILDDIR='../build/darwin' BF_INSTALLDIR='../install/darwin' diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 48009152699..95399227c99 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -6,7 +6,17 @@ Import ('env') window_system = env['OURPLATFORM'] -sources = env.Glob('intern/*.cpp') +sources = env.Glob('intern/*.cpp') + env.Glob('intern/*.mm') + +if env['WITH_GHOST_COCOA'] == True: + env.Append(CFLAGS=['-DGHOST_COCOA']) + env.Append(CXXFLAGS=['-DGHOST_COCOA']) + env.Append(CPPFLAGS=['-DGHOST_COCOA']) + +#defs = '' +#if env['WITH_GHOST_COCOA']: +# defs += 'GHOST_COCOA' +# maybe we need it later pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_Window'] @@ -19,9 +29,17 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64 sources.remove('intern' + os.sep + f + 'X11.cpp') sources.remove('intern' + os.sep + f + 'Carbon.cpp') elif window_system == 'darwin': - for f in pf: - sources.remove('intern' + os.sep + f + 'Win32.cpp') - sources.remove('intern' + os.sep + f + 'X11.cpp') + if env['WITH_GHOST_COCOA']: + for f in pf: + sources.remove('intern' + os.sep + f + 'Win32.cpp') + sources.remove('intern' + os.sep + f + 'X11.cpp') + sources.remove('intern' + os.sep + f + 'Carbon.cpp') + else: + for f in pf: + sources.remove('intern' + os.sep + f + 'Win32.cpp') + sources.remove('intern' + os.sep + f + 'X11.cpp') + sources.remove('intern' + os.sep + f + 'Cocoa.mm') + else: print "Unknown window system specified." Exit() @@ -30,3 +48,4 @@ incs = '. ../string ' + env['BF_OPENGL_INC'] if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'): incs = env['BF_WINTAB_INC'] + ' ' + incs env.BlenderLib ('bf_ghost', sources, Split(incs), defines=['_USE_MATH_DEFINES'], libtype=['intern','player'], priority = [40,15] ) + diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 03a617ebdd7..5dbf79a0293 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -700,7 +700,7 @@ GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 //Quartz Display Services uses the old coordinates (top left origin) yf = screenRect.size.height -yf; - CGDisplayMoveCursorToPoint([[[windowScreen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue], CGPointMake(xf, yf)); + CGDisplayMoveCursorToPoint((CGDirectDisplayID)[[[windowScreen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue], CGPointMake(xf, yf)); return GHOST_kSuccess; } diff --git a/tools/Blender.py b/tools/Blender.py index 5641104ab15..8a2ef93bb26 100644 --- a/tools/Blender.py +++ b/tools/Blender.py @@ -456,7 +456,13 @@ def AppIt(target=None, source=None, env=None): a = '%s' % (target[0]) builddir, b = os.path.split(a) libdir = env['LCGDIR'][1:] - + osxarch = env['MACOSX_ARCHITECTURE'] + print("compiled architecture: %s"%(osxarch)) + if libdir == '../lib/darwin-9.x.universal': + python_zip = 'python_' + osxarch + '.zip' # set specific python_arch.zip + else: + python_zip = 'python.zip' # compatibility for darwin8 python.zip + print("unzipping to app-bundle: %s"%(python_zip)) bldroot = env.Dir('.').abspath binary = env['BINARYKIND'] @@ -477,7 +483,7 @@ def AppIt(target=None, source=None, env=None): cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,builddir, binary, binary) commands.getoutput(cmd) cmd = 'mkdir %s/%s.app/Contents/MacOS/.blender/'%(builddir, binary) - print cmd +# print cmd commands.getoutput(cmd) cmd = builddir + '/%s.app/Contents/MacOS/.blender'%binary shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd) @@ -490,7 +496,7 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'mkdir %s/%s.app/Contents/MacOS/.blender/python/'%(builddir,binary) commands.getoutput(cmd) - cmd = 'unzip -q %s/release/python.zip -d %s/%s.app/Contents/MacOS/.blender/python/'%(libdir,builddir,binary) + cmd = 'unzip -q %s/release/%s -d %s/%s.app/Contents/MacOS/.blender/python/'%(libdir,python_zip,builddir,binary) commands.getoutput(cmd) cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary) commands.getoutput(cmd) @@ -504,6 +510,8 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary) commands.getoutput(cmd) + cmd = 'find %s/%s.app -name __MACOSX -exec rm -rf {} \;'%(builddir, binary) + commands.getoutput(cmd) # extract copy system python, be sure to update other build systems # when making changes to the files that are copied. diff --git a/tools/btools.py b/tools/btools.py index b1584ae8784..cacff349dcf 100755 --- a/tools/btools.py +++ b/tools/btools.py @@ -63,6 +63,7 @@ def validate_arguments(args, bc): 'WITHOUT_BF_INSTALL', 'WITHOUT_BF_PYTHON_INSTALL', 'WITH_BF_OPENMP', + 'WITH_GHOST_COCOA', 'BF_FANCY', 'BF_QUIET', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', @@ -84,7 +85,7 @@ def validate_arguments(args, bc): 'BF_PROFILE_CFLAGS', 'BF_PROFILE_CCFLAGS', 'BF_PROFILE_CXXFLAGS', 'BF_PROFILE_LINKFLAGS', 'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS', 'C_WARN', 'CC_WARN', 'CXX_WARN', - 'LLIBS', 'PLATFORM_LINKFLAGS', + 'LLIBS', 'PLATFORM_LINKFLAGS','MACOSX_ARCHITECTURE', ] @@ -311,6 +312,7 @@ def read_opts(cfg, args): ('BF_FREETYPE_LIBPATH', 'Freetype library path', ''), (BoolVariable('WITH_BF_OPENMP', 'Use OpenMP if true', False)), + (BoolVariable('WITH_GHOST_COCOA', 'Use Cocoa-framework if true', False)), (BoolVariable('WITH_BF_QUICKTIME', 'Use QuickTime if true', False)), ('BF_QUICKTIME', 'QuickTime base path', ''), @@ -350,6 +352,7 @@ def read_opts(cfg, args): ('LLIBS', 'Platform libs', ''), ('PLATFORM_LINKFLAGS', 'Platform linkflags', ''), + ('MACOSX_ARCHITECTURE', 'python_arch.zip select', ''), (BoolVariable('BF_PROFILE', 'Add profiling information if true', False)), ('BF_PROFILE_CFLAGS', 'C only profiling flags', ''), |