1 # Copyright (C) Reece H Dunn 2004
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt or copy at
4 # http://www.boost.org/LICENSE_1_0.txt)
6 # based on the msvc.jam toolset
12 import toolset : flags ;
13 import errors : error ;
14 import feature : feature get-values ;
16 import sequence : unique ;
19 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
21 .debug-configuration = true ;
24 feature.extend toolset : cw ;
26 toolset.add-requirements <toolset>cw,<runtime-link>shared:<threading>multi ;
31 rule init ( version ? : command * : options * )
33 # TODO: fix the $(command[1]) = $(compiler) issue
35 setup = [ get-values <setup> : $(options) ] ;
37 compiler = [ get-values <compiler> : $(options) ] ;
39 linker = [ get-values <linker> : $(options) ] ;
42 local condition = [ common.check-init-parameters cw :
43 version $(version) ] ;
45 command = [ common.get-invocation-command cw : mwcc.exe : $(command) :
46 [ default-paths $(version) ] ] ;
48 common.handle-options cw : $(condition) : $(command) : $(options) ;
50 local root = [ feature.get-values <root> : $(options) ] ;
53 command = [ common.get-absolute-tool-path $(command[-1]) ] ;
55 local tool-root = $(command) ;
57 setup = $(tool-root)\\$(setup) ;
59 # map the batch file in setup so it can be executed
61 other-tools = $(tool-root:D) ;
62 root ?= $(other-tools:D) ;
64 flags cw.link RUN_PATH $(condition) :
65 "$(root)\\Win32-x86 Support\\Libraries\\Runtime"
66 "$(root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs\\MSL_All-DLLs" ;
68 setup = "set \"CWFOLDER="$(root)"\" && call \""$(setup)"\" > nul " ;
77 setup = "cmd /S /C "$(setup)" \"&&\" " ;
80 # bind the setup command to the tool so it can be executed before the
83 local prefix = $(setup) ;
85 flags cw.compile .CC $(condition) : $(prefix)$(compiler) ;
86 flags cw.link .LD $(condition) : $(prefix)$(linker) ;
87 flags cw.archive .LD $(condition) : $(prefix)$(linker) ;
89 if [ MATCH ^([89]\\.) : $(version) ]
93 # The runtime libraries
94 flags cw.compile CFLAGS <runtime-link>static/<threading>single/<runtime-debugging>off : -runtime ss ;
95 flags cw.compile CFLAGS <runtime-link>static/<threading>single/<runtime-debugging>on : -runtime ssd ;
97 flags cw.compile CFLAGS <runtime-link>static/<threading>multi/<runtime-debugging>off : -runtime sm ;
98 flags cw.compile CFLAGS <runtime-link>static/<threading>multi/<runtime-debugging>on : -runtime smd ;
100 flags cw.compile CFLAGS <runtime-link>shared/<runtime-debugging>off : -runtime dm ;
101 flags cw.compile CFLAGS <runtime-link>shared/<runtime-debugging>on : -runtime dmd ;
107 local rule default-paths ( version ? ) # FIXME
109 local possible-paths ;
110 local ProgramFiles = [ common.get-program-files-dir ] ;
112 # TODO: add support for cw8 and cw9 detection
114 local version-6-path = $(ProgramFiles)"\\Metrowerks\\CodeWarrior" ;
115 possible-paths += $(version-6-path) ;
117 # perform post-processing
120 = $(possible-paths)"\\Other Metrowerks Tools\\Command Line Tools" ;
122 possible-paths += [ modules.peek : PATH Path path ] ;
124 return $(possible-paths) ;
130 ## declare generators
132 generators.register-c-compiler cw.compile.c++ : CPP : OBJ : <toolset>cw ;
133 generators.register-c-compiler cw.compile.c : C : OBJ : <toolset>cw ;
135 generators.register-linker cw.link
136 : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
140 generators.register-linker cw.link.dll
141 : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
142 : SHARED_LIB IMPORT_LIB
146 generators.register-archiver cw.archive
154 flags cw WHATEVER <toolset-cw:version> ;
156 flags cw.compile CFLAGS <debug-symbols>on : -g ;
157 flags cw.compile CFLAGS <optimization>off : -O0 ;
158 flags cw.compile CFLAGS <optimization>speed : -O4,p ;
159 flags cw.compile CFLAGS <optimization>space : -O4,s ;
160 flags cw.compile CFLAGS <inlining>off : -inline off ;
161 flags cw.compile CFLAGS <inlining>on : -inline on ;
162 flags cw.compile CFLAGS <inlining>full : -inline all ;
163 flags cw.compile CFLAGS <exception-handling>off : -Cpp_exceptions off ;
166 flags cw.compile CFLAGS <rtti>on : -RTTI on ;
167 flags cw.compile CFLAGS <rtti>off : -RTTI off ;
169 flags cw.compile CFLAGS <warnings>on : -w on ;
170 flags cw.compile CFLAGS <warnings>off : -w off ;
171 flags cw.compile CFLAGS <warnings>all : -w all ;
172 flags cw.compile CFLAGS <warnings-as-errors>on : -w error ;
174 flags cw.compile USER_CFLAGS <cflags> : ;
175 flags cw.compile.c++ USER_CFLAGS <cxxflags> : ;
177 flags cw.compile DEFINES <define> ;
178 flags cw.compile UNDEFS <undef> ;
179 flags cw.compile INCLUDES <include> ;
183 $(.CC) -c -cwd include -lang c -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) -I- -o "$(<)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")"
187 $(.CC) -c -cwd include -lang c++ -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) -I- -o "$(<)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")"
192 flags cw.link DEF_FILE <def-file> ;
194 flags cw LINKFLAGS : -search ;
195 flags cw LINKFLAGS <debug-symbols>on : -g ;
196 flags cw LINKFLAGS <user-interface>console : -subsystem console ;
197 flags cw LINKFLAGS <user-interface>gui : -subsystem windows ;
198 flags cw LINKFLAGS <user-interface>wince : -subsystem wince ;
199 flags cw LINKFLAGS <user-interface>native : -subsystem native ;
200 flags cw LINKFLAGS <user-interface>auto : -subsystem auto ;
202 flags cw LINKFLAGS <main-target-type>LIB/<link>static : -library ;
204 flags cw.link USER_LINKFLAGS <linkflags> ;
205 flags cw.link LINKPATH <library-path> ;
207 flags cw.link FINDLIBS_ST <find-static-library> ;
208 flags cw.link FINDLIBS_SA <find-shared-library> ;
209 flags cw.link LIBRARY_OPTION <toolset>cw : "" : unchecked ;
210 flags cw.link LIBRARIES_MENTIONED_BY_FILE : <library-file> ;
212 rule link.dll ( targets + : sources * : properties * )
214 DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ;
221 if exist "$(<[1])" DEL "$(<[1])"
222 $(.LD) -library -o "$(<[1])" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
230 if test -f "$_bbv2_out_" ; then
231 _bbv2_existing_="$(<:W)"
233 $(.LD) -library -o "$(<:W)" $_bbv2_existing_ @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
237 actions link bind DEF_FILE
239 $(.LD) -o "$(<[1]:W)" -L"$(LINKPATH)" $(LINKFLAGS) $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
242 actions link.dll bind DEF_FILE
244 $(.LD) -shared -o "$(<[1]:W)" -implib "$(<[2]:W)" -L"$(LINKPATH)" $(LINKFLAGS) -f"$(DEF_FILE)" $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"