]>
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 | |
11fdf7f2 | 36 | : <inlining>full |
7c673cae FG |
37 | <architecture>x86/<address-model>32 |
38 | <architecture>x86/<address-model>64 | |
39 | ; | |
40 | ||
41 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] | |
42 | { | |
43 | .debug-configuration = true ; | |
44 | } | |
45 | ||
7c673cae FG |
46 | # Initializes the clang-darwin toolset |
47 | # version in optional | |
48 | # name (default clang++) is used to invoke the specified clang complier | |
49 | # compile and link options allow you to specify addition command line options for each version | |
50 | rule init ( version ? : command * : options * ) | |
51 | { | |
52 | command = [ common.get-invocation-command clang-darwin : clang++ | |
b32b8144 | 53 | : $(command) : /usr/bin /usr/local/bin ] ; |
7c673cae FG |
54 | |
55 | # Determine the version | |
56 | local command-string = $(command:J=" ") ; | |
57 | if $(command) | |
58 | { | |
59 | version ?= [ MATCH "^([0-9.]+)" | |
60 | : [ SHELL "$(command-string) -dumpversion" ] ] ; | |
61 | } | |
62 | ||
b32b8144 FG |
63 | local condition = [ common.check-init-parameters clang |
64 | : version $(version) ] ; | |
7c673cae FG |
65 | |
66 | common.handle-options clang-darwin : $(condition) : $(command) : $(options) ; | |
11fdf7f2 | 67 | clang.init-cxxstd-flags clang-darwin : $(condition) : $(version) ; |
b32b8144 FG |
68 | |
69 | # - Ranlib. | |
70 | local ranlib = [ feature.get-values <ranlib> : $(options) ] ; | |
71 | toolset.flags clang-darwin.archive .RANLIB $(condition) : $(ranlib[1]) ; | |
7c673cae | 72 | |
b32b8144 FG |
73 | # - Archive builder. |
74 | local archiver = [ feature.get-values <archiver> : $(options) ] ; | |
75 | toolset.flags clang-darwin.archive .AR $(condition) : $(archiver[1]) ; | |
7c673cae FG |
76 | } |
77 | ||
78 | SPACE = " " ; | |
79 | ||
7c673cae FG |
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> ; | |
7c673cae FG |
83 | |
84 | # Declare flags and action for compilation. | |
7c673cae FG |
85 | |
86 | # For clang, 'on' and 'full' are identical | |
7c673cae FG |
87 | toolset.flags clang-darwin.compile OPTIONS <inlining>full : -Wno-inline ; |
88 | ||
11fdf7f2 TL |
89 | # SJW 12/2017: Support for <flags> is widely inconsistant. |
90 | # shouldn't this be handled by the common gcc? | |
7c673cae FG |
91 | toolset.flags clang-darwin.compile OPTIONS <flags> ; |
92 | ||
93 | actions compile.c | |
94 | { | |
11fdf7f2 | 95 | "$(CONFIG_COMMAND)" -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" |
7c673cae FG |
96 | } |
97 | ||
98 | actions compile.c++ | |
99 | { | |
11fdf7f2 | 100 | "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" |
7c673cae FG |
101 | } |
102 | ||
103 | actions compile.m | |
104 | { | |
105 | "$(CONFIG_COMMAND)" -x objective-c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
106 | } | |
107 | ||
108 | actions compile.mm | |
109 | { | |
110 | "$(CONFIG_COMMAND)" -x objective-c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
111 | } | |
112 | ||
7c673cae FG |
113 | # Default value. Mostly for the sake of clang-linux |
114 | # that inherits from gcc, but does not has the same | |
115 | # logic to set the .AR variable. We can put the same | |
116 | # logic in clang-linux, but that's hardly worth the trouble | |
117 | # as on Linux, 'ar' is always available. | |
118 | .AR = ar ; | |
b32b8144 | 119 | .RANLIB = ranlib -cs ; |
7c673cae FG |
120 | |
121 | rule archive ( targets * : sources * : properties * ) | |
122 | { | |
123 | # Always remove archive and start again. Here's rationale from | |
124 | # Andre Hentz: | |
125 | # | |
126 | # I had a file, say a1.c, that was included into liba.a. | |
127 | # I moved a1.c to a2.c, updated my Jamfiles and rebuilt. | |
128 | # My program was crashing with absurd errors. | |
129 | # After some debugging I traced it back to the fact that a1.o was *still* | |
130 | # in liba.a | |
131 | # | |
132 | # Rene Rivera: | |
133 | # | |
134 | # Originally removing the archive was done by splicing an RM | |
135 | # onto the archive action. That makes archives fail to build on NT | |
136 | # when they have many files because it will no longer execute the | |
137 | # action directly and blow the line length limit. Instead we | |
138 | # remove the file in a different action, just before the building | |
139 | # of the archive. | |
140 | # | |
141 | local clean.a = $(targets[1])(clean) ; | |
142 | TEMPORARY $(clean.a) ; | |
143 | NOCARE $(clean.a) ; | |
144 | LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ; | |
145 | DEPENDS $(clean.a) : $(sources) ; | |
146 | DEPENDS $(targets) : $(clean.a) ; | |
147 | common.RmTemps $(clean.a) : $(targets) ; | |
148 | } | |
149 | ||
150 | actions piecemeal archive | |
151 | { | |
152 | "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" | |
b32b8144 | 153 | "$(.RANLIB)" "$(<)" |
7c673cae FG |
154 | } |
155 | ||
7c673cae FG |
156 | # Declare actions for linking |
157 | rule link ( targets * : sources * : properties * ) | |
158 | { | |
159 | SPACE on $(targets) = " " ; | |
160 | # Serialize execution of the 'link' action, since | |
161 | # running N links in parallel is just slower. | |
162 | JAM_SEMAPHORE on $(targets) = <s>clang-darwin-link-semaphore ; | |
163 | } | |
164 | ||
165 | actions link bind LIBRARIES | |
166 | { | |
167 | "$(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) | |
168 | } | |
169 | ||
170 | actions link.dll bind LIBRARIES | |
171 | { | |
172 | "$(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) | |
173 | } |