~david-ar/numpy.scons.support/checkfuncsatonce

« back to all changes in this revision

Viewing changes to numscons/core/initialization.py

  • Committer: david
  • Date: 2008-08-08 20:32:05 UTC
  • Revision ID: david@evans-2.local-20080808203205-lb5nhpp8tm9j78f3
Simplify compilers initialization.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
def initialize_cc(env):
39
39
    """Initialize C compiler from distutils info."""
40
40
    def set_cc_from_distutils():
41
 
        name = None
42
41
        if len(env['cc_opt_path']) > 0:
43
42
            debug('Setting cc_opt_path from distutils (%s).' % env['cc_opt_path'])
44
 
            if built_with_mstools(env):
45
 
                info('Detecting ms build.')
46
 
                name = "msvc"
47
 
                # We need msvs tool too (before customization !)
48
 
                env.Tool('msvs')
49
 
                env.Tool("msvc")
50
 
            else:
51
 
                name = get_cc_type(env, pjoin(env['cc_opt_path'], env['cc_opt']))
52
 
                info('Detecting CC type: %s' % name)
53
 
                if name == 'gcc' and sys.platform == 'win32':
54
 
                    name = 'mingw'
55
 
                    debug('Changing cc => mingw')
56
 
                env.Tool(name)
 
43
            cc = pjoin(env["cc_opt_path"], env["cc_opt"])
57
44
        else:
58
45
            debug('Setting wo cc_opt_path')
59
 
            # Do not care about PATH info because none given from scons
60
 
            # distutils command
 
46
            cc = env["cc_opt"]
 
47
 
 
48
        if built_with_mstools(env):
 
49
            info('Detecting ms build.')
 
50
            name = "msvc"
 
51
            # We need msvs tool too (before customization !)
 
52
            env.Tool('msvs')
 
53
        else:
 
54
            name = get_cc_type(env, cc)
 
55
            if name == 'gcc' and sys.platform == 'win32':
 
56
                name = 'mingw'
 
57
                debug('Changing cc => mingw')
 
58
 
 
59
            info('Detected CC type: %s' % name)
61
60
            try:
62
 
                name = env['cc_opt']
63
61
                env.Tool(name)
64
62
            except ImportError:
65
63
                raise UnknownCompiler(env['cc_opt'])
82
80
    from SCons.Tool import Tool, FindTool
83
81
 
84
82
    def set_f77_from_distutils():
85
 
        name = None
86
83
        env.AppendUnique(F77FILESUFFIXES = ['.f'])
87
84
        if len(env['f77_opt']) > 0:
88
85
            debug('Setting F77 from distutils: %s' % env['f77_opt'])
89
86
            if len(env['f77_opt_path']) > 0:
90
 
                name = get_f77_type(env, pjoin(env['f77_opt_path'], env['f77_opt']))
91
 
                info('Detecting F77 type: %s' % name)
92
 
                env.Tool(name)
 
87
                f77 = pjoin(env['f77_opt_path'], env['f77_opt'])
93
88
            else:
94
 
                name = get_f77_type(env, env['f77_opt'])
95
 
                info('Detecting F77 type: %s' % name)
96
 
                env.Tool(name)
 
89
                f77 = env['f77_opt']
 
90
 
 
91
            name = get_f77_type(env, f77)
 
92
            info('Detecting F77 type: %s' % name)
 
93
            env.Tool(name)
97
94
        else:
98
95
            debug('Setting F77 from default list')
99
96
            name =  FindTool(DEF_FORTRAN_COMPILERS, env)
115
112
    from SCons.Tool import Tool, FindTool
116
113
 
117
114
    def set_cxx_from_distutils():
118
 
        name = None
119
115
        if len(env['cxx_opt']) > 0:
120
116
            if len(env['cxx_opt_path']) > 0:
121
 
                if built_with_mstools(env):
122
 
                    name = "msvc"
123
 
                    env.Tool(name)
124
 
                    info("Detected CXX type: msvc")
125
 
                    # We need msvs tool too (before customization !)
126
 
                else:
127
 
                    name = get_cxx_type(env, pjoin(env['cxx_opt_path'],
128
 
                                             env['cxx_opt']))
129
 
                    info("Detected CXX type: %s" % name)
130
 
                    env.Tool(name)
 
117
                cxx = pjoin(env['cxx_opt_path'], env['cxx_opt'])
 
118
            else:
 
119
                cxx = env['cxx_opt']
 
120
 
 
121
            if built_with_mstools(env):
 
122
                name = "msvc"
 
123
                env.Tool(name)
 
124
            else:
 
125
                name = get_cxx_type(env, cxx)
 
126
            info("Detected CXX type: %s" % name)
 
127
            env.Tool(name)
131
128
        else:
132
129
            name =  FindTool(DEF_CXX_COMPILERS, env)
 
130
            info("Detected CXX type: %s" % name)
133
131
            if name:
134
132
                env.Tool(name)
135
133
        return name