Boost logo

Boost-Build :

From: Alexey Pakhunov (alexeypa_at_[hidden])
Date: 2005-07-17 15:12:27


Hi,

Sorry for a delay. The last two weeks I was really busy...

So, the link to "How to build a COM server using BBv2?":
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Boost.Build_V2/MIDL_HOWTO

The patch itself together with examples can be found here:
http://boost-sandbox.sourceforge.net/vault/index.php?action=downloadfile&filename=how%20to%20build%20a%20com%20server%20using%20bbv2.zip&directory=&

I also attached the patch to this message (only diff, to get a
prepatched version use the link above). Now it is looks very similar to
rc.jam.

--------------------------------------------------------------------

I played a bit trying to create a separate toolset for midl.exe. So I
created the toolset "midl" that registers a rule:

---
generators.register-c-compiler midl.compile.idl : IDL : TLB H C(%_i) 
C(%_proxy) C(%_dlldata) H(%_proxy) : <toolset>midl ;
---
The actions look like before:
---
actions compile.idl
{
$(.IDL) /nologo /U$(UNDEFS) /D$(DEFINES) $(MIDLFLAGS) 
/I"$(INCLUDES)" /tlb "$(<[1]:W)" /h "$(<[2]:W)" /iid "$(<[3]:W)" /proxy 
"$(<[4]:W)" /dlldata "$(<[5]:W)" "$(>:W)"
}
---
The initialization rule in msvc.jam creates .IDL variable for 
midl.compile.idl rule:
---
flags midl.compile .IDL $(condition) : $(prefix)$(idl-compiler) : 
unchecked ;
---
As result for each mvsc-x.y corresponding midl-x.y is registered. Thus a 
user can choose versions of the compiler and midl.exe individually:
---
bjam --v2 msvc-7.1 midl-8.0
---
I expected that "msvc-7.1 midl-8.0" will be turned to "<toolset>msvc 
<toolset-version:msvc>7.1 <toolset>midl <toolset-version:midl>8.0" in 
the list of properties. But it turns out when it comes to the generators 
BBv2 cannot find a rule to build .idl because of "<toolset>midl" 
requirement. Only one value is present in the property list at this 
stage - "<toolset>msvc <toolset-version:msvc>7.1" in my case.
It seems that only one toolset can be used in the chain "sources -> ... 
-> result of a main rule".
To All: Any comment on this?
> exe hello : a.cpp a.idl b.idl ;
> 
> How we can solve the conflict between midl and xpidl compilers?
Including .idl files to the list of sources in an exe rule is not 
supported even now. So in theory it will be done using separate main rules:
---
midl a-typelib : a.idl ;
xpidl b-typelib : b.idl ;
exe hello : a.cpp : <implicit-dependency>a-typelib 
<implicit-dependency>b-typelib ;
---
> using midl : msvc ; # midl installed with Visual Studio 2002
> using midl : vc-7_0 ; # midl installed with Visual Studio 2002
> using midl : vc-7_1 ;
> using midl : borland ;
> using midl : mspsdk ; # from standalone psdk installation
We need some workaround to conflicting <toolset> values (see above).
>>- How to deal with several versions of VS installed?
> That's a big problem. See above.
In fact this can be solved much easily then I thought before. :)
>>>Also I'd like to see complete patched msvc.jam, not just diff.
Use the link to the archive with examples. There you will find what you 
need.
Best regards,
Alexey Pakhunov.
 --------------060400070902020903030306 Content-Type: text/plain;
