1 #============================================================================
2 # Rules for creating msvc projectfiles
3 #============================================================================
7 # - Create a secondary target (such as "msvcinst") which copies the generated
8 # project files from the build/"out" directory back into the source
9 # directory. This is useful for maintainers who, after having created and
10 # tested a new set of project files, want to then commit them to the CVS
13 # - Either respect ExternaLibs() or fix all the Jamfiles which require special
14 # Windows libraries to invoke MsvcExternalLibrary(). This is necessary for
15 # modules such as cssocket and ensocket which require wsock32.lib, for
16 # instance. There are a number of other such modules. The current monlithic
17 # solution of placing this information in CS/mk/msvcgen/Jamconfig is ugly,
18 # error-prone, and a maintenance headache.
20 # - Overhaul the "config" file handling rule so that it associates
21 # configuration files with built targets. This will allow the generated
22 # projects to reference configuration files. Rather than the present
23 # InstallConfig rule, we either need a ConfigFile:<target>:<configs> rule, or
24 # we should upgrade the Application and Plugin rules to also accept
25 # configuration files.
27 # - Likewise, provide a generic Resources() rule which allows specification of
28 # additional textual resources for inclusion in generated projects.
30 # - Upgrade module Jamfiles to mention headers from the CS/include/module
31 # directory. This will allow related headers to appear in the generated
32 # project files. For instance, the libcsengine project should mention
33 # headers from CS/include/csengine, in addition to the ones from
34 # CS/libs/csengine which it currently mentions.
36 # - When PERL5.SDK.AVAILABLE is "yes", Jam reports that it doesn't know how to
37 # locate or create <grist>csperlxs.c.
42 MSVCGEN = "$(PERL) $(TOP)/mk/msvcgen/msvcgen.pl" ;
43 MKVERRES = "$(SHELL) $(TOP)/libs/cssys/win32/mkverres.sh" ;
44 MKMETADATARES = "$(SHELL) $(TOP)/libs/cssys/win32/mkmetadatares.sh" ;
45 MERGERES = "$(SHELL) $(TOP)/libs/cssys/win32/mergeres.sh" ;
47 MSVCGEN_BUILD_ROOT = $(BUILDTOP)/out ;
50 if $(MSVC_VERSION) = 6
52 MSVCGEN_LOCATE_TARGET ?= $(MSVCGEN_BUILD_ROOT)/mk/visualc6 ;
53 MSVCGEN_LOCATE_FRAGMENT ?= $(MSVCGEN_BUILD_ROOT)/mk/fragment6 ;
54 MSVCGEN_TEMPLATEDIR ?= $(TOP)/mk/msvcgen/template6 ;
55 MSVCGEN_EXTRA_OPTS = ;
61 else if $(MSVC_VERSION) = 7
63 MSVCGEN_LOCATE_TARGET ?= $(MSVCGEN_BUILD_ROOT)/mk/visualc7 ;
64 MSVCGEN_LOCATE_FRAGMENT ?= $(MSVCGEN_BUILD_ROOT)/mk/fragment7 ;
65 MSVCGEN_TEMPLATEDIR ?= $(TOP)/mk/msvcgen/template7 ;
66 MSVCGEN_EXTRA_OPTS = --xml-protect ;
74 EXIT "No support for MSVC version $(MSVC_VERSION) yet!" ;
77 #----------------------------------------------------------------------------
81 ## MsvcProject target : sources : type : target-with-ext
84 local rcpath resource msvcname target fragments fragroot files i ;
99 exit "Unknown msvc projecttype: $(3) specified!" ;
101 $(<)_MSVCNAME = $(msvcname) ;
103 fragroot = $(MSVCGEN_LOCATE_FRAGMENT)/$(msvcname).frag ;
104 NotFile $(fragroot) ;
106 fragments = [ FAppendSuffix $(msvcname) : .frag.cff ]
107 [ FAppendSuffix $(msvcname) : .frag.dpf ]
108 [ FAppendSuffix $(msvcname) : .frag.pjf ] ;
109 MakeLocate $(fragments) : $(MSVCGEN_LOCATE_FRAGMENT) ;
110 target = [ FAppendSuffix $(msvcname) : $(SUFPRJ) ] ;
111 MakeLocate $(target) : $(MSVCGEN_LOCATE_TARGET) ;
112 target += $(fragments) ;
113 $(<)_TARGET = $(target) ;
115 # Only include source and headers files for now. In the future, we also
116 # want to include .cfg files and any other textual resources which which the
117 # user might care to read/view in the MSVC IDE.
120 i = $(i:G=$(LOCATE_SOURCE)) ;
123 case .h : files += $(i) ;
124 case .hpp : files += $(i) ;
125 case .H : files += $(i) ;
126 case .c : files += $(i) ;
127 case .cc : files += $(i) ;
128 case .cpp : files += $(i) ;
129 case .m : files += $(i) ;
130 case .mm : files += $(i) ;
131 case .M : files += $(i) ;
134 # Search at the correct place for the files
135 SEARCH on $(files) = $(SEARCH_SOURCE) ;
138 if $(3) = "plugin" || $(3) = "appgui" || $(3) = "appcon"
140 resource = $(msvcname:S=.rc) ;
142 rcpath = ../../../mk/visualc7/$(msvcname:S=.rc) ;
143 #files += $(resource) ;
144 Depends $(target) : $(resource) ;
145 LOCATE on $(resource) = $(MSVCGEN_LOCATE_TARGET) ;
146 SEARCH on $(resource) = $(MSVCGEN_LOCATE_FRAGMENT) ;
147 NAME on $(resource) = $(<) ;
148 #RCNAME on $(<) = $(resource) ;
149 $(<)_RCNAME = $(resource) ;
150 #ResourceGen $(resource) ;
152 local versionrc = $(resource:S=.vrctmp) ;
154 # normalize version list
155 local v1, v2, v3, v4 ;
156 v1 = $(PACKAGE.VERSION.LIST[1]) ;
157 if ! $(v1) { v1 = 0 ; }
158 v2 = $(PACKAGE.VERSION.LIST[2]) ;
159 if ! $(v2) { v2 = 0 ; }
160 v3 = $(PACKAGE.VERSION.LIST[3]) ;
161 if ! $(v3) { v3 = 0 ; }
162 v4 = $(PACKAGE.VERSION.LIST[4]) ;
163 if ! $(v4) { v4 = 0 ; }
164 PACKAGE.VERSION.LIST on $(versionrc) = $(v1) $(v2) $(v3) $(v4) ;
166 # @@@ The "Help" rule is usually invoked after 'Plugin'/'Application',
167 # so "$(<)_help" is empty...
168 DESCRIPTION on $(versionrc) = $($(<)_help) ;
170 LOCATE on $(versionrc) = $(MSVCGEN_LOCATE_FRAGMENT) ;
172 GenerateWin32VersionRc $(versionrc) ;
173 Always $(versionrc) ;
174 Win32Resource $(<) : $(versionrc) ;
175 RmTemps $(target) : $(versionrc) ;
179 local metarc = $(resource:S=.mrctmp) ;
181 LOCATE on $(metarc) = $(MSVCGEN_LOCATE_FRAGMENT) ;
182 SEARCH on $(metarc) = $(SEARCH_SOURCE) ;
184 Depends $(metarc) : $($(<)_METAFILE) ;
185 GenerateWin32MetadataRc $(metarc) : $($(<)_METAFILE) ;
187 Win32Resource $(<) : $(metarc) ;
188 RmTemps $(target) : $(metarc) ;
194 RAWNAME on $(target) = $(<) ;
195 PROJECTNAME on $(target) = $(msvcname) ;
196 TARGET on $(target) = $(4) ;
197 TYPE on $(target) = $(3) ;
198 FRAGMENT_ROOT on $(target) = $(fragroot) ;
199 DEPEND on $(target) += $(MSVC.DEPEND) $(MSVC.DEPEND.$(3)) ;
200 LIBRARIES on $(target) += $(MSVC.LIBRARY) $(MSVC.LIBRARY.$(3)) ;
201 LFLAGS on $(target) += $(MSVC.LFLAGS) $(MSVC.LFLAGS.$(3)) ;
202 CFLAGS on $(target) += $(MSVC.CFLAGS) $(MSVC.CFLAGS.$(3)) ;
204 Depends msvcgen : $(target) ;
205 Depends $(target) : $(files) $(MSVCGEN_LOCATE_FRAGMENT:G=dir) ;
206 MsvcProjectGen $(target) : $(files) $(rcpath) ;
209 MSVCWorkspace csall : $(fragments) : $(fragroot) ;
211 Clean msvcclean : $(target) ;
214 #----------------------------------------------------------------------------
218 # _Options $(<) : $(3) ;
221 if $(CONSOLEAPP_$(<)) = "yes"
230 MsvcProject $(<) : $(>) : $(projtype) : $(<:S=.exe) ;
231 CompileGroups $(<) : all apps ;
237 metafile = [ FAppendSuffix $(<) : $(SUFMETA) ] ;
238 SEARCH on $(metafile) = $(SEARCH_SOURCE) ;
240 $(<)_METAFILE = $(metafile) ;
242 MsvcProject $(<) : $(>) : plugin : $(<:S=.dll) ;
243 CompileGroups $(<) : all plugins ;
248 MsvcProject $(<) : $(>) : library : $(<:S=.lib) ;
249 CompileGroups $(<) : all libs ;
252 rule RegisterCompileGroups
257 RegisterCompileGroup $(i) ;
261 rule RegisterCompileGroup
263 MsvcProject $(<) : $(>) : group ;
270 DEPEND on $($(i)_TARGET) += $($(<)_MSVCNAME) ;
276 DEPEND on $($(<)_TARGET) += lib$(>) ;
279 rule MsvcExternalLibrary
281 LIBRARIES on $($(<)_TARGET) += $(>) ;
288 CFLAGS on $($(<)_TARGET) += $(>) ;
294 LFLAGS on $($(<)_TARGET) += $(>) ;
303 CFlags $(<) : $($(i).CFLAGS) ;
304 LFlags $(<) : $($(i).LFLAGS) ;
305 MsvcExternalLibrary $(<) : $($(i).MSVCLIBS) ;
313 target = [ FAppendSuffix $(<) : $(SUFWSP) ] ;
314 MakeLocate $(target) : $(MSVCGEN_LOCATE_TARGET) ;
316 Depends msvcgen : $(target) ;
317 Depends $(target) : $(>[1]) ;
318 MsvcWorkspaceGen $(target) : $(3) ;
320 RmTemps $(target) : $(>) ;
325 Depends $(<) : $($(<)_RCNAME) ;
326 Depends $($(<)_RCNAME) : $(>) ;
327 MergeRcs $($(<)_RCNAME) : $(>) ;
330 #----------------------------------------------------------------------------
332 actions MsvcProjectGen
337 $(MSVCGEN_EXTRA_OPTS) \
338 --project-extension=$(SSUFPRJ) \
341 --template-dir=$(MSVCGEN_TEMPLATEDIR) \
342 --project-name=$(PROJECTNAME) \
345 --fragment=$(FRAGMENT_ROOT) \
347 --library=$(LIBRARIES) \
348 --lflags='$(LFLAGS)' \
349 --cflags='$(CFLAGS)' \
350 --strip-root='$(TOP)/' \
351 --strip-root='$(MSVCGEN_BUILD_ROOT)/' \
355 actions together MsvcWorkspaceGen
360 $(MSVCGEN_EXTRA_OPTS) \
361 --workspace-extension=$(SSUFWSP) \
363 --template-dir=$(MSVCGEN_TEMPLATEDIR) \
367 actions together MergeRcs
369 $(MERGERES) '$(<)' '$(TOP)' '../..' '$(>)'
372 #----------------------------------------------------------------------------
374 RegisterCompileGroups all apps plugins libs ;
377 Clean clean : $(MSVCGEN_LOCATE_TARGET:G=dir) ;
378 Clean clean : $(MSVCGEN_LOCATE_FRAGMENT:G=dir) ;
379 Clean clean : $(MSVCGEN_BUILD_ROOT) ;
380 Clean msvcclean : $(MSVCGEN_LOCATE_TARGET:G=dir) ;
381 Clean msvcclean : $(MSVCGEN_LOCATE_FRAGMENT:G=dir) ;