Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 511036 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/engine/SCons/Environment.py (-2 / +2 lines)
Lines 1803-1810 Link Here
1803
                pass
1803
                pass
1804
        elif SCons.Util.is_String(pathext):
1804
        elif SCons.Util.is_String(pathext):
1805
            pathext = self.subst(pathext)
1805
            pathext = self.subst(pathext)
1806
        prog = self.subst(prog)
1806
        prog = SCons.Util.CLVar(self.subst(prog)) # support "program --with-args"
1807
        path = SCons.Util.WhereIs(prog, path, pathext, reject)
1807
        path = SCons.Util.WhereIs(prog[0], path, pathext, reject)
1808
        if path: return path
1808
        if path: return path
1809
        return None
1809
        return None
1810
1810
(-)a/src/engine/SCons/Tool/c++.py (-2 / +3 lines)
Lines 72-78 Link Here
72
72
73
    SCons.Tool.cc.add_common_cc_variables(env)
73
    SCons.Tool.cc.add_common_cc_variables(env)
74
74
75
    env['CXX']        = 'c++'
75
    if 'CXX' not in env:
76
        env['CXX']    = env.Detect(compilers) or compilers[0]
76
    env['CXXFLAGS']   = SCons.Util.CLVar('')
77
    env['CXXFLAGS']   = SCons.Util.CLVar('')
77
    env['CXXCOM']     = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
78
    env['CXXCOM']     = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
78
    env['SHCXX']      = '$CXX'
79
    env['SHCXX']      = '$CXX'
Lines 90-96 Link Here
90
    env['CXXFILESUFFIX'] = '.cc'
91
    env['CXXFILESUFFIX'] = '.cc'
91
92
92
def exists(env):
93
def exists(env):
93
    return env.Detect(compilers)
94
    return env.Detect(env.get('CXX', compilers))
94
95
95
# Local Variables:
96
# Local Variables:
96
# tab-width:4
97
# tab-width:4
(-)a/src/engine/SCons/Tool/cc.py (-2 / +5 lines)
Lines 62-67 Link Here
62
    if 'SHCCFLAGS' not in env:
62
    if 'SHCCFLAGS' not in env:
63
        env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
63
        env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
64
64
65
compilers = ['cc']
66
65
def generate(env):
67
def generate(env):
66
    """
68
    """
67
    Add Builders and construction variables for C compilers to an Environment.
69
    Add Builders and construction variables for C compilers to an Environment.
Lines 76-82 Link Here
76
78
77
    add_common_cc_variables(env)
79
    add_common_cc_variables(env)
78
80
79
    env['CC']        = 'cc'
81
    if 'CC' not in env:
82
        env['CC']    = env.Detect(compilers) or compilers[0]
80
    env['CFLAGS']    = SCons.Util.CLVar('')
83
    env['CFLAGS']    = SCons.Util.CLVar('')
81
    env['CCCOM']     = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
84
    env['CCCOM']     = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
82
    env['SHCC']      = '$CC'
85
    env['SHCC']      = '$CC'
Lines 93-99 Link Here
93
    env['CFILESUFFIX'] = '.c'
96
    env['CFILESUFFIX'] = '.c'
94
97
95
def exists(env):
98
def exists(env):
96
    return env.Detect('cc')
99
    return env.Detect(env.get('CC', compilers))
97
100
98
# Local Variables:
101
# Local Variables:
99
# tab-width:4
102
# tab-width:4
(-)a/src/engine/SCons/Tool/g++.py (-20 / +10 lines)
Lines 40-45 Link Here
40
import SCons.Tool
40
import SCons.Tool
41
import SCons.Util
41
import SCons.Util
42
42
43
import gcc
44
43
cplusplus = __import__('c++', globals(), locals(), [])
45
cplusplus = __import__('c++', globals(), locals(), [])
44
46
45
compilers = ['g++']
47
compilers = ['g++']
Lines 48-57 Link Here
48
    """Add Builders and construction variables for g++ to an Environment."""
50
    """Add Builders and construction variables for g++ to an Environment."""
49
    static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
51
    static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
50
52
53
    if 'CXX' not in env:
54
        env['CXX']    = env.Detect(compilers) or compilers[0]
55
51
    cplusplus.generate(env)
56
    cplusplus.generate(env)
52
57
53
    env['CXX']        = env.Detect(compilers)
54
55
    # platform specific settings
58
    # platform specific settings
56
    if env['PLATFORM'] == 'aix':
59
    if env['PLATFORM'] == 'aix':
57
        env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc')
60
        env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc')
Lines 62-87 Link Here
62
    elif env['PLATFORM'] == 'sunos':
65
    elif env['PLATFORM'] == 'sunos':
63
        env['SHOBJSUFFIX'] = '.pic.o'
66
        env['SHOBJSUFFIX'] = '.pic.o'
64
    # determine compiler version
67
    # determine compiler version
65
    if env['CXX']:
68
    version = gcc.detect_version(env, env['CXX'])
66
        #pipe = SCons.Action._subproc(env, [env['CXX'], '-dumpversion'],
69
    if version:
