| 352 | |
| 353 | |
| 354 | class CScanner (scanner.Scanner): |
| 355 | def __init__ (self, includes): |
| 356 | scanner.Scanner.__init__ (self) |
| 357 | |
| 358 | self.includes_ = [] |
| 359 | |
| 360 | for i in includes: |
| 361 | self.includes_.extend(i.split("&&")) |
| 362 | |
| 363 | def pattern (self): |
| 364 | return r'#[ \t]*include[ ]*(<(.*)>|"(.*)")' |
| 365 | |
| 366 | def process (self, target, matches, binding): |
| 367 | |
| 368 | angle = regex.transform (matches, "<(.*)>") |
| 369 | quoted = regex.transform (matches, '"(.*)"') |
| 370 | |
| 371 | g = str(id(self)) |
| 372 | b = os.path.normpath(os.path.dirname(binding[0])) |
| 373 | |
| 374 | # Attach binding of including file to included targets. |
| 375 | # When target is directly created from virtual target |
| 376 | # this extra information is unnecessary. But in other |
| 377 | # cases, it allows to distinguish between two headers of the |
| 378 | # same name included from different places. |
| 379 | # We don't need this extra information for angle includes, |
| 380 | # since they should not depend on including file (we can't |
| 381 | # get literal "." in include path). |
| 382 | g2 = g + "#" + b |
| 383 | |
| 384 | g = "<" + g + ">" |
| 385 | g2 = "<" + g2 + ">" |
| 386 | angle = [g + x for x in angle] |
| 387 | quoted = [g2 + x for x in quoted] |
| 388 | |
| 389 | all = angle + quoted |
| 390 | bjam.call("mark-included", target, all) |
| 391 | |
| 392 | engine = get_manager().engine() |
| 393 | engine.set_target_variable(angle, "SEARCH", get_value(self.includes_)) |
| 394 | engine.set_target_variable(quoted, "SEARCH", [b] + get_value(self.includes_)) |
| 395 | |
| 396 | # Just propagate current scanner to includes, in a hope |
| 397 | # that includes do not change scanners. |
| 398 | get_manager().scanners().propagate(self, angle + quoted) |
| 399 | |
| 400 | scanner.register (CScanner, 'include') |
| 401 | type.set_scanner ('CPP', CScanner) |
nothing calls this directly
no outgoing calls
no test coverage detected