From 52d3137598be98a0c41598324f8cc4dd0e83ccc5 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sun, 1 Aug 2010 16:30:22 +0000 Subject: [PATCH] Build with -msse3 on OS X. The first Intel Macs were Core Duo/Solo, which had SSE3. Keep -msse2 on other platforms. Not sure if there are actually any Dolphin-capable machines out there without SSE3, but.. Use -search_paths_first to give our statically linked libraries precedence over /usr/local/lib. Some work-in-progress changes to facilitate a more easily redistributable application bundle on OS X. Group compiler/preprocessor/linker flags together to make the full set more intuitively apparent. The various libraries in Externals have rather inconsistent conventions for include paths. Best to encapsulate that knowledge in foo/SConscript. Re-use utils.GenerateRevFile for all three places in the build system where we need the SVN revision number. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6030 8ced0084-cf51-0410-be5f-012b33b47a6e --- Externals/Bochs_disasm/SConscript | 1 + Externals/GLew/SConscript | 4 + Externals/LZO/SConscript | 4 + Externals/Lua/SConscript | 1 + Externals/SDL/SConscript | 4 + Externals/SFML/src/SConscript | 4 + Externals/SOIL/SConscript | 4 + Externals/WiiUse/Src/SConscript | 10 +- Externals/zlib/SConscript | 4 + SConstruct | 322 ++++++++++++--------------- SconsTests/__init__.py | 0 SconsTests/utils.py | 42 ++-- Source/Core/Common/Src/SConscript | 6 + Source/Core/DolphinWX/Src/SConscript | 12 +- 14 files changed, 209 insertions(+), 209 deletions(-) create mode 100644 SconsTests/__init__.py diff --git a/Externals/Bochs_disasm/SConscript b/Externals/Bochs_disasm/SConscript index 3e5c48c325..0894d8020b 100644 --- a/Externals/Bochs_disasm/SConscript +++ b/Externals/Bochs_disasm/SConscript @@ -15,3 +15,4 @@ if sys.platform == 'win32': files += [ "stdafx.cpp" ] env.StaticLibrary(env['local_libs'] + "bdisasm", files) +env['CPPPATH'] += ['#Externals/Bochs_disasm'] diff --git a/Externals/GLew/SConscript b/Externals/GLew/SConscript index 4ce77db4f5..d4e5b00ea8 100644 --- a/Externals/GLew/SConscript +++ b/Externals/GLew/SConscript @@ -2,6 +2,9 @@ Import('env') +if env.has_key('shared_glew') and env['shared_glew']: + Return() + files = [ 'src/glew.c', 'src/glewinfo.c', @@ -9,3 +12,4 @@ files = [ ] env.StaticLibrary(env['local_libs'] + "GLEW", files) +env['CPPPATH'] += ['#Externals/GLew/include'] diff --git a/Externals/LZO/SConscript b/Externals/LZO/SConscript index 96ee32cf24..463cc8856c 100644 --- a/Externals/LZO/SConscript +++ b/Externals/LZO/SConscript @@ -2,8 +2,12 @@ Import('env') +if env.has_key('shared_lzo') and env['shared_lzo']: + Return() + files = [ "minilzo.c", ] env.StaticLibrary(env['local_libs'] + "lzo2", files) +env['CPPPATH'] += ['#Externals/LZO'] diff --git a/Externals/Lua/SConscript b/Externals/Lua/SConscript index ab8496d3e9..88340cb763 100644 --- a/Externals/Lua/SConscript +++ b/Externals/Lua/SConscript @@ -42,3 +42,4 @@ files = [ ] luaenv.StaticLibrary(env['local_libs'] + "lua", files) +env['CPPPATH'] += ['#Externals/Lua'] diff --git a/Externals/SDL/SConscript b/Externals/SDL/SConscript index c7837e7c02..0bb73cde5d 100644 --- a/Externals/SDL/SConscript +++ b/Externals/SDL/SConscript @@ -3,6 +3,9 @@ Import('env') import sys +if env.has_key('shared_sdl') and env['shared_sdl']: + Return() + files = [ 'src/SDL.c', 'src/SDL_error.c', @@ -36,3 +39,4 @@ else: ] env.StaticLibrary(env['local_libs'] + "SDL", files) +env['CPPPATH'] += ['#Externals/SDL', '#Externals/SDL/include'] diff --git a/Externals/SFML/src/SConscript b/Externals/SFML/src/SConscript index 2ec3e26d6d..258d3df72a 100644 --- a/Externals/SFML/src/SConscript +++ b/Externals/SFML/src/SConscript @@ -2,6 +2,9 @@ Import('env') +if env.has_key('shared_sfml') and env['shared_sfml']: + Return() + files = [ "SFML/Network/Ftp.cpp", "SFML/Network/Http.cpp", @@ -14,3 +17,4 @@ files = [ ] env.StaticLibrary(env['local_libs'] + "sfml-network", files) +env['CPPPATH'] += ['#Externals/SFML/include'] diff --git a/Externals/SOIL/SConscript b/Externals/SOIL/SConscript index dbe2788eaf..805f36412e 100644 --- a/Externals/SOIL/SConscript +++ b/Externals/SOIL/SConscript @@ -2,6 +2,9 @@ Import('env') +if env.has_key('shared_soil') and env['shared_soil']: + Return() + files = [ 'image_DXT.c', 'image_helper.c', @@ -10,3 +13,4 @@ files = [ ] env.StaticLibrary(env['local_libs'] + "SOIL", files) +env['CPPPATH'] += ['#Externals/SOIL'] diff --git a/Externals/WiiUse/Src/SConscript b/Externals/WiiUse/Src/SConscript index 45935b40cf..e5693d0fc9 100644 --- a/Externals/WiiUse/Src/SConscript +++ b/Externals/WiiUse/Src/SConscript @@ -3,11 +3,10 @@ Import('env') import sys -if (sys.platform == 'linux2' and not env['HAVE_BLUEZ']) or \ - (not sys.platform == 'darwin' and - not sys.platform == 'linux2' and - not sys.platform == 'win32'): - env['HAVE_WIIUSE'] = 0 +env['HAVE_WIIUSE'] = 0 + +if not sys.platform == 'darwin' and not sys.platform == 'win32' and \ + not (sys.platform == 'linux2' and env['HAVE_BLUEZ']): Return() env['HAVE_WIIUSE'] = 1 @@ -25,3 +24,4 @@ elif sys.platform == 'win32': files += [ "io_win.c" ] env.StaticLibrary(env['local_libs'] + "wiiuse", files) +env['CPPPATH'] += ['#Externals/WiiUse/Src'] diff --git a/Externals/zlib/SConscript b/Externals/zlib/SConscript index caabb46e8c..e648c37e6c 100644 --- a/Externals/zlib/SConscript +++ b/Externals/zlib/SConscript @@ -2,6 +2,9 @@ Import('env') +if env.has_key('shared_zlib') and env['shared_zlib']: + Return() + files = [ 'adler32.c', 'compress.c', @@ -18,3 +21,4 @@ files = [ ] env.StaticLibrary(env['local_libs'] + "z", files) +env['CPPPATH'] += ['#Externals/zlib'] diff --git a/SConstruct b/SConstruct index af1e46198f..3ebfff7cde 100644 --- a/SConstruct +++ b/SConstruct @@ -5,13 +5,15 @@ import sys import platform # Home made tests -sys.path.append('SconsTests') -import wxconfig -import utils +from SconsTests import utils +from SconsTests import wxconfig # Some features need at least SCons 1.2 EnsureSConsVersion(1, 2) +# Construction presets for platform +env = Environment(ENV = os.environ) + # Handle command line options vars = Variables('args.cache') @@ -19,43 +21,37 @@ vars.AddVariables( BoolVariable('verbose', 'Set to show compilation lines', False), BoolVariable('bundle', 'Set to create distribution bundle', False), BoolVariable('lint', 'Set for lint build (fail on warnings)', False), - BoolVariable('nowx', 'Set for building with no WX libs', False), + BoolVariable('nowx', 'Set for building without wxWidgets', False), PathVariable('wxconfig', 'Path to wxconfig', None), - EnumVariable('flavor', 'Choose a build flavor', 'release', - allowed_values = ('release','devel','debug','fastlog','prof'), - ignorecase = 2), + EnumVariable('flavor', 'Choose a build flavor', 'release', allowed_values = + ('release','devel','debug','fastlog','prof'), ignorecase = 2), ) -if not sys.platform == 'win32' and not sys.platform == 'darwin': - vars.AddVariables( - PathVariable('destdir', - 'Temporary install location (for package building)', - None, PathVariable.PathAccept), - EnumVariable('install', - 'Choose a local or global installation', 'local', - allowed_values = ('local', 'global'), ignorecase = 2), - PathVariable('prefix', - 'Installation prefix (only used for a global build)', - '/usr', PathVariable.PathAccept), - PathVariable('userdir', - 'Set the name of the user data directory in home', - '.dolphin-emu', PathVariable.PathAccept), - BoolVariable('opencl', 'Build with OpenCL', False), - EnumVariable('pgo', 'Profile-Guided Optimization (generate or use)', - 'none', allowed_values = ('none', 'generate', 'use'), - ignorecase = 2), - BoolVariable('shared_glew', 'Use system shared libGLEW', True), - BoolVariable('shared_lzo', 'Use system shared liblzo2', True), - BoolVariable('shared_sdl', 'Use system shared libSDL', True), - BoolVariable('shared_sfml', 'Use system shared libsfml-network', True), - BoolVariable('shared_soil', 'Use system shared libSOIL', True), - BoolVariable('shared_zlib', 'Use system shared libz', True), - ('CC', 'The C compiler', 'gcc'), - ('CXX', 'The C++ compiler', 'g++'), - ) +if env['PLATFORM'] == 'posix': vars.AddVariables( + PathVariable('destdir', 'Temporary install location (for package building)', + None, PathVariable.PathAccept), + EnumVariable('install', 'Choose a local or global installation', 'local', + allowed_values = ('local', 'global'), ignorecase = 2), + PathVariable('prefix', 'Installation prefix (only used for a global build)', + '/usr', PathVariable.PathAccept), + PathVariable('userdir', 'Set the name of the user data directory in home', + '.dolphin-emu', PathVariable.PathAccept), + BoolVariable('opencl', 'Build with OpenCL', False), + EnumVariable('pgo', 'Profile-Guided Optimization (generate or use)', 'none', + allowed_values = ('none', 'generate', 'use'), ignorecase = 2), + BoolVariable('shared_glew', 'Use system shared libGLEW', True), + BoolVariable('shared_lzo', 'Use system shared liblzo2', True), + BoolVariable('shared_sdl', 'Use system shared libSDL', True), + BoolVariable('shared_sfml', 'Use system shared libsfml-network', True), + BoolVariable('shared_soil', 'Use system shared libSOIL', True), + BoolVariable('shared_zlib', 'Use system shared libz', True), + PathVariable('CC', 'The C compiler', 'gcc', PathVariable.PathAccept), + PathVariable('CXX', 'The C++ compiler', 'g++', PathVariable.PathAccept), + ) -env = Environment(ENV = os.environ, variables = vars) -Export('env') +# Save the given command line options +vars.Update(env) +vars.Save('args.cache', env) # Die on unknown variables unknown = vars.UnknownVariables() @@ -63,61 +59,6 @@ if unknown: print "Unknown variables:", unknown.keys() Exit(1) -# Save the given command line options -vars.Save('args.cache', env) - -cppDefines = [ - ( '_FILE_OFFSET_BITS', 64), - '_LARGEFILE_SOURCE', - 'GCC_HASCLASSVISIBILITY', - ] - -ccFlags = [ - '-Wall', - '-Wpacked', - '-Wpointer-arith', - '-Wshadow', - '-Wwrite-strings', - '-fPIC', - '-fno-exceptions', - '-fno-strict-aliasing', - '-fvisibility=hidden', - '-msse2', - ] - -if env['CCVERSION'] >= '4.3.0': ccFlags += [ - '-Wno-array-bounds', # False positives - '-Wno-unused-result', # Too many syscalls - ] - -# Build flavor -if env['flavor'] == 'debug': - ccFlags.append('-ggdb') - cppDefines.append('_DEBUG') #enables LOGGING - # FIXME: this disable wx debugging how do we make it work? - cppDefines.append('NDEBUG') -elif env['flavor'] == 'devel': - ccFlags.append('-ggdb') -elif env['flavor'] == 'fastlog': - ccFlags.append('-O3') - cppDefines.append('DEBUGFAST') -elif env['flavor'] == 'prof': - ccFlags.append('-O3') - ccFlags.append('-ggdb') -elif env['flavor'] == 'release': - ccFlags.append('-O3') - ccFlags.append('-fomit-frame-pointer'); - -if env['flavor'] == 'debug': - extra = '-debug' -elif env['flavor'] == 'prof': - extra = '-prof' -else: - extra = '' - -if env['lint']: - ccFlags.append('-Werror') - # Verbose compile if not env['verbose']: env['ARCOMSTR'] = "Archiving $TARGET" @@ -132,6 +73,36 @@ if not env['verbose']: env['SHLINKCOMSTR'] = "Linking $TARGET" env['TARCOMSTR'] = "Creating $TARGET" +if not env['flavor'] == 'debug': + env['CCFLAGS'] += ['-O3'] +if env['flavor'] == 'release': + env['CCFLAGS'] += ['-fomit-frame-pointer'] +elif not env['flavor'] == 'fastlog': + env['CCFLAGS'] += ['-ggdb'] +env['CCFLAGS'] += ['-fno-exceptions', '-fno-strict-aliasing'] +if env['CCVERSION'] >= '4.2.0': + env['CCFLAGS'] += ['-fvisibility=hidden'] + env['CXXFLAGS'] += ['-fvisibility-inlines-hidden'] + +if env['lint']: + env['CCFLAGS'] += ['-Werror'] +env['CCFLAGS'] += ['-Wall', '-Wextra'] +env['CCFLAGS'] += ['-Wno-missing-field-initializers', '-Wno-unused-parameter'] +env['CCFLAGS'] += ['-Wpacked', '-Wpointer-arith', '-Wshadow', '-Wwrite-strings'] +if env['CCVERSION'] < '4.2.0': + env['CCFLAGS'] += ['-Wno-pragmas'] +if env['CCVERSION'] >= '4.3.0': + env['CCFLAGS'] += ['-Wno-array-bounds', '-Wno-unused-result'] + +env['CPPDEFINES'] = [] +if env['flavor'] == 'debug': + env['CPPDEFINES'] += ['_DEBUG'] +elif env['flavor'] == 'fastlog': + env['CPPDEFINES'] += ['DEBUGFAST'] +env['CPPPATH'] = ['#Source/PluginSpecs'] +env['LIBPATH'] = [] +env['LIBS'] = [] + # Object files env['build_dir'] = 'Build' + os.sep + platform.system() + \ '-' + platform.machine() + '-' + env['flavor'] @@ -142,71 +113,70 @@ env['local_libs'] = '#' + env['build_dir'] + os.sep + 'libs' + os.sep # Default install path if not env.has_key('install') or env['install'] == 'local': env['prefix'] = 'Binary' + os.sep + platform.system() + \ - '-' + platform.machine() + extra + '-' + platform.machine() + if env['flavor'] == 'debug': + env['prefix'] += '-debug' + elif env['flavor'] == 'prof': + env['prefix'] += '-prof' -# Configuration tests section -tests = {'CheckWXConfig' : wxconfig.CheckWXConfig, - 'CheckPKGConfig' : utils.CheckPKGConfig, - 'CheckPKG' : utils.CheckPKG, - 'CheckSDL' : utils.CheckSDL, - 'CheckPortaudio' : utils.CheckPortaudio, - } - -rev = utils.GenerateRevFile(env['flavor'], - "Source/Core/Common/Src/svnrev_template.h", - "Source/Core/Common/Src/svnrev.h") - -env['CCFLAGS'] = ccFlags -env['CPPDEFINES'] = cppDefines -env['CPPPATH'] = ['#Source/PluginSpecs'] -env['CXXFLAGS'] = ['-fvisibility-inlines-hidden'] -env['LIBPATH'] = [] -env['LIBS'] = [] -env['RPATH'] = [] +rev = utils.GenerateRevFile(env['flavor'], '.', None) # OS X specifics if sys.platform == 'darwin': - gccflags = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5'] - env['CCFLAGS'] += gccflags - env['CCFLAGS'] += ['-Wextra-tokens', '-Wnewline-eof'] + ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5'] + env['CCFLAGS'] += ccld + env['CCFLAGS'] += ['-msse3'] env['CC'] = "gcc-4.2 -ObjC" env['CXX'] = "g++-4.2 -ObjC++" + #env['FRAMEWORKPATH'] += [ + # '/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks', + # '/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks'] env['FRAMEWORKS'] += ['AppKit', 'CoreFoundation', 'CoreServices'] env['FRAMEWORKS'] += ['AudioUnit', 'CoreAudio'] env['FRAMEWORKS'] += ['IOBluetooth', 'IOKit', 'OpenGL'] - env['LIBS'] += ['iconv'] - env['LINKFLAGS'] += gccflags - env['LINKFLAGS'] += ['-Z', '-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib', + #env['LIBPATH'] += ['/Developer/SDKs/MacOSX10.5.sdk/usr/lib'] + env['LIBS'] = ['gcc_s.10.5', 'iconv'] # , 'stdc++-static'] # XXX + env['LINKFLAGS'] += ccld + env['LINKFLAGS'] += ['-Wl,-search_paths_first', '-Wl,-Z'] + env['LINKFLAGS'] += ['-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib', '-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks', '-F/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks'] + if platform.mac_ver()[0] < '10.6.0': env['HAVE_OPENCL'] = 0 else: + env['CCFLAGS'] += ['-Wextra-tokens', '-Wnewline-eof'] env['HAVE_OPENCL'] = 1 - env['LINKFLAGS'] += ['-weak_framework', 'OpenCL'] + env['FRAMEWORKSFLAGS'] = ['-weak_framework', 'OpenCL'] + if env['nowx']: env['HAVE_WX'] = 0 else: - conf = env.Configure(custom_tests = tests) - env['HAVE_WX'] = conf.CheckWXConfig(2.9, - ['aui', 'adv', 'core', 'base', 'gl'], 0) + wxenv = env.Clone(LIBPATH = '') + conf = wxenv.Configure(conf_dir = None, log_file = None, + custom_tests = {'CheckWXConfig' : wxconfig.CheckWXConfig}) + env['HAVE_WX'] = \ + conf.CheckWXConfig(2.9, 'aui adv core base gl'.split(), 0) conf.Finish() - # wx-config wants us to link with the OS X QuickTime framework - # which is not available for x86_64 and we don't use it anyway. - # Strip it out to silence some harmless linker warnings. - # In the 10.5 SDK, Carbon is only partially built for x86_64. - frameworks = env['FRAMEWORKS'] - wxconfig.ParseWXConfig(env) - if env['CPPDEFINES'].count('WXUSINGDLL'): - env['FRAMEWORKS'] = frameworks + if not env['HAVE_WX']: + print "wxWidgets 2.9 not found using " + env['wxconfig'] + Exit(1) + wxconfig.ParseWXConfig(wxenv) + env['CPPDEFINES'] += ['__WXOSX_COCOA__'] + env['CPPPATH'] = wxenv['CPPPATH'] + if not wxenv['CPPDEFINES'].count('WXUSINGDLL'): + env['FRAMEWORKS'] = wxenv['FRAMEWORKS'] + env['LIBPATH'] += wxenv['LIBPATH'] + env['LIBS'] = wxenv['LIBS'] + env['CPPPATH'] += ['#Externals'] + env['FRAMEWORKPATH'] += ['Externals/Cg'] env['FRAMEWORKS'] += ['Cg'] - env['LINKFLAGS'] += ['-FExternals/Cg'] env['shared_zlib'] = True + env['data_dir'] = '#' + env['prefix'] + '/Dolphin.app/Contents/Resources' env['plugin_dir'] = '#' + env['prefix'] + '/Dolphin.app/Contents/PlugIns' - env.Install(env['data_dir'], 'Data/Sys') - env.Install(env['data_dir'], 'Data/User') + if env['bundle']: app = env['prefix'] + '/Dolphin.app' dmg = env['prefix'] + '/Dolphin-r' + rev + '.dmg' @@ -215,14 +185,24 @@ if sys.platform == 'darwin': ' && hdiutil internet-enable -yes ' + dmg) elif sys.platform == 'win32': - env['tools'] = ['mingw'] + pass else: - env['CCFLAGS'] += ['-pthread'] - env['CXXFLAGS'] += ['-Wno-deprecated'] # XXX - env['CPPPATH'].insert(0, '#') + env['CCFLAGS'] += ['-fPIC', '-msse2'] + env['CPPPATH'].insert(0, '#') # Make sure we pick up our own config.h + if sys.platform == 'linux2': + env['CPPDEFINES'] += [('_FILE_OFFSET_BITS', 64), '_LARGEFILE_SOURCE'] + env['CXXFLAGS'] += ['-Wno-deprecated'] # XXX env['LINKFLAGS'] += ['-pthread'] - conf = env.Configure(custom_tests = tests, config_h="#config.h") + env['RPATH'] = [] + + conf = env.Configure(config_h = "#config.h", custom_tests = { + 'CheckPKG' : utils.CheckPKG, + 'CheckPKGConfig' : utils.CheckPKGConfig, + 'CheckPortaudio' : utils.CheckPortaudio, + 'CheckSDL' : utils.CheckSDL, + 'CheckWXConfig' : wxconfig.CheckWXConfig, + }) if not conf.CheckPKGConfig('0.15.0'): print "Can't find pkg-config, some tests will fail" @@ -249,12 +229,11 @@ else: if env['nowx']: env['HAVE_WX'] = 0 else: - env['HAVE_WX'] = conf.CheckWXConfig(2.8, - ['aui', 'adv', 'core', 'base'], 0) + env['HAVE_WX'] = conf.CheckWXConfig(2.8, 'aui adv core base'.split(), 0) conf.Define('HAVE_WX', env['HAVE_WX']) wxconfig.ParseWXConfig(env) if not env['HAVE_WX']: - print "WX libraries not found - see config.log" + print "wxWidgets not found - see config.log" Exit(1) env['HAVE_BLUEZ'] = conf.CheckPKG('bluez') @@ -276,7 +255,6 @@ else: conf.Define('HAVE_XRANDR', env['HAVE_XRANDR']) conf.Define('HAVE_X11', env['HAVE_X11']) - # Check for GTK 2.0 or newer if env['HAVE_WX'] and not conf.CheckPKG('gtk+-2.0'): print "gtk+-2.0 developement headers not detected" print "gtk+-2.0 is required to build the WX GUI" @@ -302,18 +280,18 @@ else: env['HAVE_OPENCL'] = 0 # PGO - Profile Guided Optimization - if env['pgo']=='generate': - ccFlags.append('-fprofile-generate') - env['LINKFLAGS']='-fprofile-generate' - if env['pgo']=='use': - ccFlags.append('-fprofile-use') - env['LINKFLAGS']='-fprofile-use' + if env['pgo'] == 'generate': + env['CCFLAGS'] += ['-fprofile-generate'] + env['LINKFLAGS'] += ['-fprofile-generate'] + if env['pgo'] == 'use': + env['CCFLAGS'] += ['-fprofile-use'] + env['LINKFLAGS'] += ['-fprofile-use'] # Profiling - if (env['flavor'] == 'prof'): - proflibs = [ '/usr/lib/oprofile', '/usr/local/lib/oprofile' ] - env['LIBPATH'].append(proflibs) - env['RPATH'].append(proflibs) + if env['flavor'] == 'prof': + proflibs = ['/usr/lib/oprofile', '/usr/local/lib/oprofile'] + env['LIBPATH'] += ['proflibs'] + env['RPATH'] += ['proflibs'] if conf.CheckPKG('opagent'): conf.Define('USE_OPROFILE', 1) else: @@ -356,10 +334,6 @@ else: # After all configuration tests are done conf.Finish() - # Data install - env.InstallAs(env['data_dir'] + '/sys', 'Data/Sys') - env.InstallAs(env['data_dir'] + '/user', 'Data/User') - env.Alias('install', env['prefix']) # Local (static) libraries must be first in the search path for the build in @@ -367,37 +341,20 @@ else: # during autoconfiguration as they will then be detected as system libraries. env['LIBPATH'].insert(0, env['local_libs']) -dirs = [] - -if not env.has_key('shared_glew') or not env['shared_glew']: - env['CPPPATH'] += ['#Externals/GLew/include'] - dirs += ['Externals/GLew'] -if not env.has_key('shared_lzo') or not env['shared_lzo']: - env['CPPPATH'] += ['#Externals/LZO'] - dirs += ['Externals/LZO'] -if not env.has_key('shared_sdl') or not env['shared_sdl']: - env['CPPPATH'] += ['#Externals/SDL'] - env['CPPPATH'] += ['#Externals/SDL/include'] - dirs += ['Externals/SDL'] -if not env.has_key('shared_soil') or not env['shared_soil']: - env['CPPPATH'] += ['#Externals/SOIL'] - dirs += ['Externals/SOIL'] -if not env.has_key('shared_sfml') or not env['shared_sfml']: - env['CPPPATH'] += ['#Externals/SFML/include'] - dirs += ['Externals/SFML/src'] -if not env.has_key('shared_zlib') or not env['shared_zlib']: - env['CPPPATH'] += ['#Externals/zlib'] - dirs += ['Externals/zlib'] - -dirs += [ +dirs = [ 'Externals/Bochs_disasm', #'Externals/CLRun', 'Externals/Lua', 'Externals/MemcardManager', 'Externals/WiiUse/Src', + 'Externals/GLew', + 'Externals/LZO', #'Externals/OpenAL', - #'Externals/dylibbundler', + 'Externals/SDL', + 'Externals/SOIL', + 'Externals/SFML/src', #'Externals/wxWidgets', + 'Externals/zlib', 'Source/Core/AudioCommon/Src', 'Source/Core/Common/Src', 'Source/Core/Core/Src', @@ -412,8 +369,8 @@ dirs += [ 'Source/DSPTool/Src', 'Source/Plugins/Plugin_DSP_HLE/Src', 'Source/Plugins/Plugin_DSP_LLE/Src', - #'Source/Plugins/Plugin_VideoDX9/Src', #'Source/Plugins/Plugin_VideoDX11/Src', + #'Source/Plugins/Plugin_VideoDX9/Src', 'Source/Plugins/Plugin_VideoOGL/Src', 'Source/Plugins/Plugin_VideoSoftware/Src', 'Source/Plugins/Plugin_Wiimote/Src', @@ -421,14 +378,15 @@ dirs += [ 'Source/UnitTests', ] +# Now that platform configuration is done, propagate it to modules for subdir in dirs: SConscript(dirs = subdir, duplicate = 0, exports = 'env', variant_dir = env['build_dir'] + os.sep + subdir) - if subdir.count('Externals') or subdir.count('Source/Core'): + if subdir.startswith('Source/Core'): env['CPPPATH'] += ['#' + subdir] # Print a nice progress indication when not compiling Progress(['-\r', '\\\r', '|\r', '/\r'], interval = 5) -# Generate help +# Generate help, printing current status of options Help(vars.GenerateHelpText(env)) diff --git a/SconsTests/__init__.py b/SconsTests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/SconsTests/utils.py b/SconsTests/utils.py index 926516d247..9f5a5ab22f 100644 --- a/SconsTests/utils.py +++ b/SconsTests/utils.py @@ -30,14 +30,14 @@ def ConfigPKG(context, name): if ret: context.env.ParseConfig('pkg-config --cflags --libs \'%s\'' % name) return int(ret) - + def CheckPKG(context, name): context.Message( 'Checking for %s... ' % name ) if platform.system().lower() == 'windows': - return 0 + return 0 ret = 1 if not ConfigPKG(context, name.lower()): - ret = CheckLib(context, name) + ret = CheckLib(context, name) context.Result(ret) return int(ret) @@ -52,20 +52,20 @@ def CheckSDL(context, version): else: found_ver = os.popen('sdl-config --version').read().strip() required = [int(n) for n in version.split(".")] - found = [int(n) for n in found_ver.split(".")] + found = [int(n) for n in found_ver.split(".")] ret = (found >= required) - + context.Result(ret) if ret: context.env.ParseConfig('sdl-config --cflags --libs') ret = CheckLib(context, 'SDL') return int(ret) - + def CheckPortaudio(context, version): found = 0 if CheckPKG(context, 'portaudio'): context.Message( 'Checking for lib portaudio version > %s... ' % version) - found = context.TryRun(""" + found = context.TryRun(""" #include #include int main(int argc, char **argv) { @@ -81,18 +81,22 @@ def CheckPortaudio(context, version): context.Result(ret) return int(ret) - -def GenerateRevFile(flavour, template, output): +def GenerateRevFile(flavour, template, output): try: - svnrev = os.popen('svnversion .').read().strip().split(':')[0] + svnrev = os.popen('svnversion ' + os.path.dirname(template)).\ + read().strip().split(':')[0] except: - svnrev = "" - - revstr = svnrev + "-" + flavour - tmpstr = open(template, "r").read().replace("$WCMODS?$WCREV$M:$WCREV$$",revstr) - outfile = open(output, 'w') - outfile.write(tmpstr +"\n") - outfile.close() - - return revstr + svnrev = '' + + if flavour: + svnrev += '-' + flavour + + if output: + tmpstr = open(template, 'r').read().\ + replace("$WCMODS?$WCREV$M:$WCREV$$", svnrev) + outfile = open(output, 'w') + outfile.write(tmpstr + '\n') + outfile.close() + + return svnrev diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index 4824e0bc41..bbb83eb7a2 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -1,7 +1,12 @@ # -*- python -*- Import('env') +import os import sys +from SconsTests import utils + +utils.GenerateRevFile(env['flavor'], Dir('#Source/Core/Common/Src').abspath + + os.sep + 'svnrev_template.h', 'svnrev.h') files = [ "ABI.cpp", @@ -48,3 +53,4 @@ if sys.platform == 'win32': files += [ "stdafx.cpp" ] env.StaticLibrary(env['local_libs'] + "common", files) +env['CPPPATH'] += ['.'] diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 0336e6b0f0..7b843d416f 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -3,6 +3,7 @@ Import('env') import os import sys +from SconsTests import utils files = [ 'BootManager.cpp', @@ -64,6 +65,8 @@ elif sys.platform == 'darwin' and env['HAVE_WX']: 'Library/Frameworks/Cg.framework', '#Externals/Cg/Cg.framework/Cg') + env.Install(env['data_dir'], '#Data/Sys') + env.Install(env['data_dir'], '#Data/User') env.Install(env['data_dir'], '#Source/Core/DolphinWX/resources/Dolphin.icns') @@ -79,23 +82,26 @@ elif sys.platform == 'darwin' and env['HAVE_WX']: CFBundleIdentifier = 'com.dolphin-emu.dolphin', CFBundlePackageType = 'APPL', CFBundleShortVersionString = - os.popen('svnversion -n ' + Dir('#').abspath).read(), + utils.GenerateRevFile('', Dir('#None').abspath, None), CFBundleVersion = '2.0', LSMinimumSystemVersion = '10.5.0', LSRequiresCarbon = True, ))) def Fixup(target, source, env): + if env['CPPDEFINES'].count('WXUSINGDLL'): + pass os.link(str(source[0]), str(target[0])) env.Append(BUILDERS = {'Fixup' : Builder(action = Fixup)}) env.Depends(exeGUIdist, env['plugin_dir']) - if env['CPPDEFINES'].count('WXUSINGDLL'): - env.Fixup(exeGUIdist, exeGUI) + env.Fixup(exeGUIdist, exeGUI) else: files += [ 'X11Utils.cpp' ] libs += [ 'SDL' ] exeGUI = env['binary_dir'] + '/dolphin-emu' exeNoGUI = env['binary_dir'] + '/dolphin-emu-nogui' + env.InstallAs(env['data_dir'] + '/sys', '#Data/Sys') + env.InstallAs(env['data_dir'] + '/user', '#Data/User') if env['HAVE_WX']: env.StaticLibrary(env['local_libs'] + 'memcard', memcardfiles)