Boost logo

Boost-Build :

From: Alexey Pakhunov (alexeypa_at_[hidden])
Date: 2005-10-13 14:55:56


Hi All.

This is almost the same patch as I posted a while ago with several
enhancements. What was changed:

- The target type 'TLB' was renamed to 'MSTYPELIB' and it is derived
from 'H' now. This also affects the main target rule 'tlb'. It became
'mstypelib';
- Regular expressions in midl-scanner were made more readable;
- <architecture> and <address-model> features are used;

The rest remains the same. The patch has been used for a while by Reece
Dunn (thanks Reece :) ) and appears to be working.

WIKI documentation:
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Boost.Build_V2/MIDL_HOWTO

Best regards/Venlig hilsen,
Alexey Pakhunov.
 --------------040105090507090303070804 Content-Type: text/plain;
name="midl.jam"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="midl.jam"

# Copyright (c) 2005 Alexey Pakhunov.
#
# Use, modification and distribution is subject to 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 ;

# A type library (.tlb) is generated by MIDL compiler and can be included
# to resources of an application (.rc). In order to be found by a resource
# compiler its target type should be derived from 'H' - otherwise
# the property '<implicit-dependency>' will be ignored.
type.register MSTYPELIB : tlb : H ;

# Register scanner for MIDL files
class midl-scanner : scanner
{
import regex virtual-target path scanner ;

rule __init__ ( includes * )
{
scanner.__init__ ;

self.includes = $(includes) ;

# List of quoted strings
self.re-strings = "[ ]*\"([^\"]*)\"([ ]*,[ ]*\"([^\"]*)\")*[ ]*" ;

self.re-include = "include"$(self.re-strings) ;
self.re-import = "import"$(self.re-strings) ;
self.re-importlib = "importlib[ ]*[(]"$(self.re-strings)"[)]" ;
}

rule pattern ( )
{
# Detect 'include', 'import' and 'importlib' directives
return "((include|import|importlib)[ ]*[(]?"$(self.re-strings)"[)]?[ ]*;)" ;
}

rule process ( target : matches * : binding )
{
local included = [ regex.transform $(matches) : $(self.re-include)"[ ]*;" : 1 3 ] ;
local imported = [ regex.transform $(matches) : $(self.re-import)"[ ]*;" : 1 3 ] ;
local imported_tlbs = [ regex.transform $(matches) : $(self.re-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-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-robust>yes : /robust ;
flags midl.compile.idl MIDLFLAGS <midl-robust>no : /no_robust ;

# Architecture-specific options
architecture-x86 = <architecture> <architecture>x86 ;
address-model-32 = <address-model> <address-model>32 ;
address-model-64 = <address-model> <address-model>64 ;

flags midl.compile.idl MIDLFLAGS $(architecture-x86)/$(address-model-32) : /win32 ;
flags midl.compile.idl MIDLFLAGS $(architecture-x86)/<address-model>64 : /x64 ;
flags midl.compile.idl MIDLFLAGS <architecture>ia64/$(address-model-64) : /ia64 ;

flags midl.compile.idl DEFINES <define> ;
flags midl.compile.idl UNDEFS <undef> ;
flags midl.compile.idl INCLUDES <include> ;

generators.register-c-compiler midl.compile.idl : IDL : MSTYPELIB H C(%_i) C(%_proxy) C(%_dlldata) ;

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)"
}
 --------------040105090507090303070804 Content-Type: text/plain;
name="midl_support.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="midl_support.diff"

Index: msvc.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/msvc.jam,v
retrieving revision 1.60
diff -u -r1.60 msvc.jam
--- msvc.jam 4 Oct 2005 14:32:05 -0000 1.60
+++ msvc.jam 13 Oct 2005 19:40:52 -0000
@@ -18,6 +18,7 @@
import common ;
import "class" : new ;
import rc ;
+import midl ;

if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
@@ -36,6 +37,9 @@
# List of all registered configurations
.versions = [ new configurations ] ;

+# Inherit MIDL flags
+toolset.inherit-flags msvc : midl ;
+
RM = [ common.rm-command ] ;

@@ -319,6 +323,9 @@
assembler = [ get-values <assembler> : $(options) ] ;
assembler ?= ml ;

+ idl-compiler = [ get-values <idl-compiler> : $(options) ] ;
+ idl-compiler ?= midl ;
+

for local i in 1 2 3
{
@@ -340,6 +347,7 @@
flags msvc.compile .ASM $(cond) : $(command[$(i)])$(assembler) ;
flags msvc.link .LD $(cond) : $(command[$(i)])$(linker) ;
flags msvc.archive .LD $(cond) : $(command[$(i)])$(linker) ;
+ flags msvc.compile .IDL $(cond) : $(command[$(i)])$(idl-compiler) ;
}
}

@@ -449,6 +457,9 @@
generators.override msvc.compile.rc : rc.resource-compile ;
generators.register-standard msvc.compile.asm : ASM : OBJ : <toolset>msvc ;

+generators.register-c-compiler msvc.compile.idl : IDL : MSTYPELIB H C(%_i) C(%_proxy) C(%_dlldata) : <toolset>msvc ;
+generators.override msvc.compile.idl : midl.compile.idl ;
+
#
# Declare flags and action for compilation
#
@@ -623,6 +634,11 @@
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)"
+}
+

#
# Autodetection code
 --------------040105090507090303070804--


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