MCPcopy Create free account
hub / github.com/boostorg/build / lookup_rule

Function lookup_rule

v2/engine/rules.c:647–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

645 */
646
647RULE * lookup_rule( OBJECT * rulename, module_t * m, int local_only )
648{
649 RULE * r;
650 RULE * result = 0;
651 module_t * original_module = m;
652
653 if ( m->class_module )
654 m = m->class_module;
655
656 if ( m->rules && ( r = (RULE *)hash_find( m->rules, rulename ) ) )
657 result = r;
658 else if ( !local_only && m->imported_modules )
659 {
660 /* Try splitting the name into module and rule. */
661 char * p = strchr( object_str( rulename ), '.' ) ;
662 if ( p )
663 {
664 /* Now, r->name keeps the module name, and p + 1 keeps the rule
665 * name.
666 */
667 OBJECT * rule_part = object_new( p + 1 );
668 OBJECT * module_part;
669 {
670 string buf[ 1 ];
671 string_new( buf );
672 string_append_range( buf, object_str( rulename ), p );
673 module_part = object_new( buf->value );
674 string_free( buf );
675 }
676 if ( hash_find( m->imported_modules, module_part ) )
677 result = lookup_rule( rule_part, bindmodule( module_part ), 1 );
678 object_free( module_part );
679 object_free( rule_part );
680 }
681 }
682
683 if ( result )
684 {
685 if ( local_only && !result->exported )
686 result = 0;
687 else if ( original_module != m )
688 {
689 /* Lookup started in class module. We have found a rule in class
690 * module, which is marked for execution in that module, or in some
691 * instance. Mark it for execution in the instance where we started
692 * the lookup.
693 */
694 int const execute_in_class = result->module == m;
695 int const execute_in_some_instance =
696 result->module->class_module == m;
697 if ( execute_in_class || execute_in_some_instance )
698 result->module = original_module;
699 }
700 }
701
702 return result;
703}
704

Callers 1

bindruleFunction · 0.85

Calls 8

hash_findFunction · 0.85
object_strFunction · 0.85
object_newFunction · 0.85
string_newFunction · 0.85
string_append_rangeFunction · 0.85
string_freeFunction · 0.85
bindmoduleFunction · 0.85
object_freeFunction · 0.85

Tested by

no test coverage detected