]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/midl.jam
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / src / tools / midl.jam
1 # Copyright (c) 2005 Alexey Pakhunov.
2 #
3 # Use, modification and distribution is subject to the Boost Software
4 # License Version 1.0. (See accompanying file LICENSE.txt or
5 # https://www.bfgroup.xyz/b2/LICENSE.txt)
6
7 # Microsoft Interface Definition Language (MIDL) related routines
8
9 import common ;
10 import generators ;
11 import feature : feature get-values ;
12 import os ;
13 import scanner ;
14 import toolset : flags ;
15 import type ;
16
17 rule init ( )
18 {
19 }
20
21 type.register IDL : idl ;
22
23 # A type library (.tlb) is generated by MIDL compiler and can be included
24 # to resources of an application (.rc). In order to be found by a resource
25 # compiler its target type should be derived from 'H' - otherwise
26 # the property '<implicit-dependency>' will be ignored.
27 type.register MSTYPELIB : tlb : H ;
28
29
30 # Register scanner for MIDL files
31 class midl-scanner : scanner
32 {
33 import path property-set regex scanner type virtual-target ;
34
35 rule __init__ ( includes * )
36 {
37 scanner.__init__ ;
38
39 self.includes = $(includes) ;
40
41 # List of quoted strings
42 self.re-strings = "[ \t]*\"([^\"]*)\"([ \t]*,[ \t]*\"([^\"]*)\")*[ \t]*" ;
43
44 # 'import' and 'importlib' directives
45 self.re-import = "import"$(self.re-strings)"[ \t]*;" ;
46 self.re-importlib = "importlib[ \t]*[(]"$(self.re-strings)"[)][ \t]*;" ;
47
48 # C preprocessor 'include' directive
49 self.re-include-angle = "#[ \t]*include[ \t]*<(.*)>" ;
50 self.re-include-quoted = "#[ \t]*include[ \t]*\"(.*)\"" ;
51 }
52
53 rule pattern ( )
54 {
55 # Match '#include', 'import' and 'importlib' directives
56 return "((#[ \t]*include|import(lib)?).+(<(.*)>|\"(.*)\").+)" ;
57 }
58
59 rule process ( target : matches * : binding )
60 {
61 local included-angle = [ regex.transform $(matches) : $(self.re-include-angle) : 1 ] ;
62 local included-quoted = [ regex.transform $(matches) : $(self.re-include-quoted) : 1 ] ;
63 local imported = [ regex.transform $(matches) : $(self.re-import) : 1 3 ] ;
64 local imported_tlbs = [ regex.transform $(matches) : $(self.re-importlib) : 1 3 ] ;
65
66 # CONSIDER: the new scoping rule seem to defeat "on target" variables.
67 local g = [ on $(target) return $(HDRGRIST) ] ;
68 local b = [ NORMALIZE_PATH $(binding:D) ] ;
69
70 # Attach binding of including file to included targets.
71 # When target is directly created from virtual target
72 # this extra information is unnecessary. But in other
73 # cases, it allows to distinguish between two headers of the
74 # same name included from different places.
75 local g2 = $(g)"#"$(b) ;
76
77 included-angle = $(included-angle:G=$(g)) ;
78 included-quoted = $(included-quoted:G=$(g2)) ;
79 imported = $(imported:G=$(g2)) ;
80 imported_tlbs = $(imported_tlbs:G=$(g2)) ;
81
82 local all = $(included-angle) $(included-quoted) $(imported) ;
83
84 INCLUDES $(target) : $(all) ;
85 DEPENDS $(target) : $(imported_tlbs) ;
86 NOCARE $(all) $(imported_tlbs) ;
87 SEARCH on $(included-angle) = $(self.includes:G=) ;
88 SEARCH on $(included-quoted) = $(b) $(self.includes:G=) ;
89 SEARCH on $(imported) = $(b) $(self.includes:G=) ;
90 SEARCH on $(imported_tlbs) = $(b) $(self.includes:G=) ;
91
92 scanner.propagate
93 [ type.get-scanner CPP : [ property-set.create $(self.includes) ] ] :
94 $(included-angle) $(included-quoted) : $(target) ;
95
96 scanner.propagate $(__name__) : $(imported) : $(target) ;
97 }
98 }
99
100 scanner.register midl-scanner : include ;
101 type.set-scanner IDL : midl-scanner ;
102
103
104 # Command line options
105 feature midl-stubless-proxy : yes no : propagated ;
106 feature midl-robust : yes no : propagated ;
107
108 flags midl.compile.idl MIDLFLAGS <midl-stubless-proxy>yes : /Oicf ;
109 flags midl.compile.idl MIDLFLAGS <midl-stubless-proxy>no : /Oic ;
110 flags midl.compile.idl MIDLFLAGS <midl-robust>yes : /robust ;
111 flags midl.compile.idl MIDLFLAGS <midl-robust>no : /no_robust ;
112
113 # Architecture-specific options
114 architecture-x86 = <architecture> <architecture>x86 ;
115 address-model-32 = <address-model> <address-model>32 ;
116 address-model-64 = <address-model> <address-model>64 ;
117
118 flags midl.compile.idl MIDLFLAGS $(architecture-x86)/$(address-model-32) : /win32 ;
119 flags midl.compile.idl MIDLFLAGS $(architecture-x86)/<address-model>64 : /x64 ;
120 flags midl.compile.idl MIDLFLAGS <architecture>ia64/$(address-model-64) : /ia64 ;
121
122
123 flags midl.compile.idl DEFINES <define> ;
124 flags midl.compile.idl UNDEFS <undef> ;
125 flags midl.compile.idl INCLUDES <include> ;
126
127
128 generators.register-c-compiler midl.compile.idl : IDL : MSTYPELIB H C(%_i) C(%_proxy) C(%_dlldata) ;
129
130
131 # MIDL does not always generate '%_proxy.c' and '%_dlldata.c'. This behavior
132 # depends on contents of the source IDL file. Calling TOUCH_FILE below ensures
133 # that both files will be created so bjam will not try to recreate them
134 # constantly.
135 TOUCH_FILE = [ common.file-touch-command ] ;
136
137 actions compile.idl
138 {
139 midl /nologo @"@($(<[1]:W).rsp:E=$(nl)"$(>:W)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)" $(nl)-U$(UNDEFS) $(nl)$(MIDLFLAGS) $(nl)/tlb "$(<[1]:W)" $(nl)/h "$(<[2]:W)" $(nl)/iid "$(<[3]:W)" $(nl)/proxy "$(<[4]:W)" $(nl)/dlldata "$(<[5]:W)")"
140 $(TOUCH_FILE) "$(<[4]:W)"
141 $(TOUCH_FILE) "$(<[5]:W)"
142 }