new wscript using compiler flags dictionary and very basic provision for msvc
This commit is contained in:
parent
58148819d5
commit
8568cb9d8b
171
wscript
171
wscript
@ -9,6 +9,103 @@ import sys
|
||||
import platform as PLATFORM
|
||||
from waflib.Tools import winres
|
||||
|
||||
compiler_flags_dictionaries= {
|
||||
'gcc' : {
|
||||
# Flags required when building a debug build
|
||||
'debuggable' : [ '-O0', '-g' ],
|
||||
# Flags required for the linker (if any) when building a debug build
|
||||
'linker-debuggable' : '',
|
||||
# Flags required when building a non-debug optimized build
|
||||
'nondebuggable' : '-DNDEBUG',
|
||||
# Flags required to enable profiling at runtime
|
||||
'profile' : '-pg',
|
||||
# Flags required to disable warnings about unused arguments to function calls
|
||||
'silence-unused-arguments' : '',
|
||||
# Flags required to use SSE unit for general math
|
||||
'sse' : '-msse',
|
||||
# Flags required to use SSE unit for floating point math
|
||||
'fpmath-sse' : '-mfpmath=sse',
|
||||
# Flags required to use XMM Intrinsics
|
||||
'xmmintrinsics' : '-DUSE_XMMINTRIN',
|
||||
# Flags to use posix pipes between compiler stages
|
||||
'pipe' : '-pipe',
|
||||
# Flags for maximally optimized build
|
||||
'full-optimization' : [ '-O3', '-fomit-frame-pointer', '-ffast-math', '-fstrength-reduce', ],
|
||||
# Flag to ensure that compiler error output includes column/line numbers
|
||||
'show-column' : '-fshow-column',
|
||||
# Flags required to build for x86 only (OS X feature)
|
||||
'generic-x86' : '',
|
||||
# Flags required to build for PowerPC only (OS X feature)
|
||||
'generic-ppc' : '',
|
||||
# All flags required to get basic warnings to be generated by the compiler
|
||||
'basic-warnings' : [ '-Wall', '-Wpointer-arith', '-Wcast-qual', '-Wcast-align', '-Wno-unused-parameter' ],
|
||||
# Any additional flags for warnings that are specific to C (not C++)
|
||||
'extra-c-warnings' : [ '-Wstrict-prototypes', '-Wmissing-prototypes' ],
|
||||
# Any additional flags for warnings that are specific to C++ (not C)
|
||||
'extra-cxx-warnings' : [ '-Woverloaded-virtual', '-Wno-unused-local-typedefs' ],
|
||||
# Flags used for "strict" compilation, C and C++ (i.e. compiler will warn about language issues)
|
||||
'strict' : ['-Wall', '-Wcast-align', '-Wextra', '-Wwrite-strings', '-Wunsafe-loop-optimizations', '-Wlogical-op' ],
|
||||
# Flags used for "strict" compilation, C only (i.e. compiler will warn about language issues)
|
||||
'c-strict' : ['-std=c99', '-pedantic', '-Wshadow'],
|
||||
# Flags used for "strict" compilation, C++ only (i.e. compiler will warn about language issues)
|
||||
'cxx-strict' : [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual', '-fstrict-overflow' ],
|
||||
# Flags required for whatever consider the strictest possible compilation
|
||||
'ultra-strict' : ['-Wredundant-decls', '-Wstrict-prototypes', '-Wmissing-prototypes'],
|
||||
# Flag to turn on C99 compliance by itself
|
||||
'c99': '-std=c99',
|
||||
},
|
||||
'msvc' : {
|
||||
'debuggable' : ['/Od', '/Zi', '/MTd'],
|
||||
'linker-debuggable' : ['/DEBUG' ],
|
||||
'nondebuggable' : [ '/MD', '-DNDEBUG' ],
|
||||
'profile' : '',
|
||||
'silence-unused-arguments' : '',
|
||||
'sse' : '',
|
||||
'fpmath-see' : '',
|
||||
'xmmintrinsics' : '',
|
||||
'pipe' : '',
|
||||
'full-optimization' : '',
|
||||
'no-frame-pointer' : '',
|
||||
'fast-math' : '',
|
||||
'strength-reduce' : '',
|
||||
'show-column' : '',
|
||||
'generic-x86' : '',
|
||||
'generic-ppc' : '',
|
||||
'basic-warnings' : '',
|
||||
'extra-c-warnings' : '',
|
||||
'extra-cxx-warnings' : '',
|
||||
'ultra-strict' : '',
|
||||
'c-strict' : '',
|
||||
'cxx-strict' : '',
|
||||
'strict' : '',
|
||||
'c99': '-TP',
|
||||
},
|
||||
}
|
||||
|
||||
# Copy, edit and insert variants on gcc dict for gcc-darwin and clang
|
||||
|
||||
gcc_darwin_dict = compiler_flags_dictionaries['gcc'].copy()
|
||||
gcc_darwin_dict['extra-cxx-warnings'] = [ '-Woverloaded-virtual' ]
|
||||
gcc_darwin_dict['cxx-strict'] = [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual' ]
|
||||
gcc_darwin_dict['strict'] = ['-Wall', '-Wcast-align', '-Wextra', '-Wwrite-strings' ]
|
||||
gcc_darwin_dict['generic-x86'] = [ '-arch', 'i386' ]
|
||||
gcc_darwin_dict['generic-ppc'] = [ '-arch', 'ppc' ]
|
||||
compiler_flags_dictionaries['gcc-darwin'] = gcc_darwin_dict;
|
||||
|
||||
clang_dict = compiler_flags_dictionaries['gcc'].copy();
|
||||
clang_dict['sse'] = ''
|
||||
clang_dict['fpmath-sse'] = ''
|
||||
clang_dict['xmmintrinsics'] = ''
|
||||
clang_dict['silence-unused-arguments'] = '-Qunused-arguments'
|
||||
clang_dict['extra-cxx-warnings'] = [ '-Woverloaded-virtual', '-Wno-mismatched-tags' ]
|
||||
clang_dict['cxx-strict'] = [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual', '-fstrict-overflow' ]
|
||||
clang_dict['strict'] = ['-Wall', '-Wcast-align', '-Wextra', '-Wwrite-strings' ]
|
||||
compiler_flags_dictionaries['clang'] = clang_dict;
|
||||
|
||||
clang_darwin_dict = compiler_flags_dictionaries['clang'].copy();
|
||||
clang_darwin_dict['cxx-strict'] = [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual', ]
|
||||
compiler_flags_dictionaries['clang-darwin'] = clang_darwin_dict;
|
||||
|
||||
def fetch_git_revision ():
|
||||
cmd = "git describe HEAD"
|
||||
output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
|
||||
@ -127,7 +224,6 @@ def set_compiler_flags (conf,opt):
|
||||
#
|
||||
# Compiler flags and other system-dependent stuff
|
||||
#
|
||||
|
||||
build_host_supports_sse = False
|
||||
|
||||
# Flags necessary for building
|
||||
@ -158,6 +254,25 @@ int main() { return 0; }''',
|
||||
execute = False,
|
||||
msg = 'Checking for clang')
|
||||
|
||||
if is_clang:
|
||||
if platform == darwin:
|
||||
compiler_name = 'clang-darwin'
|
||||
else:
|
||||
compiler_name = 'clang'
|
||||
elif conf.env['CC'][0].find ('msvc') != -1:
|
||||
compiler_name = 'msvc'
|
||||
else:
|
||||
if platform == 'darwin':
|
||||
compiler_name = 'gcc-darwin'
|
||||
else:
|
||||
compiler_name = 'gcc'
|
||||
|
||||
print "Compiler name is ", compiler_name, "\n"
|
||||
|
||||
flags_dict = compiler_flags_dictionaries[compiler_name]
|
||||
|
||||
autowaf.set_basic_compiler_flags (conf,flags_dict)
|
||||
|
||||
if conf.options.asan:
|
||||
conf.check_cxx(cxxflags=["-fsanitize=address", "-fno-omit-frame-pointer"], linkflags=["-fsanitize=address"])
|
||||
cxx_flags.append('-fsanitize=address')
|
||||
@ -165,7 +280,7 @@ int main() { return 0; }''',
|
||||
linker_flags.append('-fsanitize=address')
|
||||
|
||||
if opt.gprofile:
|
||||
debug_flags = [ '-pg' ]
|
||||
debug_flags = [ flags_dict['profile'] ]
|
||||
|
||||
# OSX
|
||||
if platform == 'darwin':
|
||||
@ -270,8 +385,8 @@ int main() { return 0; }''',
|
||||
elif cpu == "i686":
|
||||
compiler_flags.append ("-march=i686")
|
||||
|
||||
if not is_clang and ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
|
||||
compiler_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
|
||||
if ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
|
||||
compiler_flags.extend ([ flags_dict['sse'], flags_dict['fpmath-sse'], flags_dict['xmmintrinsics'] ])
|
||||
|
||||
# end of processor-specific section
|
||||
|
||||
@ -347,7 +462,7 @@ int main() { return 0; }''',
|
||||
# prepend boiler plate optimization flags that work on all architectures
|
||||
#
|
||||
|
||||
optimization_flags[:0] = ["-pipe"]
|
||||
optimization_flags[:0] = [flags_dict['pipe']]
|
||||
|
||||
# don't prepend optimization flags if "-O<something>" is present
|
||||
prepend_opt_flags = True
|
||||
@ -357,15 +472,10 @@ int main() { return 0; }''',
|
||||
break
|
||||
|
||||
if prepend_opt_flags:
|
||||
optimization_flags[:0] = [
|
||||
"-O3",
|
||||
"-fomit-frame-pointer",
|
||||
"-ffast-math",
|
||||
"-fstrength-reduce"
|
||||
]
|
||||
optimization_flags[:0] = [ flags_dict['full-optimization'] ]
|
||||
|
||||
if opt.debug_symbols:
|
||||
optimization_flags += [ '-g' ]
|
||||
optimization_flags += [ flags_dict['debuggable'] ]
|
||||
|
||||
if opt.stl_debug:
|
||||
cxx_flags.append("-D_GLIBCXX_DEBUG")
|
||||
@ -378,26 +488,21 @@ int main() { return 0; }''',
|
||||
compiler_flags.append('-DDEBUG_DENORMAL_EXCEPTION')
|
||||
|
||||
if opt.generic:
|
||||
compiler_flags.extend(('-arch', 'i386'))
|
||||
linker_flags.extend(('-arch', 'i386'))
|
||||
compiler_flags.extend(flags_dict['generic-x86'])
|
||||
linker_flags.extend(flags_dict['generic-x86'])
|
||||
|
||||
if opt.ppc:
|
||||
compiler_flags.extend(('-arch', 'ppc'))
|
||||
linker_flags.extend(('-arch', 'ppc'))
|
||||
compiler_flags.extend(flags_dict['generic-ppc'])
|
||||
linker_flags.extend(flags_dict['generic-ppc'])
|
||||
|
||||
#
|
||||
# warnings flags
|
||||
#
|
||||
|
||||
compiler_flags.extend(
|
||||
('-Wall', '-Wpointer-arith', '-Wcast-qual', '-Wcast-align', '-Wno-unused-parameter'))
|
||||
compiler_flags.extend(flags_dict['basic-warnings'])
|
||||
|
||||
c_flags.extend(('-Wstrict-prototypes', '-Wmissing-prototypes'))
|
||||
cxx_flags.append('-Woverloaded-virtual')
|
||||
if (not is_clang and not platform == "darwin"):
|
||||
cxx_flags.append('-Wno-unused-local-typedefs')
|
||||
if is_clang:
|
||||
cxx_flags.append('-Wno-mismatched-tags')
|
||||
c_flags.extend(flags_dict['extra-c-warnings'])
|
||||
cxx_flags.extend (flags_dict['extra-cxx-warnings'])
|
||||
|
||||
#
|
||||
# more boilerplate
|
||||
@ -461,7 +566,7 @@ def options(opt):
|
||||
opt.add_option('--depstack-root', type='string', default='~', dest='depstack_root',
|
||||
help='Directory/folder where dependency stack trees (gtk, a3) can be found (defaults to ~)')
|
||||
opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
|
||||
help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,tiger,leopard,mingw]')
|
||||
help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,tiger,leopard,mingw,msvc]')
|
||||
opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
|
||||
help='Build runtime checked assembler code (default)')
|
||||
opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization')
|
||||
@ -550,6 +655,11 @@ def configure(conf):
|
||||
if Options.options.dist_target == 'mingw':
|
||||
conf.load('winres')
|
||||
|
||||
if Options.options.dist_target == 'msvc':
|
||||
conf.env['MSVC_VERSIONS'] = ['msvc 10.0', 'msvc 9.0', 'msvc 8.0', 'msvc 7.1', 'msvc 7.0', 'msvc 6.0', ]
|
||||
conf.env['MSVC_TARGETS'] = ['x64']
|
||||
conf.load('msvc')
|
||||
|
||||
conf.env['VERSION'] = VERSION
|
||||
conf.env['MAJOR'] = MAJOR
|
||||
conf.env['MINOR'] = MINOR
|
||||
@ -735,6 +845,17 @@ def configure(conf):
|
||||
conf.env.append_value('CFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
|
||||
conf.env.append_value('CXXFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
|
||||
|
||||
if Options.options.dist_target == 'msvc':
|
||||
conf.env.append_value('CFLAGS', '-DPLATFORM_WINDOWS')
|
||||
conf.env.append_value('CFLAGS', '-DCOMPILER_MSVC')
|
||||
conf.env.append_value('CXXFLAGS', '-DPLATFORM_WINDOWS')
|
||||
conf.env.append_value('CXXFLAGS', '-DCOMPILER_MSVC')
|
||||
# work around GdkDrawable BitBlt performance issue on windows
|
||||
# see http://gareus.org/wiki/ardour_windows_gdk_and_cairo
|
||||
conf.env.append_value('CFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
|
||||
conf.env.append_value('CXXFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
|
||||
# MORE STUFF PROBABLY NEEDED HERE
|
||||
|
||||
# Tell everyone that this is a waf build
|
||||
|
||||
conf.env.append_value('CFLAGS', '-DWAF_BUILD')
|
||||
|
Loading…
Reference in New Issue
Block a user