Initializes the gcc toolset for the given version. If necessary, command may be used to specify where the compiler is located. The parameter 'options' is a space-delimited list of options, each one specified as option-value. Valid option names are: cxxfl
(version = None, command = None, options = None)
| 85 | __version_match = re.compile('^([0-9.]+)') |
| 86 | |
| 87 | def init(version = None, command = None, options = None): |
| 88 | """ |
| 89 | Initializes the gcc toolset for the given version. If necessary, command may |
| 90 | be used to specify where the compiler is located. The parameter 'options' is a |
| 91 | space-delimited list of options, each one specified as |
| 92 | <option-name>option-value. Valid option names are: cxxflags, linkflags and |
| 93 | linker-type. Accepted linker-type values are gnu, darwin, osf, hpux or sun |
| 94 | and the default value will be selected based on the current OS. |
| 95 | Example: |
| 96 | using gcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ; |
| 97 | """ |
| 98 | |
| 99 | options = to_seq(options) |
| 100 | command = to_seq(command) |
| 101 | |
| 102 | # Information about the gcc command... |
| 103 | # The command. |
| 104 | command = to_seq(common.get_invocation_command('gcc', 'g++', command)) |
| 105 | # The root directory of the tool install. |
| 106 | root = feature.get_values('<root>', options) ; |
| 107 | # The bin directory where to find the command to execute. |
| 108 | bin = None |
| 109 | # The flavor of compiler. |
| 110 | flavor = feature.get_values('<flavor>', options) |
| 111 | # Autodetect the root and bin dir if not given. |
| 112 | if command: |
| 113 | if not bin: |
| 114 | bin = common.get_absolute_tool_path(command[-1]) |
| 115 | if not root: |
| 116 | root = os.path.dirname(bin) |
| 117 | # Autodetect the version and flavor if not given. |
| 118 | if command: |
| 119 | machine_info = subprocess.Popen(command + ['-dumpmachine'], stdout=subprocess.PIPE).communicate()[0] |
| 120 | machine = __machine_match.search(machine_info).group(1) |
| 121 | |
| 122 | version_info = subprocess.Popen(command + ['-dumpversion'], stdout=subprocess.PIPE).communicate()[0] |
| 123 | version = __version_match.search(version_info).group(1) |
| 124 | if not flavor and machine.find('mingw') != -1: |
| 125 | flavor = 'mingw' |
| 126 | |
| 127 | condition = None |
| 128 | if flavor: |
| 129 | condition = common.check_init_parameters('gcc', None, |
| 130 | ('version', version), |
| 131 | ('flavor', flavor)) |
| 132 | else: |
| 133 | condition = common.check_init_parameters('gcc', None, |
| 134 | ('version', version)) |
| 135 | |
| 136 | if command: |
| 137 | command = command[0] |
| 138 | |
| 139 | common.handle_options('gcc', condition, command, options) |
| 140 | |
| 141 | linker = feature.get_values('<linker-type>', options) |
| 142 | if not linker: |
| 143 | if os_name() == 'OSF': |
| 144 | linker = 'osf' |
nothing calls this directly
no test coverage detected