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 From a6c725839482f3d0f2af0eb15e5b6ab80184fb6c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Sep 2008 09:47:40 +0900 Subject: scons: Optimize for speed, not size, with MSVC. --- scons/gallium.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 43603e5104..342a0879c3 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -290,7 +290,7 @@ def generate(env): ] if msvc: # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx + # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx # - cl /? if debug: cflags += [ @@ -302,7 +302,8 @@ def generate(env): cflags += [ '/Ox', # maximum optimizations '/Oi', # enable intrinsic functions - '/Os', # favor code space + '/Ot', # favor code speed + #'/fp:fast', # fast floating point ] if env['profile']: cflags += [ @@ -313,6 +314,11 @@ def generate(env): '/W3', # warning level #'/Wp64', # enable 64 bit porting warnings ] + if env['machine'] == 'x86': + cflags += [ + #'/QIfist', # Suppress _ftol + #'/arch:SSE2', # use the SSE2 instructions + ] if platform == 'windows': cflags += [ # TODO -- cgit v1.2.3 From 52c2dd1f73e17c8352fe976e2ee4cdf049f81957 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 8 Sep 2008 07:54:15 +0900 Subject: scons: Install libGL.so and respective symlinks. --- scons/gallium.py | 25 +++++++++++++++++++++++++ src/gallium/winsys/xlib/SConscript | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 342a0879c3..abe962493d 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -140,6 +140,30 @@ def createCodeGenerateMethod(env): env.AddMethod(code_generate, 'CodeGenerate') +def symlink(target, source, env): + target = str(target[0]) + source = str(source[0]) + if os.path.islink(target) or os.path.exists(target): + os.remove(target) + os.symlink(os.path.basename(source), target) + +def install_shared_library(env, source, version = ()): + source = str(source[0]) + version = tuple(map(str, version)) + target_dir = os.path.join(env['build'], 'lib') + target_name = '.'.join((str(source),) + version) + last = env.InstallAs(os.path.join(target_dir, target_name), source) + while len(version): + version = version[:-1] + target_name = '.'.join((str(source),) + version) + action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE") + print os.path.join(target_dir, target_name), last + last = env.Command(os.path.join(target_dir, target_name), last, action) + +def createInstallMethods(env): + env.AddMethod(install_shared_library, 'InstallSharedLibrary') + + def generate(env): """Common environment generation code""" @@ -426,6 +450,7 @@ def generate(env): # Custom builders and methods createConvenienceLibBuilder(env) createCodeGenerateMethod(env) + createInstallMethods(env) # for debugging #print env.Dump() diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index 8650f595a7..324fbef306 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -36,8 +36,10 @@ if env['platform'] == 'linux' \ drivers += [trace] # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions - env.SharedLibrary( + libgl = env.SharedLibrary( target ='GL', source = sources, LIBS = glapi + mesa + drivers + auxiliaries + env['LIBS'], ) + + env.InstallSharedLibrary(libgl, version=(1, 5)) -- cgit v1.2.3 From 7cfc294c70e96269055341d327622774c9173b37 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 8 Sep 2008 21:50:50 +0900 Subject: scons: Install shared libs in the right subdir. --- scons/gallium.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index abe962493d..3631607e66 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -150,14 +150,13 @@ def symlink(target, source, env): def install_shared_library(env, source, version = ()): source = str(source[0]) version = tuple(map(str, version)) - target_dir = os.path.join(env['build'], 'lib') + target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib') target_name = '.'.join((str(source),) + version) last = env.InstallAs(os.path.join(target_dir, target_name), source) while len(version): version = version[:-1] target_name = '.'.join((str(source),) + version) action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE") - print os.path.join(target_dir, target_name), last last = env.Command(os.path.join(target_dir, target_name), last, action) def createInstallMethods(env): -- cgit v1.2.3 From 6b69e3c71741d99a54c6f4dcb605a3c241239aeb Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 23 Oct 2008 10:28:48 +0200 Subject: scons: ppc support. --- SConstruct | 2 ++ common.py | 3 ++- scons/gallium.py | 1 + src/gallium/auxiliary/draw/SConscript | 1 + src/gallium/auxiliary/rtasm/SConscript | 1 + src/gallium/auxiliary/tgsi/SConscript | 1 + src/mesa/SConscript | 4 ++++ 7 files changed, 12 insertions(+), 1 deletion(-) (limited to 'scons') diff --git a/SConstruct b/SConstruct index c1dc624651..8c96817dae 100644 --- a/SConstruct +++ b/SConstruct @@ -70,12 +70,14 @@ platform = env['platform'] # derived options x86 = machine == 'x86' +ppc = machine == 'ppc' gcc = platform in ('linux', 'freebsd', 'darwin') msvc = platform in ('windows', 'winddk') Export([ 'debug', 'x86', + 'ppc', 'dri', 'llvm', 'platform', diff --git a/common.py b/common.py index dd64e0f434..cc2582f1a4 100644 --- a/common.py +++ b/common.py @@ -24,6 +24,7 @@ _machine_map = { 'i486': 'x86', 'i586': 'x86', 'i686': 'x86', + 'ppc' : 'ppc', 'x86_64': 'x86_64', } if 'PROCESSOR_ARCHITECTURE' in os.environ: @@ -56,7 +57,7 @@ def AddOptions(opts): opts.Add(BoolOption('profile', 'profile build', 'no')) #opts.Add(BoolOption('quiet', 'quiet command lines', 'no')) opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, - allowed_values=('generic', 'x86', 'x86_64'))) + allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) diff --git a/scons/gallium.py b/scons/gallium.py index 3631607e66..2a42bdf2bb 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -175,6 +175,7 @@ def generate(env): machine = env['machine'] platform = env['platform'] x86 = env['machine'] == 'x86' + ppc = env['machine'] == 'ppc' gcc = env['platform'] in ('linux', 'freebsd', 'darwin') msvc = env['platform'] in ('windows', 'winddk', 'wince') diff --git a/src/gallium/auxiliary/draw/SConscript b/src/gallium/auxiliary/draw/SConscript index 544a04918b..5f05aa324a 100644 --- a/src/gallium/auxiliary/draw/SConscript +++ b/src/gallium/auxiliary/draw/SConscript @@ -38,6 +38,7 @@ draw = env.ConvenienceLibrary( 'draw_vs_aos_machine.c', 'draw_vs_exec.c', 'draw_vs_llvm.c', + 'draw_vs_ppc.c', 'draw_vs_sse.c', 'draw_vs_varient.c' ]) diff --git a/src/gallium/auxiliary/rtasm/SConscript b/src/gallium/auxiliary/rtasm/SConscript index 8ea25922aa..eb48368acc 100644 --- a/src/gallium/auxiliary/rtasm/SConscript +++ b/src/gallium/auxiliary/rtasm/SConscript @@ -6,6 +6,7 @@ rtasm = env.ConvenienceLibrary( 'rtasm_cpu.c', 'rtasm_execmem.c', 'rtasm_x86sse.c', + 'rtasm_ppc.c', 'rtasm_ppc_spe.c', ]) diff --git a/src/gallium/auxiliary/tgsi/SConscript b/src/gallium/auxiliary/tgsi/SConscript index 45bf3f6d57..8200cce42f 100644 --- a/src/gallium/auxiliary/tgsi/SConscript +++ b/src/gallium/auxiliary/tgsi/SConscript @@ -12,6 +12,7 @@ tgsi = env.ConvenienceLibrary( 'tgsi_parse.c', 'tgsi_sanity.c', 'tgsi_scan.c', + 'tgsi_ppc.c', 'tgsi_sse2.c', 'tgsi_text.c', 'tgsi_transform.c', diff --git a/src/mesa/SConscript b/src/mesa/SConscript index af8dfcb493..89b98b37ab 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -283,6 +283,10 @@ if env['platform'] != 'winddk': 'x86-64/glapi_x86-64.S' ] elif gcc and env['machine'] == 'ppc': + env.Append(CPPDEFINES = [ + 'USE_PPC_ASM', + 'USE_VMX_ASM', + ]) mesa_sources += [ 'ppc/common_ppc.c', ] -- cgit v1.2.3 From 40b3bb0407b6833a06e0a3a2e859cfac75b9100b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 4 Nov 2008 10:53:02 +0900 Subject: gallium: Yet another WinCE portability fix. --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 2a42bdf2bb..c9d5368989 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -275,6 +275,7 @@ def generate(env): cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] if platform == 'wince': cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL'] env.Append(CPPDEFINES = cppdefines) # C preprocessor includes -- cgit v1.2.3 From 6cf59e1293c5777ba5675e6315cbfad3211f9260 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 18 Nov 2008 19:13:32 +0900 Subject: scons: Support MinGW32 cross compiler. To build an alternative opengl32.dll with Gallium's software-rasterizer from a debian-based distribution run: sudo apt-get install mingw32 scons platform=windows toolchain=crossmingw machine=x86 winsys=gdi dri=no --- common.py | 2 + scons/crossmingw.py | 182 ++++++++++++++++++++++++++++++++++++++ scons/gallium.py | 22 ++--- src/gallium/winsys/gdi/SConscript | 6 ++ 4 files changed, 202 insertions(+), 10 deletions(-) create mode 100644 scons/crossmingw.py (limited to 'scons') diff --git a/common.py b/common.py index cc2582f1a4..d9e919ef76 100644 --- a/common.py +++ b/common.py @@ -60,6 +60,8 @@ def AddOptions(opts): allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince'))) + opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default', + allowed_values=('default', 'crossmingw'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) diff --git a/scons/crossmingw.py b/scons/crossmingw.py new file mode 100644 index 0000000000..cf4887ba46 --- /dev/null +++ b/scons/crossmingw.py @@ -0,0 +1,182 @@ +"""SCons.Tool.gcc + +Tool-specific initialization for MinGW (http://www.mingw.org/) + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +See also http://www.scons.org/wiki/CrossCompilingMingw +""" + +# +# Copyright (c) 2001, 2002, 2003, 2004 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 +import os.path +import string + +import SCons.Action +import SCons.Builder +import SCons.Tool +import SCons.Util + +# This is what we search for to find mingw: +prefixes = SCons.Util.Split(""" + mingw32- + mingw32msvc- + i386-mingw32- + i486-mingw32- + i586-mingw32- + i686-mingw32- + i386-mingw32msvc- + i486-mingw32msvc- + i586-mingw32msvc- + i686-mingw32msvc- +""") + +def find(env): + for prefix in prefixes: + # First search in the SCons path and then the OS path: + if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'): + return prefix + + return '' + +def shlib_generator(target, source, env, for_signature): + cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS']) + + dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX') + if dll: cmd.extend(['-o', dll]) + + cmd.extend(['$SOURCES', '$_LIBDIRFLAGS', '$_LIBFLAGS']) + + implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX') + if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature)) + + def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') + if def_target: cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature)) + + return [cmd] + +def shlib_emitter(target, source, env): + 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") + + if not no_import_lib and \ + not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'): + + # Append an import library to the list of targets. + target.append(env.ReplaceIxes(dll, + 'SHLIBPREFIX', 'SHLIBSUFFIX', + 'LIBPREFIX', 'LIBSUFFIX')) + + # Append a def file target if there isn't already a def file target + # or a def file source. There is no option to disable def file + # target emitting, because I can't figure out why someone would ever + # want to turn it off. + def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') + def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') + if not def_source and not def_target: + target.append(env.ReplaceIxes(dll, + 'SHLIBPREFIX', 'SHLIBSUFFIX', + 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')) + + return (target, source) + + +shlib_action = SCons.Action.Action(shlib_generator, generator=1) + +res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR') + +res_builder = SCons.Builder.Builder(action=res_action, suffix='.o', + source_scanner=SCons.Tool.SourceFileScanner) +SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan) + +def generate(env): + mingw_prefix = find(env) + + if mingw_prefix: + dir = os.path.dirname(env.WhereIs(mingw_prefix + 'gcc') or SCons.Util.WhereIs(mingw_prefix + 'gcc')) + + # The mingw bin directory must be added to the path: + path = env['ENV'].get('PATH', []) + if not path: + path = [] + if SCons.Util.is_String(path): + path = string.split(path, os.pathsep) + + env['ENV']['PATH'] = string.join([dir] + path, os.pathsep) + + # Most of mingw is the same as gcc and friends... + gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas'] + for tool in gnu_tools: + SCons.Tool.Tool(tool)(env) + + #... but a few things differ: + env['CC'] = mingw_prefix + 'gcc' + env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') + env['CXX'] = mingw_prefix + 'g++' + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') + env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared') + env['SHLINKCOM'] = shlib_action + env.Append(SHLIBEMITTER = [shlib_emitter]) + env['LINK'] = mingw_prefix + 'g++' + env['AR'] = mingw_prefix + 'ar' + env['RANLIB'] = mingw_prefix + 'ranlib' + env['LINK'] = mingw_prefix + 'g++' + env['AS'] = mingw_prefix + 'as' + env['WIN32DEFPREFIX'] = '' + env['WIN32DEFSUFFIX'] = '.def' + env['SHOBJSUFFIX'] = '.o' + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + + env['RC'] = mingw_prefix + 'windres' + env['RCFLAGS'] = SCons.Util.CLVar('') + env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS ${INCPREFIX}${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET' + env['BUILDERS']['RES'] = res_builder + + # Some setting from the platform also have to be overridden: + env['OBJPREFIX'] = '' + env['OBJSUFFIX'] = '.o' + env['LIBPREFIX'] = 'lib' + env['LIBSUFFIX'] = '.a' + env['SHOBJPREFIX'] = '$OBJPREFIX' + env['SHOBJSUFFIX'] = '$OBJSUFFIX' + env['PROGPREFIX'] = '' + env['PROGSUFFIX'] = '.exe' + env['LIBPREFIX'] = '' + env['LIBSUFFIX'] = '.lib' + env['SHLIBPREFIX'] = '' + env['SHLIBSUFFIX'] = '.dll' + env['LIBPREFIXES'] = [ '$LIBPREFIX' ] + env['LIBSUFFIXES'] = [ '$LIBSUFFIX' ] + + env.AppendUnique(LIBS = ['iberty']) + env.AppendUnique(LINKFLAGS = ['-Wl,--enable-stdcall-fixup']) + +def exists(env): + return find(env) diff --git a/scons/gallium.py b/scons/gallium.py index c9d5368989..f7ac5e543e 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -170,22 +170,24 @@ def generate(env): #if env.get('quiet', False): # quietCommandLines(env) + # Toolchain + platform = env['platform'] + if env['toolchain'] == 'default': + if platform == 'winddk': + env['toolchain'] == 'winddk' + elif platform == 'wince': + env.Tool('wcesdk') + env['toolchain'] == 'wcesdk' + env.Tool(env['toolchain']) + # shortcuts debug = env['debug'] machine = env['machine'] platform = env['platform'] x86 = env['machine'] == 'x86' ppc = env['machine'] == 'ppc' - 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') + gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw' + msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw' # Put build output in a separate dir, which depends on the current # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 170fdf5127..dce81ec1ca 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -13,6 +13,12 @@ if env['platform'] == 'windows': '#src/mesa/main', ]) + env.Append(CPPDEFINES = [ + '__GL_EXPORTS', + 'BUILD_GL32', + '_GNU_H_WINDOWS32_DEFINES', + ]) + sources = [ 'opengl32.def', 'wgl.c', -- cgit v1.2.3 From 4f3dcf3864c3cbd8a6ebc6af38e53d57e4d421d6 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 19 Nov 2008 20:31:38 +0100 Subject: scons: Fix toolchain selection. --- scons/gallium.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index f7ac5e543e..14065e40c0 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -174,10 +174,9 @@ def generate(env): platform = env['platform'] if env['toolchain'] == 'default': if platform == 'winddk': - env['toolchain'] == 'winddk' + env['toolchain'] = 'winddk' elif platform == 'wince': - env.Tool('wcesdk') - env['toolchain'] == 'wcesdk' + env['toolchain'] = 'wcesdk' env.Tool(env['toolchain']) # shortcuts -- cgit v1.2.3 From 15b92b09e0f066a9d38c445b80b33193a8d9ea14 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 18 Nov 2008 19:13:32 +0900 Subject: scons: Support MinGW32 cross compiler. To build an alternative opengl32.dll with Gallium's software-rasterizer from a debian-based distribution run: sudo apt-get install mingw32 scons platform=windows toolchain=crossmingw machine=x86 winsys=gdi dri=no --- common.py | 2 + scons/crossmingw.py | 182 ++++++++++++++++++++++++++++++++++++++ scons/gallium.py | 22 ++--- src/gallium/winsys/gdi/SConscript | 6 ++ 4 files changed, 202 insertions(+), 10 deletions(-) create mode 100644 scons/crossmingw.py (limited to 'scons') diff --git a/common.py b/common.py index dd64e0f434..8d8b1631fd 100644 --- a/common.py +++ b/common.py @@ -59,6 +59,8 @@ def AddOptions(opts): allowed_values=('generic', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince'))) + opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default', + allowed_values=('default', 'crossmingw'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) diff --git a/scons/crossmingw.py b/scons/crossmingw.py new file mode 100644 index 0000000000..cf4887ba46 --- /dev/null +++ b/scons/crossmingw.py @@ -0,0 +1,182 @@ +"""SCons.Tool.gcc + +Tool-specific initialization for MinGW (http://www.mingw.org/) + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +See also http://www.scons.org/wiki/CrossCompilingMingw +""" + +# +# Copyright (c) 2001, 2002, 2003, 2004 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 +import os.path +import string + +import SCons.Action +import SCons.Builder +import SCons.Tool +import SCons.Util + +# This is what we search for to find mingw: +prefixes = SCons.Util.Split(""" + mingw32- + mingw32msvc- + i386-mingw32- + i486-mingw32- + i586-mingw32- + i686-mingw32- + i386-mingw32msvc- + i486-mingw32msvc- + i586-mingw32msvc- + i686-mingw32msvc- +""") + +def find(env): + for prefix in prefixes: + # First search in the SCons path and then the OS path: + if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'): + return prefix + + return '' + +def shlib_generator(target, source, env, for_signature): + cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS']) + + dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX') + if dll: cmd.extend(['-o', dll]) + + cmd.extend(['$SOURCES', '$_LIBDIRFLAGS', '$_LIBFLAGS']) + + implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX') + if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature)) + + def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') + if def_target: cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature)) + + return [cmd] + +def shlib_emitter(target, source, env): + 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") + + if not no_import_lib and \ + not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'): + + # Append an import library to the list of targets. + target.append(env.ReplaceIxes(dll, + 'SHLIBPREFIX', 'SHLIBSUFFIX', + 'LIBPREFIX', 'LIBSUFFIX')) + + # Append a def file target if there isn't already a def file target + # or a def file source. There is no option to disable def file + # target emitting, because I can't figure out why someone would ever + # want to turn it off. + def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') + def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') + if not def_source and not def_target: + target.append(env.ReplaceIxes(dll, + 'SHLIBPREFIX', 'SHLIBSUFFIX', + 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')) + + return (target, source) + + +shlib_action = SCons.Action.Action(shlib_generator, generator=1) + +res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR') + +res_builder = SCons.Builder.Builder(action=res_action, suffix='.o', + source_scanner=SCons.Tool.SourceFileScanner) +SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan) + +def generate(env): + mingw_prefix = find(env) + + if mingw_prefix: + dir = os.path.dirname(env.WhereIs(mingw_prefix + 'gcc') or SCons.Util.WhereIs(mingw_prefix + 'gcc')) + + # The mingw bin directory must be added to the path: + path = env['ENV'].get('PATH', []) + if not path: + path = [] + if SCons.Util.is_String(path): + path = string.split(path, os.pathsep) + + env['ENV']['PATH'] = string.join([dir] + path, os.pathsep) + + # Most of mingw is the same as gcc and friends... + gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas'] + for tool in gnu_tools: + SCons.Tool.Tool(tool)(env) + + #... but a few things differ: + env['CC'] = mingw_prefix + 'gcc' + env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') + env['CXX'] = mingw_prefix + 'g++' + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') + env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared') + env['SHLINKCOM'] = shlib_action + env.Append(SHLIBEMITTER = [shlib_emitter]) + env['LINK'] = mingw_prefix + 'g++' + env['AR'] = mingw_prefix + 'ar' + env['RANLIB'] = mingw_prefix + 'ranlib' + env['LINK'] = mingw_prefix + 'g++' + env['AS'] = mingw_prefix + 'as' + env['WIN32DEFPREFIX'] = '' + env['WIN32DEFSUFFIX'] = '.def' + env['SHOBJSUFFIX'] = '.o' + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + + env['RC'] = mingw_prefix + 'windres' + env['RCFLAGS'] = SCons.Util.CLVar('') + env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS ${INCPREFIX}${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET' + env['BUILDERS']['RES'] = res_builder + + # Some setting from the platform also have to be overridden: + env['OBJPREFIX'] = '' + env['OBJSUFFIX'] = '.o' + env['LIBPREFIX'] = 'lib' + env['LIBSUFFIX'] = '.a' + env['SHOBJPREFIX'] = '$OBJPREFIX' + env['SHOBJSUFFIX'] = '$OBJSUFFIX' + env['PROGPREFIX'] = '' + env['PROGSUFFIX'] = '.exe' + env['LIBPREFIX'] = '' + env['LIBSUFFIX'] = '.lib' + env['SHLIBPREFIX'] = '' + env['SHLIBSUFFIX'] = '.dll' + env['LIBPREFIXES'] = [ '$LIBPREFIX' ] + env['LIBSUFFIXES'] = [ '$LIBSUFFIX' ] + + env.AppendUnique(LIBS = ['iberty']) + env.AppendUnique(LINKFLAGS = ['-Wl,--enable-stdcall-fixup']) + +def exists(env): + return find(env) diff --git a/scons/gallium.py b/scons/gallium.py index 3631607e66..4622903edd 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -170,21 +170,23 @@ def generate(env): #if env.get('quiet', False): # quietCommandLines(env) + # Toolchain + platform = env['platform'] + if env['toolchain'] == 'default': + if platform == 'winddk': + env['toolchain'] == 'winddk' + elif platform == 'wince': + env.Tool('wcesdk') + env['toolchain'] == 'wcesdk' + env.Tool(env['toolchain']) + # 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') + gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw' + msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw' # Put build output in a separate dir, which depends on the current # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 170fdf5127..dce81ec1ca 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -13,6 +13,12 @@ if env['platform'] == 'windows': '#src/mesa/main', ]) + env.Append(CPPDEFINES = [ + '__GL_EXPORTS', + 'BUILD_GL32', + '_GNU_H_WINDOWS32_DEFINES', + ]) + sources = [ 'opengl32.def', 'wgl.c', -- cgit v1.2.3 From 79bfe372f2bfa633c457e82a3e37f3eb42af4b5b Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 19 Nov 2008 20:31:38 +0100 Subject: scons: Fix toolchain selection. --- scons/gallium.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 4622903edd..59ec6eccf8 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -174,10 +174,9 @@ def generate(env): platform = env['platform'] if env['toolchain'] == 'default': if platform == 'winddk': - env['toolchain'] == 'winddk' + env['toolchain'] = 'winddk' elif platform == 'wince': - env.Tool('wcesdk') - env['toolchain'] == 'wcesdk' + env['toolchain'] = 'wcesdk' env.Tool(env['toolchain']) # shortcuts -- cgit v1.2.3 From 72ebf4fd03fdf64b483026879e18a3158be0c6c8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 21 Nov 2008 03:40:48 +0900 Subject: scons: Build progs. Just demos and trivial dirs for starters. --- .gitignore | 9 +- progs/SConscript | 4 + progs/SConstruct | 43 ++++ progs/demos/SConscript | 71 +++++++ progs/trivial/SConscript | 163 +++++++++++++++ scons/generic.py | 531 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 819 insertions(+), 2 deletions(-) create mode 100644 progs/SConscript create mode 100644 progs/SConstruct create mode 100644 progs/demos/SConscript create mode 100644 progs/trivial/SConscript create mode 100644 scons/generic.py (limited to 'scons') diff --git a/.gitignore b/.gitignore index d519cab474..1c3d44665e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,15 @@ *.a +*.dll +*.exe +*.ilk *.o +*.obj +*.pc +*.pdb *.pyc *.pyo *.so *.sw[a-z] -*.pc *~ depend depend.bak @@ -16,6 +21,6 @@ aclocal.m4 config.log config.status cscope* -.sconsign* +.scon* config.py build diff --git a/progs/SConscript b/progs/SConscript new file mode 100644 index 0000000000..245fc26725 --- /dev/null +++ b/progs/SConscript @@ -0,0 +1,4 @@ +SConscript([ + 'demos/SConscript', + 'trivial/SConscript', +]) diff --git a/progs/SConstruct b/progs/SConstruct new file mode 100644 index 0000000000..ac5314fac5 --- /dev/null +++ b/progs/SConstruct @@ -0,0 +1,43 @@ +import os +import os.path +import sys + +env = Environment( + tools = ['generic'], + toolpath = ['../scons'], + ENV = os.environ, +) + + +# Use Mesa's headers and libs +if 0: + env.Append(CPPPATH = ['#../include']) + env.Append(LIBPATH = ['#../lib']) + + +conf = Configure(env) + +# OpenGL +if env['platform'] == 'windows': + env.Prepend(LIBS = ['glu32', 'opengl32']) +else: + env.Prepend(LIBS = ['GLU', 'GL']) + +# Glut +env['GLUT'] = False +if conf.CheckCHeader('GL/glut.h'): + if env['platform'] == 'windows': + env['GLUT_LIB'] = 'glut32' + else: + env['GLUT_LIB'] = 'glut' + env['GLUT'] = True + +conf.Finish() + + +Export('env') + +SConscript( + 'SConscript', + duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html +) diff --git a/progs/demos/SConscript b/progs/demos/SConscript new file mode 100644 index 0000000000..112da7bedb --- /dev/null +++ b/progs/demos/SConscript @@ -0,0 +1,71 @@ +Import('env') + +if not env['GLUT']: + Return() + +env = env.Clone() + +env.Prepend(LIBS = ['$GLUT_LIB']) + +progs = [ + 'arbfplight', + 'arbfslight', + 'arbocclude', + 'bounce', + 'clearspd', + 'copypix', + 'cubemap', + 'drawpix', + 'engine', + 'fbo_firecube', + 'fire', + 'fogcoord', + 'fplight', + 'fslight', + 'gamma', + 'gearbox', + 'gears', + 'geartrain', + 'glinfo', + 'gloss', + 'glslnoise', + 'gltestperf', + 'glutfx', + 'isosurf', + 'ipers', + 'lodbias', + 'morph3d', + 'multiarb', + 'paltex', + 'pointblast', + 'rain', + 'ray', + 'readpix', + 'reflect', + 'renormal', + 'shadowtex', + 'singlebuffer', + 'streaming_rect', + 'spectex', + 'spriteblast', + 'stex3d', + 'teapot', + 'terrain', + 'tessdemo', + 'texcyl', + 'texdown', + 'texenv', + 'texobj', + 'textures', + 'trispd', + 'tunnel', + 'tunnel2', + 'vao_demo', + 'winpos', +] + +for prog in progs: + prog = env.Program( + target = prog, + source = prog + '.c', + ) diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript new file mode 100644 index 0000000000..edb8386c5b --- /dev/null +++ b/progs/trivial/SConscript @@ -0,0 +1,163 @@ +Import('env') + +if not env['GLUT']: + Return() + +env = env.Clone() + +env.Prepend(LIBS = ['$GLUT_LIB']) + +progs = [ + 'clear-fbo-tex', + 'clear-fbo', + 'clear-scissor', + 'clear-undefined', + 'clear-repeat', + 'clear', + 'dlist-dangling', + 'dlist-edgeflag-dangling', + 'dlist-edgeflag', + 'dlist-degenerate', + 'drawarrays', + 'drawelements', + 'drawrange', + 'flat-clip', + 'fs-tri', + 'line-clip', + 'line-cull', + 'line-smooth', + 'line-stipple-wide', + 'line-userclip-clip', + 'line-userclip-nop-clip', + 'line-userclip-nop', + 'line-userclip', + 'line-wide', + 'line', + 'lineloop-clip', + 'lineloop-elts', + 'lineloop', + 'linestrip-flat-stipple', + 'linestrip-stipple-wide', + 'linestrip-stipple', + 'linestrip', + 'long-fixed-func', + 'pgon-mode', + 'point-clip', + 'point-param', + 'point-sprite', + 'point-wide', + 'point-wide-smooth', + 'point', + 'poly-flat', + 'poly-flat-clip', + 'poly-flat-unfilled-clip', + 'poly-unfilled', + 'poly', + 'quad-clip-all-vertices', + 'quad-clip-nearplane', + 'quad-clip', + 'quad-degenerate', + 'quad-flat', + 'quad-offset-factor', + 'quad-offset-unfilled', + 'quad-offset-units', + 'quad-tex-2d', + 'quad-tex-3d', + 'quad-tex-alpha', + 'quad-tex-pbo', + 'quad-unfilled-clip', + 'quad-unfilled-stipple', + 'quad-unfilled', + 'quad', + 'quads', + 'quadstrip-cont', + 'quadstrip-flat', + 'quadstrip', + 'tri-alpha', + 'tri-blend-color', + 'tri-blend-max', + 'tri-blend-min', + 'tri-blend-revsub', + 'tri-blend-sub', + 'tri-blend', + 'tri-clip', + 'tri-cull-both', + 'tri-cull', + 'tri-dlist', + 'tri-edgeflag', + 'tri-fbo-tex', + 'tri-fbo', + 'tri-flat-clip', + 'tri-flat', + 'tri-fog', + 'tri-fp', + 'tri-fp-const-imm', + 'tri-lit', + 'tri-mask-tri', + 'tri-orig', + 'tri-query', + 'tri-repeat', + 'tri-scissor-tri', + 'tri-stencil', + 'tri-tex', + 'tri-tex-3d', + 'tri-tri', + 'tri-unfilled-edgeflag', + 'tri-unfilled-clip', + 'tri-unfilled-smooth', + 'tri-unfilled-tri', + 'tri-unfilled-tri-lit', + 'tri-unfilled-userclip-stip', + 'tri-unfilled-userclip', + 'tri-unfilled', + 'tri-userclip', + 'tri-z-eq', + 'tri-z', + 'tri', + 'trifan-flat', + 'trifan-flat-clip', + 'trifan-flat-unfilled-clip', + 'trifan-unfilled', + 'trifan', + 'tristrip-clip', + 'tristrip-flat', + 'tristrip', + 'vbo-drawarrays', + 'vbo-drawelements', + 'vbo-drawrange', + 'vp-array', + 'vp-array-int', + 'vp-clip', + 'vp-line-clip', + 'vp-tri', + 'vp-tri-swap', + 'vp-tri-tex', + 'vp-tri-imm', + 'vp-tri-cb', + 'vp-tri-cb-pos', + 'vp-tri-cb-tex', + 'vp-unfilled', +] + +for prog in progs: + prog = env.Program( + target = prog, + source = prog + '.c', + ) + +# auto code generation +#getprocaddress: getprocaddress.c getproclist.h + +#getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py +# python getprocaddress.py > getproclist.h + + +#readtex.h: $(TOP)/progs/util/readtex.h +# ln -s $(TOP)/progs/util/readtex.h . + +#readtex.c: $(TOP)/progs/util/readtex.c +# ln -s $(TOP)/progs/util/readtex.c . + + +#extfuncs.h: $(TOP)/progs/util/extfuncs.h +# cp $< . diff --git a/scons/generic.py b/scons/generic.py new file mode 100644 index 0000000000..f0bb3de9fc --- /dev/null +++ b/scons/generic.py @@ -0,0 +1,531 @@ +"""generic + +Generic tool that provides a commmon ground for all platforms. + +""" + +# +# 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 +import os.path +import re +import platform as _platform +import sys + +import SCons.Action +import SCons.Builder +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 ..." + + +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 + + 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 symlink(target, source, env): + target = str(target[0]) + source = str(source[0]) + if os.path.islink(target) or os.path.exists(target): + os.remove(target) + os.symlink(os.path.basename(source), target) + +def install_shared_library(env, source, version = ()): + source = str(source[0]) + version = tuple(map(str, version)) + target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib') + target_name = '.'.join((str(source),) + version) + last = env.InstallAs(os.path.join(target_dir, target_name), source) + while len(version): + version = version[:-1] + target_name = '.'.join((str(source),) + version) + action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE") + last = env.Command(os.path.join(target_dir, target_name), last, action) + +def createInstallMethods(env): + env.AddMethod(install_shared_library, 'InstallSharedLibrary') + + +_platform_map = { + 'linux2': 'linux', + 'win32': 'windows', +} + + +_machine_map = { + 'x86': 'x86', + 'i386': 'x86', + 'i486': 'x86', + 'i586': 'x86', + 'i686': 'x86', + 'ppc': 'ppc', + 'x86_64': 'x86_64', +} + + +_toolchain_map = { + 'winddk': 'winddk', + 'wince': 'wcesdk', +} + + +_bool_map = { + 'y': 1, + 'yes': 1, + 't': 1, + 'true': 1, + '1': 1, + 'on': 1, + 'all': 1, + 'n': 0, + 'no': 0, + 'f': 0, + 'false': 0, + '0': 0, + 'off': 0, + 'none': 0, +} + + +def generate(env): + """Common environment generation code""" + + from SCons.Script import ARGUMENTS + + # FIXME: this is already too late + #if env.get('quiet', False): + # quietCommandLines(env) + + + # Platform + try: + env['platform'] = ARGUMENTS['platform'] + except KeyError: + env['platform'] = _platform_map.get(sys.platform, sys.platform) + + # Machine + try: + env['machine'] = ARGUMENTS['machine'] + except KeyError: + env['machine'] = _machine_map.get(os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine()), 'generic') + + # Toolchain + try: + env['toolchain'] = ARGUMENTS['toolchain'] + except KeyError: + if env['platform'] in ('windows', 'winddk', 'wince') and sys.platform != 'win32': + env['toolchain'] = 'crossmingw' + else: + env['toolchain'] = _toolchain_map.get(env['platform'], 'default') + if env['toolchain'] == 'crossmingw' and env['machine'] not in ('generic', 'x86'): + env['machine'] = 'x86' + + # Build type + env['debug'] = _bool_map[ARGUMENTS.get('debug', 'no')] + env['profile'] = _bool_map[ARGUMENTS.get('profile', 'no')] + + # Put build output in a separate dir, which depends on the current + # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample + try: + env['variant_dir'] = ARGUMENTS['variant_dir'] + except KeyError: + build_topdir = 'build' + build_subdir = env['platform'] + if env['machine'] != 'generic': + build_subdir += '-' + env['machine'] + if env['debug']: + build_subdir += "-debug" + if env['profile']: + build_subdir += "-profile" + env['variant_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.VariantDir(env['variant_dir'] + #env.SConsignFile(os.path.join(env['variant_dir'], '.sconsign')) + + # Summary + print + print ' platform=%s' % env['platform'] + print ' machine=%s' % env['machine'] + print ' toolchain=%s' % env['toolchain'] + print ' debug=%s' % ['no', 'yes'][env['debug']] + print ' profile=%s' % ['no', 'yes'][env['profile']] + #print ' variant_dir=%s' % env['variant_dir'] + print + + # Load tool chain + env.Tool(env['toolchain']) + + # shortcuts + debug = env['debug'] + machine = env['machine'] + platform = env['platform'] + x86 = env['machine'] == 'x86' + ppc = env['machine'] == 'ppc' + gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw' + msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw' + + # 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'), + ] + 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', '-g0'] + 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://msdn.microsoft.com/en-us/library/19z1t1wy.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 + '/Ot', # favor code speed + #'/fp:fast', # fast floating point + ] + 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 env['machine'] == 'x86': + cflags += [ + #'/QIfist', # Suppress _ftol + #'/arch:SSE2', # use the SSE2 instructions + ] + 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) + + # Default libs + env.Append(LIBS = []) + + # Custom builders and methods + createConvenienceLibBuilder(env) + createCodeGenerateMethod(env) + createInstallMethods(env) + + # for debugging + #print env.Dump() + + +def exists(env): + return 1 -- cgit v1.2.3 From 129c6ed67807db5d1d5ec4bc09bcc32bc5a329d4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Dec 2008 11:53:26 -0800 Subject: scons: Target Windows XP on userspace. --- scons/gallium.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 59ec6eccf8..1136d26908 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -221,6 +221,8 @@ def generate(env): '_WINDOWS', '_UNICODE', 'UNICODE', + ('_WIN32_WINNT', '0x0501'), # minimum required OS version + ('WINVER', '0x0501'), # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, 'WIN32_LEAN_AND_MEAN', 'VC_EXTRALEAN', -- cgit v1.2.3 From 975e58499a07775e071c2517b4fa21306e8349bb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 30 Dec 2008 17:13:38 +0000 Subject: scons: Specify C99 throughout all the tree. MSVC may not support full C99, but supports more than plain C90. And -pedantic without -std=c99 generates too many spurious warnings (specially C++ style comments) to be of any use. Note that using certain C99 features in the cross-platform parts of Gallium is still not possible; namely mid-of-scope variable declarations and named structure initializers will break MSVC builds. --- scons/gallium.py | 1 + src/mesa/SConscript | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 6dbce62b8e..92cafa27e0 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -313,6 +313,7 @@ def generate(env): '-Wmissing-prototypes', '-Wno-long-long', '-ffast-math', + '-std=c99', '-pedantic', '-fmessage-length=0', # be nice to Eclipse ] diff --git a/src/mesa/SConscript b/src/mesa/SConscript index abd64030b6..dd0468fb93 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -12,11 +12,6 @@ if env['platform'] != 'winddk': '#/src/mesa', ]) - if gcc: - env.Append(CFLAGS = [ - '-std=c99', - ]) - # # Source files # @@ -165,6 +160,7 @@ if env['platform'] != 'winddk': 'state_tracker/st_context.c', 'state_tracker/st_debug.c', 'state_tracker/st_draw.c', + 'state_tracker/st_draw_feedback.c', 'state_tracker/st_extensions.c', 'state_tracker/st_format.c', 'state_tracker/st_framebuffer.c', -- cgit v1.2.3 From 1781d7fa3880ffb6d3062414704fb4d29e9297ad Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 6 Jan 2009 16:16:38 +0000 Subject: scons: Choose the appropriate MSVC CRT. --- scons/gallium.py | 10 ++++++++++ scons/generic.py | 10 ++++++++++ 2 files changed, 20 insertions(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 92cafa27e0..3d5a0532ec 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -392,6 +392,16 @@ def generate(env): env.Append(CFLAGS = cflags) env.Append(CXXFLAGS = cflags) + if env['platform'] == 'windows' and msvc: + # Choose the appropriate MSVC CRT + # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx + if env['debug']: + env.Append(CCFLAGS = ['/MTd']) + env.Append(SHCCFLAGS = ['/LDd']) + else: + env.Append(CCFLAGS = ['/MT']) + env.Append(SHCCFLAGS = ['/LD']) + # Assembler options if gcc: if env['machine'] == 'x86': diff --git a/scons/generic.py b/scons/generic.py index f0bb3de9fc..0ed21a4e6c 100644 --- a/scons/generic.py +++ b/scons/generic.py @@ -458,6 +458,16 @@ def generate(env): env.Append(CFLAGS = cflags) env.Append(CXXFLAGS = cflags) + if env['platform'] == 'windows' and msvc: + # Choose the appropriate MSVC CRT + # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx + if env['debug']: + env.Append(CCFLAGS = ['/MTd']) + env.Append(SHCCFLAGS = ['/LDd']) + else: + env.Append(CCFLAGS = ['/MT']) + env.Append(SHCCFLAGS = ['/LD']) + # Assembler options if gcc: if env['machine'] == 'x86': -- cgit v1.2.3 From 83155aa11f1b12982ba501a495d8ccb15dc9b92e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 14 Jan 2009 11:36:02 +0000 Subject: scons: Use .a suffix for MinGW. This allows to build MinGW and MSVC within the same dir. --- scons/crossmingw.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'scons') diff --git a/scons/crossmingw.py b/scons/crossmingw.py index cf4887ba46..b1141c97ce 100644 --- a/scons/crossmingw.py +++ b/scons/crossmingw.py @@ -162,18 +162,16 @@ def generate(env): # Some setting from the platform also have to be overridden: env['OBJPREFIX'] = '' env['OBJSUFFIX'] = '.o' - env['LIBPREFIX'] = 'lib' - env['LIBSUFFIX'] = '.a' env['SHOBJPREFIX'] = '$OBJPREFIX' env['SHOBJSUFFIX'] = '$OBJSUFFIX' env['PROGPREFIX'] = '' env['PROGSUFFIX'] = '.exe' - env['LIBPREFIX'] = '' - env['LIBSUFFIX'] = '.lib' + env['LIBPREFIX'] = 'lib' + env['LIBSUFFIX'] = '.a' env['SHLIBPREFIX'] = '' env['SHLIBSUFFIX'] = '.dll' - env['LIBPREFIXES'] = [ '$LIBPREFIX' ] - env['LIBSUFFIXES'] = [ '$LIBSUFFIX' ] + env['LIBPREFIXES'] = [ 'lib', '' ] + env['LIBSUFFIXES'] = [ '.a', '.lib' ] env.AppendUnique(LIBS = ['iberty']) env.AppendUnique(LINKFLAGS = ['-Wl,--enable-stdcall-fixup']) -- cgit v1.2.3 From 47ca0234dc9f83808cb141944537c78eaade5d55 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 14 Jan 2009 13:03:09 +0000 Subject: scons: Use -std=gnu99 It a scary world out there: people use all sort of non standard C stuff, and we must enable support for that in here in order to build. -pedantic still warn us when we use that nonstandard though. --- scons/gallium.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 3d5a0532ec..1218067985 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -313,7 +313,7 @@ def generate(env): '-Wmissing-prototypes', '-Wno-long-long', '-ffast-math', - '-std=c99', + '-std=gnu99', '-pedantic', '-fmessage-length=0', # be nice to Eclipse ] -- cgit v1.2.3 From 42be0104a22fdff0db3c39af9feb7d157ac87f46 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Jan 2009 14:26:30 +0000 Subject: scons: Don't define UNICODE on windows builds. It creates problems in many libraries (glut, glew) which are not unicode aware. --- scons/gallium.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 1218067985..65dd0ab664 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -220,8 +220,8 @@ def generate(env): cppdefines += [ 'WIN32', '_WINDOWS', - '_UNICODE', - 'UNICODE', + #'_UNICODE', + #'UNICODE', ('_WIN32_WINNT', '0x0501'), # minimum required OS version ('WINVER', '0x0501'), # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, -- cgit v1.2.3 From de29f5781ad9f3630b28f341bb41622a090cd8dc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Jan 2009 16:25:37 +0000 Subject: scons: Allow to specify the MSVS version on command line. --- scons/generic.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scons') diff --git a/scons/generic.py b/scons/generic.py index 0ed21a4e6c..7ded920790 100644 --- a/scons/generic.py +++ b/scons/generic.py @@ -239,6 +239,11 @@ def generate(env): if env['toolchain'] == 'crossmingw' and env['machine'] not in ('generic', 'x86'): env['machine'] = 'x86' + try: + env['MSVS_VERSION'] = ARGUMENTS['MSVS_VERSION'] + except KeyError: + pass + # Build type env['debug'] = _bool_map[ARGUMENTS.get('debug', 'no')] env['profile'] = _bool_map[ARGUMENTS.get('profile', 'no')] -- cgit v1.2.3 From 18170bb51b27fbcef44d84c783511360151a53d4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Jan 2009 21:01:16 +0000 Subject: scons: Use a cache for built files. Like ccache, but works on all OSes. --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 65dd0ab664..4825e4098c 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -207,6 +207,7 @@ def generate(env): # different scons versions building the same source file env['build'] = build_dir env.SConsignFile(os.path.join(build_dir, '.sconsign')) + env.CacheDir('build/cache') # C preprocessor options cppdefines = [] -- cgit v1.2.3 From 9bd39eb3af492f3fe314dc7432f89109264f13f6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Jan 2009 10:28:39 +0000 Subject: scons: Don't build the DRI drivers in a seperate dir. DRI drivers can be build side by side with other non-DRI drivers, therefore there is no need to build gallium twice. --- scons/gallium.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 4825e4098c..bb4e3ab902 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -192,8 +192,6 @@ def generate(env): # 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': -- cgit v1.2.3 From 017892636a29a40966085d360df8f35865e226d2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Jan 2009 14:33:54 +0000 Subject: scons: Use --enable-stdcall-fixup only when building DLLs. --- scons/crossmingw.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scons') diff --git a/scons/crossmingw.py b/scons/crossmingw.py index b1141c97ce..53b4d2e47d 100644 --- a/scons/crossmingw.py +++ b/scons/crossmingw.py @@ -174,7 +174,8 @@ def generate(env): env['LIBSUFFIXES'] = [ '.a', '.lib' ] env.AppendUnique(LIBS = ['iberty']) - env.AppendUnique(LINKFLAGS = ['-Wl,--enable-stdcall-fixup']) + env.AppendUnique(SHLINKFLAGS = ['-Wl,--enable-stdcall-fixup']) + #env.AppendUnique(SHLINKFLAGS = ['-Wl,--kill-at']) def exists(env): return find(env) -- cgit v1.2.3 From 9bf83fb0162b5ce95fc10ca1a38e6b4a62f9690f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Jan 2009 15:56:28 +0000 Subject: scons: Build the progs into seperate dirs as well. --- SConstruct | 2 +- progs/SConstruct | 1 + scons/generic.py | 9 ++++----- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'scons') diff --git a/SConstruct b/SConstruct index baa0f9069b..88cdffa504 100644 --- a/SConstruct +++ b/SConstruct @@ -162,6 +162,6 @@ Export('env') SConscript( 'src/SConscript', - build_dir = env['build'], + variant_dir = env['build'], duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html ) diff --git a/progs/SConstruct b/progs/SConstruct index bce48f72ff..4d268cc6d7 100644 --- a/progs/SConstruct +++ b/progs/SConstruct @@ -60,5 +60,6 @@ Export('env') SConscript( 'SConscript', + build_dir = env['build'], duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html ) diff --git a/scons/generic.py b/scons/generic.py index 7ded920790..df7ef42402 100644 --- a/scons/generic.py +++ b/scons/generic.py @@ -251,7 +251,7 @@ def generate(env): # Put build output in a separate dir, which depends on the current # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample try: - env['variant_dir'] = ARGUMENTS['variant_dir'] + env['build'] = ARGUMENTS['build'] except KeyError: build_topdir = 'build' build_subdir = env['platform'] @@ -261,11 +261,10 @@ def generate(env): build_subdir += "-debug" if env['profile']: build_subdir += "-profile" - env['variant_dir'] = os.path.join(build_topdir, build_subdir) + env['build'] = 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.VariantDir(env['variant_dir'] - #env.SConsignFile(os.path.join(env['variant_dir'], '.sconsign')) + env.SConsignFile(os.path.join(env['build'], '.sconsign')) # Summary print @@ -274,7 +273,7 @@ def generate(env): print ' toolchain=%s' % env['toolchain'] print ' debug=%s' % ['no', 'yes'][env['debug']] print ' profile=%s' % ['no', 'yes'][env['profile']] - #print ' variant_dir=%s' % env['variant_dir'] + print ' build=%s' % env['build'] print # Load tool chain -- cgit v1.2.3 From 3d607ef37fdfa0871096c99674af92278f33246b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 26 Jan 2009 20:16:36 +0000 Subject: scons: Request the stabs debug info format for Mingw. Mingw gdb apparently chokes on dwarf debug info. --- scons/crossmingw.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scons') diff --git a/scons/crossmingw.py b/scons/crossmingw.py index 53b4d2e47d..bf81f16fd6 100644 --- a/scons/crossmingw.py +++ b/scons/crossmingw.py @@ -173,6 +173,10 @@ def generate(env): env['LIBPREFIXES'] = [ 'lib', '' ] env['LIBSUFFIXES'] = [ '.a', '.lib' ] + # MinGW port of gdb does not handle well dwarf debug info which is the + # default in recent gcc versions + env.AppendUnique(CFLAGS = ['-gstabs']) + env.AppendUnique(LIBS = ['iberty']) env.AppendUnique(SHLINKFLAGS = ['-Wl,--enable-stdcall-fixup']) #env.AppendUnique(SHLINKFLAGS = ['-Wl,--kill-at']) -- cgit v1.2.3 From 9a7aeac49c9bed7507eed876e1d35fa4386f0382 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 26 Jan 2009 12:12:38 +0000 Subject: scons: remove pedantic flag --- scons/gallium.py | 1 - 1 file changed, 1 deletion(-) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index bb4e3ab902..065c53c54b 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -313,7 +313,6 @@ def generate(env): '-Wno-long-long', '-ffast-math', '-std=gnu99', - '-pedantic', '-fmessage-length=0', # be nice to Eclipse ] if msvc: -- cgit v1.2.3 From 9aa73cfae84c7710df97ce182d32bea8d3423ab7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 1 Feb 2009 12:00:07 +0000 Subject: progs: Get more samples building on windows. --- progs/SConscript | 1 + progs/demos/SConscript | 26 ++++++++++++++++++++++---- progs/demos/fogcoord.c | 28 +++++++++++----------------- progs/demos/gloss.c | 2 ++ progs/demos/multiarb.c | 2 ++ progs/demos/rain.cxx | 2 -- progs/demos/stex3d.c | 4 +++- progs/demos/winpos.c | 18 ++++++++---------- progs/trivial/fs-tri.c | 39 ++++++++++++++++++--------------------- progs/util/SConscript | 15 +++++++++++++++ scons/generic.py | 40 +++++++++++++++++++++++----------------- 11 files changed, 105 insertions(+), 72 deletions(-) create mode 100644 progs/util/SConscript (limited to 'scons') diff --git a/progs/SConscript b/progs/SConscript index ffb6de4f16..631923a38f 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -1,4 +1,5 @@ SConscript([ + 'util/SConscript', 'demos/SConscript', 'trivial/SConscript', 'vp/SConscript', diff --git a/progs/demos/SConscript b/progs/demos/SConscript index 112da7bedb..bc166dd789 100644 --- a/progs/demos/SConscript +++ b/progs/demos/SConscript @@ -1,11 +1,22 @@ -Import('env') +Import('*') if not env['GLUT']: Return() env = env.Clone() -env.Prepend(LIBS = ['$GLUT_LIB']) +env.Prepend(CPPPATH = [ + '../util', +]) + +env.Prepend(LIBS = [ + util, + '$GLUT_LIB' +]) + +if env['platform'] == 'windows': + env.Append(CPPDEFINES = ['NOMINMAX']) + env.Prepend(LIBS = ['winmm']) progs = [ 'arbfplight', @@ -38,7 +49,6 @@ progs = [ 'multiarb', 'paltex', 'pointblast', - 'rain', 'ray', 'readpix', 'reflect', @@ -65,7 +75,15 @@ progs = [ ] for prog in progs: - prog = env.Program( + env.Program( target = prog, source = prog + '.c', ) + +env.Program( + target = 'rain', + source = [ + 'rain.cxx', + 'particles.cxx', + ] +) diff --git a/progs/demos/fogcoord.c b/progs/demos/fogcoord.c index 00c73c6f04..6f50993c98 100644 --- a/progs/demos/fogcoord.c +++ b/progs/demos/fogcoord.c @@ -7,19 +7,16 @@ * Daniel Borca */ -#define GL_GLEXT_PROTOTYPES #include #include #include +#include #include #define DEPTH 5.0f -static PFNGLFOGCOORDFEXTPROC glFogCoordf_ext; static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext; -static GLboolean have_fog_coord; - static GLfloat camz; static GLint fogMode; @@ -45,10 +42,11 @@ Reset(void) } -static void APIENTRY -glFogCoordf_nop (GLfloat f) +static void +glFogCoordf_ext (GLfloat f) { - (void)f; + if (fogCoord) + glFogCoordfEXT(f); } @@ -120,14 +118,11 @@ SetFogMode(GLint fogMode) static GLboolean SetFogCoord(GLboolean fogCoord) { - glFogCoordf_ext = glFogCoordf_nop; - - if (!have_fog_coord) { + if (!GLEW_EXT_fog_coord) { return GL_FALSE; } if (fogCoord) { - glFogCoordf_ext = (PFNGLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT"); glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); } else { @@ -340,7 +335,7 @@ Key( unsigned char key, int x, int y ) SetFogMode(fogMode); break; case 'c': - fogCoord = SetFogCoord(fogCoord ^ GL_TRUE); + fogCoord = SetFogCoord(fogCoord ^ GL_TRUE); break; case 't': Texture = !Texture; @@ -372,8 +367,7 @@ Init(void) printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); - have_fog_coord = glutExtensionSupported("GL_EXT_fog_coord"); - if (!have_fog_coord) { + if (!GLEW_EXT_fog_coord) { printf("GL_EXT_fog_coord not supported!\n"); } @@ -400,10 +394,9 @@ Init(void) glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, texcoord_pointer); - if (have_fog_coord) { - glFogCoordPointer_ext = (PFNGLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT"); + if (GLEW_EXT_fog_coord) { glEnableClientState(GL_FOG_COORDINATE_ARRAY_EXT); - glFogCoordPointer_ext(GL_FLOAT, 0, fogcoord_pointer); + glFogCoordPointerEXT(GL_FLOAT, 0, fogcoord_pointer); } Reset(); @@ -417,6 +410,7 @@ main( int argc, char *argv[] ) glutInitWindowSize( 600, 600 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/demos/gloss.c b/progs/demos/gloss.c index 9974f0dab2..b2126e3267 100644 --- a/progs/demos/gloss.c +++ b/progs/demos/gloss.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "readtex.h" @@ -438,6 +439,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0] ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/demos/multiarb.c b/progs/demos/multiarb.c index 451fd11efe..85c4e3a266 100644 --- a/progs/demos/multiarb.c +++ b/progs/demos/multiarb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "readtex.h" @@ -326,6 +327,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); Init( argc, argv ); diff --git a/progs/demos/rain.cxx b/progs/demos/rain.cxx index 59b6471ef8..265d90cd95 100644 --- a/progs/demos/rain.cxx +++ b/progs/demos/rain.cxx @@ -24,8 +24,6 @@ extern "C" { #ifdef _WIN32 #include #include -#include "particles.cxx" -#include "readtex.c" #endif #ifdef XMESA diff --git a/progs/demos/stex3d.c b/progs/demos/stex3d.c index 83ae3684ae..c0bbea0960 100644 --- a/progs/demos/stex3d.c +++ b/progs/demos/stex3d.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include @@ -662,6 +662,8 @@ main(int argc, char **argv) exit(0); } + glewInit(); + init(); printHelp(); diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c index b58e330864..13a9c7e9a8 100644 --- a/progs/demos/winpos.c +++ b/progs/demos/winpos.c @@ -11,7 +11,7 @@ #ifdef _WIN32 #include #endif -#define GL_GLEXT_PROTOTYPES +#include "GL/glew.h" #include "GL/glut.h" #include "readtex.h" @@ -29,8 +29,7 @@ static GLubyte *Image; static int ImgWidth, ImgHeight; static GLenum ImgFormat; -typedef void (APIENTRY * PFNWINDOWPOSFUNC)(GLfloat x, GLfloat y); -static PFNWINDOWPOSFUNC WindowPosFunc; +static PFNGLWINDOWPOS2FPROC WindowPosFunc; static void draw( void ) { @@ -71,19 +70,16 @@ static void reshape( int width, int height ) static void init( void ) { -#ifdef GL_ARB_window_pos - if (glutExtensionSupported("GL_ARB_window_pos")) { + if (GLEW_ARB_window_pos) { printf("Using GL_ARB_window_pos\n"); - WindowPosFunc = &glWindowPos2fARB; + WindowPosFunc = glWindowPos2fARB; } else -#elif defined(GL_MESA_window_pos) - if (glutExtensionSupported("GL_MESA_window_pos")) { + if (GLEW_MESA_window_pos) { printf("Using GL_MESA_window_pos\n"); - WindowPosFunc = &glWindowPos2fMESA; + WindowPosFunc = glWindowPos2fMESA; } else -#endif { printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n"); exit(1); @@ -109,6 +105,8 @@ int main( int argc, char *argv[] ) exit(0); } + glewInit(); + init(); glutReshapeFunc( reshape ); diff --git a/progs/trivial/fs-tri.c b/progs/trivial/fs-tri.c index 3be4d42e54..6e86df1dcf 100644 --- a/progs/trivial/fs-tri.c +++ b/progs/trivial/fs-tri.c @@ -5,10 +5,8 @@ #include #include #include -#include +#include #include -#include -#include "extfuncs.h" static GLuint fragShader; @@ -56,9 +54,9 @@ Reshape(int width, int height) static void CleanUp(void) { - glDeleteShader_func(fragShader); - glDeleteShader_func(vertShader); - glDeleteProgram_func(program); + glDeleteShader(fragShader); + glDeleteShader(vertShader); + glDeleteProgram(program); glutDestroyWindow(win); } @@ -110,15 +108,15 @@ LoadAndCompileShader(GLuint shader, const char *text) { GLint stat; - glShaderSource_func(shader, 1, (const GLchar **) &text, NULL); + glShaderSource(shader, 1, (const GLchar **) &text, NULL); - glCompileShader_func(shader); + glCompileShader(shader); - glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat); + glGetShaderiv(shader, GL_COMPILE_STATUS, &stat); if (!stat) { GLchar log[1000]; GLsizei len; - glGetShaderInfoLog_func(shader, 1000, &len, log); + glGetShaderInfoLog(shader, 1000, &len, log); fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log); exit(1); } @@ -129,11 +127,11 @@ static void CheckLink(GLuint prog) { GLint stat; - glGetProgramiv_func(prog, GL_LINK_STATUS, &stat); + glGetProgramiv(prog, GL_LINK_STATUS, &stat); if (!stat) { GLchar log[1000]; GLsizei len; - glGetProgramInfoLog_func(prog, 1000, &len, log); + glGetProgramInfoLog(prog, 1000, &len, log); fprintf(stderr, "Linker error:\n%s\n", log); } } @@ -165,24 +163,22 @@ Init(void) exit(1); } - GetExtensionFuncs(); - - fragShader = glCreateShader_func(GL_FRAGMENT_SHADER); + fragShader = glCreateShader(GL_FRAGMENT_SHADER); LoadAndCompileShader(fragShader, fragShaderText); #if 0 - vertShader = glCreateShader_func(GL_VERTEX_SHADER); + vertShader = glCreateShader(GL_VERTEX_SHADER); LoadAndCompileShader(vertShader, vertShaderText); #endif - program = glCreateProgram_func(); - glAttachShader_func(program, fragShader); + program = glCreateProgram(); + glAttachShader(program, fragShader); #if 0 - glAttachShader_func(program, vertShader); + glAttachShader(program, vertShader); #endif - glLinkProgram_func(program); + glLinkProgram(program); CheckLink(program); - glUseProgram_func(program); + glUseProgram(program); assert(glGetError() == 0); @@ -200,6 +196,7 @@ main(int argc, char *argv[]) glutInitWindowSize(200, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/util/SConscript b/progs/util/SConscript new file mode 100644 index 0000000000..8ad2466291 --- /dev/null +++ b/progs/util/SConscript @@ -0,0 +1,15 @@ +Import('env') + +env = env.Clone() + +util = env.StaticLibrary( + target = ['util'], + source = [ + 'readtex.c', + 'trackball.c', + 'showbuffer.c', + 'shaderutil.c', + ], +) + +Export('util') diff --git a/scons/generic.py b/scons/generic.py index df7ef42402..05f7356b76 100644 --- a/scons/generic.py +++ b/scons/generic.py @@ -303,7 +303,7 @@ def generate(env): #'_UNICODE', #'UNICODE', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx, - 'WIN32_LEAN_AND_MEAN', + #'WIN32_LEAN_AND_MEAN', 'VC_EXTRALEAN', '_CRT_SECURE_NO_DEPRECATE', ] @@ -362,24 +362,26 @@ def generate(env): ]) # C compiler options - cflags = [] + cflags = [] # C + cxxflags = [] # C++ + ccflags = [] # C & C++ if gcc: if debug: - cflags += ['-O0', '-g3'] + ccflags += ['-O0', '-g3'] else: - cflags += ['-O3', '-g0'] + ccflags += ['-O3', '-g0'] if env['profile']: - cflags += ['-pg'] + ccflags += ['-pg'] if env['machine'] == 'x86': - cflags += [ + ccflags += [ '-m32', #'-march=pentium4', '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics #'-mfpmath=sse', ] if env['machine'] == 'x86_64': - cflags += ['-m64'] - cflags += [ + ccflags += ['-m64'] + ccflags += [ '-Wall', '-Wmissing-prototypes', '-Wno-long-long', @@ -387,43 +389,46 @@ def generate(env): '-pedantic', '-fmessage-length=0', # be nice to Eclipse ] + cflags += [ + '-Wmissing-prototypes', + ] if msvc: # See also: # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx # - cl /? if debug: - cflags += [ + ccflags += [ '/Od', # disable optimizations '/Oi', # enable intrinsic functions '/Oy-', # disable frame pointer omission ] else: - cflags += [ + ccflags += [ '/Ox', # maximum optimizations '/Oi', # enable intrinsic functions '/Ot', # favor code speed #'/fp:fast', # fast floating point ] if env['profile']: - cflags += [ + ccflags += [ '/Gh', # enable _penter hook function '/GH', # enable _pexit hook function ] - cflags += [ + ccflags += [ '/W3', # warning level #'/Wp64', # enable 64 bit porting warnings ] if env['machine'] == 'x86': - cflags += [ + ccflags += [ #'/QIfist', # Suppress _ftol #'/arch:SSE2', # use the SSE2 instructions ] if platform == 'windows': - cflags += [ + ccflags += [ # TODO ] if platform == 'winddk': - cflags += [ + ccflags += [ '/Zl', # omit default library name in .OBJ '/Zp8', # 8bytes struct member alignment '/Gy', # separate functions for linker @@ -442,7 +447,7 @@ def generate(env): ] if platform == 'wince': # See also C:\WINCE600\public\common\oak\misc\makefile.def - cflags += [ + ccflags += [ '/Zl', # omit default library name in .OBJ '/GF', # enable read-only string pooling '/GR-', # disable C++ RTTI @@ -459,8 +464,9 @@ def generate(env): # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 env.EnsureSConsVersion(0, 98, 0) env['PDB'] = '${TARGET.base}.pdb' + env.Append(CCFLAGS = ccflags) env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cflags) + env.Append(CXXFLAGS = cxxflags) if env['platform'] == 'windows' and msvc: # Choose the appropriate MSVC CRT -- cgit v1.2.3 From 1e8177ee178b131afa86d874b062a8ae3fae0cca Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 10 Feb 2009 18:11:56 +0000 Subject: scons: Use parallel builds by default. --- scons/gallium.py | 23 +++++++++++++++++++++++ scons/generic.py | 24 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 065c53c54b..fc1ed08e47 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -163,6 +163,25 @@ def createInstallMethods(env): env.AddMethod(install_shared_library, 'InstallSharedLibrary') +def num_jobs(): + try: + return int(os.environ['NUMBER_OF_PROCESSORS']) + except (ValueError, KeyError): + pass + + try: + return os.sysconf('SC_NPROCESSORS_ONLN') + except (ValueError, OSError, AttributeError): + pass + + try: + return int(os.popen2("sysctl -n hw.ncpu")[1].read()) + except ValueError: + pass + + return 1 + + def generate(env): """Common environment generation code""" @@ -207,6 +226,10 @@ def generate(env): env.SConsignFile(os.path.join(build_dir, '.sconsign')) env.CacheDir('build/cache') + # Parallel build + if env.GetOption('num_jobs') <= 1: + env.SetOption('num_jobs', num_jobs()) + # C preprocessor options cppdefines = [] if debug: diff --git a/scons/generic.py b/scons/generic.py index 05f7356b76..2323196673 100644 --- a/scons/generic.py +++ b/scons/generic.py @@ -206,6 +206,25 @@ _bool_map = { } +def num_jobs(): + try: + return int(os.environ['NUMBER_OF_PROCESSORS']) + except (ValueError, KeyError): + pass + + try: + return os.sysconf('SC_NPROCESSORS_ONLN') + except (ValueError, OSError, AttributeError): + pass + + try: + return int(os.popen2("sysctl -n hw.ncpu")[1].read()) + except ValueError: + pass + + return 1 + + def generate(env): """Common environment generation code""" @@ -266,6 +285,10 @@ def generate(env): # different scons versions building the same source file env.SConsignFile(os.path.join(env['build'], '.sconsign')) + # Parallel build + if env.GetOption('num_jobs') <= 1: + env.SetOption('num_jobs', num_jobs()) + # Summary print print ' platform=%s' % env['platform'] @@ -274,6 +297,7 @@ def generate(env): print ' debug=%s' % ['no', 'yes'][env['debug']] print ' profile=%s' % ['no', 'yes'][env['profile']] print ' build=%s' % env['build'] + print ' %s jobs' % env.GetOption('num_jobs') print # Load tool chain -- cgit v1.2.3