Ticket #4667: tools_gcc.jam.patch

File tools_gcc.jam.patch, 3.3 KB (added by mhassert@…, 12 years ago)

Patch for configuration of toolset gcc

  • tools/gcc.jam

     
    5858# Example:
    5959#   using gcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ;
    6060#
     61# The compiler command to use is detected in a three step manner:
     62# 1) If an explicit command is specified by the user, it will be used and must available.
     63# 2) If only a certain version is specified, it is enforced:
     64#    - either a command 'g++-VERSION' must be available
     65#    - or the default command 'g++' must be available and match the exact version.
     66# 3) Without user-provided restrictions use default 'g++'
    6167rule init ( version ? : command * : options * )
    6268{
     69    #1): use user-provided command
     70    local tool-command = ;
     71    if $(command)
     72    {
     73       tool-command  =  [ common.get-invocation-command-nodefault gcc : g++ : $(command) ] ;
     74       if ! $(tool-command)
     75       {
     76           errors.error "toolset gcc initialization:" :
     77                        "provided command '$(command)' not found" :
     78                        "initialized from" [ errors.nearest-user-location ] ;
     79       }
     80    }
     81    #2): enforce user-provided version
     82    else if $(version)
     83    {
     84        tool-command  =  [ common.get-invocation-command-nodefault gcc : g++ : "g++-$(version[1])" ] ;
     85       
     86        #2.1) fallback: check whether "g++" reports the requested version
     87        if ! $(tool-command)
     88        {
     89            tool-command = [ common.get-invocation-command-nodefault gcc : g++ : g++ ] ;
     90            if $(tool-command)
     91            {
     92                local tool-version = [ MATCH "^([0-9.]+)" : [ SHELL "g++ -dumpversion" ] ] ;
     93                if $(tool-version) != $(version)
     94                {
     95                    errors.error "toolset gcc initialization:" :
     96                                 "version '$(version)' requested but 'g++-$(version)' not found and version '$(tool-version)' of default 'g++' does not match" :
     97                                 "initialized from" [ errors.nearest-user-location ] ;
     98                    tool-command = ;
     99                }
     100            }
     101            else
     102            {
     103                errors.error "toolset gcc initialization:" :
     104                             "version '$(version)' requested but neither 'g++-$(version)' nor default 'g++' found" :
     105                             "initialized from" [ errors.nearest-user-location ] ;
     106            }
     107        }
     108    }
     109    #3) default: no command and no version specified, try using default command "g++"
     110    else
     111    {
     112        tool-command = [ common.get-invocation-command-nodefault gcc : g++ : g++ ] ;
     113        if ! $(tool-command)
     114        {
     115            errors.error "toolset gcc initialization:" :
     116                         "no command provided, default command 'g++' not found" :
     117                         "initialized from" [ errors.nearest-user-location ] ;
     118        }
     119    }
     120   
     121   
    63122    # Information about the gcc command...
    64123    #   The command.
    65     local command = [ common.get-invocation-command gcc : g++ : $(command) ] ;
     124    local command = $(tool-command) ;
    66125    #   The root directory of the tool install.
    67126    local root = [ feature.get-values <root> : $(options) ] ;
    68127    #   The bin directory where to find the command to execute.