From 9409043c58bbcac37b439032fc61aff2a0b0d543 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 27 Feb 2008 17:36:28 +0900 Subject: scons: Move common code to a separate file. --- common.py | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 common.py (limited to 'common.py') diff --git a/common.py b/common.py new file mode 100644 index 0000000000..e2650d6c8e --- /dev/null +++ b/common.py @@ -0,0 +1,113 @@ +####################################################################### +# Common SCons code + +import os +import os.path +import sys +import platform as _platform + + +####################################################################### +# Defaults + +_platform_map = { + 'linux2': 'linux', + 'win32': 'winddk', +} + +default_platform = sys.platform +default_platform = _platform_map.get(default_platform, default_platform) + +_machine_map = { + 'x86': 'x86', + 'i386': 'x86', + 'i486': 'x86', + 'i586': 'x86', + 'i686': 'x86', + 'x86_64': 'x86_64', +} +if 'PROCESSOR_ARCHITECTURE' in os.environ: + default_machine = os.environ['PROCESSOR_ARCHITECTURE'] +else: + default_machine = _platform.machine() +default_machine = _machine_map.get(default_machine, 'generic') + +if default_platform in ('linux', 'freebsd', 'darwin'): + default_dri = 'yes' +elif default_platform in ('winddk',): + default_dri = 'no' +else: + default_dri = 'no' + + +####################################################################### +# Common options + +def Options(): + from SCons.Options import Options + from SCons.Options.BoolOption import BoolOption + from SCons.Options.EnumOption import EnumOption + opts = Options('config.py') + opts.Add(BoolOption('debug', 'build debug version', 'no')) + opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, + allowed_values=('generic', 'x86', 'x86_64'))) + opts.Add(EnumOption('platform', 'target platform', default_platform, + allowed_values=('linux', 'cell', 'winddk'))) + opts.Add(BoolOption('llvm', 'use LLVM', 'no')) + opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) + return opts + + +####################################################################### +# Convenience Library Builder +# based on the stock StaticLibrary and SharedLibrary builders + +import SCons.Action +import SCons.Builder + +def createConvenienceLibBuilder(env): + """This is a utility function that creates the ConvenienceLibrary + Builder in an Environment if it is not there already. + + If it is already there, we return the existing one. + """ + + try: + convenience_lib = env['BUILDERS']['ConvenienceLibrary'] + except KeyError: + action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ] + if env.Detect('ranlib'): + ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR") + action_list.append(ranlib_action) + + convenience_lib = SCons.Builder.Builder(action = action_list, + emitter = '$LIBEMITTER', + prefix = '$LIBPREFIX', + suffix = '$LIBSUFFIX', + src_suffix = '$SHOBJSUFFIX', + src_builder = 'SharedObject') + env['BUILDERS']['ConvenienceLibrary'] = convenience_lib + env['BUILDERS']['Library'] = convenience_lib + + return convenience_lib + + +####################################################################### +# Build + +def make_build_dir(env): + # Put build output in a separate dir, which depends on the current configuration + # See also http://www.scons.org/wiki/AdvancedBuildExample + build_topdir = 'build' + build_subdir = env['platform'] + if env['dri']: + build_subdir += "-dri" + if env['llvm']: + build_subdir += "-llvm" + if env['machine'] != 'generic': + build_subdir += '-' + env['machine'] + if env['debug']: + build_subdir += "-debug" + build_dir = os.path.join(build_topdir, build_subdir) + return build_dir + -- cgit v1.2.3 From 7a678556d4311168ac1dacdd613eb7b94684e443 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 27 Feb 2008 20:13:16 +0900 Subject: scons: Place the .sconsign file on the builddir too. To avoid issues with different scons versions building the same source file --- common.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common.py') diff --git a/common.py b/common.py index e2650d6c8e..b65ed7eaaa 100644 --- a/common.py +++ b/common.py @@ -109,5 +109,8 @@ def make_build_dir(env): if env['debug']: build_subdir += "-debug" build_dir = os.path.join(build_topdir, build_subdir) + # Place the .sconsign file on the builddir too, to avoid issues with different scons + # versions building the same source file + env.SConsignFile(os.path.join(build_dir, '.sconsign')) return build_dir -- cgit v1.2.3 From 13174c195e057f443b23df788ea0c10251942189 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 Mar 2008 18:52:37 +0100 Subject: scons: Make command line arguments effective again. --- SConstruct | 6 ++---- common.py | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'common.py') diff --git a/SConstruct b/SConstruct index 8013e7c3b2..6f95d123ff 100644 --- a/SConstruct +++ b/SConstruct @@ -33,18 +33,16 @@ if common.default_platform in ('linux', 'freebsd', 'darwin'): default_statetrackers = 'mesa' default_drivers = 'softpipe,failover,i915simple,i965simple' default_winsys = 'xlib' - default_dri = 'yes' elif common.default_platform in ('winddk',): default_statetrackers = 'none' default_drivers = 'softpipe,i915simple' default_winsys = 'none' - default_dri = 'no' else: default_drivers = 'all' default_winsys = 'all' - default_dri = 'no' -opts = common.Options() +opts = Options('config.py') +common.AddOptions(opts) opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers, ['mesa'])) opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers, diff --git a/common.py b/common.py index b65ed7eaaa..1e5f7dad39 100644 --- a/common.py +++ b/common.py @@ -43,11 +43,9 @@ else: ####################################################################### # Common options -def Options(): - from SCons.Options import Options +def AddOptions(opts): from SCons.Options.BoolOption import BoolOption from SCons.Options.EnumOption import EnumOption - opts = Options('config.py') opts.Add(BoolOption('debug', 'build debug version', 'no')) opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'x86', 'x86_64'))) @@ -55,7 +53,6 @@ def Options(): allowed_values=('linux', 'cell', 'winddk'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) - return opts ####################################################################### -- cgit v1.2.3 From 5aa108214a21181406ec38a2fd5e82a279348f77 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 4 Mar 2008 14:29:27 +0100 Subject: scons: Preliminary code for quieting command lines. --- SConstruct | 7 +------ common.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'common.py') diff --git a/SConstruct b/SConstruct index 44ac0ad60d..6088128010 100644 --- a/SConstruct +++ b/SConstruct @@ -55,9 +55,6 @@ env = Environment( ENV = os.environ) Help(opts.GenerateHelpText(env)) -# for debugging -#print env.Dump() - # replicate options values in local variables debug = env['debug'] dri = env['dri'] @@ -87,6 +84,7 @@ Export([ # TODO: put the compiler specific settings in separate files # TODO: auto-detect as much as possible +common.generate(env) if platform == 'winddk': env.Tool('winddk', ['.']) @@ -219,9 +217,6 @@ if platform not in ('winddk',): 'Xfixes', ]) -# Convenience library support -common.createConvenienceLibBuilder(env) - Export('env') diff --git a/common.py b/common.py index 1e5f7dad39..b836a8b41d 100644 --- a/common.py +++ b/common.py @@ -47,6 +47,7 @@ def AddOptions(opts): from SCons.Options.BoolOption import BoolOption from SCons.Options.EnumOption import EnumOption opts.Add(BoolOption('debug', 'build debug version', 'no')) + #opts.Add(BoolOption('quiet', 'quiet command lines', 'no')) opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, @@ -55,6 +56,19 @@ def AddOptions(opts): opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) +####################################################################### +# Quiet command lines +# +# See also http://www.scons.org/wiki/HidingCommandLinesInOutput + +def quietCommandLines(env): + env['CCCOMSTR'] = "Compiling $SOURCE ..." + env['CXXCOMSTR'] = "Compiling $SOURCE ..." + env['ARCOMSTR'] = "Archiving $TARGET ..." + env['RANLIBCOMSTR'] = "" + env['LINKCOMSTR'] = "Linking $TARGET ..." + + ####################################################################### # Convenience Library Builder # based on the stock StaticLibrary and SharedLibrary builders @@ -111,3 +125,16 @@ def make_build_dir(env): env.SConsignFile(os.path.join(build_dir, '.sconsign')) return build_dir + +####################################################################### +# Common environment generation code + +def generate(env): + # FIXME: this is already too late + #if env.get('quiet', False): + # quietCommandLines(env) + createConvenienceLibBuilder(env) + + # for debugging + #print env.Dump() + -- cgit v1.2.3 From 35460fc91cf5311a4cbaee3c577ad8a95ccab1a1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 25 Apr 2008 18:16:25 +0900 Subject: scons: Teach scons about user-land windows. Actually, more like get rid of all our hacks when compiling for user-land windows. Only MSVC is supported atm though. --- SConstruct | 37 +------------- common.py | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- winddk.py | 101 --------------------------------------- 3 files changed, 158 insertions(+), 139 deletions(-) (limited to 'common.py') diff --git a/SConstruct b/SConstruct index 4785e39ec5..9b46e6ade2 100644 --- a/SConstruct +++ b/SConstruct @@ -65,7 +65,7 @@ platform = env['platform'] # derived options x86 = machine == 'x86' gcc = platform in ('linux', 'freebsd', 'darwin') -msvc = platform in ('win32', 'winddk') +msvc = platform in ('windows', 'winddk') Export([ 'debug', @@ -84,8 +84,6 @@ Export([ # TODO: put the compiler specific settings in separate files # TODO: auto-detect as much as possible -common.generate(env) - if platform == 'winddk': env.Tool('winddk', ['.']) @@ -96,37 +94,7 @@ if platform == 'winddk': env['CRT_INC_PATH'], ]) -# Optimization flags -if gcc: - if debug: - env.Append(CFLAGS = '-O0 -g3') - env.Append(CXXFLAGS = '-O0 -g3') - else: - env.Append(CFLAGS = '-O3 -g3') - env.Append(CXXFLAGS = '-O3 -g3') - - env.Append(CFLAGS = '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic') - env.Append(CXXFLAGS = '-Wall -pedantic') - - # Be nice to Eclipse - env.Append(CFLAGS = '-fmessage-length=0') - env.Append(CXXFLAGS = '-fmessage-length=0') - -if msvc: - cflags = [ - #'/Wp64', # enable 64 bit porting warnings - ] - env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cflags) - # Put debugging information in a separate .pdb file for each object file as - # descrived in the scons manpage - env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb' - -# Defines -if debug: - env.Append(CPPDEFINES = ['DEBUG']) -else: - env.Append(CPPDEFINES = ['NDEBUG']) +common.generate(env) # Includes @@ -188,7 +156,6 @@ if llvm: # See also http://www.scons.org/wiki/UsingPkgConfig env.ParseConfig('llvm-config --cflags --ldflags --libs') env.Append(CPPDEFINES = ['MESA_LLVM']) - env.Append(CXXFLAGS = ['-Wno-long-long']) # Force C++ linkage env['LINK'] = env['CXX'] diff --git a/common.py b/common.py index b836a8b41d..51cbd90f1d 100644 --- a/common.py +++ b/common.py @@ -34,7 +34,7 @@ default_machine = _machine_map.get(default_machine, 'generic') if default_platform in ('linux', 'freebsd', 'darwin'): default_dri = 'yes' -elif default_platform in ('winddk',): +elif default_platform in ('winddk', 'windows'): default_dri = 'no' else: default_dri = 'no' @@ -51,7 +51,7 @@ def AddOptions(opts): opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, - allowed_values=('linux', 'cell', 'winddk'))) + allowed_values=('linux', 'cell', 'windows', 'winddk'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) @@ -133,8 +133,161 @@ def generate(env): # FIXME: this is already too late #if env.get('quiet', False): # quietCommandLines(env) - createConvenienceLibBuilder(env) + + # shortcuts + debug = env['debug'] + machine = env['machine'] + platform = env['platform'] + x86 = env['machine'] == 'x86' + gcc = env['platform'] in ('linux', 'freebsd', 'darwin') + msvc = env['platform'] in ('windows', 'winddk') + + # C preprocessor options + cppdefines = [] + if debug: + cppdefines += ['DEBUG'] + else: + cppdefines += ['NDEBUG'] + if platform == 'windows': + cppdefines += [ + 'WIN32', + '_WINDOWS', + '_UNICODE', + 'UNICODE', + # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, + 'WIN32_LEAN_AND_MEAN', + 'VC_EXTRALEAN', + ] + if debug: + cppdefines += ['_DEBUG'] + if platform == 'winddk': + # Mimic WINDDK's builtin flags. See also: + # - WINDDK's bin/makefile.new i386mk.inc for more info. + # - buildchk_wxp_x86.log files, generated by the WINDDK's build + # - http://alter.org.ua/docs/nt_kernel/vc8_proj/ + cppdefines += [ + ('_X86_', '1'), + ('i386', '1'), + 'STD_CALL', + ('CONDITION_HANDLING', '1'), + ('NT_INST', '0'), + ('WIN32', '100'), + ('_NT1X_', '100'), + ('WINNT', '1'), + ('_WIN32_WINNT', '0x0501'), # minimum required OS version + ('WINVER', '0x0501'), + ('_WIN32_IE', '0x0603'), + ('WIN32_LEAN_AND_MEAN', '1'), + ('DEVL', '1'), + ('__BUILDMACHINE__', 'WinDDK'), + ('FPO', '0'), + ] + if debug: + cppdefines += [('DBG', 1)] + if platform == 'windows': + cppdefines += ['PIPE_SUBSYSTEM_USER'] + if platform == 'winddk': + cppdefines += ['PIPE_SUBSYSTEM_KERNEL'] + env.Append(CPPDEFINES = cppdefines) + + # C compiler options + cflags = [] + if gcc: + if debug: + cflags += ['-O0', '-g3'] + else: + cflags += ['-O3', '-g3'] + cflags += [ + '-Wall', + '-Wmissing-prototypes', + '-Wno-long-long', + '-ffast-math', + '-pedantic', + '-fmessage-length=0', # be nice to Eclipse + ] + if msvc: + # See also: + # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx + # - cl /? + if debug: + cflags += [ + '/Od', # disable optimizations + '/Oi', # enable intrinsic functions + '/Oy-', # disable frame pointer omission + ] + else: + cflags += [ + '/Ox', # maximum optimizations + '/Oi', # enable intrinsic functions + '/Os', # favor code space + ] + if platform == 'windows': + cflags += [ + # TODO + #'/Wp64', # enable 64 bit porting warnings + ] + if platform == 'winddk': + cflags += [ + '/Zl', # omit default library name in .OBJ + '/Zp8', # 8bytes struct member alignment + '/Gy', # separate functions for linker + '/Gm-', # disable minimal rebuild + '/W3', # warning level + '/WX', # treat warnings as errors + '/Gz', # __stdcall Calling convention + '/GX-', # disable C++ EH + '/GR-', # disable C++ RTTI + '/GF', # enable read-only string pooling + '/GS', # enable security checks + '/G6', # optimize for PPro, P-II, P-III + '/Ze', # enable extensions + #'/Gi-', # ??? + '/QIfdiv-', # disable Pentium FDIV fix + #'/hotpatch', # ??? + #'/Z7', #enable old-style debug info + ] + # Put debugging information in a separate .pdb file for each object file as + # descrived in the scons manpage + env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb' + env.Append(CFLAGS = cflags) + env.Append(CXXFLAGS = cflags) + # Linker options + if platform == 'winddk': + # See also: + # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx + env.Append(LINKFLAGS = [ + '/merge:_PAGE=PAGE', + '/merge:_TEXT=.text', + '/section:INIT,d', + '/opt:ref', + '/opt:icf', + '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', + '/incremental:no', + '/fullbuild', + '/release', + '/nodefaultlib', + '/wx', + '/debug', + '/debugtype:cv', + '/version:5.1', + '/osversion:5.1', + '/functionpadmin:5', + '/safeseh', + '/pdbcompress', + '/stack:0x40000,0x1000', + '/driver', + '/align:0x80', + '/subsystem:native,5.01', + '/base:0x10000', + + '/entry:DrvEnableDriver', + ]) + + + createConvenienceLibBuilder(env) + + # for debugging #print env.Dump() diff --git a/winddk.py b/winddk.py index c112329cd6..58de183857 100644 --- a/winddk.py +++ b/winddk.py @@ -89,105 +89,6 @@ def get_winddk_paths(env, version=None): exe_path = string.join(exe_paths, os.pathsep ) return (include_path, lib_path, exe_path) -def set_winddk_flags(env): - """Mimic WINDDK's builtin flags. - - See also: - - WINDDK's bin/makefile.new i386mk.inc for more info. - - buildchk_wxp_x86.log files, generated by the WINDDK's build - - http://alter.org.ua/docs/nt_kernel/vc8_proj/ - """ - - cppdefines = [ - ('_X86_', '1'), - ('i386', '1'), - 'STD_CALL', - ('CONDITION_HANDLING', '1'), - ('NT_INST', '0'), - ('WIN32', '100'), - ('_NT1X_', '100'), - ('WINNT', '1'), - ('_WIN32_WINNT', '0x0501'), # minimum required OS version - ('WINVER', '0x0501'), - ('_WIN32_IE', '0x0603'), - ('WIN32_LEAN_AND_MEAN', '1'), - ('DEVL', '1'), - ('__BUILDMACHINE__', 'WinDDK'), - ('FPO', '0'), - ] - if env.get('DEBUG', False): - cppdefines += [ - ('DBG', 1), - ] - env.Append(CPPDEFINES = cppdefines) - - # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - # - cl /? - cflags = [ - '/Zl', # omit default library name in .OBJ - '/Zp8', # 8bytes struct member alignment - '/Gy', # separate functions for linker - '/Gm-', # disable minimal rebuild - '/W3', # warning level - '/WX', # treat warnings as errors - '/Gz', # __stdcall Calling convention - '/GX-', # disable C++ EH - '/GR-', # disable C++ RTTI - '/GF', # enable read-only string pooling - '/GS', # enable security checks - '/G6', # optimize for PPro, P-II, P-III - '/Ze', # enable extensions - #'/Gi-', # ??? - '/QIfdiv-', # disable Pentium FDIV fix - #'/hotpatch', # ??? - #'/Z7', #enable old-style debug info - ] - if env.get('debug', False): - cflags += [ - '/Od', # disable optimizations - '/Oi', # enable intrinsic functions - '/Oy-', # disable frame pointer omission - ] - else: - cflags += [ - '/Ox', # maximum optimizations - '/Oi', # enable intrinsic functions - '/Os', # favor code space - ] - env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cflags) - - # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - env.Append(LINKFLAGS = [ - '/merge:_PAGE=PAGE', - '/merge:_TEXT=.text', - '/section:INIT,d', - '/opt:ref', - '/opt:icf', - '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', - '/incremental:no', - '/fullbuild', - '/release', - '/nodefaultlib', - '/wx', - '/debug', - '/debugtype:cv', - '/version:5.1', - '/osversion:5.1', - '/functionpadmin:5', - '/safeseh', - '/pdbcompress', - '/stack:0x40000,0x1000', - '/driver', - '/align:0x80', - '/subsystem:native,5.01', - '/base:0x10000', - - '/entry:DrvEnableDriver', - ]) - def validate_vars(env): """Validate the PCH and PCHSTOP construction variables.""" if env.has_key('PCH') and env['PCH']: @@ -314,8 +215,6 @@ def generate(env): SCons.Tool.mslink.generate(env) - set_winddk_flags(env) - if not env.has_key('ENV'): env['ENV'] = {} -- cgit v1.2.3 From 1e71283ccee61aa5d774fdef6d7668d3376d3a6d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 26 Apr 2008 01:55:32 +0900 Subject: scons: Silent MSVC CRT security warnings. --- common.py | 1 + 1 file changed, 1 insertion(+) (limited to 'common.py') diff --git a/common.py b/common.py index 51cbd90f1d..1c939e0e24 100644 --- a/common.py +++ b/common.py @@ -157,6 +157,7 @@ def generate(env): # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, 'WIN32_LEAN_AND_MEAN', 'VC_EXTRALEAN', + '_CRT_SECURE_NO_DEPRECATE', ] if debug: cppdefines += ['_DEBUG'] -- cgit v1.2.3 From c9acd439b1af4b037ded324139664cf9832930f8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 1 May 2008 00:58:04 +0900 Subject: scons: Try to cope with scons 0.98+. --- common.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'common.py') diff --git a/common.py b/common.py index 1c939e0e24..6de181739b 100644 --- a/common.py +++ b/common.py @@ -44,8 +44,14 @@ else: # Common options def AddOptions(opts): - from SCons.Options.BoolOption import BoolOption - from SCons.Options.EnumOption import EnumOption + try: + from SCons.Options.BoolOption import BoolOption + except ImportError: + from SCons.Variables.BoolVariable import BoolVariable as BoolOption + try: + from SCons.Options.EnumOption import EnumOption + except ImportError: + from SCons.Variables.EnumVariable import EnumVariable as EnumOption opts.Add(BoolOption('debug', 'build debug version', 'no')) #opts.Add(BoolOption('quiet', 'quiet command lines', 'no')) opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, -- cgit v1.2.3 From a3195e9d4eeb44032c0435f09b3e4a3dbf606777 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 5 May 2008 23:57:51 +0900 Subject: scons: A few more compiler flags adjustments to match winddk. --- common.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'common.py') diff --git a/common.py b/common.py index 6de181739b..36b190ce89 100644 --- a/common.py +++ b/common.py @@ -245,12 +245,11 @@ def generate(env): '/GX-', # disable C++ EH '/GR-', # disable C++ RTTI '/GF', # enable read-only string pooling - '/GS', # enable security checks '/G6', # optimize for PPro, P-II, P-III '/Ze', # enable extensions - #'/Gi-', # ??? + '/Gi-', # disable incremental compilation '/QIfdiv-', # disable Pentium FDIV fix - #'/hotpatch', # ??? + '/hotpatch', # prepares an image for hotpatching. #'/Z7', #enable old-style debug info ] # Put debugging information in a separate .pdb file for each object file as -- cgit v1.2.3 From 059a652d64da470ccc7f2f3266fd64721848a7be Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 May 2008 19:25:02 +0900 Subject: scons: New profile build. --- common.py | 14 +++++++++++++- src/gallium/auxiliary/util/SConscript | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'common.py') diff --git a/common.py b/common.py index 36b190ce89..d3c0261d71 100644 --- a/common.py +++ b/common.py @@ -52,7 +52,8 @@ def AddOptions(opts): from SCons.Options.EnumOption import EnumOption except ImportError: from SCons.Variables.EnumVariable import EnumVariable as EnumOption - opts.Add(BoolOption('debug', 'build debug version', 'no')) + opts.Add(BoolOption('debug', 'debug build', 'no')) + opts.Add(BoolOption('profile', 'profile build', 'no')) #opts.Add(BoolOption('quiet', 'quiet command lines', 'no')) opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'x86', 'x86_64'))) @@ -125,6 +126,8 @@ def make_build_dir(env): build_subdir += '-' + env['machine'] if env['debug']: build_subdir += "-debug" + if env['profile']: + build_subdir += "-profile" build_dir = os.path.join(build_topdir, build_subdir) # Place the .sconsign file on the builddir too, to avoid issues with different scons # versions building the same source file @@ -154,6 +157,8 @@ def generate(env): cppdefines += ['DEBUG'] else: cppdefines += ['NDEBUG'] + if env['profile']: + cppdefines += ['PROFILE'] if platform == 'windows': cppdefines += [ 'WIN32', @@ -204,6 +209,8 @@ def generate(env): cflags += ['-O0', '-g3'] else: cflags += ['-O3', '-g3'] + if env['profile']: + cflags += ['-pg'] cflags += [ '-Wall', '-Wmissing-prototypes', @@ -228,6 +235,11 @@ def generate(env): '/Oi', # enable intrinsic functions '/Os', # favor code space ] + if env['profile']: + cflags += [ + '/Gh', # enable _penter hook function + '/GH', # enable _pexit hook function + ] if platform == 'windows': cflags += [ # TODO diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript index d55d2c7081..0309de1ac2 100644 --- a/src/gallium/auxiliary/util/SConscript +++ b/src/gallium/auxiliary/util/SConscript @@ -5,6 +5,7 @@ util = env.ConvenienceLibrary( source = [ 'p_debug.c', 'p_debug_mem.c', + 'p_debug_prof.c', 'p_tile.c', 'p_util.c', 'u_blit.c', -- cgit v1.2.3 From b215d7d10c011adce839b80f87c0ea03a3edd427 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 28 May 2008 01:24:06 +0900 Subject: scons: Play nice with MS Embedded Visual C++. --- SConstruct | 5 +- common.py | 24 +++++- scons/evc.py | 108 ++++++++++++++++++++++++ scons/mslib_sa.py | 49 +++++++++++ scons/mslink_sa.py | 211 +++++++++++++++++++++++++++++++++++++++++++++++ scons/msvc_sa.py | 173 +++++++++++++++++++++++++++++++++++++++ scons/winddk.py | 114 ++++++++++++++++++++++++++ winddk.py | 236 ----------------------------------------------------- 8 files changed, 680 insertions(+), 240 deletions(-) create mode 100644 scons/evc.py create mode 100644 scons/mslib_sa.py create mode 100644 scons/mslink_sa.py create mode 100644 scons/msvc_sa.py create mode 100644 scons/winddk.py delete mode 100644 winddk.py (limited to 'common.py') diff --git a/SConstruct b/SConstruct index e7c10fcf52..5f7b6dd4d1 100644 --- a/SConstruct +++ b/SConstruct @@ -85,7 +85,7 @@ Export([ # TODO: auto-detect as much as possible if platform == 'winddk': - env.Tool('winddk', ['.']) + env.Tool('winddk', ['scons']) env.Append(CPPPATH = [ env['SDK_INC_PATH'], @@ -94,6 +94,9 @@ if platform == 'winddk': env['CRT_INC_PATH'], ]) +if platform == 'wince': + env.Tool('evc', ['scons']) + common.generate(env) diff --git a/common.py b/common.py index d3c0261d71..c040c6ddd4 100644 --- a/common.py +++ b/common.py @@ -34,7 +34,7 @@ default_machine = _machine_map.get(default_machine, 'generic') if default_platform in ('linux', 'freebsd', 'darwin'): default_dri = 'yes' -elif default_platform in ('winddk', 'windows'): +elif default_platform in ('winddk', 'windows', 'wince'): default_dri = 'no' else: default_dri = 'no' @@ -58,7 +58,7 @@ def AddOptions(opts): opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, - allowed_values=('linux', 'cell', 'windows', 'winddk'))) + allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) @@ -149,7 +149,7 @@ def generate(env): platform = env['platform'] x86 = env['machine'] == 'x86' gcc = env['platform'] in ('linux', 'freebsd', 'darwin') - msvc = env['platform'] in ('windows', 'winddk') + msvc = env['platform'] in ('windows', 'winddk', 'wince') # C preprocessor options cppdefines = [] @@ -196,6 +196,19 @@ def generate(env): ] if debug: cppdefines += [('DBG', 1)] + if platform == 'wince': + cppdefines += [ + ('_WIN32_WCE', '500'), + 'WCE_PLATFORM_STANDARDSDK_500', + '_i386_', + ('UNDER_CE', '500'), + 'UNICODE', + '_UNICODE', + '_X86_', + 'x86', + '_USRDLL', + 'TEST_EXPORTS' , + ] if platform == 'windows': cppdefines += ['PIPE_SUBSYSTEM_USER'] if platform == 'winddk': @@ -264,6 +277,11 @@ def generate(env): '/hotpatch', # prepares an image for hotpatching. #'/Z7', #enable old-style debug info ] + if platform == 'wince': + cflags += [ + '/Gs8192', + '/GF', # enable read-only string pooling + ] # Put debugging information in a separate .pdb file for each object file as # descrived in the scons manpage env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb' diff --git a/scons/evc.py b/scons/evc.py new file mode 100644 index 0000000000..22a92607e5 --- /dev/null +++ b/scons/evc.py @@ -0,0 +1,108 @@ +"""evc + +Tool-specific initialization for Microsoft eMbedded Visual C++. + +""" + +# +# Copyright (c) 2001-2007 The SCons Foundation +# Copyright (c) 2008 Tungsten Graphics, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +import os.path +import re +import string + +import SCons.Action +import SCons.Builder +import SCons.Errors +import SCons.Platform.win32 +import SCons.Tool +import SCons.Util +import SCons.Warnings + +import msvc_sa +import mslib_sa +import mslink_sa + +def get_evc_paths(env, version=None): + """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values + of those three environment variables that should be set + in order to execute the MSVC tools properly.""" + + exe_paths = [] + lib_paths = [] + include_paths = [] + + # mymic the batch files located in Microsoft eMbedded C++ 4.0\EVC\WCExxx\BIN + os_version = os.environ.get('OSVERSION', 'WCE500') + platform = os.environ.get('PLATFORM', 'STANDARDSDK_500') + wce_root = os.environ.get('WCEROOT', 'C:\\Program Files\\Microsoft eMbedded C++ 4.0') + sdk_root = os.environ.get('SDKROOT', 'C:\\Windows CE Tools') + + target_cpu = 'x86' + cfg = 'none' + + exe_paths.append( os.path.join(wce_root, 'COMMON', 'EVC', 'bin') ) + exe_paths.append( os.path.join(wce_root, 'EVC', os_version, 'bin') ) + include_paths.append( os.path.join(sdk_root, os_version, platform, 'include', target_cpu) ) + include_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'include') ) + include_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'include') ) + lib_paths.append( os.path.join(sdk_root, os_version, platform, 'lib', target_cpu) ) + lib_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'lib', target_cpu) ) + lib_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'lib', target_cpu) ) + + include_path = string.join( include_paths, os.pathsep ) + lib_path = string.join(lib_paths, os.pathsep ) + exe_path = string.join(exe_paths, os.pathsep ) + return (include_path, lib_path, exe_path) + +def generate(env): + + msvc_sa.generate(env) + mslib_sa.generate(env) + mslink_sa.generate(env) + + if not env.has_key('ENV'): + env['ENV'] = {} + + try: + include_path, lib_path, exe_path = get_evc_paths(env) + + # since other tools can set these, we just make sure that the + # relevant stuff from WINDDK is in there somewhere. + env.PrependENVPath('INCLUDE', include_path) + env.PrependENVPath('LIB', lib_path) + env.PrependENVPath('PATH', exe_path) + except (SCons.Util.RegError, SCons.Errors.InternalError): + pass + +def exists(env): + if not msvc_sa.exits(env): + return 0 + if not mslib_sa.exits(env): + return 0 + if not mslink_sa.exits(env): + return 0 + return 1 + +# vim:set ts=4 sw=4 et: diff --git a/scons/mslib_sa.py b/scons/mslib_sa.py new file mode 100644 index 0000000000..da51c574b6 --- /dev/null +++ b/scons/mslib_sa.py @@ -0,0 +1,49 @@ +"""mslib_sa + +Tool-specific initialization for lib (MicroSoft library archiver). + +Based on SCons.Tool.mslib, without the MSVC detection. + +""" + +# +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +import SCons.Defaults +import SCons.Tool +import SCons.Util + +def generate(env): + """Add Builders and construction variables for lib to an Environment.""" + SCons.Tool.createStaticLibBuilder(env) + + env['AR'] = 'lib' + env['ARFLAGS'] = SCons.Util.CLVar('/nologo') + env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}" + env['LIBPREFIX'] = '' + env['LIBSUFFIX'] = '.lib' + +def exists(env): + return env.Detect('lib') + +# vim:set ts=4 sw=4 et: diff --git a/scons/mslink_sa.py b/scons/mslink_sa.py new file mode 100644 index 0000000000..53331def1a --- /dev/null +++ b/scons/mslink_sa.py @@ -0,0 +1,211 @@ +"""mslink_sa + +Tool-specific initialization for the Microsoft linker. + +Based on SCons.Tool.mslink, without the MSVS detection. + +""" + +# +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +import os.path + +import SCons.Action +import SCons.Defaults +import SCons.Errors +import SCons.Platform.win32 +import SCons.Tool +import SCons.Tool.msvc +import SCons.Util + +def pdbGenerator(env, target, source, for_signature): + try: + return ['/PDB:%s' % target[0].attributes.pdb, '/DEBUG'] + except (AttributeError, IndexError): + return None + +def windowsShlinkTargets(target, source, env, for_signature): + listCmd = [] + dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX') + if dll: listCmd.append("/out:%s"%dll.get_string(for_signature)) + + implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX') + if implib: listCmd.append("/implib:%s"%implib.get_string(for_signature)) + + return listCmd + +def windowsShlinkSources(target, source, env, for_signature): + listCmd = [] + + deffile = env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX") + for src in source: + if src == deffile: + # Treat this source as a .def file. + listCmd.append("/def:%s" % src.get_string(for_signature)) + else: + # Just treat it as a generic source file. + listCmd.append(src) + return listCmd + +def windowsLibEmitter(target, source, env): + SCons.Tool.msvc.validate_vars(env) + + extratargets = [] + extrasources = [] + + dll = env.FindIxes(target, "SHLIBPREFIX", "SHLIBSUFFIX") + no_import_lib = env.get('no_import_lib', 0) + + if not dll: + raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX") + + insert_def = env.subst("$WINDOWS_INSERT_DEF") + if not insert_def in ['', '0', 0] and \ + not env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX"): + + # append a def file to the list of sources + extrasources.append( + env.ReplaceIxes(dll, + "SHLIBPREFIX", "SHLIBSUFFIX", + "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX")) + + if env.has_key('PDB') and env['PDB']: + pdb = env.arg2nodes('$PDB', target=target, source=source)[0] + extratargets.append(pdb) + target[0].attributes.pdb = pdb + + if not no_import_lib and \ + not env.FindIxes(target, "LIBPREFIX", "LIBSUFFIX"): + # Append an import library to the list of targets. + extratargets.append( + env.ReplaceIxes(dll, + "SHLIBPREFIX", "SHLIBSUFFIX", + "LIBPREFIX", "LIBSUFFIX")) + # and .exp file is created if there are exports from a DLL + extratargets.append( + env.ReplaceIxes(dll, + "SHLIBPREFIX", "SHLIBSUFFIX", + "WINDOWSEXPPREFIX", "WINDOWSEXPSUFFIX")) + + return (target+extratargets, source+extrasources) + +def prog_emitter(target, source, env): + SCons.Tool.msvc.validate_vars(env) + + extratargets = [] + + exe = env.FindIxes(target, "PROGPREFIX", "PROGSUFFIX") + if not exe: + raise SCons.Errors.UserError, "An executable should have exactly one target with the suffix: %s" % env.subst("$PROGSUFFIX") + + if env.has_key('PDB') and env['PDB']: + pdb = env.arg2nodes('$PDB', target=target, source=source)[0] + extratargets.append(pdb) + target[0].attributes.pdb = pdb + + return (target+extratargets,source) + +def RegServerFunc(target, source, env): + if env.has_key('register') and env['register']: + ret = regServerAction([target[0]], [source[0]], env) + if ret: + raise SCons.Errors.UserError, "Unable to register %s" % target[0] + else: + print "Registered %s sucessfully" % target[0] + return ret + return 0 + +regServerAction = SCons.Action.Action("$REGSVRCOM", "$REGSVRCOMSTR") +regServerCheck = SCons.Action.Action(RegServerFunc, None) +shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $_SHLINK_SOURCES")}') +compositeLinkAction = shlibLinkAction + regServerCheck + +def generate(env): + """Add Builders and construction variables for ar to an Environment.""" + SCons.Tool.createSharedLibBuilder(env) + SCons.Tool.createProgBuilder(env) + + env['SHLINK'] = '$LINK' + env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS /dll') + env['_SHLINK_TARGETS'] = windowsShlinkTargets + env['_SHLINK_SOURCES'] = windowsShlinkSources + env['SHLINKCOM'] = compositeLinkAction + env.Append(SHLIBEMITTER = [windowsLibEmitter]) + env['LINK'] = 'link' + env['LINKFLAGS'] = SCons.Util.CLVar('/nologo') + env['_PDB'] = pdbGenerator + env['LINKCOM'] = '${TEMPFILE("$LINK $LINKFLAGS /OUT:$TARGET.windows $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $SOURCES.windows")}' + env.Append(PROGEMITTER = [prog_emitter]) + env['LIBDIRPREFIX']='/LIBPATH:' + env['LIBDIRSUFFIX']='' + env['LIBLINKPREFIX']='' + env['LIBLINKSUFFIX']='$LIBSUFFIX' + + env['WIN32DEFPREFIX'] = '' + env['WIN32DEFSUFFIX'] = '.def' + env['WIN32_INSERT_DEF'] = 0 + env['WINDOWSDEFPREFIX'] = '${WIN32DEFPREFIX}' + env['WINDOWSDEFSUFFIX'] = '${WIN32DEFSUFFIX}' + env['WINDOWS_INSERT_DEF'] = '${WIN32_INSERT_DEF}' + + env['WIN32EXPPREFIX'] = '' + env['WIN32EXPSUFFIX'] = '.exp' + env['WINDOWSEXPPREFIX'] = '${WIN32EXPPREFIX}' + env['WINDOWSEXPSUFFIX'] = '${WIN32EXPSUFFIX}' + + env['WINDOWSSHLIBMANIFESTPREFIX'] = '' + env['WINDOWSSHLIBMANIFESTSUFFIX'] = '${SHLIBSUFFIX}.manifest' + env['WINDOWSPROGMANIFESTPREFIX'] = '' + env['WINDOWSPROGMANIFESTSUFFIX'] = '${PROGSUFFIX}.manifest' + + env['REGSVRACTION'] = regServerCheck + env['REGSVR'] = os.path.join(SCons.Platform.win32.get_system_root(),'System32','regsvr32') + env['REGSVRFLAGS'] = '/s ' + env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS ${TARGET.windows}' + + # For most platforms, a loadable module is the same as a shared + # library. Platforms which are different can override these, but + # setting them the same means that LoadableModule works everywhere. + SCons.Tool.createLoadableModuleBuilder(env) + env['LDMODULE'] = '$SHLINK' + env['LDMODULEPREFIX'] = '$SHLIBPREFIX' + env['LDMODULESUFFIX'] = '$SHLIBSUFFIX' + env['LDMODULEFLAGS'] = '$SHLINKFLAGS' + # We can't use '$SHLINKCOM' here because that will stringify the + # action list on expansion, and will then try to execute expanded + # strings, with the upshot that it would try to execute RegServerFunc + # as a command. + env['LDMODULECOM'] = compositeLinkAction + +def exists(env): + platform = env.get('PLATFORM', '') + if platform in ('win32', 'cygwin'): + # Only explicitly search for a 'link' executable on Windows + # systems. Some other systems (e.g. Ubuntu Linux) have an + # executable named 'link' and we don't want that to make SCons + # think Visual Studio is installed. + return env.Detect('link') + return None + +# vim:set ts=4 sw=4 et: diff --git a/scons/msvc_sa.py b/scons/msvc_sa.py new file mode 100644 index 0000000000..136d305265 --- /dev/null +++ b/scons/msvc_sa.py @@ -0,0 +1,173 @@ +"""msvc_sa + +Tool-specific initialization for Microsoft Visual C/C++. + +Based on SCons.Tool.msvc, without the MSVS detection. + +""" + +# +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +import os.path +import re +import string + +import SCons.Action +import SCons.Builder +import SCons.Errors +import SCons.Platform.win32 +import SCons.Tool +import SCons.Util +import SCons.Warnings + +CSuffixes = ['.c', '.C'] +CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] + +def validate_vars(env): + """Validate the PCH and PCHSTOP construction variables.""" + if env.has_key('PCH') and env['PCH']: + if not env.has_key('PCHSTOP'): + raise SCons.Errors.UserError, "The PCHSTOP construction must be defined if PCH is defined." + if not SCons.Util.is_String(env['PCHSTOP']): + raise SCons.Errors.UserError, "The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP'] + +def pch_emitter(target, source, env): + """Adds the object file target.""" + + validate_vars(env) + + pch = None + obj = None + + for t in target: + if SCons.Util.splitext(str(t))[1] == '.pch': + pch = t + if SCons.Util.splitext(str(t))[1] == '.obj': + obj = t + + if not obj: + obj = SCons.Util.splitext(str(pch))[0]+'.obj' + + target = [pch, obj] # pch must be first, and obj second for the PCHCOM to work + + return (target, source) + +def object_emitter(target, source, env, parent_emitter): + """Sets up the PCH dependencies for an object file.""" + + validate_vars(env) + + parent_emitter(target, source, env) + + if env.has_key('PCH') and env['PCH']: + env.Depends(target, env['PCH']) + + return (target, source) + +def static_object_emitter(target, source, env): + return object_emitter(target, source, env, + SCons.Defaults.StaticObjectEmitter) + +def shared_object_emitter(target, source, env): + return object_emitter(target, source, env, + SCons.Defaults.SharedObjectEmitter) + +pch_action = SCons.Action.Action('$PCHCOM', '$PCHCOMSTR') +pch_builder = SCons.Builder.Builder(action=pch_action, suffix='.pch', + emitter=pch_emitter, + source_scanner=SCons.Tool.SourceFileScanner) +res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR') +res_builder = SCons.Builder.Builder(action=res_action, + src_suffix='.rc', + suffix='.res', + src_builder=[], + source_scanner=SCons.Tool.SourceFileScanner) +SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan) + +def generate(env): + """Add Builders and construction variables for MSVC++ to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + for suffix in CSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCAction) + static_obj.add_emitter(suffix, static_object_emitter) + shared_obj.add_emitter(suffix, shared_object_emitter) + + for suffix in CXXSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CXXAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) + static_obj.add_emitter(suffix, static_object_emitter) + shared_obj.add_emitter(suffix, shared_object_emitter) + + env['CCPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Z7") or ""}']) + env['CCPCHFLAGS'] = SCons.Util.CLVar(['${(PCH and "/Yu%s /Fp%s"%(PCHSTOP or "",File(PCH))) or ""}']) + env['CCCOMFLAGS'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET $CCPCHFLAGS $CCPDBFLAGS' + env['CC'] = 'cl' + env['CCFLAGS'] = SCons.Util.CLVar('/nologo') + env['CFLAGS'] = SCons.Util.CLVar('') + env['CCCOM'] = '$CC $CFLAGS $CCFLAGS $CCCOMFLAGS' + env['SHCC'] = '$CC' + env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') + env['SHCFLAGS'] = SCons.Util.CLVar('$CFLAGS') + env['SHCCCOM'] = '$SHCC $SHCFLAGS $SHCCFLAGS $CCCOMFLAGS' + env['CXX'] = '$CC' + env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS $( /TP $)') + env['CXXCOM'] = '$CXX $CXXFLAGS $CCCOMFLAGS' + env['SHCXX'] = '$CXX' + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') + env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CCCOMFLAGS' + env['CPPDEFPREFIX'] = '/D' + env['CPPDEFSUFFIX'] = '' + env['INCPREFIX'] = '/I' + env['INCSUFFIX'] = '' +# env.Append(OBJEMITTER = [static_object_emitter]) +# env.Append(SHOBJEMITTER = [shared_object_emitter]) + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + + env['RC'] = 'rc' + env['RCFLAGS'] = SCons.Util.CLVar('') + env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES' + env['BUILDERS']['RES'] = res_builder + env['OBJPREFIX'] = '' + env['OBJSUFFIX'] = '.obj' + env['SHOBJPREFIX'] = '$OBJPREFIX' + env['SHOBJSUFFIX'] = '$OBJSUFFIX' + + env['CFILESUFFIX'] = '.c' + env['CXXFILESUFFIX'] = '.cc' + + env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + env['PCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo${TARGETS[1]} /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS' + env['BUILDERS']['PCH'] = pch_builder + + if not env.has_key('ENV'): + env['ENV'] = {} + if not env['ENV'].has_key('SystemRoot'): # required for dlls in the winsxs folders + env['ENV']['SystemRoot'] = SCons.Platform.win32.get_system_root() + +def exists(env): + return env.Detect('cl') + +# vim:set ts=4 sw=4 et: diff --git a/scons/winddk.py b/scons/winddk.py new file mode 100644 index 0000000000..be81d12ea9 --- /dev/null +++ b/scons/winddk.py @@ -0,0 +1,114 @@ +"""winddk + +Tool-specific initialization for Microsoft Windows DDK. + +""" + +# +# Copyright (c) 2001-2007 The SCons Foundation +# Copyright (c) 2008 Tungsten Graphics, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +import os.path +import re +import string + +import SCons.Action +import SCons.Builder +import SCons.Errors +import SCons.Platform.win32 +import SCons.Tool +import SCons.Util +import SCons.Warnings + +import msvc_sa +import mslib_sa +import mslink_sa + +def get_winddk_paths(env, version=None): + """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values + of those three environment variables that should be set + in order to execute the MSVC tools properly.""" + + WINDDKdir = None + exe_paths = [] + lib_paths = [] + include_paths = [] + + if 'BASEDIR' in os.environ: + WINDDKdir = os.environ['BASEDIR'] + else: + WINDDKdir = "C:\\WINDDK\\3790.1830" + + exe_paths.append( os.path.join(WINDDKdir, 'bin') ) + exe_paths.append( os.path.join(WINDDKdir, 'bin', 'x86') ) + include_paths.append( os.path.join(WINDDKdir, 'inc', 'wxp') ) + lib_paths.append( os.path.join(WINDDKdir, 'lib') ) + + target_os = 'wxp' + target_cpu = 'i386' + + env['SDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', target_os) + env['CRT_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'crt') + env['DDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', target_os) + env['WDM_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', 'wdm', target_os) + + env['SDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu) + env['CRT_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', 'crt', target_cpu) + env['DDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu) + env['WDM_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu) + + include_path = string.join( include_paths, os.pathsep ) + lib_path = string.join(lib_paths, os.pathsep ) + exe_path = string.join(exe_paths, os.pathsep ) + return (include_path, lib_path, exe_path) + +def generate(env): + + msvc_sa.generate(env) + mslib_sa.generate(env) + mslink_sa.generate(env) + + if not env.has_key('ENV'): + env['ENV'] = {} + + try: + include_path, lib_path, exe_path = get_winddk_paths(env) + + # since other tools can set these, we just make sure that the + # relevant stuff from WINDDK is in there somewhere. + env.PrependENVPath('INCLUDE', include_path) + env.PrependENVPath('LIB', lib_path) + env.PrependENVPath('PATH', exe_path) + except (SCons.Util.RegError, SCons.Errors.InternalError): + pass + +def exists(env): + if not msvc_sa.exits(env): + return 0 + if not mslib_sa.exits(env): + return 0 + if not mslink_sa.exits(env): + return 0 + return 1 + +# vim:set ts=4 sw=4 et: diff --git a/winddk.py b/winddk.py deleted file mode 100644 index 58de183857..0000000000 --- a/winddk.py +++ /dev/null @@ -1,236 +0,0 @@ -"""winddk - -Tool-specific initialization for Microsoft Windows DDK. - -Based on engine.SCons.Tool.msvc. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# -# Copyright (c) 2001-2007 The SCons Foundation -# Copyright (c) 2008 Tungsten Graphics, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -import os.path -import re -import string - -import SCons.Action -import SCons.Builder -import SCons.Errors -import SCons.Platform.win32 -import SCons.Tool -import SCons.Tool.mslib -import SCons.Tool.mslink -import SCons.Util -import SCons.Warnings - -CSuffixes = ['.c', '.C'] -CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] - -def get_winddk_paths(env, version=None): - """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values - of those three environment variables that should be set - in order to execute the MSVC tools properly.""" - - WINDDKdir = None - exe_paths = [] - lib_paths = [] - include_paths = [] - - if 'BASEDIR' in os.environ: - WINDDKdir = os.environ['BASEDIR'] - else: - WINDDKdir = "C:\\WINDDK\\3790.1830" - - exe_paths.append( os.path.join(WINDDKdir, 'bin') ) - exe_paths.append( os.path.join(WINDDKdir, 'bin', 'x86') ) - include_paths.append( os.path.join(WINDDKdir, 'inc', 'wxp') ) - lib_paths.append( os.path.join(WINDDKdir, 'lib') ) - - target_os = 'wxp' - target_cpu = 'i386' - - env['SDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', target_os) - env['CRT_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'crt') - env['DDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', target_os) - env['WDM_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', 'wdm', target_os) - - env['SDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu) - env['CRT_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', 'crt', target_cpu) - env['DDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu) - env['WDM_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu) - - include_path = string.join( include_paths, os.pathsep ) - lib_path = string.join(lib_paths, os.pathsep ) - exe_path = string.join(exe_paths, os.pathsep ) - return (include_path, lib_path, exe_path) - -def validate_vars(env): - """Validate the PCH and PCHSTOP construction variables.""" - if env.has_key('PCH') and env['PCH']: - if not env.has_key('PCHSTOP'): - raise SCons.Errors.UserError, "The PCHSTOP construction must be defined if PCH is defined." - if not SCons.Util.is_String(env['PCHSTOP']): - raise SCons.Errors.UserError, "The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP'] - -def pch_emitter(target, source, env): - """Adds the object file target.""" - - validate_vars(env) - - pch = None - obj = None - - for t in target: - if SCons.Util.splitext(str(t))[1] == '.pch': - pch = t - if SCons.Util.splitext(str(t))[1] == '.obj': - obj = t - - if not obj: - obj = SCons.Util.splitext(str(pch))[0]+'.obj' - - target = [pch, obj] # pch must be first, and obj second for the PCHCOM to work - - return (target, source) - -def object_emitter(target, source, env, parent_emitter): - """Sets up the PCH dependencies for an object file.""" - - validate_vars(env) - - parent_emitter(target, source, env) - - if env.has_key('PCH') and env['PCH']: - env.Depends(target, env['PCH']) - - return (target, source) - -def static_object_emitter(target, source, env): - return object_emitter(target, source, env, - SCons.Defaults.StaticObjectEmitter) - -def shared_object_emitter(target, source, env): - return object_emitter(target, source, env, - SCons.Defaults.SharedObjectEmitter) - -pch_action = SCons.Action.Action('$PCHCOM', '$PCHCOMSTR') -pch_builder = SCons.Builder.Builder(action=pch_action, suffix='.pch', - emitter=pch_emitter, - source_scanner=SCons.Tool.SourceFileScanner) -res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR') -res_builder = SCons.Builder.Builder(action=res_action, - src_suffix='.rc', - suffix='.res', - src_builder=[], - source_scanner=SCons.Tool.SourceFileScanner) -SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan) - -def generate(env): - """Add Builders and construction variables for MSVC++ to an Environment.""" - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - - for suffix in CSuffixes: - static_obj.add_action(suffix, SCons.Defaults.CAction) - shared_obj.add_action(suffix, SCons.Defaults.ShCAction) - static_obj.add_emitter(suffix, static_object_emitter) - shared_obj.add_emitter(suffix, shared_object_emitter) - - for suffix in CXXSuffixes: - static_obj.add_action(suffix, SCons.Defaults.CXXAction) - shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) - static_obj.add_emitter(suffix, static_object_emitter) - shared_obj.add_emitter(suffix, shared_object_emitter) - - env['CCPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Z7") or ""}']) - env['CCPCHFLAGS'] = SCons.Util.CLVar(['${(PCH and "/Yu%s /Fp%s"%(PCHSTOP or "",File(PCH))) or ""}']) - env['CCCOMFLAGS'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET $CCPCHFLAGS $CCPDBFLAGS' - env['CC'] = 'cl' - env['CCFLAGS'] = SCons.Util.CLVar('/nologo') - env['CFLAGS'] = SCons.Util.CLVar('') - env['CCCOM'] = '$CC $CFLAGS $CCFLAGS $CCCOMFLAGS' - env['SHCC'] = '$CC' - env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') - env['SHCFLAGS'] = SCons.Util.CLVar('$CFLAGS') - env['SHCCCOM'] = '$SHCC $SHCFLAGS $SHCCFLAGS $CCCOMFLAGS' - env['CXX'] = '$CC' - env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS $( /TP $)') - env['CXXCOM'] = '$CXX $CXXFLAGS $CCCOMFLAGS' - env['SHCXX'] = '$CXX' - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') - env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CCCOMFLAGS' - env['CPPDEFPREFIX'] = '/D' - env['CPPDEFSUFFIX'] = '' - env['INCPREFIX'] = '/I' - env['INCSUFFIX'] = '' -# env.Append(OBJEMITTER = [static_object_emitter]) -# env.Append(SHOBJEMITTER = [shared_object_emitter]) - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 - - env['RC'] = 'rc' - env['RCFLAGS'] = SCons.Util.CLVar('') - env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES' - env['BUILDERS']['RES'] = res_builder - env['OBJPREFIX'] = '' - env['OBJSUFFIX'] = '.obj' - env['SHOBJPREFIX'] = '$OBJPREFIX' - env['SHOBJSUFFIX'] = '$OBJSUFFIX' - - env['CFILESUFFIX'] = '.c' - env['CXXFILESUFFIX'] = '.cc' - - env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) - env['PCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo${TARGETS[1]} /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS' - env['BUILDERS']['PCH'] = pch_builder - - env['AR'] = 'lib' - env['ARFLAGS'] = SCons.Util.CLVar('/nologo') - env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}" - env['LIBPREFIX'] = '' - env['LIBSUFFIX'] = '.lib' - - SCons.Tool.mslink.generate(env) - - if not env.has_key('ENV'): - env['ENV'] = {} - - try: - include_path, lib_path, exe_path = get_winddk_paths(env) - - # since other tools can set these, we just make sure that the - # relevant stuff from WINDDK is in there somewhere. - env.PrependENVPath('INCLUDE', include_path) - env.PrependENVPath('LIB', lib_path) - env.PrependENVPath('PATH', exe_path) - except (SCons.Util.RegError, SCons.Errors.InternalError): - pass - - -def exists(env): - return env.Detect('cl') - -# vim:set sw=4 et: -- cgit v1.2.3 From 5463420741744c39849a038b6079a7b46ddcb729 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 2 Jun 2008 18:27:00 +0900 Subject: scons: Set /W3 warning level for all MSVC based platforms. --- common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'common.py') diff --git a/common.py b/common.py index c040c6ddd4..8b70e9b426 100644 --- a/common.py +++ b/common.py @@ -253,10 +253,13 @@ def generate(env): '/Gh', # enable _penter hook function '/GH', # enable _pexit hook function ] + cflags += [ + '/W3', # warning level + #'/Wp64', # enable 64 bit porting warnings + ] if platform == 'windows': cflags += [ # TODO - #'/Wp64', # enable 64 bit porting warnings ] if platform == 'winddk': cflags += [ @@ -264,7 +267,6 @@ def generate(env): '/Zp8', # 8bytes struct member alignment '/Gy', # separate functions for linker '/Gm-', # disable minimal rebuild - '/W3', # warning level '/WX', # treat warnings as errors '/Gz', # __stdcall Calling convention '/GX-', # disable C++ EH @@ -283,7 +285,7 @@ def generate(env): '/GF', # enable read-only string pooling ] # Put debugging information in a separate .pdb file for each object file as - # descrived in the scons manpage + # described in the scons manpage env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb' env.Append(CFLAGS = cflags) env.Append(CXXFLAGS = cflags) -- cgit v1.2.3 From 275fc32d588fb6d2b78038f5a97cc2bcd2cd61dc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 2 Jun 2008 19:36:53 +0900 Subject: gallium: Identify each Windows platform individually from scons. --- common.py | 6 +++-- src/gallium/include/pipe/p_config.h | 51 ++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 22 deletions(-) (limited to 'common.py') diff --git a/common.py b/common.py index 8b70e9b426..b6251d3960 100644 --- a/common.py +++ b/common.py @@ -210,9 +210,11 @@ def generate(env): 'TEST_EXPORTS' , ] if platform == 'windows': - cppdefines += ['PIPE_SUBSYSTEM_USER'] + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] if platform == 'winddk': - cppdefines += ['PIPE_SUBSYSTEM_KERNEL'] + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] + if platform == 'wince': + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] env.Append(CPPDEFINES = cppdefines) # C compiler options diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h index d2d2ae1617..af3746c026 100644 --- a/src/gallium/include/pipe/p_config.h +++ b/src/gallium/include/pipe/p_config.h @@ -33,12 +33,13 @@ * architecture, and operating system being used. These defines should be used * throughout the code to facilitate porting to new platforms. It is likely that * this file is auto-generated by an autoconf-like tool at some point, as some - * things cannot be determined by existing defines alone. + * things cannot be determined by pre-defined environment alone. * * See also: * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html * - echo | gcc -dM -E - | sort * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx + * * @author José Fonseca */ @@ -54,6 +55,15 @@ #define PIPE_CC_GCC #endif +/* + * Meaning of _MSC_VER value: + * - 1400: Visual C++ 2005 + * - 1310: Visual C++ .NET 2003 + * - 1300: Visual C++ .NET 2002 + * + * __MSC__ seems to be an old macro -- it is not pre-defined on recent MSVC + * versions. + */ #if defined(_MSC_VER) || defined(__MSC__) #define PIPE_CC_MSVC #endif @@ -81,7 +91,9 @@ /* - * Operating system + * Operating system family. + * + * See subsystem below for a more fine-grained distinction. */ #if defined(__linux__) @@ -94,32 +106,31 @@ /* - * Subsystem + * Subsystem. * - * XXX: There is no way to autodetect this. + * NOTE: There is no way to auto-detect most of these. */ #if defined(PIPE_OS_LINUX) #define PIPE_SUBSYSTEM_DRI -#endif +#endif /* PIPE_OS_LINUX */ #if defined(PIPE_OS_WINDOWS) -#ifndef _WIN32_WCE -#if !defined(PIPE_SUBSYSTEM_USER) && !defined(PIPE_SUBSYSTEM_KERNEL) -#error Neither PIPE_SUBSYSTEM_USER or PIPE_SUBSYSTEM_KERNEL defined. -#endif -#if defined(PIPE_SUBSYSTEM_KERNEL) -#define PIPE_SUBSYSTEM_WINDOWS_DISPLAY -#endif -#if 0 /* FIXME */ -#define PIPE_SUBSYSTEM_WINDOWS_MINIPORT -#endif -#if defined(PIPE_SUBSYSTEM_USER) -#define PIPE_SUBSYSTEM_WINDOWS_USER -#endif -#else /* _WIN32_WCE */ +#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) +/* Windows 2000/XP Display Driver */ +#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) +/* Windows 2000/XP Miniport Driver */ +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +/* Windows User-space Library */ +#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE) +/* Windows CE 5.0/6.0 */ +#else +#ifdef _WIN32_WCE #define PIPE_SUBSYSTEM_WINDOWS_CE -#endif /* _WIN32_WCE */ +#else /* !_WIN32_WCE */ +#error No PIPE_SUBSYSTEM_WINDOWS_xxx subsystem defined. +#endif /* !_WIN32_WCE */ +#endif #endif /* PIPE_OS_WINDOWS */ -- cgit v1.2.3 From 113ab51a8cf767cc95bdc9f6faea6956e17c1da7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 4 Jun 2008 23:57:55 +0900 Subject: scons: Some provisions to cross-compile x86 on x86_64 machines and vice-versa. --- common.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'common.py') diff --git a/common.py b/common.py index b6251d3960..c82f3026dd 100644 --- a/common.py +++ b/common.py @@ -226,6 +226,10 @@ def generate(env): cflags += ['-O3', '-g3'] if env['profile']: cflags += ['-pg'] + if env['machine'] == 'x86' and default_machine == 'x86_64': + cflags += ['-m32'] + if env['machine'] == 'x86_64' and default_machine == 'x86': + cflags += ['-m64'] cflags += [ '-Wall', '-Wmissing-prototypes', @@ -293,10 +297,16 @@ def generate(env): env.Append(CXXFLAGS = cflags) # Linker options + linkflags = [] + if gcc: + if env['machine'] == 'x86' and default_machine == 'x86_64': + linkflags += ['-m32'] + if env['machine'] == 'x86_64' and default_machine == 'x86': + linkflags += ['-m64'] if platform == 'winddk': # See also: # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - env.Append(LINKFLAGS = [ + linkflags += [ '/merge:_PAGE=PAGE', '/merge:_TEXT=.text', '/section:INIT,d', @@ -322,7 +332,8 @@ def generate(env): '/base:0x10000', '/entry:DrvEnableDriver', - ]) + ] + env.Append(LINKFLAGS = linkflags) createConvenienceLibBuilder(env) -- cgit v1.2.3 From b04aa714afad014f2cdecc3ded9df0586f685921 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 6 Jun 2008 14:48:57 +0900 Subject: scons: Put the tool logic in a frontend tool. More logic can be shared between public and private branches this way. --- SConstruct | 36 ++----- common.py | 280 ----------------------------------------------- scons/gallium.py | 323 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 330 insertions(+), 309 deletions(-) create mode 100644 scons/gallium.py (limited to 'common.py') diff --git a/SConstruct b/SConstruct index 8c8a82b38e..4fddcc531e 100644 --- a/SConstruct +++ b/SConstruct @@ -53,8 +53,12 @@ opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys, env = Environment( MSVS_VERSION = '7.1', - options = opts, - ENV = os.environ) + options = opts, + tools = ['gallium'], + toolpath = ['scons'], + ENV = os.environ, +) + Help(opts.GenerateHelpText(env)) # replicate options values in local variables @@ -82,25 +86,6 @@ Export([ ####################################################################### # Environment setup -# -# TODO: put the compiler specific settings in separate files -# TODO: auto-detect as much as possible - -if platform == 'winddk': - env.Tool('winddk', ['scons']) - - env.Append(CPPPATH = [ - env['SDK_INC_PATH'], - env['DDK_INC_PATH'], - env['WDM_INC_PATH'], - env['CRT_INC_PATH'], - ]) - -if platform == 'wince': - env.Tool('evc', ['scons']) - -common.generate(env) - # Includes env.Append(CPPPATH = [ @@ -111,13 +96,6 @@ env.Append(CPPPATH = [ ]) -# x86 assembly -if x86: - if gcc: - env.Append(CFLAGS = '-m32') - env.Append(CXXFLAGS = '-m32') - - # Posix if platform in ('posix', 'linux', 'freebsd', 'darwin'): env.Append(CPPDEFINES = [ @@ -182,6 +160,6 @@ Export('env') SConscript( 'src/SConscript', - build_dir = common.make_build_dir(env), + build_dir = env['build'], duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html ) diff --git a/common.py b/common.py index c82f3026dd..dd64e0f434 100644 --- a/common.py +++ b/common.py @@ -62,283 +62,3 @@ def AddOptions(opts): opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) - -####################################################################### -# Quiet command lines -# -# See also http://www.scons.org/wiki/HidingCommandLinesInOutput - -def quietCommandLines(env): - env['CCCOMSTR'] = "Compiling $SOURCE ..." - env['CXXCOMSTR'] = "Compiling $SOURCE ..." - env['ARCOMSTR'] = "Archiving $TARGET ..." - env['RANLIBCOMSTR'] = "" - env['LINKCOMSTR'] = "Linking $TARGET ..." - - -####################################################################### -# Convenience Library Builder -# based on the stock StaticLibrary and SharedLibrary builders - -import SCons.Action -import SCons.Builder - -def createConvenienceLibBuilder(env): - """This is a utility function that creates the ConvenienceLibrary - Builder in an Environment if it is not there already. - - If it is already there, we return the existing one. - """ - - try: - convenience_lib = env['BUILDERS']['ConvenienceLibrary'] - except KeyError: - action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ] - if env.Detect('ranlib'): - ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR") - action_list.append(ranlib_action) - - convenience_lib = SCons.Builder.Builder(action = action_list, - emitter = '$LIBEMITTER', - prefix = '$LIBPREFIX', - suffix = '$LIBSUFFIX', - src_suffix = '$SHOBJSUFFIX', - src_builder = 'SharedObject') - env['BUILDERS']['ConvenienceLibrary'] = convenience_lib - env['BUILDERS']['Library'] = convenience_lib - - return convenience_lib - - -####################################################################### -# Build - -def make_build_dir(env): - # Put build output in a separate dir, which depends on the current configuration - # See also http://www.scons.org/wiki/AdvancedBuildExample - build_topdir = 'build' - build_subdir = env['platform'] - if env['dri']: - build_subdir += "-dri" - if env['llvm']: - build_subdir += "-llvm" - if env['machine'] != 'generic': - build_subdir += '-' + env['machine'] - if env['debug']: - build_subdir += "-debug" - if env['profile']: - build_subdir += "-profile" - build_dir = os.path.join(build_topdir, build_subdir) - # Place the .sconsign file on the builddir too, to avoid issues with different scons - # versions building the same source file - env.SConsignFile(os.path.join(build_dir, '.sconsign')) - return build_dir - - -####################################################################### -# Common environment generation code - -def generate(env): - # FIXME: this is already too late - #if env.get('quiet', False): - # quietCommandLines(env) - - # shortcuts - debug = env['debug'] - machine = env['machine'] - platform = env['platform'] - x86 = env['machine'] == 'x86' - gcc = env['platform'] in ('linux', 'freebsd', 'darwin') - msvc = env['platform'] in ('windows', 'winddk', 'wince') - - # C preprocessor options - cppdefines = [] - if debug: - cppdefines += ['DEBUG'] - else: - cppdefines += ['NDEBUG'] - if env['profile']: - cppdefines += ['PROFILE'] - if platform == 'windows': - cppdefines += [ - 'WIN32', - '_WINDOWS', - '_UNICODE', - 'UNICODE', - # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, - 'WIN32_LEAN_AND_MEAN', - 'VC_EXTRALEAN', - '_CRT_SECURE_NO_DEPRECATE', - ] - if debug: - cppdefines += ['_DEBUG'] - if platform == 'winddk': - # Mimic WINDDK's builtin flags. See also: - # - WINDDK's bin/makefile.new i386mk.inc for more info. - # - buildchk_wxp_x86.log files, generated by the WINDDK's build - # - http://alter.org.ua/docs/nt_kernel/vc8_proj/ - cppdefines += [ - ('_X86_', '1'), - ('i386', '1'), - 'STD_CALL', - ('CONDITION_HANDLING', '1'), - ('NT_INST', '0'), - ('WIN32', '100'), - ('_NT1X_', '100'), - ('WINNT', '1'), - ('_WIN32_WINNT', '0x0501'), # minimum required OS version - ('WINVER', '0x0501'), - ('_WIN32_IE', '0x0603'), - ('WIN32_LEAN_AND_MEAN', '1'), - ('DEVL', '1'), - ('__BUILDMACHINE__', 'WinDDK'), - ('FPO', '0'), - ] - if debug: - cppdefines += [('DBG', 1)] - if platform == 'wince': - cppdefines += [ - ('_WIN32_WCE', '500'), - 'WCE_PLATFORM_STANDARDSDK_500', - '_i386_', - ('UNDER_CE', '500'), - 'UNICODE', - '_UNICODE', - '_X86_', - 'x86', - '_USRDLL', - 'TEST_EXPORTS' , - ] - if platform == 'windows': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] - if platform == 'winddk': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] - if platform == 'wince': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] - env.Append(CPPDEFINES = cppdefines) - - # C compiler options - cflags = [] - if gcc: - if debug: - cflags += ['-O0', '-g3'] - else: - cflags += ['-O3', '-g3'] - if env['profile']: - cflags += ['-pg'] - if env['machine'] == 'x86' and default_machine == 'x86_64': - cflags += ['-m32'] - if env['machine'] == 'x86_64' and default_machine == 'x86': - cflags += ['-m64'] - cflags += [ - '-Wall', - '-Wmissing-prototypes', - '-Wno-long-long', - '-ffast-math', - '-pedantic', - '-fmessage-length=0', # be nice to Eclipse - ] - if msvc: - # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - # - cl /? - if debug: - cflags += [ - '/Od', # disable optimizations - '/Oi', # enable intrinsic functions - '/Oy-', # disable frame pointer omission - ] - else: - cflags += [ - '/Ox', # maximum optimizations - '/Oi', # enable intrinsic functions - '/Os', # favor code space - ] - if env['profile']: - cflags += [ - '/Gh', # enable _penter hook function - '/GH', # enable _pexit hook function - ] - cflags += [ - '/W3', # warning level - #'/Wp64', # enable 64 bit porting warnings - ] - if platform == 'windows': - cflags += [ - # TODO - ] - if platform == 'winddk': - cflags += [ - '/Zl', # omit default library name in .OBJ - '/Zp8', # 8bytes struct member alignment - '/Gy', # separate functions for linker - '/Gm-', # disable minimal rebuild - '/WX', # treat warnings as errors - '/Gz', # __stdcall Calling convention - '/GX-', # disable C++ EH - '/GR-', # disable C++ RTTI - '/GF', # enable read-only string pooling - '/G6', # optimize for PPro, P-II, P-III - '/Ze', # enable extensions - '/Gi-', # disable incremental compilation - '/QIfdiv-', # disable Pentium FDIV fix - '/hotpatch', # prepares an image for hotpatching. - #'/Z7', #enable old-style debug info - ] - if platform == 'wince': - cflags += [ - '/Gs8192', - '/GF', # enable read-only string pooling - ] - # Put debugging information in a separate .pdb file for each object file as - # described in the scons manpage - env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb' - env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cflags) - - # Linker options - linkflags = [] - if gcc: - if env['machine'] == 'x86' and default_machine == 'x86_64': - linkflags += ['-m32'] - if env['machine'] == 'x86_64' and default_machine == 'x86': - linkflags += ['-m64'] - if platform == 'winddk': - # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - linkflags += [ - '/merge:_PAGE=PAGE', - '/merge:_TEXT=.text', - '/section:INIT,d', - '/opt:ref', - '/opt:icf', - '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', - '/incremental:no', - '/fullbuild', - '/release', - '/nodefaultlib', - '/wx', - '/debug', - '/debugtype:cv', - '/version:5.1', - '/osversion:5.1', - '/functionpadmin:5', - '/safeseh', - '/pdbcompress', - '/stack:0x40000,0x1000', - '/driver', - '/align:0x80', - '/subsystem:native,5.01', - '/base:0x10000', - - '/entry:DrvEnableDriver', - ] - env.Append(LINKFLAGS = linkflags) - - - createConvenienceLibBuilder(env) - - - # for debugging - #print env.Dump() - diff --git a/scons/gallium.py b/scons/gallium.py new file mode 100644 index 0000000000..1787adb312 --- /dev/null +++ b/scons/gallium.py @@ -0,0 +1,323 @@ +"""gallium + +Frontend-tool for Gallium3D architecture. + +""" + +# +# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + + +import os.path + +import SCons.Action +import SCons.Builder + + +def quietCommandLines(env): + # Quiet command lines + # See also http://www.scons.org/wiki/HidingCommandLinesInOutput + env['CCCOMSTR'] = "Compiling $SOURCE ..." + env['CXXCOMSTR'] = "Compiling $SOURCE ..." + env['ARCOMSTR'] = "Archiving $TARGET ..." + env['RANLIBCOMSTR'] = "" + env['LINKCOMSTR'] = "Linking $TARGET ..." + + +def createConvenienceLibBuilder(env): + """This is a utility function that creates the ConvenienceLibrary + Builder in an Environment if it is not there already. + + If it is already there, we return the existing one. + + Based on the stock StaticLibrary and SharedLibrary builders. + """ + + try: + convenience_lib = env['BUILDERS']['ConvenienceLibrary'] + except KeyError: + action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ] + if env.Detect('ranlib'): + ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR") + action_list.append(ranlib_action) + + convenience_lib = SCons.Builder.Builder(action = action_list, + emitter = '$LIBEMITTER', + prefix = '$LIBPREFIX', + suffix = '$LIBSUFFIX', + src_suffix = '$SHOBJSUFFIX', + src_builder = 'SharedObject') + env['BUILDERS']['ConvenienceLibrary'] = convenience_lib + env['BUILDERS']['Library'] = convenience_lib + + return convenience_lib + + +def generate(env): + """Common environment generation code""" + + # FIXME: this is already too late + #if env.get('quiet', False): + # quietCommandLines(env) + + # shortcuts + debug = env['debug'] + machine = env['machine'] + platform = env['platform'] + x86 = env['machine'] == 'x86' + gcc = env['platform'] in ('linux', 'freebsd', 'darwin') + msvc = env['platform'] in ('windows', 'winddk', 'wince') + + # Tool + if platform == 'winddk': + env.Tool('winddk') + elif platform == 'wince': + env.Tool('evc') + else: + env.Tool('default') + + # Put build output in a separate dir, which depends on the current + # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample + build_topdir = 'build' + build_subdir = env['platform'] + if env['dri']: + build_subdir += "-dri" + if env['llvm']: + build_subdir += "-llvm" + if env['machine'] != 'generic': + build_subdir += '-' + env['machine'] + if env['debug']: + build_subdir += "-debug" + if env['profile']: + build_subdir += "-profile" + build_dir = os.path.join(build_topdir, build_subdir) + # Place the .sconsign file in the build dir too, to avoid issues with + # different scons versions building the same source file + env['build'] = build_dir + env.SConsignFile(os.path.join(build_dir, '.sconsign')) + + # C preprocessor options + cppdefines = [] + if debug: + cppdefines += ['DEBUG'] + else: + cppdefines += ['NDEBUG'] + if env['profile']: + cppdefines += ['PROFILE'] + if platform == 'windows': + cppdefines += [ + 'WIN32', + '_WINDOWS', + '_UNICODE', + 'UNICODE', + # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, + 'WIN32_LEAN_AND_MEAN', + 'VC_EXTRALEAN', + '_CRT_SECURE_NO_DEPRECATE', + ] + if debug: + cppdefines += ['_DEBUG'] + if platform == 'winddk': + # Mimic WINDDK's builtin flags. See also: + # - WINDDK's bin/makefile.new i386mk.inc for more info. + # - buildchk_wxp_x86.log files, generated by the WINDDK's build + # - http://alter.org.ua/docs/nt_kernel/vc8_proj/ + cppdefines += [ + ('_X86_', '1'), + ('i386', '1'), + 'STD_CALL', + ('CONDITION_HANDLING', '1'), + ('NT_INST', '0'), + ('WIN32', '100'), + ('_NT1X_', '100'), + ('WINNT', '1'), + ('_WIN32_WINNT', '0x0501'), # minimum required OS version + ('WINVER', '0x0501'), + ('_WIN32_IE', '0x0603'), + ('WIN32_LEAN_AND_MEAN', '1'), + ('DEVL', '1'), + ('__BUILDMACHINE__', 'WinDDK'), + ('FPO', '0'), + ] + if debug: + cppdefines += [('DBG', 1)] + if platform == 'wince': + cppdefines += [ + ('_WIN32_WCE', '500'), + 'WCE_PLATFORM_STANDARDSDK_500', + '_i386_', + ('UNDER_CE', '500'), + 'UNICODE', + '_UNICODE', + '_X86_', + 'x86', + '_USRDLL', + 'TEST_EXPORTS' , + ] + if platform == 'windows': + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] + if platform == 'winddk': + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] + if platform == 'wince': + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] + env.Append(CPPDEFINES = cppdefines) + + # C preprocessor includes + if platform == 'winddk': + env.Append(CPPPATH = [ + env['SDK_INC_PATH'], + env['DDK_INC_PATH'], + env['WDM_INC_PATH'], + env['CRT_INC_PATH'], + ]) + + # C compiler options + cflags = [] + if gcc: + if debug: + cflags += ['-O0', '-g3'] + else: + cflags += ['-O3', '-g3'] + if env['profile']: + cflags += ['-pg'] + if env['machine'] == 'x86': + cflags += ['-m32'] + if env['machine'] == 'x86_64': + cflags += ['-m64'] + cflags += [ + '-Wall', + '-Wmissing-prototypes', + '-Wno-long-long', + '-ffast-math', + '-pedantic', + '-fmessage-length=0', # be nice to Eclipse + ] + if msvc: + # See also: + # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx + # - cl /? + if debug: + cflags += [ + '/Od', # disable optimizations + '/Oi', # enable intrinsic functions + '/Oy-', # disable frame pointer omission + ] + else: + cflags += [ + '/Ox', # maximum optimizations + '/Oi', # enable intrinsic functions + '/Os', # favor code space + ] + if env['profile']: + cflags += [ + '/Gh', # enable _penter hook function + '/GH', # enable _pexit hook function + ] + cflags += [ + '/W3', # warning level + #'/Wp64', # enable 64 bit porting warnings + ] + if platform == 'windows': + cflags += [ + # TODO + ] + if platform == 'winddk': + cflags += [ + '/Zl', # omit default library name in .OBJ + '/Zp8', # 8bytes struct member alignment + '/Gy', # separate functions for linker + '/Gm-', # disable minimal rebuild + '/WX', # treat warnings as errors + '/Gz', # __stdcall Calling convention + '/GX-', # disable C++ EH + '/GR-', # disable C++ RTTI + '/GF', # enable read-only string pooling + '/G6', # optimize for PPro, P-II, P-III + '/Ze', # enable extensions + '/Gi-', # disable incremental compilation + '/QIfdiv-', # disable Pentium FDIV fix + '/hotpatch', # prepares an image for hotpatching. + #'/Z7', #enable old-style debug info + ] + if platform == 'wince': + cflags += [ + '/Gs8192', + '/GF', # enable read-only string pooling + ] + # Automatic pdb generation + # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 + env.EnsureSConsVersion(0, 98, 0) + env['PDB'] = '${TARGET.base}.pdb' + env.Append(CFLAGS = cflags) + env.Append(CXXFLAGS = cflags) + + # Linker options + linkflags = [] + if gcc: + if env['machine'] == 'x86': + linkflags += ['-m32'] + if env['machine'] == 'x86_64': + linkflags += ['-m64'] + if platform == 'winddk': + # See also: + # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx + linkflags += [ + '/merge:_PAGE=PAGE', + '/merge:_TEXT=.text', + '/section:INIT,d', + '/opt:ref', + '/opt:icf', + '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', + '/incremental:no', + '/fullbuild', + '/release', + '/nodefaultlib', + '/wx', + '/debug', + '/debugtype:cv', + '/version:5.1', + '/osversion:5.1', + '/functionpadmin:5', + '/safeseh', + '/pdbcompress', + '/stack:0x40000,0x1000', + '/driver', + '/align:0x80', + '/subsystem:native,5.01', + '/base:0x10000', + + '/entry:DrvEnableDriver', + ] + env.Append(LINKFLAGS = linkflags) + + # Convenience Library Builder + createConvenienceLibBuilder(env) + + # for debugging + #print env.Dump() + + +def exists(env): + return 1 -- cgit v1.2.3