rts.py
来自「这是整套横扫千军3D版游戏的源码」· Python 代码 · 共 453 行 · 第 1/2 页
PY
453 行
else:
level = '0'
if int(level) == 0:
print "debugging NOT enabled,",
env['debug'] = 0
elif int(level) >= 1 and int(level) <= 3:
print "level", level, "debugging enabled,",
env['debug'] = level
# MinGW gdb chokes on the dwarf debugging format produced by '-ggdb',
# so use the more generic '-g' instead.
if env['platform'] == 'windows' or env['syncdebug']:
env.AppendUnique(CCFLAGS=['-g'])
else:
env.AppendUnique(CCFLAGS=['-ggdb'+level])
# We can't enable -Wall because that silently enables an order of
# initialization warning for initializers in constructors that
# can not be disabled. (and it takes days to fix them all in code)
env.AppendUnique(CCFLAGS=[
'-Wchar-subscripts',
'-Wformat=2',
'-Winit-self',
'-Wimplicit',
'-Wmissing-braces',
'-Wparentheses',
'-Wsequence-point',
'-Wreturn-type',
'-Wswitch',
'-Wtrigraphs',
'-Wunused',
'-Wuninitialized',
'-Wunknown-pragmas'
])
if not args.has_key('debugdefines') or not args['debugdefines']:
env.AppendUnique(CPPDEFINES=['DEBUG', '_DEBUG'])
else:
env.AppendUnique(CPPDEFINES=['NDEBUG'])
else:
print "\ninvalid debug option, must be one of: yes, true, no, false, 0, 1, 2, 3."
env.Exit(1)
# optimize?
if args.has_key('optimize'):
level = args['optimize']
if level == 'no' or level == 'false': level = '0'
elif level == 'yes' or level == 'true': level = '2'
else:
if env['debug']: level = '0'
else: level = '2'
if level == 's' or level == 'size' or (int(level) >= 1 and int(level) <= 3):
print "level", level, "optimizing enabled"
env['optimize'] = level
#archflags = detect.processor(gcc_version >= ['3','4','0'])
# -fstrict-aliasing causes constructs like:
# float f = 10.0f; int x = *(int*)&f;
# to break.
# Since those constructs are used in the netcode and MathTest code, we disable the optimization.
env.AppendUnique(CCFLAGS=['-O'+level, '-pipe', '-fno-strict-aliasing'])
elif int(level) == 0:
print "optimizing NOT enabled",
env['optimize'] = 0
else:
print "\ninvalid optimize option, must be one of: yes, true, no, false, 0, 1, 2, 3, s, size."
env.Exit(1)
# Generate profiling information? (for profile directed optimization)
bool_opt('profile_generate', False)
if env['profile_generate']:
print "build will generate profiling information"
env.AppendUnique(CCFLAGS=['-fprofile-generate'], LINKFLAGS=['-fprofile-generate'])
# Use profiling information? (for profile directed optimization)
bool_opt('profile_use', False)
if env['profile_use']:
print "build will use profiling information"
env.AppendUnique(CCFLAGS=['-fprofile-use'], LINKFLAGS=['-fprofile-use'])
# Must come before the '-fvisibility=hidden' code.
bool_opt('syncdebug', False)
bool_opt('synccheck', True)
if env['syncdebug'] and env['synccheck']:
print "syncdebug and synccheck are mutually exclusive. Please choose one."
env.Exit(1)
string_opt('fpmath', '387')
# If sync debugger is on, disable inlining, as it makes it much harder to follow backtraces.
if env['syncdebug']:
# Disable all possible inlining, just to be sure.
env['CCFLAGS'] += ['-fno-default-inline', '-fno-inline', '-fno-inline-functions', '-fno-inline-functions-called-once']
# It seems only gcc 4.0 and higher supports this.
if gcc_version >= ['4','0','0'] and env['platform'] != 'windows':
env['CCFLAGS'] += ['-fvisibility=hidden']
# Allow easy switching between 387 and SSE fpmath.
if env['fpmath']:
env['CCFLAGS'] += ['-mfpmath='+env['fpmath']]
if env['fpmath'] == 'sse':
print "WARNING: SSE math vs X87 math is unsynced!"
print "WARNING: Do not go online with the binary you are currently building!"
env['CCFLAGS'] += ['-msse', '-msse2']
env['CXXFLAGS'] = env['CCFLAGS']
# Do not do this anymore because it may severely mess up our carefully selected options.
# Print a warning and ignore them instead.
# fall back to environment variables if neither debug nor optimize options are present
if not args.has_key('debug') and not args.has_key('optimize'):
if os.environ.has_key('CFLAGS'):
#print "using CFLAGS:", os.environ['CFLAGS']
#env['CCFLAGS'] = SCons.Util.CLVar(os.environ['CFLAGS'])
print "WARNING: attempt to use environment CFLAGS has been ignored."
if os.environ.has_key('CXXFLAGS'):
#print "using CXXFLAGS:", os.environ['CXXFLAGS']
#env['CXXFLAGS'] = SCons.Util.CLVar(os.environ['CXXFLAGS'])
print "WARNING: attempt to use environment CXXFLAGS has been ignored."
#else:
# env['CXXFLAGS'] = env['CCFLAGS']
bool_opt('strip', False)
bool_opt('disable_avi', env['platform'] != 'windows')
bool_opt('use_tcmalloc', False)
bool_opt('use_mmgr', False)
bool_opt('dc_allowed', True)
string_opt('prefix', '/usr/local')
string_opt('installprefix', '$prefix')
string_opt('datadir', 'share/games/spring')
string_opt('bindir', 'games')
string_opt('libdir', 'lib/spring')
string_opt('cachedir', None)
# Make a list of preprocessor defines.
env.AppendUnique(CPPDEFINES = ['_REENTRANT', '_SZ_ONE_DIRECTORY'])
spring_defines = []
# Add define specifying type of floating point math to use.
if env['fpmath']:
if env['fpmath'] == 'sse':
spring_defines += ['STREFLOP_SSE']
if env['fpmath'] == '387':
spring_defines += ['STREFLOP_X87']
# Add/remove SYNCDEBUG to enable/disable sync debugging.
if env['syncdebug']:
spring_defines += ['SYNCDEBUG']
if env['synccheck']:
spring_defines += ['SYNCCHECK']
# Don't define this: it causes a full recompile when you change it, even though it is only used in Main.cpp,
# and some AIs maybe. Just make exceptions in SConstruct.
#defines += ['SPRING_DATADIR="\\"'+env['datadir']+'\\""']
if env['disable_avi'] : spring_defines += ['NO_AVI']
if env['use_mmgr'] : spring_defines += ['USE_MMGR']
if env['dc_allowed'] : spring_defines += ['DIRECT_CONTROL_ALLOWED']
env['spring_defines'] = spring_defines
stringarray_opt('cpppath', [])
stringarray_opt('libpath', [])
include_path = env['cpppath'] + ['rts', 'rts/System']
include_path += ['rts/lib/luabind', 'rts/lib/lua/include']
lib_path = env['libpath'] + ['rts/lib/streflop']
if env['platform'] == 'freebsd':
include_path += ['/usr/local/include', '/usr/X11R6/include', '/usr/X11R6/include/GL']
lib_path += ['/usr/local/lib', '/usr/X11R6/lib']
env.AppendUnique(CCFLAGS = ['-pthread'], CXXFLAGS = ['-pthread'])
elif env['platform'] == 'linux':
include_path += ['/usr/include', '/usr/include/GL']
env.AppendUnique(CCFLAGS = ['-pthread'], CXXFLAGS = ['-pthread'], LINKFLAGS = ['-Wl,-E'])
elif env['platform'] == 'darwin':
include_path += ['/usr/include', '/usr/local/include', '/opt/local/include', '/usr/X11R6/include']
lib_path += ['/opt/local/lib', '/usr/local/lib']
env['SHLINKFLAGS'] = '$LINKFLAGS -dynamic'
env['SHLIBSUFFIX'] = '.dylib'
elif env['platform'] == 'windows':
include_path += [os.path.join('mingwlibs', 'include')]
lib_path += [os.path.join('mingwlibs', 'lib')]
if os.environ.has_key('MINGDIR'):
include_path += [os.path.join(os.environ['MINGDIR'], 'include')]
lib_path += [os.path.join(os.environ['MINGDIR'], 'lib')]
else:
print 'ERROR: MINGDIR environment variable not set and MSVC build unsupported.'
print 'Set it to your Dev-Cpp or MinGW install directory (e.g. C:\\Dev-Cpp) and try again.'
env.Exit(1)
env.AppendUnique(CCFLAGS = ['-mthreads'], CXXFLAGS = ['-mthreads'], LINKFLAGS = ['-mwindows'])
# use '-pthreads' for Solaris, according to /usr/include/boost/config/requires_threads.hpp
env.AppendUnique(CPPPATH=include_path, LIBPATH=lib_path)
config.configure(env, conf_dir=os.path.join(env['builddir'], 'sconf_temp'))
env.AppendUnique(LIBS=['streflop'])
usropts.Save(usrcachefile, env)
intopts.Save(intcachefile, env)
# Substitute prefix in installprefix
env['installprefix'] = env.subst(env['installprefix'])
# Fix up some suffices for mingw crosscompile.
if env['platform'] == 'windows':
env['SHLIBSUFFIX'] = '.dll'
env['PROGSUFFIX'] = '.exe'
#Should we strip the exe?
if env.has_key('strip') and env['strip'] and not env['debug'] and not env['profile'] and not env.GetOption('clean'):
env['strip'] = True
else:
env['strip'] = False
#BuildDir support code
if env['builddir']:
for d in filelist.list_directories(env, 'rts'):
env.BuildDir(os.path.join(env['builddir'], d), d, duplicate = False)
for d in filelist.list_directories(env, 'AI'):
env.BuildDir(os.path.join(env['builddir'], d), d, duplicate = False)
#CacheDir support code
if env.has_key('cachedir') and env['cachedir']:
if not os.path.exists(env['cachedir']):
os.makedirs(env['cachedir'])
env.CacheDir(env['cachedir'])
fix_windows_spawn(env)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?