name="msvc.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="msvc.diff"
? idl.jam
? midl.jam
? msvc.diff
Index: msvc.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/msvc.jam,v
retrieving revision 1.48
diff -c -3 -r1.48 msvc.jam
*** msvc.jam	15 Jul 2005 13:35:58 -0000	1.48
--- msvc.jam	17 Jul 2005 18:40:15 -0000
***************
*** 15,20 ****
--- 15,21 ----
import common ;
import rc ;
+ import midl ;
if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
***************
*** 30,35 ****
--- 31,39 ----
# to be seen, though ;-)
;
+ # Inherit MIDL flags
+ toolset.inherit-flags msvc : midl ;
+ 
RM = [ common.rm-command ] ;
# Initialize the toolset for a specific version. As the result, path to
***************
*** 65,71 ****
# 
# - if compiler is not found in default locations, PATH will be searched. 
: options * 
! # options can include <setup>, <compiler>, <linker> and <resource-compiler>
)
{ 
# setup will be used iff a path has been specified. If setup is
--- 69,75 ----
# 
# - if compiler is not found in default locations, PATH will be searched. 
: options * 
! # options can include <setup>, <compiler>, <linker>, <resource-compiler> and <idl-compiler>
)
{ 
# setup will be used iff a path has been specified. If setup is
***************
*** 78,83 ****
--- 82,89 ----
linker ?= link ;
resource-compiler = [ get-values <resource-compiler> : $(options) ] ;
resource-compiler ?= rc ;
+ idl-compiler = [ get-values <idl-compiler> : $(options) ] ;
+ idl-compiler ?= midl ;
local condition = [ common.check-init-parameters msvc : 
version $(version) ] ;
***************
*** 115,123 ****
flags msvc.compile .CC $(condition) : $(prefix)$(compiler) ;
flags msvc.compile .RC $(condition) : $(prefix)$(resource-compiler) ;
flags msvc.link .LD $(condition) : $(prefix)$(linker) ;
flags msvc.archive .LD $(condition) : $(prefix)$(linker) ;
! 
if ! $(version) 
{
# Even if version is not explicitly specified, try to detect the version
--- 121,130 ----
flags msvc.compile .CC $(condition) : $(prefix)$(compiler) ;
flags msvc.compile .RC $(condition) : $(prefix)$(resource-compiler) ;
+ flags msvc.compile .IDL $(condition) : $(prefix)$(idl-compiler) ;
flags msvc.link .LD $(condition) : $(prefix)$(linker) ;
flags msvc.archive .LD $(condition) : $(prefix)$(linker) ;
! 
if ! $(version) 
{
# Even if version is not explicitly specified, try to detect the version
***************
*** 229,237 ****
generators.register-archiver msvc.archive : OBJ : STATIC_LIB : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c++ : CPP : OBJ : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c : C : OBJ : <toolset>msvc ;
! generators.register-standard msvc.compile.rc : RC : OBJ(%_res) : <toolset>msvc ;
generators.override msvc.compile.rc : rc.resource-compile ;
#
# Declare flags and action for compilation
#
--- 236,250 ----
generators.register-archiver msvc.archive : OBJ : STATIC_LIB : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c++ : CPP : OBJ : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c : C : OBJ : <toolset>msvc ;
! 
! # 'register-c-compiler' causes a build directory to be added to INCLUDES
! generators.register-c-compiler msvc.compile.rc : RC : OBJ(%_res) : <toolset>msvc ;
! 
generators.override msvc.compile.rc : rc.resource-compile ;
+ generators.register-c-compiler msvc.compile.idl : IDL : TLB H C(%_i) C(%_proxy) C(%_dlldata) H(%_proxy) : <toolset>msvc ;
+ generators.override msvc.compile.idl : midl.compile.idl ;
+ 
#
# Declare flags and action for compilation
#
***************
*** 375,378 ****
--- 388,395 ----
common.response-file $(targets) : $(sources) : $(targets[2]) : $(properties) ;
}
+ actions compile.idl
+ {
+ $(.IDL) /nologo /U$(UNDEFS) /D$(DEFINES) $(MIDLFLAGS) /I"$(INCLUDES)" /tlb "$(<[1]:W)" /h "$(<[2]:W)" /iid "$(<[3]:W)" /proxy "$(<[4]:W)" /dlldata "$(<[5]:W)" "$(>:W)"
+ }
 --------------060400070902020903030306 Content-Type: text/plain;
name="midl.jam"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="midl.jam"
#~ Copyright 2005 Alexey Pakhunov.
#~ Distributed under the Boost Software License, Version 1.0.
#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Microsoft Interface Definition Language (MIDL) related routines
import common ;
import generators ;
import feature : feature get-values ;
import scanner ;
import toolset : flags ;
import type ;
rule init ( )
{
}
type.register IDL : idl ;
type.register TLB : tlb ;
# Register scanner for MIDL files
class midl-scanner : scanner 
{
import regex virtual-target path scanner ; 
rule __init__ ( includes * )
{
scanner.__init__ ;
self.includes = $(includes) ;
} 
rule pattern ( )
{
return
"(((include[ ]*\"[^\"]*\"([ ]*,[ ]*\"[^\"]*\")*)|(import[ ]*\"[^\"]*\"([ ]*,[ ]*\"[^\"]*\")*)|(importlib[ ]*[(][ ]*\"[^\"]*\"([ ]*,[ ]*\"[^\"]*\")*[ ]*[)]))[ ]*;)" ;
}
rule process ( target : matches * : binding )
{
local included = [ regex.transform $(matches) : "include[ ]*\"([^\"]*)\"([ ]*,[ ]*\"([^\"]*)\")*[ ]*;" : 1 3 ] ;
local imported = [ regex.transform $(matches) : "import[ ]*\"([^\"]*)\"([ ]*,[ ]*\"([^\"]*)\")*[ ]*;" : 1 3 ] ;
local imported_tlbs = [ regex.transform $(matches) : "importlib[ ]*[(][ ]*\"([^\"]*)\"([ ]*,[ ]*\"([^\"]*)\")*[ ]*[)][ ]*;" : 1 3 ] ;
# CONSIDER: the new scoping rule seem to defeat "on target" variables.
local g = [ on $(target) return $(HDRGRIST) ] ; 
local b = [ NORMALIZE_PATH $(binding:D) ] ;
# Attach binding of including file to included targets.
# When target is directly created from virtual target
# this extra information is unnecessary. But in other
# cases, it allows to distinguish between two headers of the 
# same name included from different places. 
local g2 = $(g)"#"$(b) ;
included = $(included:G=$(g2)) ;
imported = $(imported:G=$(g2)) ;
imported_tlbs = $(imported_tlbs:G=$(g2)) ;
local all = $(included) $(imported) ;
INCLUDES $(target) : $(all) ;
DEPENDS $(target) : $(imported_tlbs) ;
NOCARE $(all) $(imported_tlbs) ;
SEARCH on $(included) = $(b) $(self.includes:G=) ;
SEARCH on $(imported) = $(b) $(self.includes:G=) ;
SEARCH on $(imported_tlbs) = $(b) $(self.includes:G=) ;
scanner.propagate c-scanner : $(included) : $(target) ;
scanner.propagate $(__name__) : $(imported) : $(target) ;
} 
}
scanner.register midl-scanner : include ;
type.set-scanner IDL : midl-scanner ;
# Command line options
feature midl-stubless-proxy : yes no : propagated ;
feature midl-environment : win32 win64 : propagated ;
feature midl-robust : yes no : propagated ;
flags midl.compile.idl MIDLFLAGS <midl-stubless-proxy>yes : /Oicf ;
flags midl.compile.idl MIDLFLAGS <midl-stubless-proxy>no : /Oic ;
flags midl.compile.idl MIDLFLAGS <midl-environment>win32 : /win32 ;
flags midl.compile.idl MIDLFLAGS <midl-environment>win64 : /win64 ;
flags midl.compile.idl MIDLFLAGS <midl-robust>yes : /robust ;
flags midl.compile.idl MIDLFLAGS <midl-robust>no : /no_robust ;
generators.register-c-compiler midl.compile.idl : IDL : TLB H C(%_i) C(%_proxy) C(%_dlldata) H(%_proxy) ;
actions compile.idl
{
midl /nologo /U$(UNDEFS) /D$(DEFINES) $(MIDLFLAGS) /I"$(INCLUDES)" /tlb "$(<[1]:W)" /h "$(<[2]:W)" /iid "$(<[3]:W)" /proxy "$(<[4]:W)" /dlldata "$(<[5]:W)" "$(>:W)"
}
 --------------060400070902020903030306-- 

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