]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright Vladimir Prus 2004. |
2 | # Copyright Noel Belcourt 2007. | |
3 | # Distributed under the Boost Software License, Version 1.0. | |
4 | # (See accompanying file LICENSE_1_0.txt | |
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | import clang ; | |
8 | import feature : feature ; | |
9 | import os ; | |
10 | import toolset ; | |
11 | import toolset : flags ; | |
12 | import gcc ; | |
13 | import common ; | |
14 | import errors ; | |
15 | import generators ; | |
16 | ||
17 | feature.extend-subfeature toolset clang : platform : darwin ; | |
18 | ||
19 | toolset.inherit-generators clang-darwin | |
20 | <toolset>clang <toolset-clang:platform>darwin | |
21 | : gcc | |
22 | # Don't inherit PCH generators. They were not tested, and probably | |
23 | # don't work for this compiler. | |
24 | : gcc.mingw.link gcc.mingw.link.dll gcc.compile.c.pch gcc.compile.c++.pch | |
25 | ; | |
26 | ||
27 | generators.override clang-darwin.prebuilt : builtin.lib-generator ; | |
28 | generators.override clang-darwin.prebuilt : builtin.prebuilt ; | |
29 | generators.override clang-darwin.searched-lib-generator : searched-lib-generator ; | |
30 | ||
31 | generators.register-c-compiler clang-darwin.compile.m : OBJECTIVE_C : OBJ : <toolset>clang <toolset-clang:platform>darwin ; | |
32 | generators.register-c-compiler clang-darwin.compile.mm : OBJECTIVE_CPP : OBJ : <toolset>clang <toolset-clang:platform>darwin ; | |
33 | ||
34 | toolset.inherit-rules clang-darwin : gcc ; | |
35 | toolset.inherit-flags clang-darwin : gcc | |
36 | : <inlining>off <inlining>on <inlining>full <optimization>space | |
37 | <warnings>off <warnings>all <warnings>on | |
38 | <architecture>x86/<address-model>32 | |
39 | <architecture>x86/<address-model>64 | |
40 | ; | |
41 | ||
42 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] | |
43 | { | |
44 | .debug-configuration = true ; | |
45 | } | |
46 | ||
47 | # vectorization diagnostics | |
48 | feature vectorize : off on full ; | |
49 | ||
50 | # Initializes the clang-darwin toolset | |
51 | # version in optional | |
52 | # name (default clang++) is used to invoke the specified clang complier | |
53 | # compile and link options allow you to specify addition command line options for each version | |
54 | rule init ( version ? : command * : options * ) | |
55 | { | |
56 | command = [ common.get-invocation-command clang-darwin : clang++ | |
57 | : $(command) ] ; | |
58 | ||
59 | # Determine the version | |
60 | local command-string = $(command:J=" ") ; | |
61 | if $(command) | |
62 | { | |
63 | version ?= [ MATCH "^([0-9.]+)" | |
64 | : [ SHELL "$(command-string) -dumpversion" ] ] ; | |
65 | } | |
66 | ||
67 | local condition = [ common.check-init-parameters clang-darwin | |
68 | : version $(version) ] ; | |
69 | ||
70 | common.handle-options clang-darwin : $(condition) : $(command) : $(options) ; | |
71 | ||
72 | gcc.init-link-flags clang-darwin darwin $(condition) ; | |
73 | ||
74 | } | |
75 | ||
76 | SPACE = " " ; | |
77 | ||
78 | toolset.flags clang-darwin.compile OPTIONS <cflags> ; | |
79 | toolset.flags clang-darwin.compile.c++ OPTIONS <cxxflags> ; | |
80 | toolset.flags clang-darwin.compile.m OPTIONS <mflags> ; | |
81 | toolset.flags clang-darwin.compile.mm OPTIONS <mflags> ; | |
82 | toolset.flags clang-darwin.compile.mm OPTIONS <mmflags> ; | |
83 | # toolset.flags clang-darwin.compile INCLUDES <include> ; | |
84 | ||
85 | # Declare flags and action for compilation. | |
86 | toolset.flags clang-darwin.compile OPTIONS <optimization>off : -O0 ; | |
87 | toolset.flags clang-darwin.compile OPTIONS <optimization>speed : -O3 ; | |
88 | toolset.flags clang-darwin.compile OPTIONS <optimization>space : -Os ; | |
89 | ||
90 | # For clang, 'on' and 'full' are identical | |
91 | toolset.flags clang-darwin.compile OPTIONS <inlining>off : -fno-inline ; | |
92 | toolset.flags clang-darwin.compile OPTIONS <inlining>on : -Wno-inline ; | |
93 | toolset.flags clang-darwin.compile OPTIONS <inlining>full : -Wno-inline ; | |
94 | ||
95 | toolset.flags clang-darwin.compile OPTIONS <warnings>off : -w ; | |
96 | toolset.flags clang-darwin.compile OPTIONS <warnings>on : -Wall ; | |
97 | toolset.flags clang-darwin.compile OPTIONS <warnings>all : -Wall -pedantic ; | |
98 | toolset.flags clang-darwin.compile OPTIONS <warnings-as-errors>on : -Werror ; | |
99 | ||
100 | toolset.flags clang-darwin.compile OPTIONS <debug-symbols>on : -g ; | |
101 | toolset.flags clang-darwin.compile OPTIONS <profiling>on : -pg ; | |
102 | toolset.flags clang-darwin.compile OPTIONS <rtti>off : -fno-rtti ; | |
103 | ||
104 | toolset.flags clang-darwin.compile OPTIONS <flags> ; | |
105 | ||
106 | actions compile.c | |
107 | { | |
108 | "$(CONFIG_COMMAND)" -x c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
109 | } | |
110 | ||
111 | actions compile.c++ | |
112 | { | |
113 | "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
114 | } | |
115 | ||
116 | actions compile.m | |
117 | { | |
118 | "$(CONFIG_COMMAND)" -x objective-c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
119 | } | |
120 | ||
121 | actions compile.mm | |
122 | { | |
123 | "$(CONFIG_COMMAND)" -x objective-c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
124 | } | |
125 | ||
126 | flags clang-darwin ARFLAGS <archiveflags> ; | |
127 | ||
128 | # Default value. Mostly for the sake of clang-linux | |
129 | # that inherits from gcc, but does not has the same | |
130 | # logic to set the .AR variable. We can put the same | |
131 | # logic in clang-linux, but that's hardly worth the trouble | |
132 | # as on Linux, 'ar' is always available. | |
133 | .AR = ar ; | |
134 | ||
135 | rule archive ( targets * : sources * : properties * ) | |
136 | { | |
137 | # Always remove archive and start again. Here's rationale from | |
138 | # Andre Hentz: | |
139 | # | |
140 | # I had a file, say a1.c, that was included into liba.a. | |
141 | # I moved a1.c to a2.c, updated my Jamfiles and rebuilt. | |
142 | # My program was crashing with absurd errors. | |
143 | # After some debugging I traced it back to the fact that a1.o was *still* | |
144 | # in liba.a | |
145 | # | |
146 | # Rene Rivera: | |
147 | # | |
148 | # Originally removing the archive was done by splicing an RM | |
149 | # onto the archive action. That makes archives fail to build on NT | |
150 | # when they have many files because it will no longer execute the | |
151 | # action directly and blow the line length limit. Instead we | |
152 | # remove the file in a different action, just before the building | |
153 | # of the archive. | |
154 | # | |
155 | local clean.a = $(targets[1])(clean) ; | |
156 | TEMPORARY $(clean.a) ; | |
157 | NOCARE $(clean.a) ; | |
158 | LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ; | |
159 | DEPENDS $(clean.a) : $(sources) ; | |
160 | DEPENDS $(targets) : $(clean.a) ; | |
161 | common.RmTemps $(clean.a) : $(targets) ; | |
162 | } | |
163 | ||
164 | actions piecemeal archive | |
165 | { | |
166 | "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" | |
167 | "ranlib" -cs "$(<)" | |
168 | } | |
169 | ||
170 | flags clang-darwin.link USER_OPTIONS <linkflags> ; | |
171 | ||
172 | # Declare actions for linking | |
173 | rule link ( targets * : sources * : properties * ) | |
174 | { | |
175 | SPACE on $(targets) = " " ; | |
176 | # Serialize execution of the 'link' action, since | |
177 | # running N links in parallel is just slower. | |
178 | JAM_SEMAPHORE on $(targets) = <s>clang-darwin-link-semaphore ; | |
179 | } | |
180 | ||
181 | actions link bind LIBRARIES | |
182 | { | |
183 | "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" $(START-GROUP) $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) | |
184 | } | |
185 | ||
186 | actions link.dll bind LIBRARIES | |
187 | { | |
188 | "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" -single_module -dynamiclib -install_name "@rpath/$(<[1]:D=)" "$(>)" "$(LIBRARIES)" $(START-GROUP) $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) | |
189 | } |