Ticket #234: msvc.jam.patch

File msvc.jam.patch, 3.0 KB (added by Md Abdur Rahim, 10 years ago)
  • msvc.jam

     
    3232import pch ;
    3333import property ;
    3434import rc ;
     35import set ;
    3536import toolset ;
    3637import type ;
    3738
     
    677678}
    678679
    679680
     681# Helper rule to get the environment side-effects of a batch file.
     682# We used to call MSVC setup scripts directly in every action, however in
     683# newer MSVC versions (10.0+) they make long-lasting registry queries
     684# which have a significant impact on build time.
     685# Note that this requires 'cmd.exe' based SHELL, it will not work with
     686# Cygwin built b2.
     687local rule batch-file-environment ( batch-file )
     688{
     689    local original-vars = [ SPLIT_BY_CHARACTERS [ SHELL set ] : "\n" ] ;
     690    local new-vars = [ SPLIT_BY_CHARACTERS [ SHELL "$(batch-file)>nul && set" ] : "\n" ] ;
     691    local diff-vars = [ set.difference $(new-vars) : $(original-vars) ] ;
     692    diff-vars = "SET "$(diff-vars) ;
     693    return $(diff-vars:J="\n")\n ;
     694}
     695
     696
    680697# Worker rule for toolset version configuration. Takes an explicit version id or
    681698# nothing in case it should configure the default toolset version (the first
    682699# registered one or a new 'default' one in case no toolset versions have been
     
    887904                default-global-setup-options-ia64 = ia64 ;
    888905            }
    889906
    890             local setup-prefix = "call " ;
    891             local setup-suffix = " >nul"$(.nl) ;
    892             if ! [ os.name ] in NT
    893             {
    894                 setup-prefix = "cmd.exe /S /C call " ;
    895                 setup-suffix = " \">nul\" \"&&\" " ;
    896             }
    897 
    898907            for local c in $(cpu)
    899908            {
    900909                local setup-options ;
     
    927936                # Append setup options to the setup name and add the final setup
    928937                # prefix & suffix.
    929938                setup-options ?= "" ;
    930                 setup-$(c) = $(setup-prefix)$(setup-$(c):J=" ")" "$(setup-options:J=" ")$(setup-suffix) ;
     939
     940                setup-$(c) = $(setup-$(c):J=" ") $(setup-options:J=" ") ;
    931941            }
    932942        }
    933943
     
    981991            local cpu-assembler = $(assembler) ;
    982992            cpu-assembler ?= $(default-assembler-$(c)) ;
    983993
     994            if $(setup-$(c))
     995            {
     996                if ! [ os.name ] in NT
     997                {
     998                    local prefix = "cmd.exe /S /C call " ;
     999                    local suffix = " \">nul\" \"&&\" " ;
     1000                    setup-$(c) = $(prefix)$(setup-$(c):J=" ")$(suffix) ;
     1001                }
     1002                else
     1003                {
     1004                    setup-$(c) = [ batch-file-environment $(setup-$(c):J=" ") ] ;
     1005                }
     1006            }
     1007
    9841008            toolset.flags msvc.compile .CC  $(cpu-conditions) : $(setup-$(c))$(compiler) /Zm800 -nologo ;
    9851009            toolset.flags msvc.compile .RC  $(cpu-conditions) : $(setup-$(c))$(resource-compiler) ;
    9861010            toolset.flags msvc.compile .ASM $(cpu-conditions) : $(setup-$(c))$(cpu-assembler) -nologo ;