Subject: Re: [Boost-build] Very slow Visual Studio 2012 builds
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-11-04 16:49:59
On 11/04/2013 01:01 PM, Nogradi, Chris wrote:
> Well I had originally implemented this wrong as well and Steve corrected me. I think you REALLY want to create a batch file with the environment variables set to deal with command line size limits and make it a dependency of all the compile/assembly/link/... targets. This also makes incrementals a bit faster since the batch file is created once and then used on every subsequent build. I originally did this but have not had time to fix it to do what Steve suggested (also it is going to take me a while to figure it out since I am not an expert):
The command line limits may not matter.
Boost.Build writes the whole command
out into a temporary batch script anyway,
unless you explicitly set JAMSHELL to "%".
> # Append setup options to the setup name and add the final setup
> # prefix & suffix.
> setup-options ?= "" ;
> setup-$(c) = [ create-setup $(setup-$(c)) : $(setup-prefix) : $(setup-options) : setup-$(c) ] ;
> setup-$(c) = $(setup-prefix)$(setup-$(c):J=" ")$(setup-suffix) ;
> local rule create-setup ( setup : setup-prefix * : setup-options * : file )
> import regex ;
> import set ;
> vars ?= [ SHELL "set" ] ;
> original-vars ?= [ regex.split "$(vars)" "\\\n" ] ;
> setup = $(setup-prefix)$(setup:J=" ")" "$(setup-options:J=" ")" >nul && set" ;
> local new-vars = [ SHELL "$(setup)" ] ;
> new-vars = [ regex.split "$(new-vars)" "\\\n" ] ;
> local diff = [ set.difference $(new-vars) : $(original-vars) ] ;
> local path = [ path.join bin [ property.as-path [ feature.split $(conditions) ] ] ] ;
> common.MkDir $(path) ;
> local msvc-setup = [ path.native [ path.join $(path) $(file).bat ] ] ;
> local target = <setup-file>$(msvc-setup) ;
> DEPENDS $(target) : $(path) ;
> FILE_CONTENTS on $(target) = "@echo off"$(.nl)set" "$(diff:J="$(.nl)set ") ;
> ALWAYS $(target) ;
> msvc.write-setup $(target) ;
> .log-fd ?= [ FILE_OPEN [ path.join bin msvc.log ] : "w" ] ;
> UPDATE_NOW $(target) : $(.log-fd) : ignore-minus-n ;
> return $(msvc-setup) ;
> actions write-setup
> @($(STDOUT):E=$(FILE_CONTENTS:J=)) > "$(<)"
write-setup can be spelled:
import print ;
print.output $(target) ;
print.text ... ;
(b2 --help print for more details)
> This solution kind of works except the destination dir is hard coded to bin and if the real bin dir is bin also there is a directory creation conflict. I think Steve's batch file target as a dependency of all targets is a much better solution. I was going to get to it this week but I am not opposed to you doing it for me ;)
boostbook.jam creates a file called boostbook_config.xml.
You can use its implementation for inspiration.
(FWIW, common.MkDir is intended to be called many
times with the same paths. It shouldn't create a
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk