Ticket #4667: tools_gcc.jam_v2.patch

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

Second version of patch. Fixed tool search on windows.

  • 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++-$(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++ ] ;
     90            if $(tool-command)
     91            {
     92                local tool-command-string = $(tool-command:J=" ") ;
     93                local tool-version = [ MATCH "^([0-9.]+)" : [ SHELL "$(tool-command-string) -dumpversion" ] ] ;
     94                if $(tool-version) != $(version)
     95                {
     96                    errors.error "toolset gcc initialization:" :
     97                                 "version '$(version)' requested but 'g++-$(version)' not found and version '$(tool-version)' of default '$(tool-command)' does not match" :
     98                                 "initialized from" [ errors.nearest-user-location ] ;
     99                    tool-command = ;
     100                }
     101            }
     102            else
     103            {
     104                errors.error "toolset gcc initialization:" :
     105                             "version '$(version)' requested but neither 'g++-$(version)' nor default 'g++' found" :
     106                             "initialized from" [ errors.nearest-user-location ] ;
     107            }
     108        }
     109    }
     110    #3) default: no command and no version specified, try using default command "g++"
     111    else
     112    {
     113        tool-command = [ common.get-invocation-command-nodefault gcc : g++ ] ;
     114        if ! $(tool-command)
     115        {
     116            errors.error "toolset gcc initialization:" :
     117                         "no command provided, default command 'g++' not found" :
     118                         "initialized from" [ errors.nearest-user-location ] ;
     119        }
     120    }
     121   
     122   
    63123    # Information about the gcc command...
    64124    #   The command.
    65     local command = [ common.get-invocation-command gcc : g++ : $(command) ] ;
     125    local command = $(tool-command) ;
    66126    #   The root directory of the tool install.
    67127    local root = [ feature.get-values <root> : $(options) ] ;
    68128    #   The bin directory where to find the command to execute.