]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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) | |
5 | ||
6 | # based on the msvc.jam toolset | |
7 | ||
8 | import property ; | |
9 | import generators ; | |
10 | import os ; | |
11 | import type ; | |
12 | import toolset : flags ; | |
13 | import errors : error ; | |
14 | import feature : feature get-values ; | |
15 | import path ; | |
16 | import sequence : unique ; | |
17 | import common ; | |
18 | ||
19 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] | |
20 | { | |
21 | .debug-configuration = true ; | |
22 | } | |
23 | ||
24 | feature.extend toolset : cw ; | |
25 | ||
26 | toolset.add-requirements <toolset>cw,<runtime-link>shared:<threading>multi ; | |
27 | ||
28 | nl = " | |
29 | " ; | |
30 | ||
31 | rule init ( version ? : command * : options * ) | |
32 | { | |
33 | # TODO: fix the $(command[1]) = $(compiler) issue | |
34 | ||
35 | setup = [ get-values <setup> : $(options) ] ; | |
36 | setup ?= cwenv.bat ; | |
37 | compiler = [ get-values <compiler> : $(options) ] ; | |
38 | compiler ?= mwcc ; | |
39 | linker = [ get-values <linker> : $(options) ] ; | |
40 | linker ?= mwld ; | |
41 | ||
42 | local condition = [ common.check-init-parameters cw : | |
43 | version $(version) ] ; | |
44 | ||
45 | command = [ common.get-invocation-command cw : mwcc.exe : $(command) : | |
46 | [ default-paths $(version) ] ] ; | |
47 | ||
48 | common.handle-options cw : $(condition) : $(command) : $(options) ; | |
49 | ||
50 | local root = [ feature.get-values <root> : $(options) ] ; | |
51 | if $(command) | |
52 | { | |
53 | command = [ common.get-absolute-tool-path $(command[-1]) ] ; | |
54 | } | |
55 | local tool-root = $(command) ; | |
56 | ||
57 | setup = $(tool-root)\\$(setup) ; | |
58 | ||
59 | # map the batch file in setup so it can be executed | |
60 | ||
61 | other-tools = $(tool-root:D) ; | |
62 | root ?= $(other-tools:D) ; | |
63 | ||
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" ; | |
67 | ||
68 | setup = "set \"CWFOLDER="$(root)"\" && call \""$(setup)"\" > nul " ; | |
69 | ||
70 | if [ os.name ] = NT | |
71 | { | |
72 | setup = $(setup)" | |
73 | " ; | |
74 | } | |
75 | else | |
76 | { | |
77 | setup = "cmd /S /C "$(setup)" \"&&\" " ; | |
78 | } | |
79 | ||
80 | # bind the setup command to the tool so it can be executed before the | |
81 | # command | |
82 | ||
83 | local prefix = $(setup) ; | |
84 | ||
85 | flags cw.compile .CC $(condition) : $(prefix)$(compiler) ; | |
86 | flags cw.link .LD $(condition) : $(prefix)$(linker) ; | |
87 | flags cw.archive .LD $(condition) : $(prefix)$(linker) ; | |
88 | ||
11fdf7f2 | 89 | if [ MATCH "^([89]\\.)" : $(version) ] |
7c673cae FG |
90 | { |
91 | if [ os.name ] = NT | |
92 | { | |
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 ; | |
96 | ||
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 ; | |
99 | ||
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 ; | |
102 | } | |
103 | } | |
104 | } | |
105 | ||
106 | ||
107 | local rule default-paths ( version ? ) # FIXME | |
108 | { | |
109 | local possible-paths ; | |
110 | local ProgramFiles = [ common.get-program-files-dir ] ; | |
111 | ||
112 | # TODO: add support for cw8 and cw9 detection | |
113 | ||
114 | local version-6-path = $(ProgramFiles)"\\Metrowerks\\CodeWarrior" ; | |
115 | possible-paths += $(version-6-path) ; | |
116 | ||
117 | # perform post-processing | |
118 | ||
119 | possible-paths | |
120 | = $(possible-paths)"\\Other Metrowerks Tools\\Command Line Tools" ; | |
121 | ||
122 | possible-paths += [ modules.peek : PATH Path path ] ; | |
123 | ||
124 | return $(possible-paths) ; | |
125 | } | |
126 | ||
127 | ||
128 | ||
129 | ||
130 | ## declare generators | |
131 | ||
132 | generators.register-c-compiler cw.compile.c++ : CPP : OBJ : <toolset>cw ; | |
133 | generators.register-c-compiler cw.compile.c : C : OBJ : <toolset>cw ; | |
134 | ||
135 | generators.register-linker cw.link | |
136 | : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB | |
137 | : EXE | |
138 | : <toolset>cw | |
139 | ; | |
140 | generators.register-linker cw.link.dll | |
141 | : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB | |
142 | : SHARED_LIB IMPORT_LIB | |
143 | : <toolset>cw | |
144 | ; | |
145 | ||
146 | generators.register-archiver cw.archive | |
147 | : OBJ | |
148 | : STATIC_LIB | |
149 | : <toolset>cw | |
150 | ; | |
151 | ||
152 | ## compilation phase | |
153 | ||
154 | flags cw WHATEVER <toolset-cw:version> ; | |
155 | ||
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 ; | |
164 | ||
165 | ||
166 | flags cw.compile CFLAGS <rtti>on : -RTTI on ; | |
167 | flags cw.compile CFLAGS <rtti>off : -RTTI off ; | |
168 | ||
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 ; | |
173 | ||
174 | flags cw.compile USER_CFLAGS <cflags> : ; | |
175 | flags cw.compile.c++ USER_CFLAGS <cxxflags> : ; | |
176 | ||
177 | flags cw.compile DEFINES <define> ; | |
178 | flags cw.compile UNDEFS <undef> ; | |
179 | flags cw.compile INCLUDES <include> ; | |
180 | ||
181 | actions compile.c | |
182 | { | |
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)")" | |
184 | } | |
185 | actions compile.c++ | |
186 | { | |
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)")" | |
188 | } | |
189 | ||
190 | ## linking phase | |
191 | ||
192 | flags cw.link DEF_FILE <def-file> ; | |
193 | ||
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 ; | |
201 | ||
202 | flags cw LINKFLAGS <main-target-type>LIB/<link>static : -library ; | |
203 | ||
204 | flags cw.link USER_LINKFLAGS <linkflags> ; | |
205 | flags cw.link LINKPATH <library-path> ; | |
206 | ||
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> ; | |
211 | ||
212 | rule link.dll ( targets + : sources * : properties * ) | |
213 | { | |
214 | DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ; | |
215 | } | |
216 | ||
217 | if [ os.name ] in NT | |
218 | { | |
219 | actions archive | |
220 | { | |
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)")" | |
223 | } | |
224 | } | |
225 | else # cygwin | |
226 | { | |
227 | actions archive | |
228 | { | |
229 | _bbv2_out_="$(<)" | |
230 | if test -f "$_bbv2_out_" ; then | |
231 | _bbv2_existing_="$(<:W)" | |
232 | fi | |
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)")" | |
234 | } | |
235 | } | |
236 | ||
237 | actions link bind DEF_FILE | |
238 | { | |
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)")" | |
240 | } | |
241 | ||
242 | actions link.dll bind DEF_FILE | |
243 | { | |
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)")" | |
245 | } | |
246 |