Added missing root AMBuildScript.
Added missing root AMBuildScript.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/AMBuildScript Wed Jul 25 00:15:45 2012 -0700
1.3 @@ -0,0 +1,175 @@
1.4 +# vim: set ts=2 sw=2 tw=99 noet ft=python:
1.5 +import os
1.6 +import sys
1.7 +from ambuild.command import SymlinkCommand
1.8 +
1.9 +class KE:
1.10 + def __init__(self):
1.11 + self.compiler = Cpp.Compiler()
1.12 +
1.13 + if AMBuild.mode == 'config':
1.14 + #Detect compilers
1.15 + self.compiler.DetectAll(AMBuild)
1.16 +
1.17 + #Set up defines
1.18 + cxx = self.compiler.cxx
1.19 + if isinstance(cxx, Cpp.CompatGCC):
1.20 + if isinstance(cxx, Cpp.GCC):
1.21 + self.vendor = 'gcc'
1.22 + elif isinstance(cxx, Cpp.Clang):
1.23 + self.vendor = 'clang'
1.24 + self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp')
1.25 + self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp')
1.26 + self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf')
1.27 + self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf')
1.28 + self.compiler.AddToListVar('CFLAGS', '-pipe')
1.29 + self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing')
1.30 + if (self.vendor == 'gcc' and cxx.majorVersion >= 4) or self.vendor == 'clang':
1.31 + self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden')
1.32 + self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden')
1.33 + self.compiler.AddToListVar('CFLAGS', '-Wall')
1.34 + self.compiler.AddToListVar('CFLAGS', '-Werror')
1.35 + self.compiler.AddToListVar('CFLAGS', '-Wno-switch')
1.36 +
1.37 + if AMBuild.options.arch == 'x86':
1.38 + self.compiler.AddToListVar('CFLAGS', '-m32')
1.39 + self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
1.40 + elif AMBuild.options.arch == 'x64':
1.41 + self.compiler.AddToListVar('CFLAGS', '-m64')
1.42 + self.compiler.AddToListVar('POSTLINKFLAGS', '-m64')
1.43 + elif AMBuild.options.arch:
1.44 + raise Exception('Unknown architecture: {0}'.format(AMBuild.options.arch))
1.45 +
1.46 + # Disable some stuff we don't use, that gives us better binary
1.47 + # compatibility on Linux.
1.48 + self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
1.49 + self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti')
1.50 + self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
1.51 +
1.52 + self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor')
1.53 + self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual')
1.54 +
1.55 + if (self.vendor == 'gcc' and cxx.majorVersion >= 4 and cxx.minorVersion >= 7) or \
1.56 + (self.vendor == 'clang' and cxx.majorVersion >= 3):
1.57 + self.compiler.AddToListVar('CXXFLAGS', '-Wno-delete-non-virtual-dtor')
1.58 + elif isinstance(cxx, Cpp.MSVC):
1.59 + self.vendor = 'msvc'
1.60 + if AMBuild.options.debug == '1':
1.61 + self.compiler.AddToListVar('CFLAGS', '/MTd')
1.62 + self.compiler.AddToListVar('POSTLINKFLAGS', '/NODEFAULTLIB:libcmt')
1.63 + else:
1.64 + self.compiler.AddToListVar('CFLAGS', '/MT')
1.65 + self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE')
1.66 + self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_WARNINGS')
1.67 + self.compiler.AddToListVar('CDEFINES', '_CRT_NONSTDC_NO_DEPRECATE')
1.68 + self.compiler.AddToListVar('CXXFLAGS', '/EHsc')
1.69 + self.compiler.AddToListVar('CXXFLAGS', '/GR-')
1.70 + self.compiler.AddToListVar('CFLAGS', '/W3')
1.71 + self.compiler.AddToListVar('CFLAGS', '/nologo')
1.72 + self.compiler.AddToListVar('CFLAGS', '/Zi')
1.73 + self.compiler.AddToListVar('CXXFLAGS', '/TP')
1.74 + self.compiler.AddToListVar('POSTLINKFLAGS', '/DEBUG')
1.75 +
1.76 + # if AMBuild.options.arch == 'x86':
1.77 + # self.compiler.AddToListVar('POSTLINKFLAGS', '/MACHINE:X86')
1.78 + # elif AMBuild.options.arch == 'x64':
1.79 + # self.compiler.AddToListVar('POSTLINKFLAGS', '/MACHINE:X64')
1.80 + # elif AMBuild.options.arch:
1.81 + # raise Exception('Unknown architecture: {0}'.format(AMBuild.options.arch))
1.82 +
1.83 + self.compiler.AddToListVar('POSTLINKFLAGS', 'kernel32.lib')
1.84 + self.compiler.AddToListVar('POSTLINKFLAGS', 'user32.lib')
1.85 + self.compiler.AddToListVar('POSTLINKFLAGS', 'gdi32.lib')
1.86 + self.compiler.AddToListVar('POSTLINKFLAGS', 'winspool.lib')
1.87 + self.compiler.AddToListVar('POSTLINKFLAGS', 'comdlg32.lib')
1.88 + self.compiler.AddToListVar('POSTLINKFLAGS', 'advapi32.lib')
1.89 + self.compiler.AddToListVar('POSTLINKFLAGS', 'shell32.lib')
1.90 + self.compiler.AddToListVar('POSTLINKFLAGS', 'ole32.lib')
1.91 + self.compiler.AddToListVar('POSTLINKFLAGS', 'oleaut32.lib')
1.92 + self.compiler.AddToListVar('POSTLINKFLAGS', 'uuid.lib')
1.93 + self.compiler.AddToListVar('POSTLINKFLAGS', 'odbc32.lib')
1.94 + self.compiler.AddToListVar('POSTLINKFLAGS', 'odbccp32.lib')
1.95 +
1.96 + #Optimization
1.97 + if AMBuild.options.opt == '1':
1.98 + self.compiler.AddToListVar('CDEFINES', 'NDEBUG')
1.99 + if self.vendor == 'gcc' or self.vendor == 'clang':
1.100 + self.compiler.AddToListVar('CFLAGS', '-O3')
1.101 + elif self.vendor == 'msvc':
1.102 + self.compiler.AddToListVar('CFLAGS', '/Ox')
1.103 + self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF')
1.104 + self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:REF')
1.105 +
1.106 + #Debugging
1.107 + if AMBuild.options.debug == '1':
1.108 + self.compiler.AddToListVar('CDEFINES', 'DEBUG')
1.109 + self.compiler.AddToListVar('CDEFINES', '_DEBUG')
1.110 + if self.vendor == 'gcc' or self.vendor == 'clang':
1.111 + self.compiler.AddToListVar('CFLAGS', '-g3')
1.112 + elif self.vendor == 'msvc':
1.113 + self.compiler.AddToListVar('CFLAGS', '/Od')
1.114 + self.compiler.AddToListVar('CFLAGS', '/RTC1')
1.115 +
1.116 + #Platform-specifics
1.117 + if AMBuild.target['platform'] == 'linux':
1.118 + self.compiler.AddToListVar('CDEFINES', '_LINUX')
1.119 + if self.vendor == 'gcc':
1.120 + self.compiler.AddToListVar('POSTLINKFLAGS', '-static-libgcc')
1.121 + if self.vendor == 'clang':
1.122 + self.compiler.AddToListVar('POSTLINKFLAGS', '-lgcc_eh')
1.123 + elif AMBuild.target['platform'] == 'darwin':
1.124 + self.compiler.AddToListVar('POSTLINKFLAGS', '-mmacosx-version-min=10.5')
1.125 + if AMBuild.options.arch == 'x86':
1.126 + self.compiler.AddToListVar('POSTLINKFLAGS', ['-arch', 'i386'])
1.127 + elif AMBuild.options.arch == 'x64':
1.128 + self.compiler.AddToListVar('POSTLINKFLAGS', ['-arch', 'x86_64'])
1.129 + self.compiler.AddToListVar('POSTLINKFLAGS', '-lstdc++')
1.130 +
1.131 + # For OS X dylib versioning
1.132 + import re
1.133 + productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r')
1.134 + productContents = productFile.read()
1.135 + productFile.close()
1.136 + m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
1.137 + if m == None:
1.138 + self.version = '1.0.0'
1.139 + else:
1.140 + major, minor, release = m.groups()
1.141 + self.version = '{0}.{1}.{2}'.format(major, minor, release)
1.142 + AMBuild.cache.CacheVariable('version', self.version)
1.143 +
1.144 + #Finish up
1.145 + self.compiler.ToConfig(AMBuild, 'compiler')
1.146 + AMBuild.cache.CacheVariable('vendor', self.vendor)
1.147 + self.targetMap = { }
1.148 + AMBuild.cache.CacheVariable('targetMap', self.targetMap)
1.149 + else:
1.150 + self.compiler.FromConfig(AMBuild, 'compiler')
1.151 + self.targetMap = AMBuild.cache['targetMap']
1.152 +
1.153 + def DefaultCompiler(self):
1.154 + return self.compiler.Clone()
1.155 +
1.156 + def JobMatters(self, jobname):
1.157 + file = sys._getframe().f_code.co_filename
1.158 + if AMBuild.mode == 'config':
1.159 + self.targetMap[jobname] = file
1.160 + return True
1.161 + if len(AMBuild.args) == 0:
1.162 + return True
1.163 + if not jobname in AMBuild.args:
1.164 + return False
1.165 +
1.166 +ke = KE()
1.167 +globals = {
1.168 + 'KE': ke
1.169 +}
1.170 +
1.171 +FileList = [
1.172 + ['src', 'AMBuild.library'],
1.173 + ['src', 'AMBuild.shell']
1.174 + ]
1.175 +
1.176 +for parts in FileList:
1.177 + AMBuild.Include(os.path.join(*parts), globals)
1.178 +