| 17 | |
| 18 | |
| 19 | class CScanner(scanner.Scanner): |
| 20 | def __init__(self, includes): |
| 21 | scanner.Scanner.__init__(self) |
| 22 | self.includes = [] |
| 23 | for include in includes: |
| 24 | self.includes.extend(replace_grist(include, '').split('&&')) |
| 25 | |
| 26 | def pattern(self): |
| 27 | return '#\s*include\s*(<(.*)>|"(.*)")' |
| 28 | |
| 29 | def process(self, target, matches, binding): |
| 30 | # create a single string so that findall |
| 31 | # can be used since it returns a list of |
| 32 | # all grouped matches |
| 33 | match_str = ' '.join(matches) |
| 34 | # the question mark makes the regexes non-greedy |
| 35 | angles = re.findall(r'<(.*?)>', match_str) |
| 36 | quoted = re.findall(r'"(.*?)"', match_str) |
| 37 | |
| 38 | # CONSIDER: the new scoping rules seem to defeat "on target" variables. |
| 39 | g = ENGINE.get_target_variable(target, 'HDRGRIST') |
| 40 | b = os.path.normpath(os.path.dirname(binding)) |
| 41 | |
| 42 | # Attach binding of including file to included targets. When a target is |
| 43 | # directly created from a virtual target this extra information is |
| 44 | # unnecessary. But in other cases, it allows us to distinguish between |
| 45 | # two headers of the same name included from different places. We do not |
| 46 | # need this extra information for angle includes, since they should not |
| 47 | # depend on the including file (we can not get literal "." in the |
| 48 | # include path). |
| 49 | # local g2 = $(g)"#"$(b) ; |
| 50 | g2 = g + '#' + b |
| 51 | |
| 52 | angles = [replace_grist(angle, g) for angle in angles] |
| 53 | quoted = [replace_grist(quote, g2) for quote in quoted] |
| 54 | |
| 55 | includes = angles + quoted |
| 56 | |
| 57 | bjam.call('INCLUDES', target, includes) |
| 58 | bjam.call('NOCARE', includes) |
| 59 | ENGINE.set_target_variable(angles, 'SEARCH', self.includes) |
| 60 | ENGINE.set_target_variable(quoted, 'SEARCH', [b] + self.includes) |
| 61 | |
| 62 | # Just propagate the current scanner to includes, in hope that includes |
| 63 | # do not change scanners. |
| 64 | SCANNERS.propagate(self, includes) |
| 65 | |
| 66 | bjam.call('ISFILE', includes) |
| 67 | |
| 68 | |
| 69 | scanner.register(CScanner, 'include') |
nothing calls this directly
no outgoing calls
no test coverage detected