Given a target, as given to a custom tag rule, returns a string formatted according to the passed format. Format is a list of properties that is represented in the result. For each element of format the corresponding target information is obtained and added to the result str
(format, name, target_type, prop_set)
| 588 | __re_version = re.compile(r'^([^.]+)[.]([^.]+)[.]?([^.]*)') |
| 589 | |
| 590 | def format_name(format, name, target_type, prop_set): |
| 591 | """ Given a target, as given to a custom tag rule, returns a string formatted |
| 592 | according to the passed format. Format is a list of properties that is |
| 593 | represented in the result. For each element of format the corresponding target |
| 594 | information is obtained and added to the result string. For all, but the |
| 595 | literal, the format value is taken as the as string to prepend to the output |
| 596 | to join the item to the rest of the result. If not given "-" is used as a |
| 597 | joiner. |
| 598 | |
| 599 | The format options can be: |
| 600 | |
| 601 | <base>[joiner] |
| 602 | :: The basename of the target name. |
| 603 | <toolset>[joiner] |
| 604 | :: The abbreviated toolset tag being used to build the target. |
| 605 | <threading>[joiner] |
| 606 | :: Indication of a multi-threaded build. |
| 607 | <runtime>[joiner] |
| 608 | :: Collective tag of the build runtime. |
| 609 | <version:/version-feature | X.Y[.Z]/>[joiner] |
| 610 | :: Short version tag taken from the given "version-feature" |
| 611 | in the build properties. Or if not present, the literal |
| 612 | value as the version number. |
| 613 | <property:/property-name/>[joiner] |
| 614 | :: Direct lookup of the given property-name value in the |
| 615 | build properties. /property-name/ is a regular expression. |
| 616 | e.g. <property:toolset-.*:flavor> will match every toolset. |
| 617 | /otherwise/ |
| 618 | :: The literal value of the format argument. |
| 619 | |
| 620 | For example this format: |
| 621 | |
| 622 | boost_ <base> <toolset> <threading> <runtime> <version:boost-version> |
| 623 | |
| 624 | Might return: |
| 625 | |
| 626 | boost_thread-vc80-mt-gd-1_33.dll, or |
| 627 | boost_regex-vc80-gd-1_33.dll |
| 628 | |
| 629 | The returned name also has the target type specific prefix and suffix which |
| 630 | puts it in a ready form to use as the value from a custom tag rule. |
| 631 | """ |
| 632 | assert(isinstance(format, list)) |
| 633 | assert(isinstance(name, str)) |
| 634 | assert(isinstance(target_type, str) or not type) |
| 635 | # assert(isinstance(prop_set, property_set.PropertySet)) |
| 636 | if type.is_derived(target_type, 'LIB'): |
| 637 | result = "" ; |
| 638 | for f in format: |
| 639 | grist = get_grist(f) |
| 640 | if grist == '<base>': |
| 641 | result += os.path.basename(name) |
| 642 | elif grist == '<toolset>': |
| 643 | result += join_tag(ungrist(f), |
| 644 | toolset_tag(name, target_type, prop_set)) |
| 645 | elif grist == '<threading>': |
| 646 | result += join_tag(ungrist(f), |
| 647 | threading_tag(name, target_type, prop_set)) |
nothing calls this directly
no test coverage detected