67
        pipe = SCons.Action._subproc(env, [env['CXX'], '--version'],
70
        env['CXXVERSION'] = version
68
                                     stdin = 'devnull',
69
                                     stderr = 'devnull',
70
                                     stdout = subprocess.PIPE)
71
        if pipe.wait() != 0: return
72
        # -dumpversion was added in GCC 3.0.  As long as we're supporting
73
        # GCC versions older than that, we should use --version and a
74
        # regular expression.
75
        #line = pipe.stdout.read().strip()
76
        #if line:
77
        #    env['CXXVERSION'] = line
78
        line = pipe.stdout.readline()
79
        match = re.search(r'[0-9]+(\.[0-9]+)+', line)
80
        if match:
81
            env['CXXVERSION'] = match.group(0)
82
71
83
def exists(env):
72
def exists(env):
84
    return env.Detect(compilers)
73
    # is executable, and is a GNU compiler (or accepts '--version' at least)
74
    return gcc.detect_version(env, env.Detect(env.get('CXX', compilers)))
85
75
86
# Local Variables:
76
# Local Variables:
87
# tab-width:4
77
# tab-width:4
(-)a/src/engine/SCons/Tool/gcc.py (-19 / +39 lines)
Lines 44-77 Link Here
44
44
45
def generate(env):
45
def generate(env):
46
    """Add Builders and construction variables for gcc to an Environment."""
46
    """Add Builders and construction variables for gcc to an Environment."""
47
48
    if 'CC' not in env:
49
        env['CC'] = env.Detect(compilers) or compilers[0]
50
47
    cc.generate(env)
51
    cc.generate(env)
48
52
49
    env['CC'] = env.Detect(compilers) or 'gcc'
50
    if env['PLATFORM'] in ['cygwin', 'win32']:
53
    if env['PLATFORM'] in ['cygwin', 'win32']:
51
        env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
54
        env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
52
    else:
55
    else:
53
        env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC')
56
        env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC')
54
    # determine compiler version
57
    # determine compiler version
55
    if env['CC']:
58
    version = detect_version(env, env['CC'])
56
        #pipe = SCons.Action._subproc(env, [env['CC'], '-dumpversion'],
59
    if version:
57
        pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
60
        env['CCVERSION'] = version
58
                                     stdin = 'devnull',
59
                                     stderr = 'devnull',
60
                                     stdout = subprocess.PIPE)
61
        if pipe.wait() != 0: return
62
        # -dumpversion was added in GCC 3.0.  As long as we're supporting
63
        # GCC versions older than that, we should use --version and a
64
        # regular expression.
65
        #line = pipe.stdout.read().strip()
66
        #if line:
67
        #    env['CCVERSION'] = line
68
        line = pipe.stdout.readline()
69
        match = re.search(r'[0-9]+(\.[0-9]+)+', line)
70
        if match:
71
            env['CCVERSION'] = match.group(0)
72
61
73
def exists(env):
62
def exists(env):
74
    return env.Detect(compilers)
63
    # is executable, and is a GNU compiler (or accepts '--version' at least)
64
    return detect_version(env, env.Detect(env.get('CC', compilers)))
65
66
def detect_version(env, cc):
67
    """Return the version of the GNU compiler, or None if it is not a GNU compiler."""
68
    cc = env.subst(cc)
69
    if not cc:
70
        return None
71
    version = None
72
    #pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['-dumpversion'],
73
    pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['--version'],
74
                                 stdin = 'devnull',
75
                                 stderr = 'devnull',
76
                                 stdout = subprocess.PIPE)
77
    # -dumpversion was added in GCC 3.0.  As long as we're supporting
78
    # GCC versions older than that, we should use --version and a
79
    # regular expression.
80
    #line = pipe.stdout.read().strip()
81
    #if line:
82
    #    version = line
83
    line = pipe.stdout.readline()
84
    match = re.search(r'[0-9]+(\.[0-9]+)+', line)
85
    if match:
86
        version = match.group(0)
87
    # Non-GNU compiler's output (like AIX xlc's) may exceed the stdout buffer:
88
    # So continue with reading to let the child process actually terminate.
89
    while pipe.stdout.readline():
90
        pass
91
    ret = pipe.wait()
92
    if ret != 0:
93
        return None
94
    return version
75
95
76
# Local Variables:
96
# Local Variables:
77
# tab-width:4
97
# tab-width:4
(-)ac2d4976f7f3 (-2 / +2 lines)
Lines 197-209 Link Here
197
198
198
test.run(arguments = 'foo' + _exe)
199
test.run(arguments = 'foo' + _exe)
199
200
200
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
201
test.must_not_exist(test.workpath('wrapper.out'))
201
202
202
test.up_to_date(arguments = 'foo' + _exe)
203
test.up_to_date(arguments = 'foo' + _exe)
203
204
204
test.run(arguments = 'bar' + _exe)
205
test.run(arguments = 'bar' + _exe)
205
206
206
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
207
test.must_match('wrapper.out', "wrapper.py\n")
207
208
208
test.up_to_date(arguments = 'bar' + _exe)
209
test.up_to_date(arguments = 'bar' + _exe)
209
210

Return to bug 511036