usermode/library/configuration/mnemosyne.py

00001 # This is the main configuration class. All others inherit this.
00002 #
00003 
00004 import os
00005 import string
00006 import SCons.Environment
00007 from SCons.Script import ARGUMENTS
00008 from SCons.Variables import Variables, EnumVariable, BoolVariable
00009 import helper
00010 
00011 
00012 class Environment(SCons.Environment.Environment):
00013         """
00014                 A specialization of the SCons Environment class which does some particular
00015                 munging of the build variables needed in the source files.
00016         """
00017         
00018         def __init__(self, mainEnv, configuration_name = 'default'):
00019                 """
00020                         Applies the definitions in configuration_name to generate a correct
00021                         environment (specificall the set of compilation flags() for the
00022                         TinySTM library. That environment is returned
00023                 """
00024                 SCons.Environment.Environment.__init__(self)
00025 
00026                 # Generate build directives 
00027                 mnemosyneDirectives = helper.Directives(configuration_name, 'mnemosyne', ARGUMENTS, self._mnemosyne_boolean_directive_vars, self._mnemosyne_enumerable_directive_vars, self._mnemosyne_numerical_directive_vars)
00028 
00029                 configuration_variables = Environment._GetConfigurationVariables(self)
00030                 configuration_variables.Update(self)
00031                 self.Append(CPPPATH = '#library/common')
00032 
00033 
00034                 # Make output pretty.
00035                 if not self['VERBOSE']:
00036                         self.Replace(
00037                                          CCCOMSTR = '(COMPILE)  $SOURCES',
00038                                         CXXCOMSTR = '(COMPILE)  $SOURCES',
00039                                       SHCXXCOMSTR = '(COMPILE)  $SOURCES',
00040                                        SHCCCOMSTR = '(COMPILE)  $SOURCES',
00041                                        ASPPCOMSTR = '(ASSEMBLE) $SOURCES',
00042                                          ARCOMSTR = '(BUILD)    $TARGET',
00043                                      RANLIBCOMSTR = '(INDEX)    $TARGET',
00044                                        LINKCOMSTR = '(LINK)     $TARGET',
00045                                      SHLINKCOMSTR = '(LINK)     $TARGET')
00046         
00047                 self.Append(CPPDEFINES = mnemosyneDirectives.getPreprocessorDefinitions())
00048 
00049 
00050         # Disable some remark messages when using Intel CC 
00051                 if mainEnv is not None and mainEnv['CC'] == 'icc': 
00052                         DISABLE_WARNINGS = ['-wd869',  #remark  #869 : parameter "XYZ" was never referenced
00053                                ]
00054 
00055                         self.Append(CCFLAGS = string.join(DISABLE_WARNINGS, ' '))
00056 
00057 
00058                 # Inherit some command line options from the main environment
00059                 if mainEnv is not None:
00060                         self['BUILD_LINKAGE'] = mainEnv['BUILD_LINKAGE'] 
00061                         self['BUILD_DEBUG'] = mainEnv['BUILD_DEBUG'] 
00062                         self['BUILD_STATS'] = mainEnv['BUILD_STATS'] 
00063                         self['MY_ROOT_DIR'] = mainEnv['MY_ROOT_DIR'] 
00064                         self['MY_LINKER_DIR'] = mainEnv['MY_LINKER_DIR'] 
00065                         self['CC'] = mainEnv['CC'] 
00066                         self['CXX'] = mainEnv['CXX'] 
00067             
00068         def _GetConfigurationVariables(self):
00069                 """
00070                         Retrieve and define help variables for configuration variables.
00071                 """
00072 
00073                 cmd_line_args = ARGUMENTS
00074                 cfgVars = Variables(None, cmd_line_args)
00075                 [cfgVars.Add(BoolVariable(name, helptext, default)) for name, helptext, default in self._boolean_variables]
00076                 [cfgVars.Add(EnumVariable(name, helptext, default, valid)) for name, helptext, default, valid in self._enumerable_variables]
00077                 [cfgVars.Add(option) for option in self._numerical_variables]
00078 
00079                 return cfgVars
00080 
00081 
00082         # BUILD VARIABLES
00083 
00084         #: Build variables which are either on or off.
00085         _boolean_variables = [
00086                 # These are more to do with build behavior and output
00087                 ('VERBOSE', 'If set, displays the actual commands used and their flags instead of the default "neat" output.',
00088                         False)
00089         ]
00090 
00091         #: Build variables which have enumerated values.
00092         _enumerable_variables = [
00093                 ('LINKAGE',
00094                                  'Library linkage',
00095                                  'dynamic',
00096                                  ['dynamic', 'static'])
00097 
00098         ]
00099         
00100         #: Build variables which have numerical values
00101         _numerical_variables = [
00102         ]
00103 
00104 
00105         #: BUILD DIRECTIVES
00106 
00107         #: Build variables which are either on or off.
00108         _mnemosyne_boolean_directive_vars = [
00109                 ('M_PCM_EMULATE_CRASH',      'PCM emulation layer emulates system crashes.',
00110                         False),
00111                 ('M_PCM_EMULATE_LATENCY',    'PCM emulation layer emulates latency.',
00112                         False),
00113         ]
00114 
00115         #: Build variables which have enumerated values.
00116         _mnemosyne_enumerable_directive_vars = [
00117         ]
00118         
00119         #: Build variables which have numerical values
00120         _mnemosyne_numerical_directive_vars = [
00121                 ('M_PCM_CPUFREQ',            'CPU frequency in GHz used by the PCM emulation layer to calculate latencies', 
00122                         2500), 
00123                 ('M_PCM_LATENCY_WRITE',      'Latency of a PCM write in nanoseconds. This latency is in addition to the DRAM latency.', 
00124                         150), 
00125                 ('M_PCM_BANDWIDTH_MB',       'Bandwidth to PCM in MB/s. This is used to model sequential writes.', 
00126                         1200), 
00127         ]

Generated on Sat Apr 23 11:43:35 2011 for Mnemosyne by  doxygen 1.4.7