This commit is contained in:
Nicholas Hastings 2011-04-25 19:05:48 -04:00
commit f2fedbc3e6
14 changed files with 26 additions and 22 deletions

View File

@ -69,15 +69,18 @@ class SM:
#Set up defines #Set up defines
cxx = self.compiler.cxx cxx = self.compiler.cxx
if isinstance(cxx, Cpp.CompatGCC):
if isinstance(cxx, Cpp.GCC): if isinstance(cxx, Cpp.GCC):
self.vendor = 'gcc' self.vendor = 'gcc'
elif isinstance(cxx, Cpp.Clang):
self.vendor = 'clang'
self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp') self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp')
self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp') self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp')
self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf') self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf')
self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf') self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf')
self.compiler.AddToListVar('CFLAGS', '-pipe') self.compiler.AddToListVar('CFLAGS', '-pipe')
self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing') self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing')
if cxx.majorVersion >= 4: if (self.vendor == 'gcc' and cxx.majorVersion >= 4) or self.vendor == 'clang':
self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden') self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden')
self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden') self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden')
self.compiler.AddToListVar('CFLAGS', '-Wall') self.compiler.AddToListVar('CFLAGS', '-Wall')
@ -85,16 +88,18 @@ class SM:
self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized') self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized')
self.compiler.AddToListVar('CFLAGS', '-Wno-unused') self.compiler.AddToListVar('CFLAGS', '-Wno-unused')
self.compiler.AddToListVar('CFLAGS', '-Wno-switch') self.compiler.AddToListVar('CFLAGS', '-Wno-switch')
self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
self.compiler.AddToListVar('CFLAGS', '-msse') self.compiler.AddToListVar('CFLAGS', '-msse')
self.compiler.AddToListVar('CFLAGS', '-m32') self.compiler.AddToListVar('CFLAGS', '-m32')
self.compiler.AddToListVar('POSTLINKFLAGS', '-m32') self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
self.compiler.AddToListVar('CFLAGS', '-static-libgcc')
self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions') self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti') self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti')
self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics') self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor') self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual')
self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H') self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H')
if self.vendor == 'gcc':
self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
self.compiler.AddToListVar('CFLAGS', '-static-libgcc')
elif isinstance(cxx, Cpp.MSVC): elif isinstance(cxx, Cpp.MSVC):
self.vendor = 'msvc' self.vendor = 'msvc'
if AMBuild.options.debug == '1': if AMBuild.options.debug == '1':
@ -130,7 +135,7 @@ class SM:
#Optimization #Optimization
if AMBuild.options.opt == '1': if AMBuild.options.opt == '1':
self.compiler.AddToListVar('CDEFINES', 'NDEBUG') self.compiler.AddToListVar('CDEFINES', 'NDEBUG')
if self.vendor == 'gcc': if self.vendor == 'gcc' or self.vendor == 'clang':
self.compiler.AddToListVar('CFLAGS', '-O3') self.compiler.AddToListVar('CFLAGS', '-O3')
elif self.vendor == 'msvc': elif self.vendor == 'msvc':
self.compiler.AddToListVar('CFLAGS', '/Ox') self.compiler.AddToListVar('CFLAGS', '/Ox')
@ -141,7 +146,7 @@ class SM:
if AMBuild.options.debug == '1': if AMBuild.options.debug == '1':
self.compiler.AddToListVar('CDEFINES', 'DEBUG') self.compiler.AddToListVar('CDEFINES', 'DEBUG')
self.compiler.AddToListVar('CDEFINES', '_DEBUG') self.compiler.AddToListVar('CDEFINES', '_DEBUG')
if self.vendor == 'gcc': if self.vendor == 'gcc' or self.vendor == 'clang':
self.compiler.AddToListVar('CFLAGS', '-g3') self.compiler.AddToListVar('CFLAGS', '-g3')
elif self.vendor == 'msvc': elif self.vendor == 'msvc':
self.compiler.AddToListVar('CFLAGS', '/Od') self.compiler.AddToListVar('CFLAGS', '/Od')

View File

@ -410,7 +410,7 @@ size_t LibrarySystem::GetFileFromPath(char *buffer, size_t maxlength, const char
size_t length = strlen(path); size_t length = strlen(path);
for (size_t i = length - 1; for (size_t i = length - 1;
i >= 0 && i <= length - 1; i <= length - 1;
i--) i--)
{ {
if (path[i] == '/' if (path[i] == '/'

View File

@ -872,7 +872,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
ptr = save_ptr; ptr = save_ptr;
/* Lastly, strip ending whitespace off */ /* Lastly, strip ending whitespace off */
for (size_t i=len-1; i>=0 && i<len; i--) for (size_t i=len-1; i<len; i--)
{ {
if (g_ws_chartable[(unsigned char)ptr[i]]) if (g_ws_chartable[(unsigned char)ptr[i]])
{ {

View File

@ -37,7 +37,6 @@
template <typename T> template <typename T>
class FastLink class FastLink
{ {
friend class iterator;
public: public:
struct FastLinkNode struct FastLinkNode
{ {

View File

@ -142,7 +142,7 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late
/* Store name of game directory by itself */ /* Store name of game directory by itself */
size_t len = strlen(gamepath); size_t len = strlen(gamepath);
for (size_t i = len - 1; i >= 0; i--) for (size_t i = len - 1; i < len; i--)
{ {
if (gamepath[i] == PLATFORM_SEP_CHAR) if (gamepath[i] == PLATFORM_SEP_CHAR)
{ {

View File

@ -103,7 +103,7 @@ CallConvention CallWrapper::GetCallConvention()
const PassEncode *CallWrapper::GetParamInfo(unsigned int num) const PassEncode *CallWrapper::GetParamInfo(unsigned int num)
{ {
if (num + 1 > GetParamCount() || num < 0) if (num + 1 > GetParamCount())
{ {
return NULL; return NULL;
} }
@ -170,7 +170,7 @@ SourceHook::ProtoInfo::CallConvention CallWrapper::GetSHCallConvention()
const SourceHook::PassInfo * CallWrapper::GetSHParamInfo(unsigned int num) const SourceHook::PassInfo * CallWrapper::GetSHParamInfo(unsigned int num)
{ {
if (num + 1 > GetParamCount() || num < 0) if (num + 1 > GetParamCount())
{ {
return NULL; return NULL;
} }

View File

@ -217,7 +217,7 @@ IResultRow *MyBoundResults::FetchRow()
{ {
if (mysql_stmt_bind_result(m_stmt, m_bind) != 0) if (mysql_stmt_bind_result(m_stmt, m_bind) != 0)
{ {
return false; return NULL;
} }
m_bUpdatedBinds = false; m_bUpdatedBinds = false;
} }

View File

@ -10,7 +10,7 @@ for i in SM.sdkInfo:
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit')) compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit', 'x86')) compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit', 'x86'))
if compiler.cc.name == 'gcc': if compiler.cc.name == 'gcc' or compiler.cc.name == 'clang':
compiler['CFLAGS'].append('-Wno-parentheses') compiler['CFLAGS'].append('-Wno-parentheses')
if i != 'ep1': if i != 'ep1':

View File

@ -167,7 +167,7 @@ IDatabase *SqDriver::Connect(const DatabaseInfo *info, bool persistent, char *er
/* Chop any filename off */ /* Chop any filename off */
for (size_t i = len-1; for (size_t i = len-1;
i >= 0 && i <= len-1; i <= len-1;
i--) i--)
{ {
if (IsPathSepChar(path[i])) if (IsPathSepChar(path[i]))

View File

@ -3,7 +3,7 @@ import os
sdk = SM.sdkInfo['ep2v'] sdk = SM.sdkInfo['ep2v']
compiler = SM.DefaultHL2Compiler('extensions/tf2', 'ep2v') compiler = SM.DefaultHL2Compiler('extensions/tf2', 'ep2v')
if compiler.cc.name == 'gcc': if compiler.cc.name == 'gcc' or compiler.cc.name == 'clang':
compiler['CFLAGS'].append('-Wno-parentheses') compiler['CFLAGS'].append('-Wno-parentheses')
name = 'game.tf2.ext.' + sdk['ext'] name = 'game.tf2.ext.' + sdk['ext']

View File

@ -293,7 +293,7 @@ DLL_EXPORT void *CreateInterface(const char *iface, int *ret)
} }
size_t len = strlen(thisfile); size_t len = strlen(thisfile);
for (size_t iter=len-1; iter>=0 && iter<len; iter--) for (size_t iter=len-1; iter<len; iter--)
{ {
if (IsPathSepChar(thisfile[iter])) if (IsPathSepChar(thisfile[iter]))
{ {

View File

@ -7,7 +7,7 @@ compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'sourc
compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'compiler')) compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'compiler'))
compiler['CINCLUDES'].append(os.path.join(AMBuild.outputFolder, 'includes')) compiler['CINCLUDES'].append(os.path.join(AMBuild.outputFolder, 'includes'))
if compiler.cc.name == 'gcc': if compiler.cc.name == 'gcc' or compiler.cc.name == 'clang':
compiler['CFLAGS'].extend(['-Wno-parentheses', '-Wno-format']) compiler['CFLAGS'].extend(['-Wno-parentheses', '-Wno-format'])
if AMBuild.target['platform'] == 'linux': if AMBuild.target['platform'] == 'linux':
compiler['POSTLINKFLAGS'].extend(['-lgcc', '-lm']) compiler['POSTLINKFLAGS'].extend(['-lgcc', '-lm'])

View File

@ -579,7 +579,7 @@ static void inst_binary_name(char *binfname)
binptr = NULL; binptr = NULL;
len = strlen(binfname); len = strlen(binfname);
for (i = len - 1; i >= 0 && i < len; i--) for (i = len - 1; i < len; i--)
{ {
if (binfname[i] == '/' if (binfname[i] == '/'
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32

View File

@ -98,7 +98,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file
size_t len; size_t len;
len = strlen(file); len = strlen(file);
for (size_t i = len - 1; i >= 0 && i < len; i--) for (size_t i = len - 1; i < len; i--)
{ {
if (file[i] == '/' if (file[i] == '/'
#if defined WIN32 #if defined WIN32