Boost logo

Boost-Build :

From: Alexey Pakhunov (alexeypa_at_[hidden])
Date: 2005-05-17 14:52:58


Hello,

I implemented limited support of .idl files. Is anyone interested? :)

The attached patch adds the following:

- Scanner for .idl files. It is able to parse 'include', 'import' and
'importlib' directives.
- Support of midl.exe via msvc package;
- A small fix - msvc.compile.rc is registered using
'register-c-compiler' instead of 'register-standard'. Thus a build
directory is passed to RC as an include directory. So adding .tlb (see
the line below) will work.

1 TYPELIB "xxx.tlb"

The same is true for other resource includes generated on the fly.

Support of midl.exe includes only single command that generates UUID
(%_i.c) and header (.h) files. In other words "it works for me". At
least now it is enough to build ALT COM dll.

Best regards,
Alexey.

 --------------020701000004070801090209 Content-Type: text/plain;
name="idl.jam"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="idl.jam"

# Copyright (C) Alexey Pakhunov 2005. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears in
# all copies. This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.

# This module implements scanner for .idl files that is able to
# extract 'include', 'import' and 'importlib' directives.

import type ;
import generators ;
import feature ;
import errors ;
import scanner ;

type.register IDL : idl ;
type.register TLB : tlb ;

rule init ( )
{
}

# Register scanner for .idl
class idl-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 idl-scanner : include ;
type.set-scanner IDL : idl-scanner ;
 --------------020701000004070801090209 Content-Type: text/plain;
name="msvc.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="msvc.diff"

Index: msvc.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/msvc.jam,v
retrieving revision 1.35
diff -c -3 -r1.35 msvc.jam
*** msvc.jam 23 Nov 2004 09:57:33 -0000 1.35
--- msvc.jam 17 May 2005 17:41:26 -0000
***************
*** 15,20 ****
--- 15,25 ----
import common ;

import rc ;
+ import idl ;
+
+ # MIDL command line options
+ feature stubless-proxy : on off : propagated ;
+ feature environment : win32 win64 : propagated ;

if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
***************
*** 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
--- 70,76 ----
#
# - 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 ****
--- 83,90 ----
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,120 ****
--- 122,128 ----

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) ;

***************
*** 227,235 ****
generators.register-archiver msvc.archive : OBJ : STATIC_LIB RSP : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c++ : CPP : OBJ RSP(%_cpp) : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c : C : OBJ RSP(%_cpp) : <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
#
--- 235,248 ----
generators.register-archiver msvc.archive : OBJ : STATIC_LIB RSP : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c++ : CPP : OBJ RSP(%_cpp) : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c : C : OBJ RSP(%_cpp) : <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 ;

+ # 'register-c-compiler' causes a build directory to be added to INCLUDES
+ generators.register-c-compiler msvc.compile.idl : IDL : C(%_i) H TLB : <toolset>msvc ;
+
#
# Declare flags and action for compilation
#
***************
*** 262,267 ****
--- 275,285 ----

flags msvc WHATEVER <toolset-msvc:version> ;

+ flags msvc.compile MIDLFLAGS <stubless-proxy>on : /Oicf ;
+ flags msvc.compile MIDLFLAGS <stubless-proxy>off : /Oic ;
+ flags msvc.compile MIDLFLAGS <environment>win32 : /win32 ;
+ flags msvc.compile MIDLFLAGS <environment>win64 : /win64 ;
+
# The actions differ only by explicit selection of input language
actions compile.c
{
***************
*** 277,282 ****
--- 295,305 ----
$(.RC) -l 0x409 -U$(UNDEFS) -D$(DEFINES) -I"$(INCLUDES)" -fo "$(<:W)" "$(>:W)"
}

+ actions compile.idl
+ {
+ $(.IDL) /nologo /robust /U$(UNDEFS) /D$(DEFINES) $(MIDLFLAGS) /I"$(INCLUDES)" /iid "$(<[1]:W)" /h "$(<[2]:W)" /tlb "$(<[3]:W)" "$(>:W)"
+ }
+
# Declare flags and action for linking
flags msvc.link PDB_LINKFLAG <debug-symbols>on/<debug-store>database : /PDB: ; # not used yet
flags msvc.link LINKFLAGS <debug-symbols>on : /DEBUG ;
 --------------020701000004070801090209--


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