| 424 | |
| 425 | # Only has a path, assumes that the path (and args.gn in it) already exists. |
| 426 | class RawConfig: |
| 427 | |
| 428 | def __init__(self, path, targets, tests=[], clean=False, testrunner_args=[]): |
| 429 | self.path = path |
| 430 | self.targets = set(targets) |
| 431 | self.tests = set(tests) |
| 432 | self.testrunner_args = testrunner_args |
| 433 | self.clean = clean |
| 434 | |
| 435 | def extend(self, targets, tests=[], clean=False): |
| 436 | self.targets.update(targets) |
| 437 | self.tests.update(tests) |
| 438 | self.clean |= clean |
| 439 | |
| 440 | def update_build_distribution_args(self): |
| 441 | args_gn = self.path / "args.gn" |
| 442 | assert args_gn.exists(), f"args.gn does not exist: {args_gn}" |
| 443 | gn_args = args_gn.read_text() |
| 444 | # Remove custom reclient config path (it will be added again as part of |
| 445 | # the config line below if needed). |
| 446 | new_gn_args = DEPRECATED_RBE_CFG_RE.sub("", gn_args) |
| 447 | new_gn_args = RECLIENT_CFG_RE.sub("", new_gn_args) |
| 448 | new_gn_args = BUILD_DISTRIBUTION_RE.sub(BUILD_DISTRIBUTION_LINE, |
| 449 | new_gn_args) |
| 450 | # Remove stale goma_dir to silence GN warnings about unused options. |
| 451 | new_gn_args = GOMA_DIR_LINE.sub("", new_gn_args) |
| 452 | if gn_args != new_gn_args: |
| 453 | print(f"# Updated gn args:{BUILD_DISTRIBUTION_LINE}") |
| 454 | _write(args_gn, new_gn_args, log=False) |
| 455 | |
| 456 | def build(self): |
| 457 | self.update_build_distribution_args() |
| 458 | # If the target is to just build args.gn then we are done here; otherwise |
| 459 | # drop that target because it's not something ninja can build. |
| 460 | if 'gn_args' in self.targets: |
| 461 | self.targets.remove('gn_args') |
| 462 | if len(self.targets) == 0: |
| 463 | return 0 |
| 464 | # When printing, print a relative path for conciseness. |
| 465 | cwd = Path.cwd() |
| 466 | if cwd == V8_DIR: |
| 467 | try: |
| 468 | printable_path = self.path.relative_to(cwd) |
| 469 | except: |
| 470 | printable_path = self.path |
| 471 | else: |
| 472 | printable_path = self.path |
| 473 | build_ninja = self.path / "build.ninja" |
| 474 | if not build_ninja.exists(): |
| 475 | code = _call(f"gn gen {printable_path}") |
| 476 | if code != 0: |
| 477 | return code |
| 478 | elif self.clean: |
| 479 | code = _call(f"gn clean {printable_path}") |
| 480 | if code != 0: |
| 481 | return code |
| 482 | targets = " ".join(self.targets) |
| 483 | quiet = "--quiet " if QUIET else "" |
no outgoing calls
no test coverage detected