dolphin/Externals/MemcardManager/SConstruct

272 lines
7.0 KiB
Python

# -*- python -*-
import os
import sys
import platform
# Home made tests
sys.path.append('SconsTests')
import wxconfig
import utils
# Some features needs at least scons 0.98
EnsureSConsVersion(1, 2)
# TODO: how do we use it in help?
name="Memory Card Manager"
version="1.0"
description=""
license="GPL v2"
warnings = [
'all',
'write-strings',
'shadow',
'pointer-arith',
'packed',
'no-conversion',
]
compileFlags = [
'-fno-exceptions',
'-fno-strict-aliasing',
'-msse2',
#'-fomit-frame-pointer'
]
if sys.platform != 'win32':
compileFlags += [ '-fvisibility=hidden' ]
cppDefines = [
( '_FILE_OFFSET_BITS', 64),
'_LARGEFILE_SOURCE',
'GCC_HASCLASSVISIBILITY',
]
basedir = os.getcwd()+ '/'
include_paths = [
basedir + 'Source/Core/Common/Src',
basedir + 'Source/PluginSpecs',
basedir + 'Source/Core/DolphinWX/Src',
basedir + 'Externals/MemcardManager/src',
]
dirs = [
basedir + 'Source/Core/Common/Src',
basedir + '.',
]
builders = {}
if sys.platform == 'darwin':
from plistlib import writePlist
def createPlist(target, source, env):
properties = {}
for srcNode in source:
properties.update(srcNode.value)
for dstNode in target:
writePlist(properties, str(dstNode))
builders['Plist'] = Builder(action = createPlist)
# handle command line options
vars = Variables('args.cache')
vars.AddVariables(
BoolVariable('verbose', 'Set for compilation line', False),
BoolVariable('lint', 'Set for lint build (extra warnings)', False),
EnumVariable('flavor', 'Choose a build flavor', 'release',
allowed_values = ('release', 'devel', 'debug', 'fastlog', 'prof'),
ignorecase = 2
),
PathVariable('wxconfig', 'Path to the wxconfig', None),
('CC', 'The c compiler', 'gcc'),
('CXX', 'The c++ compiler', 'g++'),
)
if sys.platform == 'win32':
env = Environment(
CPPPATH = include_paths,
RPATH = [],
LIBS = [],
LIBPATH = [],
tools = [ 'mingw' ],
variables = vars,
ENV = os.environ,
BUILDERS = builders,
DESCRIPTION = description,
SUMMARY = description,
LICENSE = license,
NAME = name,
VERSION = version,
)
else:
env = Environment(
CPPPATH = include_paths,
RPATH = [],
LIBS = [],
LIBPATH = [],
variables = vars,
ENV = {
'PATH' : os.environ['PATH'],
'HOME' : os.environ['HOME']
},
BUILDERS = builders,
DESCRIPTION = description,
SUMMARY = description,
LICENSE = license,
NAME = name,
VERSION = version,
)
# save the given command line options
vars.Save('args.cache', env)
# verbose compile
if not env['verbose']:
env['CCCOMSTR'] = "Compiling $TARGET"
env['CXXCOMSTR'] = "Compiling $TARGET"
env['ARCOMSTR'] = "Archiving $TARGET"
env['LINKCOMSTR'] = "Linking $TARGET"
env['ASCOMSTR'] = "Assembling $TARGET"
env['ASPPCOMSTR'] = "Assembling $TARGET"
env['SHCCCOMSTR'] = "Compiling shared $TARGET"
env['SHCXXCOMSTR'] = "Compiling shared $TARGET"
env['SHLINKCOMSTR'] = "Linking shared $TARGET"
env['RANLIBCOMSTR'] = "Indexing $TARGET"
# build falvuor
flavour = ARGUMENTS.get('flavor')
if (flavour == 'debug'):
compileFlags.append('-g')
cppDefines.append('_DEBUG') #enables LOGGING
# FIXME: this disable wx debugging how do we make it work?
cppDefines.append('NDEBUG')
elif (flavour == 'devel'):
compileFlags.append('-g')
elif (flavour == 'fastlog'):
compileFlags.append('-O3')
cppDefines.append('DEBUGFAST')
elif (flavour == 'prof'):
compileFlags.append('-O3')
compileFlags.append('-g')
elif (flavour == 'release'):
compileFlags.append('-O3')
# more warnings
if env['lint']:
warnings.append('error')
warnings.append('unreachable-code')
warnings.append('float-equal')
# add the warnings to the compile flags
compileFlags += [ '-W' + warning for warning in warnings ]
env['CCFLAGS'] = compileFlags
if sys.platform == 'win32':
env['CXXFLAGS'] = compileFlags
else:
env['CXXFLAGS'] = compileFlags + [ '-fvisibility-inlines-hidden' ]
env['CPPDEFINES'] = cppDefines
# Configuration tests section
tests = {'CheckWXConfig' : wxconfig.CheckWXConfig,
'CheckPKGConfig' : utils.CheckPKGConfig,
'CheckPKG' : utils.CheckPKG,
}
#object files
env['build_dir'] = os.path.join(basedir, 'Build', platform.system() + '-' + 'MemCardManager' + os.sep)
VariantDir(env['build_dir'], '.', duplicate=0)
conf = env.Configure(custom_tests = tests,
config_h="Source/Core/Common/Src/Config.h")
if not conf.CheckPKGConfig('0.15.0'):
print "Can't find pkg-config, some tests will fail"
env['HAVE_X11'] = conf.CheckPKG('x11')
env['HAVE_COCOA'] = 0
# handling wx flags CCFLAGS should be created before
wxmods = ['adv', 'core', 'base']
env['USE_WX'] = 0
env['HAVE_WX'] = conf.CheckWXConfig('2.8', wxmods, 0)
conf.Define('HAVE_WX', env['HAVE_WX'])
conf.Define('USE_WX', env['USE_WX'])
conf.Define('HAVE_X11', env['HAVE_X11'])
conf.Define('HAVE_COCOA', env['HAVE_COCOA'])
# profile
env['USE_OPROFILE'] = 0
if (flavour == 'prof'):
proflibs = [ '/usr/lib/oprofile', '/usr/local/lib/oprofile' ]
env['LIBPATH'].append(proflibs)
env['RPATH'].append(proflibs)
if conf.CheckPKG('opagent'):
env['USE_OPROFILE'] = 1
else:
print "Can't build prof without oprofile, disabling"
conf.Define('USE_OPROFILE', env['USE_OPROFILE'])
# After all configuration tests are done
conf.Finish()
#wx windows flags
if env['HAVE_WX']:
wxconfig.ParseWXConfig(env)
else:
print "WX not found or disabled, not building GUI"
# add methods from utils to env
env.AddMethod(utils.filterWarnings)
# Where do we run from
env['base_dir'] = os.getcwd()+ '/'
# install paths
extra=''
if flavour == 'debug':
extra = '-debug'
elif flavour == 'prof':
extra = '-prof'
# TODO: support global install
env['prefix'] = os.path.join(env['base_dir'] + 'Binary', 'MemCardManager' + extra +os.sep)
#TODO add bin
env['binary_dir'] = env['prefix']
# static libs goes here
env['local_libs'] = env['build_dir'] + os.sep + 'libs' + os.sep
env['LIBPATH'].append(env['local_libs'])
# print a nice progress indication when not compiling
Progress(['-\r', '\\\r', '|\r', '/\r'], interval = 5)
# die on unknown variables
unknown = vars.UnknownVariables()
if unknown:
print "Unknown variables:", unknown.keys()
Exit(1)
# generate help
Help(vars.GenerateHelpText(env))
Export('env')
for subdir in dirs:
SConscript(
subdir + os.sep + 'SConscript',
variant_dir = env[ 'build_dir' ] + subdir + os.sep,
duplicate=0
)