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++. --- scons/evc.py | 108 +++++++++++++++++++++++++++ scons/mslib_sa.py | 49 +++++++++++++ scons/mslink_sa.py | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scons/msvc_sa.py | 173 +++++++++++++++++++++++++++++++++++++++++++ scons/winddk.py | 114 +++++++++++++++++++++++++++++ 5 files changed, 655 insertions(+) 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 (limited to 'scons') 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: -- 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 'scons') 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 From f78cc24c4b4f253223044b7019daf3e954f38a07 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 23 Jun 2008 12:49:45 +0900 Subject: scons: Update to target WinCE 6.0. --- scons/evc.py | 108 ------------------------------------- scons/gallium.py | 31 +++++++---- scons/wcesdk.py | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+), 117 deletions(-) delete mode 100644 scons/evc.py create mode 100644 scons/wcesdk.py (limited to 'scons') diff --git a/scons/evc.py b/scons/evc.py deleted file mode 100644 index 22a92607e5..0000000000 --- a/scons/evc.py +++ /dev/null @@ -1,108 +0,0 @@ -"""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/gallium.py b/scons/gallium.py index 1787adb312..217a1d61d3 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -94,7 +94,7 @@ def generate(env): if platform == 'winddk': env.Tool('winddk') elif platform == 'wince': - env.Tool('evc') + env.Tool('wcesdk') else: env.Tool('default') @@ -165,16 +165,20 @@ def generate(env): cppdefines += [('DBG', 1)] if platform == 'wince': cppdefines += [ - ('_WIN32_WCE', '500'), - 'WCE_PLATFORM_STANDARDSDK_500', - '_i386_', - ('UNDER_CE', '500'), + '_CRT_SECURE_NO_DEPRECATE', + '_USE_32BIT_TIME_T', 'UNICODE', '_UNICODE', - '_X86_', + ('UNDER_CE', '600'), + ('_WIN32_WCE', '0x600'), + 'WINCEOEM', + 'WINCEINTERNAL', + 'WIN32', + 'STRICT', 'x86', - '_USRDLL', - 'TEST_EXPORTS' , + '_X86_', + 'INTERNATIONAL', + ('INTLMSG_CODEPAGE', '1252'), ] if platform == 'windows': cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] @@ -262,9 +266,18 @@ def generate(env): #'/Z7', #enable old-style debug info ] if platform == 'wince': + # See also C:\WINCE600\public\common\oak\misc\makefile.def cflags += [ - '/Gs8192', '/GF', # enable read-only string pooling + '/GR-', # disable C++ RTTI + '/GS', # enable security checks + # Allow disabling language conformance to maintain backward compat + #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef + #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules + #'/wd4867', + #'/wd4430', + #'/MT', + #'/U_MT', ] # Automatic pdb generation # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 diff --git a/scons/wcesdk.py b/scons/wcesdk.py new file mode 100644 index 0000000000..bdaab7d19f --- /dev/null +++ b/scons/wcesdk.py @@ -0,0 +1,158 @@ +"""wcesdk + +Tool-specific initialization for Microsoft Window CE SDKs. + +""" + +# +# 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_wce500_paths(env): + """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 get_wce600_paths(env): + """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 = [] + + # See also C:\WINCE600\public\common\oak\misc\wince.bat + + os_version = os.environ.get('_winceosver', '600') + wince_root = os.environ.get('_winceroot', r'C:\WINCE600') + platform_root = os.environ.get('_platformroot', os.path.join(wince_root, 'platform')) + sdk_root = os.environ.get('_sdkroot' ,os.path.join(wince_root, 'sdk')) + + platform_root = os.environ.get('_platformroot', os.path.join(wince_root, 'platform')) + sdk_root = os.environ.get('_sdkroot' ,os.path.join(wince_root, 'sdk')) + + host_cpu = os.environ.get('_hostcputype', 'i386') + target_cpu = os.environ.get('_tgtcpu', 'x86') + + if env['debug']: + build = 'debug' + else: + build = 'retail' + + try: + project_root = os.environ['_projectroot'] + except KeyError: + # No project root defined -- use the common stuff instead + project_root = os.path.join(wince_root, 'public', 'common') + + exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu) ) + exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu, target_cpu) ) + exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'bin', host_cpu) ) + exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'misc') ) + + include_paths.append( os.path.join(project_root, 'sdk', 'inc') ) + include_paths.append( os.path.join(project_root, 'oak', 'inc') ) + include_paths.append( os.path.join(project_root, 'ddk', 'inc') ) + include_paths.append( os.path.join(sdk_root, 'CE', 'inc') ) + + lib_paths.append( os.path.join(project_root, 'sdk', 'lib', target_cpu, build) ) + lib_paths.append( os.path.join(project_root, 'oak', 'lib', target_cpu, build) ) + lib_paths.append( os.path.join(project_root, 'ddk', 'lib', target_cpu, build) ) + + 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_wce600_paths(env) + + 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: -- cgit v1.2.3 From 05cfb4c4b84b4e3119112c381ceffc583a4ef5fe Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 27 Jun 2008 13:41:23 +0900 Subject: scons: Get x86-64<->x86 cross build of assembly files right. --- scons/gallium.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 217a1d61d3..c4a5c65be4 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -286,6 +286,13 @@ def generate(env): env.Append(CFLAGS = cflags) env.Append(CXXFLAGS = cflags) + # Assembler options + if gcc: + if env['machine'] == 'x86': + env.Append(ASFLAGS = ['-m32']) + if env['machine'] == 'x86_64': + env.Append(ASFLAGS = ['-m64']) + # Linker options linkflags = [] if gcc: -- cgit v1.2.3 From 846f87d8264e2a3755b0a00e45e75602192957fe Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 1 Jul 2008 22:04:01 +0900 Subject: scons: Output mapfile on windows ddk profile builds. --- scons/gallium.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index c4a5c65be4..59ba34844b 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -330,6 +330,10 @@ def generate(env): '/entry:DrvEnableDriver', ] + if env['profile']: + linkflags += [ + '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx + ] env.Append(LINKFLAGS = linkflags) # Convenience Library Builder -- cgit v1.2.3 From 27d8d6f44faa61a61c330d032111eee64dd8b8c7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 3 Jul 2008 12:42:23 +0900 Subject: scons: Add a env.CodeGenerate method to simplify code generation via python scripts. env.CodeGenerate( target = 'my_source.c', script = 'my_generator.py', source = ['input.txt', 'another.txt'], command = 'python $SCRIPT $SOURCE > $TARGET' ) It will take care generating all appropriate dependencies, including any module imported by the generator script, and the respective .pyc file side effects. --- scons/gallium.py | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 3 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 59ba34844b..bfdd2de8db 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -30,10 +30,13 @@ Frontend-tool for Gallium3D architecture. # +import os import os.path +import re import SCons.Action import SCons.Builder +import SCons.Scanner def quietCommandLines(env): @@ -70,11 +73,73 @@ def createConvenienceLibBuilder(env): src_suffix = '$SHOBJSUFFIX', src_builder = 'SharedObject') env['BUILDERS']['ConvenienceLibrary'] = convenience_lib - env['BUILDERS']['Library'] = convenience_lib return convenience_lib +# TODO: handle import statements with multiple modules +# TODO: handle from import statements +import_re = re.compile(r'^import\s+(\S+)$', re.M) + +def python_scan(node, env, path): + # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789 + contents = node.get_contents() + source_dir = node.get_dir() + imports = import_re.findall(contents) + results = [] + for imp in imports: + for dir in path: + file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py') + if os.path.exists(file): + results.append(env.File(file)) + break + file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py') + if os.path.exists(file): + results.append(env.File(file)) + break + return results + +python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py']) + + +def code_generate(env, script, target, source, command): + """Method to simplify code generation via python scripts. + + http://www.scons.org/wiki/UsingCodeGenerators + http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html + """ + + # We're generating code using Python scripts, so we have to be + # careful with our scons elements. This entry represents + # the generator file *in the source directory*. + script_src = env.File(script).srcnode() + + # This command creates generated code *in the build directory*. + command = command.replace('$SCRIPT', script_src.path) + code = env.Command(target, source, command) + + # Explicitly mark that the generated code depends on the generator, + # and on implicitly imported python modules + path = (script_src.get_dir(),) + deps = [script_src] + deps += script_src.get_implicit_deps(env, python_scanner, path) + env.Depends(code, deps) + + # Running the Python script causes .pyc files to be generated in the + # source directory. When we clean up, they should go too. So add side + # effects for .pyc files + for dep in deps: + pyc = env.File(str(dep) + 'c') + env.SideEffect(pyc, code) + + return code + + +def createCodeGenerateMethod(env): + env.Append(SCANNERS = python_scanner) + env.AddMethod(code_generate, 'CodeGenerate') + + def generate(env): """Common environment generation code""" @@ -336,9 +401,10 @@ def generate(env): ] env.Append(LINKFLAGS = linkflags) - # Convenience Library Builder + # Custom builders and methods createConvenienceLibBuilder(env) - + createCodeGenerateMethod(env) + # for debugging #print env.Dump() -- cgit v1.2.3 From 194cfc7a4ed86653db34be0e331ad7c23b5334eb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 4 Jul 2008 22:27:50 +0900 Subject: scons: Enable gcc SSE2 intrinsics on x86. --- scons/gallium.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index bfdd2de8db..62030f0ab7 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -272,7 +272,12 @@ def generate(env): if env['profile']: cflags += ['-pg'] if env['machine'] == 'x86': - cflags += ['-m32'] + cflags += [ + '-m32', + #'-march=pentium4', + '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics + #'-mfpmath=sse', + ] if env['machine'] == 'x86_64': cflags += ['-m64'] cflags += [ -- cgit v1.2.3 From 2c4349aa3ac9a6d5ee1f7b1aeb5eb0ee1cb54690 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 15 Jul 2008 07:56:42 +0900 Subject: python: Move the python scons code to a separate tool module. --- SConstruct | 2 +- scons/python.py | 71 ++++++++++++++++++++++++++++ src/gallium/state_trackers/python/SConscript | 44 +++-------------- 3 files changed, 79 insertions(+), 38 deletions(-) create mode 100644 scons/python.py (limited to 'scons') diff --git a/SConstruct b/SConstruct index 6e166502f8..fe27ceafe7 100644 --- a/SConstruct +++ b/SConstruct @@ -53,7 +53,7 @@ opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys, env = Environment( options = opts, tools = ['gallium'], - toolpath = ['scons'], + toolpath = ['#scons'], ENV = os.environ, ) diff --git a/scons/python.py b/scons/python.py new file mode 100644 index 0000000000..e1acc775b6 --- /dev/null +++ b/scons/python.py @@ -0,0 +1,71 @@ +"""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 sys +import os.path + + +def generate(env): + + # http://www.scons.org/wiki/PythonExtensions + #env.AppendUnique(CPPATH = [distutils.sysconfig.get_python_inc()]) + #distutils.sysconfig.get_config_vars('SO') + + env['SHLIBPREFIX'] = '' + + if sys.platform in ['linux2']: + env.ParseConfig('python-config --cflags --ldflags --libs') + + if sys.platform in ['windows']: + python_root = sys.prefix + python_version = '%u%u' % sys.version_info[:2] + python_include = os.path.join(python_root, 'include') + python_libs = os.path.join(python_root, 'libs') + python_lib = os.path.join(python_libs, 'python' + python_version + '.lib') + + env.Append(CPPPATH = [python_include]) + env.Append(LIBPATH = [python_libs]) + env.Append(LIBS = ['python' + python_version + '.lib']) + env.Replace(SHLIBSUFFIX = '.pyd') + + # XXX; python25_d.lib is not included in Python for windows, and + # we'll get missing symbols unless we undefine _DEBUG + cppdefines = env['CPPDEFINES'] + cppdefines = [define for define in cppdefines if define != '_DEBUG'] + env.Replace(CPPDEFINES = cppdefines) + + # for debugging + #print env.Dump() + + +def exists(env): + return 1 diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index 854cd83b7c..687c46bfd7 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -7,50 +7,20 @@ if 'python' in env['statetrackers']: env = env.Clone() - env.Append(CPPPATH = '.') + env.Tool('python') env.Tool('swig') env.Append(SWIGPATH = ['#src/gallium/include', '#src/gallium/include/pipe']) env.Append(SWIGFLAGS = ['-python', '-keyword']) - # http://www.scons.org/wiki/PythonExtensions - #env.AppendUnique(CPPATH = [distutils.sysconfig.get_python_inc()]) - #distutils.sysconfig.get_config_vars('SO') - - env['SHLIBPREFIX'] = '' - - if platform in ['linux']: - env.ParseConfig('python-config --cflags --ldflags --libs') - - if platform in ['windows']: - python_root = sys.prefix - python_version = '%u%u' % sys.version_info[:2] - python_include = os.path.join(python_root, 'include') - python_libs = os.path.join(python_root, 'libs') - python_lib = os.path.join(python_libs, 'python' + python_version + '.lib') - - env.Append(CPPPATH = [python_include]) - env.Append(LIBPATH = [python_libs]) - env.Append(LIBS = ['python' + python_version + '.lib']) - env.Replace(SHLIBSUFFIX = '.pyd') - - if env['debug']: - # XXX; python25_d.lib is not included in Python for windows, and - # we'll get missing symbols unless we undefine _DEBUG - cppdefines = env['CPPDEFINES'] - cppdefines = [define for define in cppdefines if define != '_DEBUG'] - env.Replace(CPPDEFINES = cppdefines) - - # http://www.swig.org/Doc1.3/Windows.html - env['ENV']['PYTHON_INCLUDE'] = python_include - env['ENV']['PYTHON_LIB'] = python_lib - + env.Append(CPPPATH = '.') + env.SharedLibrary( - target = '_gallium', - source = [ - 'gallium.i', + target = '_gallium', + source = [ + 'gallium.i', 'st_device.c', 'st_softpipe_winsys.c', - ], + ], LIBS = softpipe + auxiliaries + env['LIBS'], ) -- cgit v1.2.3 From 9a99b19949e407528b5b40309efd344672de8f6f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 15 Jul 2008 12:17:35 +0900 Subject: python: Don't use python cflags as they conflict with existing flags. --- scons/python.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'scons') diff --git a/scons/python.py b/scons/python.py index e1acc775b6..539184dd39 100644 --- a/scons/python.py +++ b/scons/python.py @@ -31,20 +31,13 @@ Frontend-tool for Gallium3D architecture. import sys +import distutils.sysconfig import os.path def generate(env): - - # http://www.scons.org/wiki/PythonExtensions - #env.AppendUnique(CPPATH = [distutils.sysconfig.get_python_inc()]) - #distutils.sysconfig.get_config_vars('SO') - - env['SHLIBPREFIX'] = '' + # See http://www.scons.org/wiki/PythonExtensions - if sys.platform in ['linux2']: - env.ParseConfig('python-config --cflags --ldflags --libs') - if sys.platform in ['windows']: python_root = sys.prefix python_version = '%u%u' % sys.version_info[:2] @@ -55,6 +48,7 @@ def generate(env): env.Append(CPPPATH = [python_include]) env.Append(LIBPATH = [python_libs]) env.Append(LIBS = ['python' + python_version + '.lib']) + env.Replace(SHLIBPREFIX = '') env.Replace(SHLIBSUFFIX = '.pyd') # XXX; python25_d.lib is not included in Python for windows, and @@ -62,6 +56,11 @@ def generate(env): cppdefines = env['CPPDEFINES'] cppdefines = [define for define in cppdefines if define != '_DEBUG'] env.Replace(CPPDEFINES = cppdefines) + else: + #env.ParseConfig('python-config --cflags --ldflags --libs') + env.AppendUnique(CPPPATH = [distutils.sysconfig.get_python_inc()]) + env.Replace(SHLIBPREFIX = '') + env.Replace(SHLIBSUFFIX = distutils.sysconfig.get_config_vars()['SO']) # for debugging #print env.Dump() -- cgit v1.2.3 From e4f3770690129dc1ea683fadbe07f1fbc49cf271 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Wed, 16 Jul 2008 16:10:57 -0600 Subject: mesa: WinCE fixes --- include/GL/gl.h | 2 +- include/GLES/glplatform.h | 6 +++++- include/GLES2/gl2platform.h | 6 +++++- scons/gallium.py | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) (limited to 'scons') diff --git a/include/GL/gl.h b/include/GL/gl.h index c0cebec2ef..c9ef6136fa 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -58,7 +58,7 @@ # else /* for use with static link lib build of Win32 edition only */ # define GLAPI extern # endif /* _STATIC_MESA support */ -# if defined(__MINGW32__) && defined(GL_NO_STDCALL) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ # define GLAPIENTRY # else # define GLAPIENTRY __stdcall diff --git a/include/GLES/glplatform.h b/include/GLES/glplatform.h index dbbf2b9194..6e725b18a9 100644 --- a/include/GLES/glplatform.h +++ b/include/GLES/glplatform.h @@ -51,7 +51,11 @@ extern "C" { # else # define GL_API __declspec(dllimport) # endif -# define GL_APIENTRY __stdcall +# ifdef UNDER_CE +# define GL_APIENTRY +# else +# define GL_APIENTRY __stdcall +# endif #else # ifdef __GL_EXPORTS # define GL_API diff --git a/include/GLES2/gl2platform.h b/include/GLES2/gl2platform.h index 348daea765..7891a61ed7 100644 --- a/include/GLES2/gl2platform.h +++ b/include/GLES2/gl2platform.h @@ -51,7 +51,11 @@ extern "C" { # else # define GL_APICALL __declspec(dllimport) # endif -# define GL_APIENTRY __stdcall +# ifdef UNDER_CE +# define GL_APIENTRY +# else +# define GL_APIENTRY __stdcall +# endif #else # ifdef __GL_EXPORTS # define GL_APICALL diff --git a/scons/gallium.py b/scons/gallium.py index 62030f0ab7..75225c97c7 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -338,6 +338,7 @@ def generate(env): if platform == 'wince': # See also C:\WINCE600\public\common\oak\misc\makefile.def cflags += [ + '/Zl', # omit default library name in .OBJ '/GF', # enable read-only string pooling '/GR-', # disable C++ RTTI '/GS', # enable security checks @@ -400,6 +401,13 @@ def generate(env): '/entry:DrvEnableDriver', ] + if platform == 'wince': + linkflags += [ + '/nodefaultlib', +# '/incremental:no', +# '/fullbuild', + '/entry:_DllMainCRTStartup', + ] if env['profile']: linkflags += [ '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx -- cgit v1.2.3 From 381e3489c21c177d87bac9d7cdbfe7e2611772e5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 17 Jul 2008 11:23:43 +0900 Subject: scons: Convert tabs to spaces. --- scons/gallium.py | 682 +++++++++++++++++++++++++++---------------------------- 1 file changed, 341 insertions(+), 341 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 75225c97c7..b3e48ab3b7 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -4,10 +4,10 @@ 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 @@ -15,11 +15,11 @@ Frontend-tool for Gallium3D architecture. # 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. @@ -27,7 +27,7 @@ Frontend-tool for Gallium3D architecture. # 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 @@ -40,13 +40,13 @@ import SCons.Scanner 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 ..." + # 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): @@ -54,7 +54,7 @@ def createConvenienceLibBuilder(env): 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. """ @@ -82,345 +82,345 @@ def createConvenienceLibBuilder(env): import_re = re.compile(r'^import\s+(\S+)$', re.M) def python_scan(node, env, path): - # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789 - contents = node.get_contents() - source_dir = node.get_dir() - imports = import_re.findall(contents) - results = [] - for imp in imports: - for dir in path: - file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py') - if os.path.exists(file): - results.append(env.File(file)) - break - file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py') - if os.path.exists(file): - results.append(env.File(file)) - break - return results + # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789 + contents = node.get_contents() + source_dir = node.get_dir() + imports = import_re.findall(contents) + results = [] + for imp in imports: + for dir in path: + file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py') + if os.path.exists(file): + results.append(env.File(file)) + break + file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py') + if os.path.exists(file): + results.append(env.File(file)) + break + return results python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py']) def code_generate(env, script, target, source, command): - """Method to simplify code generation via python scripts. - - http://www.scons.org/wiki/UsingCodeGenerators - http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html - """ - - # We're generating code using Python scripts, so we have to be - # careful with our scons elements. This entry represents - # the generator file *in the source directory*. - script_src = env.File(script).srcnode() - - # This command creates generated code *in the build directory*. - command = command.replace('$SCRIPT', script_src.path) - code = env.Command(target, source, command) - - # Explicitly mark that the generated code depends on the generator, - # and on implicitly imported python modules - path = (script_src.get_dir(),) - deps = [script_src] - deps += script_src.get_implicit_deps(env, python_scanner, path) - env.Depends(code, deps) - - # Running the Python script causes .pyc files to be generated in the - # source directory. When we clean up, they should go too. So add side - # effects for .pyc files - for dep in deps: - pyc = env.File(str(dep) + 'c') - env.SideEffect(pyc, code) - - return code + """Method to simplify code generation via python scripts. + + http://www.scons.org/wiki/UsingCodeGenerators + http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html + """ + + # We're generating code using Python scripts, so we have to be + # careful with our scons elements. This entry represents + # the generator file *in the source directory*. + script_src = env.File(script).srcnode() + + # This command creates generated code *in the build directory*. + command = command.replace('$SCRIPT', script_src.path) + code = env.Command(target, source, command) + + # Explicitly mark that the generated code depends on the generator, + # and on implicitly imported python modules + path = (script_src.get_dir(),) + deps = [script_src] + deps += script_src.get_implicit_deps(env, python_scanner, path) + env.Depends(code, deps) + + # Running the Python script causes .pyc files to be generated in the + # source directory. When we clean up, they should go too. So add side + # effects for .pyc files + for dep in deps: + pyc = env.File(str(dep) + 'c') + env.SideEffect(pyc, code) + + return code def createCodeGenerateMethod(env): - env.Append(SCANNERS = python_scanner) - env.AddMethod(code_generate, 'CodeGenerate') + env.Append(SCANNERS = python_scanner) + env.AddMethod(code_generate, 'CodeGenerate') 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('wcesdk') - 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 += [ - '_CRT_SECURE_NO_DEPRECATE', - '_USE_32BIT_TIME_T', - 'UNICODE', - '_UNICODE', - ('UNDER_CE', '600'), - ('_WIN32_WCE', '0x600'), - 'WINCEOEM', - 'WINCEINTERNAL', - 'WIN32', - 'STRICT', - 'x86', - '_X86_', - 'INTERNATIONAL', - ('INTLMSG_CODEPAGE', '1252'), - ] - 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', - #'-march=pentium4', - '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics - #'-mfpmath=sse', - ] - 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': - # See also C:\WINCE600\public\common\oak\misc\makefile.def - cflags += [ - '/Zl', # omit default library name in .OBJ - '/GF', # enable read-only string pooling - '/GR-', # disable C++ RTTI - '/GS', # enable security checks - # Allow disabling language conformance to maintain backward compat - #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef - #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules - #'/wd4867', - #'/wd4430', - #'/MT', - #'/U_MT', - ] - # 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) - - # Assembler options - if gcc: - if env['machine'] == 'x86': - env.Append(ASFLAGS = ['-m32']) - if env['machine'] == 'x86_64': - env.Append(ASFLAGS = ['-m64']) - - # 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', - ] - if platform == 'wince': - linkflags += [ - '/nodefaultlib', -# '/incremental:no', -# '/fullbuild', - '/entry:_DllMainCRTStartup', - ] - if env['profile']: - linkflags += [ - '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx - ] - env.Append(LINKFLAGS = linkflags) - - # Custom builders and methods - createConvenienceLibBuilder(env) - createCodeGenerateMethod(env) - - # for debugging - #print env.Dump() + """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('wcesdk') + 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 += [ + '_CRT_SECURE_NO_DEPRECATE', + '_USE_32BIT_TIME_T', + 'UNICODE', + '_UNICODE', + ('UNDER_CE', '600'), + ('_WIN32_WCE', '0x600'), + 'WINCEOEM', + 'WINCEINTERNAL', + 'WIN32', + 'STRICT', + 'x86', + '_X86_', + 'INTERNATIONAL', + ('INTLMSG_CODEPAGE', '1252'), + ] + 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', + #'-march=pentium4', + '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics + #'-mfpmath=sse', + ] + 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': + # See also C:\WINCE600\public\common\oak\misc\makefile.def + cflags += [ + '/Zl', # omit default library name in .OBJ + '/GF', # enable read-only string pooling + '/GR-', # disable C++ RTTI + '/GS', # enable security checks + # Allow disabling language conformance to maintain backward compat + #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef + #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules + #'/wd4867', + #'/wd4430', + #'/MT', + #'/U_MT', + ] + # 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) + + # Assembler options + if gcc: + if env['machine'] == 'x86': + env.Append(ASFLAGS = ['-m32']) + if env['machine'] == 'x86_64': + env.Append(ASFLAGS = ['-m64']) + + # 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', + ] + if env['profile']: + linkflags += [ + '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx + ] + if platform == 'wince': + linkflags += [ + '/nodefaultlib', + #'/incremental:no', + #'/fullbuild', + '/entry:_DllMainCRTStartup', + ] + env.Append(LINKFLAGS = linkflags) + + # Custom builders and methods + createConvenienceLibBuilder(env) + createCodeGenerateMethod(env) + + # for debugging + #print env.Dump() def exists(env): - return 1 + return 1 -- cgit v1.2.3 From c76787a1dcfa10b00fae5ac7f3d71dda758123cf Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 17 Jul 2008 11:25:20 +0900 Subject: scons: Set default LIBS env var. --- scons/gallium.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index b3e48ab3b7..43603e5104 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -414,6 +414,9 @@ def generate(env): ] env.Append(LINKFLAGS = linkflags) + # Default libs + env.Append(LIBS = []) + # Custom builders and methods createConvenienceLibBuilder(env) createCodeGenerateMethod(env) -- cgit v1.2.3 From 4ec4ea14a587300041799c5269295ba7e160ab65 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 24 Jul 2008 20:09:54 +0900 Subject: scons: Lookup WINDDK and WINCE SDK directories in the registry. --- scons/wcesdk.py | 50 ++++++++++++++++++++++++++++++++++---------------- scons/winddk.py | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 62 insertions(+), 28 deletions(-) (limited to 'scons') diff --git a/scons/wcesdk.py b/scons/wcesdk.py index bdaab7d19f..bf73c2d73f 100644 --- a/scons/wcesdk.py +++ b/scons/wcesdk.py @@ -76,6 +76,27 @@ def get_wce500_paths(env): exe_path = string.join(exe_paths, os.pathsep ) return (include_path, lib_path, exe_path) +def get_wce600_root(env): + try: + return os.environ['_WINCEROOT'] + except KeyError: + pass + + if SCons.Util.can_read_reg: + key = r'SOFTWARE\Microsoft\Platform Builder\6.00\Directories\OS Install Dir' + try: + path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key) + except SCons.Util.RegError: + pass + else: + return path + + default_path = os.path.join(r'C:\WINCE600', version) + if os.path.exists(default_path): + return default_path + + return None + def get_wce600_paths(env): """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values of those three environment variables that should be set @@ -87,16 +108,19 @@ def get_wce600_paths(env): # See also C:\WINCE600\public\common\oak\misc\wince.bat - os_version = os.environ.get('_winceosver', '600') - wince_root = os.environ.get('_winceroot', r'C:\WINCE600') - platform_root = os.environ.get('_platformroot', os.path.join(wince_root, 'platform')) - sdk_root = os.environ.get('_sdkroot' ,os.path.join(wince_root, 'sdk')) + wince_root = get_wce600_root(env) + if wince_root is None: + raise SCons.Errors.InternalError, "Windows CE 6.0 SDK not found" + + os_version = os.environ.get('_WINCEOSVER', '600') + platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform')) + sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk')) - platform_root = os.environ.get('_platformroot', os.path.join(wince_root, 'platform')) - sdk_root = os.environ.get('_sdkroot' ,os.path.join(wince_root, 'sdk')) + platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform')) + sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk')) - host_cpu = os.environ.get('_hostcputype', 'i386') - target_cpu = os.environ.get('_tgtcpu', 'x86') + host_cpu = os.environ.get('_HOSTCPUTYPE', 'i386') + target_cpu = os.environ.get('_TGTCPU', 'x86') if env['debug']: build = 'debug' @@ -104,7 +128,7 @@ def get_wce600_paths(env): build = 'retail' try: - project_root = os.environ['_projectroot'] + project_root = os.environ['_PROJECTROOT'] except KeyError: # No project root defined -- use the common stuff instead project_root = os.path.join(wince_root, 'public', 'common') @@ -147,12 +171,6 @@ def generate(env): 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 + return get_wce600_root(env) is not None # vim:set ts=4 sw=4 et: diff --git a/scons/winddk.py b/scons/winddk.py index be81d12ea9..6a99b83a83 100644 --- a/scons/winddk.py +++ b/scons/winddk.py @@ -44,7 +44,30 @@ import msvc_sa import mslib_sa import mslink_sa -def get_winddk_paths(env, version=None): +def get_winddk_root(env): + try: + return os.environ['BASEDIR'] + except KeyError: + pass + + version = "3790.1830" + + if SCons.Util.can_read_reg: + key = r'SOFTWARE\Microsoft\WINDDK\%s\LFNDirectory' % version + try: + path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key) + except SCons.Util.RegError: + pass + else: + return path + + default_path = os.path.join(r'C:\WINDDK', version) + if os.path.exists(default_path): + return default_path + + return None + +def get_winddk_paths(env): """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.""" @@ -54,10 +77,9 @@ def get_winddk_paths(env, version=None): lib_paths = [] include_paths = [] - if 'BASEDIR' in os.environ: - WINDDKdir = os.environ['BASEDIR'] - else: - WINDDKdir = "C:\\WINDDK\\3790.1830" + WINDDKdir = get_winddk_root(env) + if WINDDKdir is None: + raise SCons.Errors.InternalError, "WINDDK not found" exe_paths.append( os.path.join(WINDDKdir, 'bin') ) exe_paths.append( os.path.join(WINDDKdir, 'bin', 'x86') ) @@ -103,12 +125,6 @@ def generate(env): 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 + return get_winddk_root(env) is not None # vim:set ts=4 sw=4 et: -- cgit v1.2.3