]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/common_clang_vc.jam
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / tools / common_clang_vc.jam
1 # Copyright 2003, 2005 Dave Abrahams
2 # Copyright 2005, 2006 Rene Rivera
3 # Copyright 2005 Toon Knapen
4 # Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7
8 # Provides actions common to all toolsets, such as creating directories and
9 # removing files.
10
11 import os ;
12 import modules ;
13 import utility ;
14 import print ;
15 import type ;
16 import feature ;
17 import errors ;
18 import path ;
19 import sequence ;
20 import toolset ;
21 import virtual-target ;
22
23 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
24 {
25 .debug-configuration = true ;
26 }
27 if [ MATCH (--show-configuration) : [ modules.peek : ARGV ] ]
28 {
29 .show-configuration = true ;
30 }
31
32 # Configurations
33 #
34 # The following class helps to manage toolset configurations. Each configuration
35 # has a unique ID and one or more parameters. A typical example of a unique ID
36 # is a condition generated by 'common.check-init-parameters' rule. Other kinds
37 # of IDs can be used. Parameters may include any details about the configuration
38 # like 'command', 'path', etc.
39 #
40 # A toolset configuration may be in one of the following states:
41 #
42 # - registered
43 # Configuration has been registered (e.g. explicitly or by auto-detection
44 # code) but has not yet been marked as used, i.e. 'toolset.using' rule has
45 # not yet been called for it.
46 # - used
47 # Once called 'toolset.using' rule marks the configuration as 'used'.
48 #
49 # The main difference between the states above is that while a configuration is
50 # 'registered' its options can be freely changed. This is useful in particular
51 # for autodetection code - all detected configurations may be safely overwritten
52 # by user code.
53
54 class configurations
55 {
56 import errors ;
57
58 rule __init__ ( )
59 {
60 }
61
62 # Registers a configuration.
63 #
64 # Returns 'true' if the configuration has been added and an empty value if
65 # it already exists. Reports an error if the configuration is 'used'.
66 #
67 rule register ( id )
68 {
69 if $(id) in $(self.used)
70 {
71 errors.error "common: the configuration '$(id)' is in use" ;
72 }
73
74 local retval ;
75
76 if ! $(id) in $(self.all)
77 {
78 self.all += $(id) ;
79
80 # Indicate that a new configuration has been added.
81 retval = true ;
82 }
83
84 return $(retval) ;
85 }
86
87 # Mark a configuration as 'used'.
88 #
89 # Returns 'true' if the state of the configuration has been changed to
90 # 'used' and an empty value if it the state has not been changed. Reports an
91 # error if the configuration is not known.
92 #
93 rule use ( id )
94 {
95 if ! $(id) in $(self.all)
96 {
97 errors.error "common: the configuration '$(id)' is not known" ;
98 }
99
100 local retval ;
101
102 if ! $(id) in $(self.used)
103 {
104 self.used += $(id) ;
105
106 # Indicate that the configuration has been marked as 'used'.
107 retval = true ;
108 }
109
110 return $(retval) ;
111 }
112
113 # Return all registered configurations.
114 #
115 rule all ( )
116 {
117 return $(self.all) ;
118 }
119
120 # Return all used configurations.
121 #
122 rule used ( )
123 {
124 return $(self.used) ;
125 }
126
127 # Returns the value of a configuration parameter.
128 #
129 rule get ( id : param )
130 {
131 return $(self.$(param).$(id)) ;
132 }
133
134 # Sets the value of a configuration parameter.
135 #
136 rule set ( id : param : value * )
137 {
138 self.$(param).$(id) = $(value) ;
139 }
140 }
141
142
143 # The rule for checking toolset parameters. Trailing parameters should all be
144 # parameter name/value pairs. The rule will check that each parameter either has
145 # a value in each invocation or has no value in each invocation. Also, the rule
146 # will check that the combination of all parameter values is unique in all
147 # invocations.
148 #
149 # Each parameter name corresponds to a subfeature. This rule will declare a
150 # subfeature the first time a non-empty parameter value is passed and will
151 # extend it with all the values.
152 #
153 # The return value from this rule is a condition to be used for flags settings.
154 #
155 rule check-init-parameters ( toolset requirement * : * )
156 {
157 local sig = $(toolset) ;
158 local condition = <toolset>$(toolset) ;
159 local subcondition ;
160 for local index in 2 3 4 5 6 7 8 9
161 {
162 local name = $($(index)[1]) ;
163 local value = $($(index)[2]) ;
164
165 if $(value)-is-not-empty
166 {
167 condition = $(condition)-$(value) ;
168 if $(.had-unspecified-value.$(toolset).$(name))
169 {
170 errors.user-error
171 "$(toolset) initialization: parameter '$(name)'"
172 "inconsistent" : "no value was specified in earlier"
173 "initialization" : "an explicit value is specified now" ;
174 }
175 # The below logic is for intel compiler. It calls this rule with
176 # 'intel-linux' and 'intel-win' as toolset, so we need to get the
177 # base part of toolset name. We can not pass 'intel' as toolset
178 # because in that case it will be impossible to register versionless
179 # intel-linux and intel-win toolsets of a specific version.
180 local t = $(toolset) ;
181 local m = [ MATCH ([^-]*)- : $(toolset) ] ;
182 if $(m)
183 {
184 t = $(m[1]) ;
185 }
186 if ! $(.had-value.$(toolset).$(name))
187 {
188 if ! $(.declared-subfeature.$(t).$(name))
189 {
190 feature.subfeature toolset $(t) : $(name) : : propagated ;
191 .declared-subfeature.$(t).$(name) = true ;
192 }
193 .had-value.$(toolset).$(name) = true ;
194 }
195 feature.extend-subfeature toolset $(t) : $(name) : $(value) ;
196 subcondition += <toolset-$(t):$(name)>$(value) ;
197 }
198 else
199 {
200 if $(.had-value.$(toolset).$(name))
201 {
202 errors.user-error
203 "$(toolset) initialization: parameter '$(name)'"
204 "inconsistent" : "an explicit value was specified in an"
205 "earlier initialization" : "no value is specified now" ;
206 }
207 .had-unspecified-value.$(toolset).$(name) = true ;
208 }
209 sig = $(sig)$(value:E="")- ;
210 }
211 if $(sig) in $(.all-signatures)
212 {
213 local message =
214 "duplicate initialization of $(toolset) with the following parameters: " ;
215 for local index in 2 3 4 5 6 7 8 9
216 {
217 local p = $($(index)) ;
218 if $(p)
219 {
220 message += "$(p[1]) = $(p[2]:E=<unspecified>)" ;
221 }
222 }
223 message += "previous initialization at $(.init-loc.$(sig))" ;
224 errors.user-error
225 $(message[1]) : $(message[2]) : $(message[3]) : $(message[4]) :
226 $(message[5]) : $(message[6]) : $(message[7]) : $(message[8]) ;
227 }
228 .all-signatures += $(sig) ;
229 .init-loc.$(sig) = [ errors.nearest-user-location ] ;
230
231 # If we have a requirement, this version should only be applied under that
232 # condition. To accomplish this we add a toolset requirement that imposes
233 # the toolset subcondition, which encodes the version.
234 if $(requirement)
235 {
236 local r = <toolset>$(toolset) $(requirement) ;
237 r = $(r:J=,) ;
238 toolset.add-requirements $(r):$(subcondition) ;
239 }
240
241 # We add the requirements, if any, to the condition to scope the toolset
242 # variables and options to this specific version.
243 condition += $(requirement) ;
244
245 if $(.show-configuration)
246 {
247 ECHO notice: $(condition) ;
248 }
249 return $(condition:J=/) ;
250 }
251
252
253 # A helper rule to get the command to invoke some tool. If
254 # 'user-provided-command' is not given, tries to find binary named 'tool' in
255 # PATH and in the passed 'additional-path'. Otherwise, verifies that the first
256 # element of 'user-provided-command' is an existing program.
257 #
258 # This rule returns the command to be used when invoking the tool. If we can not
259 # find the tool, a warning is issued. If 'path-last' is specified, PATH is
260 # checked after 'additional-paths' when searching for 'tool'.
261 #
262 rule get-invocation-command-nodefault ( toolset : tool :
263 user-provided-command * : additional-paths * : path-last ? )
264 {
265 local command ;
266 if ! $(user-provided-command)
267 {
268 command = [ find-tool $(tool) : $(additional-paths) : $(path-last) ] ;
269 if ! $(command) && $(.debug-configuration)
270 {
271 ECHO warning: toolset $(toolset) initialization: can not find tool
272 $(tool) ;
273 ECHO warning: initialized from [ errors.nearest-user-location ] ;
274 }
275 }
276 else
277 {
278 command = [ check-tool $(user-provided-command) ] ;
279 if ! $(command) && $(.debug-configuration)
280 {
281 ECHO warning: toolset $(toolset) initialization: ;
282 ECHO warning: can not find user-provided command
283 '$(user-provided-command)' ;
284 ECHO warning: initialized from [ errors.nearest-user-location ] ;
285 }
286 }
287
288 return $(command) ;
289 }
290
291
292 # Same as get-invocation-command-nodefault, except that if no tool is found,
293 # returns either the user-provided-command, if present, or the 'tool' parameter.
294 #
295 rule get-invocation-command ( toolset : tool : user-provided-command * :
296 additional-paths * : path-last ? )
297 {
298 local result = [ get-invocation-command-nodefault $(toolset) : $(tool) :
299 $(user-provided-command) : $(additional-paths) : $(path-last) ] ;
300
301 if ! $(result)
302 {
303 if $(user-provided-command)
304 {
305 result = $(user-provided-command) ;
306 }
307 else
308 {
309 result = $(tool) ;
310 }
311 }
312 return $(result) ;
313 }
314
315
316 # Given an invocation command return the absolute path to the command. This
317 # works even if command has no path element and was found on the PATH.
318 #
319 rule get-absolute-tool-path ( command )
320 {
321 if $(command:D)
322 {
323 return $(command:D) ;
324 }
325 else
326 {
327 local m = [ GLOB [ modules.peek : PATH Path path ] : $(command)
328 $(command).exe ] ;
329 return $(m[1]:D) ;
330 }
331 }
332
333
334 # Attempts to find tool (binary) named 'name' in PATH and in 'additional-paths'.
335 # If found in PATH, returns 'name' and if found in additional paths, returns
336 # absolute name. If the tool is found in several directories, returns the first
337 # path found. Otherwise, returns an empty string. If 'path-last' is specified,
338 # PATH is searched after 'additional-paths'.
339 #
340 rule find-tool ( name : additional-paths * : path-last ? )
341 {
342 local path = [ path.programs-path ] ;
343 local match = [ path.glob $(path) : $(name) $(name).exe ] ;
344 local additional-match = [ path.glob $(additional-paths) : $(name)
345 $(name).exe ] ;
346
347 local result ;
348 if $(path-last)
349 {
350 result = $(additional-match) ;
351 if ! $(result) && $(match)
352 {
353 result = $(name) ;
354 }
355 }
356 else
357 {
358 if $(match)
359 {
360 result = $(name) ;
361 }
362 else
363 {
364 result = $(additional-match) ;
365 }
366 }
367 if $(result)
368 {
369 return [ path.native $(result[1]) ] ;
370 }
371 }
372
373
374 # Checks if 'command' can be found either in path or is a full name to an
375 # existing file.
376 #
377 local rule check-tool-aux ( command )
378 {
379 if $(command:D)
380 {
381 if [ path.exists $(command) ]
382 # Both NT and Cygwin will run .exe files by their unqualified names.
383 || ( [ os.on-windows ] && [ path.exists $(command).exe ] )
384 # Only NT will run .bat & .cmd files by their unqualified names.
385 || ( ( [ os.name ] = NT ) && ( [ path.exists $(command).bat ] ||
386 [ path.exists $(command).cmd ] ) )
387 {
388 return $(command) ;
389 }
390 }
391 else
392 {
393 if [ GLOB [ modules.peek : PATH Path path ] : $(command) ]
394 {
395 return $(command) ;
396 }
397 }
398 }
399
400
401 # Checks that a tool can be invoked by 'command'. If command is not an absolute
402 # path, checks if it can be found in 'path'. If comand is an absolute path,
403 # check that it exists. Returns 'command' if ok or empty string otherwise.
404 #
405 local rule check-tool ( xcommand + )
406 {
407 if [ check-tool-aux $(xcommand[1]) ] ||
408 [ check-tool-aux $(xcommand[-1]) ]
409 {
410 return $(xcommand) ;
411 }
412 }
413
414
415 # Handle common options for toolset, specifically sets the following flag
416 # variables:
417 # - CONFIG_COMMAND to $(command)
418 # - OPTIONS for compile to the value of <compileflags> in $(options)
419 # - OPTIONS for compile.c to the value of <cflags> in $(options)
420 # - OPTIONS for compile.c++ to the value of <cxxflags> in $(options)
421 # - OPTIONS for compile.fortran to the value of <fflags> in $(options)
422 # - OPTIONS for link to the value of <linkflags> in $(options)
423 #
424 rule handle-options ( toolset : condition * : command * : options * )
425 {
426 if $(.debug-configuration)
427 {
428 ECHO notice: will use '$(command)' for $(toolset), condition
429 $(condition:E=(empty)) ;
430 }
431
432 # The last parameter ('unchecked') says it is OK to set flags for another
433 # module.
434 toolset.flags $(toolset) CONFIG_COMMAND $(condition) : $(command)
435 : unchecked ;
436
437 toolset.flags $(toolset).compile OPTIONS $(condition) :
438 [ feature.get-values <compileflags> : $(options) ] : unchecked ;
439
440 toolset.flags $(toolset).compile.c OPTIONS $(condition) :
441 [ feature.get-values <cflags> : $(options) ] : unchecked ;
442
443 toolset.flags $(toolset).compile.c++ OPTIONS $(condition) :
444 [ feature.get-values <cxxflags> : $(options) ] : unchecked ;
445
446 toolset.flags $(toolset).compile.fortran OPTIONS $(condition) :
447 [ feature.get-values <fflags> : $(options) ] : unchecked ;
448
449 toolset.flags $(toolset).link OPTIONS $(condition) :
450 [ feature.get-values <linkflags> : $(options) ] : unchecked ;
451 }
452
453
454 # Returns the location of the "program files" directory on a Windows platform.
455 #
456 rule get-program-files-dir ( )
457 {
458 local ProgramFiles = [ modules.peek : ProgramFiles ] ;
459 if $(ProgramFiles)
460 {
461 ProgramFiles = "$(ProgramFiles:J= )" ;
462 }
463 else
464 {
465 ProgramFiles = "c:\\Program Files" ;
466 }
467 return $(ProgramFiles) ;
468 }
469
470
471 if [ os.name ] = NT
472 {
473 RM = del /f /q ;
474 CP = copy /b ;
475 IGNORE = "2>nul >nul & setlocal" ;
476 LN ?= $(CP) ;
477 # Ugly hack to convince copy to set the timestamp of the destination to the
478 # current time by concatenating the source with a nonexistent file. Note
479 # that this requires /b (binary) as the default when concatenating files is
480 # /a (ascii).
481 WINDOWS-CP-HACK = "+ this-file-does-not-exist-A698EE7806899E69" ;
482 }
483 else
484 {
485 RM = rm -f ;
486 CP = cp ;
487 LN = ln ;
488 }
489
490
491 rule rm-command ( )
492 {
493 return $(RM) ;
494 }
495
496
497 rule copy-command ( )
498 {
499 return $(CP) ;
500 }
501
502
503 if "\n" = "n"
504 {
505 # Escape characters not supported so use ugly hacks. Will not work on Cygwin
506 # - see below.
507 nl = "
508 " ;
509 q = "" ;
510 }
511 else
512 {
513 nl = "\n" ;
514 q = "\"" ;
515 }
516
517 # Returns the command needed to set an environment variable on the current
518 # platform. The variable setting persists through all following commands and is
519 # visible in the environment seen by subsequently executed commands. In other
520 # words, on Unix systems, the variable is exported, which is consistent with the
521 # only possible behavior on Windows systems.
522 #
523 rule variable-setting-command ( variable : value )
524 {
525 if [ os.name ] = NT
526 {
527 return "set $(variable)=$(value)$(nl)" ;
528 }
529 else
530 {
531 # If we do not have escape character support in bjam, the cod below
532 # blows up on CYGWIN, since the $(nl) variable holds a Windows new-line
533 # \r\n sequence that messes up the executed export command which then
534 # reports that the passed variable name is incorrect.
535 # But we have a check for cygwin in kernel/bootstrap.jam already.
536 return "$(variable)=$(q)$(value)$(q)$(nl)export $(variable)$(nl)" ;
537 }
538 }
539
540
541 # Returns a command to sets a named shell path variable to the given NATIVE
542 # paths on the current platform.
543 #
544 rule path-variable-setting-command ( variable : paths * )
545 {
546 local sep = [ os.path-separator ] ;
547 return [ variable-setting-command $(variable) : $(paths:J=$(sep)) ] ;
548 }
549
550
551 # Returns a command that prepends the given paths to the named path variable on
552 # the current platform.
553 #
554 rule prepend-path-variable-command ( variable : paths * )
555 {
556 return [ path-variable-setting-command $(variable)
557 : $(paths) [ os.expand-variable $(variable) ] ] ;
558 }
559
560
561 # Return a command which can create a file. If 'r' is result of invocation, then
562 # 'r foobar' will create foobar with unspecified content. What happens if file
563 # already exists is unspecified.
564 #
565 rule file-creation-command ( )
566 {
567 if [ os.name ] = NT
568 {
569 # A few alternative implementations on Windows:
570 #
571 # 'type NUL >> '
572 # That would construct an empty file instead of a file containing
573 # a space and an end-of-line marker but it would also not change
574 # the target's timestamp in case the file already exists.
575 #
576 # 'type NUL > '
577 # That would construct an empty file instead of a file containing
578 # a space and an end-of-line marker but it would also destroy an
579 # already existing file by overwriting it with an empty one.
580 #
581 # I guess the best solution would be to allow Boost Jam to define
582 # built-in functions such as 'create a file', 'touch a file' or 'copy a
583 # file' which could be used from inside action code. That would allow
584 # completely portable operations without this kind of kludge.
585 # (22.02.2009.) (Jurko)
586 return "echo. > " ;
587 }
588 else
589 {
590 return "touch " ;
591 }
592 }
593
594
595 # Returns a command that may be used for 'touching' files. It is not a real
596 # 'touch' command on NT because it adds an empty line at the end of file but it
597 # works with source files.
598 #
599 rule file-touch-command ( )
600 {
601 if [ os.name ] = NT
602 {
603 return "echo. >> " ;
604 }
605 else
606 {
607 return "touch " ;
608 }
609 }
610
611
612 rule MkDir
613 {
614 # If dir exists, do not update it. Do this even for $(DOT).
615 NOUPDATE $(<) ;
616
617 if $(<) != $(DOT) && ! $($(<)-mkdir)
618 {
619 # Cheesy gate to prevent multiple invocations on same dir.
620 $(<)-mkdir = true ;
621
622 # Schedule the mkdir build action.
623 common.mkdir $(<) ;
624
625 # Prepare a Jam 'dirs' target that can be used to make the build only
626 # construct all the target directories.
627 DEPENDS dirs : $(<) ;
628
629 # Recursively create parent directories. $(<:P) = $(<)'s parent & we
630 # recurse until root.
631
632 local s = $(<:P) ;
633 if [ os.name ] = NT
634 {
635 switch $(s)
636 {
637 case *: : s = ;
638 case *:\\ : s = ;
639 }
640 }
641
642 if $(s)
643 {
644 if $(s) != $(<)
645 {
646 DEPENDS $(<) : $(s) ;
647 MkDir $(s) ;
648 }
649 else
650 {
651 NOTFILE $(s) ;
652 }
653 }
654 }
655 }
656
657
658 #actions MkDir1
659 #{
660 # mkdir "$(<)"
661 #}
662
663 # The following quick-fix actions should be replaced using the original MkDir1
664 # action once Boost Jam gets updated to correctly detect different paths leading
665 # up to the same filesystem target and triggers their build action only once.
666 # (todo) (04.07.2008.) (Jurko)
667
668 if [ os.name ] = NT
669 {
670 actions mkdir
671 {
672 if not exist "$(<)\\" mkdir "$(<)"
673 }
674 }
675 else
676 {
677 actions mkdir
678 {
679 mkdir -p "$(<)"
680 }
681 }
682
683 actions piecemeal together existing Clean
684 {
685 $(RM) "$(>)"
686 }
687
688
689 rule copy
690 {
691 }
692
693
694 actions copy
695 {
696 $(CP) "$(>)" $(WINDOWS-CP-HACK) "$(<)"
697 }
698
699
700 rule RmTemps
701 {
702 }
703
704
705 actions quietly updated piecemeal together RmTemps
706 {
707 $(RM) "$(>)" $(IGNORE)
708 }
709
710
711 actions hard-link
712 {
713 $(RM) "$(<)" 2$(NULL_OUT) $(NULL_OUT)
714 $(LN) "$(>)" "$(<)" $(NULL_OUT)
715 }
716
717
718 # Given a target, as given to a custom tag rule, returns a string formatted
719 # according to the passed format. Format is a list of properties that is
720 # represented in the result. For each element of format the corresponding target
721 # information is obtained and added to the result string. For all, but the
722 # literal, the format value is taken as the as string to prepend to the output
723 # to join the item to the rest of the result. If not given "-" is used as a
724 # joiner.
725 #
726 # The format options can be:
727 #
728 # <base>[joiner]
729 # :: The basename of the target name.
730 # <toolset>[joiner]
731 # :: The abbreviated toolset tag being used to build the target.
732 # <threading>[joiner]
733 # :: Indication of a multi-threaded build.
734 # <runtime>[joiner]
735 # :: Collective tag of the build runtime.
736 # <version:/version-feature | X.Y[.Z]/>[joiner]
737 # :: Short version tag taken from the given "version-feature" in the
738 # build properties. Or if not present, the literal value as the
739 # version number.
740 # <property:/property-name/>[joiner]
741 # :: Direct lookup of the given property-name value in the build
742 # properties. /property-name/ is a regular expression. E.g.
743 # <property:toolset-.*:flavor> will match every toolset.
744 # /otherwise/
745 # :: The literal value of the format argument.
746 #
747 # For example this format:
748 #
749 # boost_ <base> <toolset> <threading> <runtime> <version:boost-version>
750 #
751 # Might return:
752 #
753 # boost_thread-vc80-mt-gd-1_33.dll, or
754 # boost_regex-vc80-gd-1_33.dll
755 #
756 # The returned name also has the target type specific prefix and suffix which
757 # puts it in a ready form to use as the value from a custom tag rule.
758 #
759 rule format-name ( format * : name : type ? : property-set )
760 {
761 local result = "" ;
762 for local f in $(format)
763 {
764 switch $(f:G)
765 {
766 case <base> :
767 result += $(name:B) ;
768
769 case <toolset> :
770 result += [ join-tag $(f:G=) : [ toolset-tag $(name) : $(type) :
771 $(property-set) ] ] ;
772
773 case <threading> :
774 result += [ join-tag $(f:G=) : [ threading-tag $(name) : $(type)
775 : $(property-set) ] ] ;
776
777 case <runtime> :
778 result += [ join-tag $(f:G=) : [ runtime-tag $(name) : $(type) :
779 $(property-set) ] ] ;
780
781 case <qt> :
782 result += [ join-tag $(f:G=) : [ qt-tag $(name) : $(type) :
783 $(property-set) ] ] ;
784
785 case <address-model> :
786 result += [ join-tag $(f:G=) : [ address-model-tag $(name) :
787 $(type) : $(property-set) ] ] ;
788
789 case <version:*> :
790 local key = [ MATCH <version:(.*)> : $(f:G) ] ;
791 local version = [ $(property-set).get <$(key)> ] ;
792 version ?= $(key) ;
793 version = [ MATCH "^([^.]+)[.]([^.]+)[.]?([^.]*)" : $(version) ] ;
794 result += [ join-tag $(f:G=) : $(version[1])_$(version[2]) ] ;
795
796 case <property:*> :
797 local key = [ MATCH <property:(.*)> : $(f:G) ] ;
798 local p0 = [ MATCH <($(key))> : [ $(property-set).raw ] ] ;
799 if $(p0)
800 {
801 local p = [ $(property-set).get <$(p0)> ] ;
802 if $(p)
803 {
804 result += [ join-tag $(f:G=) : $(p) ] ;
805 }
806 }
807
808 case * :
809 result += $(f:G=) ;
810 }
811 }
812 return [ virtual-target.add-prefix-and-suffix $(result:J=) : $(type) :
813 $(property-set) ] ;
814 }
815
816
817 local rule join-tag ( joiner ? : tag ? )
818 {
819 if ! $(joiner) { joiner = - ; }
820 return $(joiner)$(tag) ;
821 }
822
823
824 local rule toolset-tag ( name : type ? : property-set )
825 {
826 local tag = ;
827
828 local properties = [ $(property-set).raw ] ;
829 switch [ $(property-set).get <toolset> ]
830 {
831 case borland* : tag += bcb ;
832 case clang* :
833 {
834 switch [ $(property-set).get <toolset-clang:platform> ]
835 {
836 case darwin : tag += clang-darwin ;
837 case linux : tag += clang ;
838 case win : tag += clang-win ;
839 }
840 }
841 case como* : tag += como ;
842 case cw : tag += cw ;
843 case darwin* : tag += xgcc ;
844 case edg* : tag += edg ;
845 case gcc* :
846 {
847 switch [ $(property-set).get <toolset-gcc:flavor> ]
848 {
849 case *mingw* : tag += mgw ;
850 case * : tag += gcc ;
851 }
852 }
853 case intel :
854 if [ $(property-set).get <toolset-intel:platform> ] = win
855 {
856 tag += iw ;
857 }
858 else
859 {
860 tag += il ;
861 }
862 case kcc* : tag += kcc ;
863 case kylix* : tag += bck ;
864 #case metrowerks* : tag += cw ;
865 #case mingw* : tag += mgw ;
866 case mipspro* : tag += mp ;
867 case msvc* : tag += vc ;
868 case qcc* : tag += qcc ;
869 case sun* : tag += sw ;
870 case tru64cxx* : tag += tru ;
871 case vacpp* : tag += xlc ;
872 }
873 local version = [ MATCH <toolset.*version>([0123456789]+)[.]([0123456789]*)
874 : $(properties) ] ;
875 # For historical reasons, vc6.0 and vc7.0 use different naming.
876 if $(tag) = vc
877 {
878 if $(version[1]) = 6
879 {
880 # Cancel minor version.
881 version = 6 ;
882 }
883 else if $(version[1]) = 7 && $(version[2]) = 0
884 {
885 version = 7 ;
886 }
887 }
888 # On intel, version is not added, because it does not matter and it is the
889 # version of vc used as backend that matters. Ideally, we should encode the
890 # backend version but that would break compatibility with V1.
891 if $(tag) = iw
892 {
893 version = ;
894 }
895 if $(tag) = clang-win
896 {
897 local my_tmp = [ $(property-set).get <toolset-clang:compatibility> ] ;
898 version = $(version[1])_$(version[2])_$(my_tmp) ;
899 }
900
901 # On borland, version is not added for compatibility with V1.
902 if $(tag) = bcb
903 {
904 version = ;
905 }
906
907 tag += $(version) ;
908
909 return $(tag:J=) ;
910 }
911
912
913 local rule threading-tag ( name : type ? : property-set )
914 {
915 if <threading>multi in [ $(property-set).raw ]
916 {
917 return mt ;
918 }
919 }
920
921
922 local rule runtime-tag ( name : type ? : property-set )
923 {
924 local tag = ;
925
926 local properties = [ $(property-set).raw ] ;
927 if <runtime-link>static in $(properties) { tag += s ; }
928
929 # This is an ugly thing. In V1, there is code to automatically detect which
930 # properties affect a target. So, if <runtime-debugging> does not affect gcc
931 # toolset, the tag rules will not even see <runtime-debugging>. Similar
932 # functionality in V2 is not implemented yet, so we just check for toolsets
933 # known to care about runtime debugging.
934 if ( <toolset>msvc in $(properties) ) ||
935 ( <stdlib>stlport in $(properties) ) ||
936 ( <toolset-intel:platform>win in $(properties) )
937 {
938 if <runtime-debugging>on in $(properties) { tag += g ; }
939 }
940
941 if <python-debugging>on in $(properties) { tag += y ; }
942 if <variant>debug in $(properties) { tag += d ; }
943 if <stdlib>stlport in $(properties) { tag += p ; }
944 if <stdlib-stlport:iostream>hostios in $(properties) { tag += n ; }
945
946 return $(tag:J=) ;
947 }
948
949
950 # Create a tag for the Qt library version
951 # "<qt>4.6.0" will result in tag "qt460"
952 local rule qt-tag ( name : type ? : property-set )
953 {
954 local v = [ MATCH ([0123456789]+)[.]?([0123456789]*)[.]?([0123456789]*) :
955 [ $(property-set).get <qt> ] ] ;
956 return qt$(v:J=) ;
957 }
958
959
960 # Create a tag for the address-model
961 # <address-model>64 will simply generate "64"
962 local rule address-model-tag ( name : type ? : property-set )
963 {
964 return [ $(property-set).get <address-model> ] ;
965 }
966
967
968 rule __test__ ( )
969 {
970 import assert ;
971
972 local save-os = [ modules.peek os : .name ] ;
973
974 modules.poke os : .name : LINUX ;
975 assert.result "PATH=\"foo:bar:baz\"\nexport PATH\n"
976 : path-variable-setting-command PATH : foo bar baz ;
977 assert.result "PATH=\"foo:bar:$PATH\"\nexport PATH\n"
978 : prepend-path-variable-command PATH : foo bar ;
979
980 modules.poke os : .name : NT ;
981 assert.result "set PATH=foo;bar;baz\n"
982 : path-variable-setting-command PATH : foo bar baz ;
983 assert.result "set PATH=foo;bar;%PATH%\n"
984 : prepend-path-variable-command PATH : foo bar ;
985
986 modules.poke os : .name : $(save-os) ;
987 }