Lines Matching refs:self
52 def __init__(self, soong_workspace: pathlib.Path): argument
53 self.soong_workspace = soong_workspace
55 self.soong_executable = self.soong_workspace.joinpath(
57 if not self.soong_executable.exists():
60 self.soong_executable)
62 def build(self, build_targets: Set[str]) -> None: argument
73 str(self.soong_executable), "--build-mode", "--all-modules",
84 cwd=self.soong_workspace,
113 def build_targets(self) -> set: argument
117 def stage(self, _): argument
122 def sync(self): argument
126 self.workspace_path.unlink(missing_ok=True)
127 self.workspace_path.symlink_to(self.stage_path)
130 def clean(self): argument
132 self.workspace_path.unlink(missing_ok=True)
141 def __init__(self, stage_path: pathlib.Path, workspace_path: pathlib.Path, argument
143 self.stage_path = stage_path
144 self.workspace_path = workspace_path
145 self._resource_path = resource_path
147 def stage(self, _): argument
148 _verify_directory(self.stage_path.parent)
149 shutil.copy(self._resource_path, self.stage_path)
150 _make_executable_if_script(self.stage_path)
152 def sync(self): argument
155 def clean(self): argument
158 def __repr__(self): argument
193 def __init__(self, stage_path: pathlib.Path, workspace_path: pathlib.Path, argument
195 self.stage_path = stage_path
196 self.workspace_path = workspace_path
197 self.resource_path = resource_path
199 def __repr__(self): argument
204 def stage(self, mapping: Dict[str, str]): argument
205 _verify_directory(self.stage_path.parent)
206 lines = self.resource_path.open().readlines()
208 line for line in lines if not self._IGNORE_LINE_REGEX.search(line)
217 with self.stage_path.open("w") as output_file:
219 _make_executable_if_script(self.stage_path)
221 def sync(self): argument
224 def clean(self): argument
254 def __init__(self, stage_path: pathlib.Path, workspace_path: pathlib.Path, argument
257 self.stage_path = stage_path
258 self.workspace_path = workspace_path
260 self._template_resource = TemplateResource(stage_path, workspace_path,
262 self.global_prebuilts_dir = global_prebuilts_dir
263 self.prebuilts_stage_path = self.stage_path.parent.joinpath(
265 self.prebuilts_workspace_path = self.workspace_path.parent.joinpath(
268 def __repr__(self): argument
275 def build_targets(self) -> set: argument
278 with self._template_resource.resource_path.open() as build_file:
280 if self._template_resource.SOONG_TARGET_KEY in line:
282 self._template_resource.read_value_from_template_var(
287 def stage(self, mapping: Dict[str, str]): argument
293 self._template_resource.stage(mapping)
294 self.prebuilts_stage_path.symlink_to(self.global_prebuilts_dir,
297 def sync(self): argument
303 self._template_resource.sync()
306 self.prebuilts_workspace_path.unlink(missing_ok=True)
307 self.prebuilts_workspace_path.symlink_to(self.global_prebuilts_dir,
310 def clean(self): argument
316 self._template_resource.clean()
317 self.prebuilts_workspace_path.unlink(missing_ok=True)
377 def __init__(self, argument
385 self.workspace_base_path = workspace_base_path
386 self.gendir_base_path = gendir_base_path
387 self.global_prebuilts_dir_path = global_prebuilts_dir_path
388 self.prebuilts_dir_name = prebuilts_dir_name
392 self.template_path = path.joinpath(Resources._TEMPLATES_DIRNAME)
393 self.static_path = path.joinpath(Resources._STATIC_DIRNAME)
395 if not self.template_path.exists() or not self.static_path.exists():
402 def __repr__(self): argument
407 def stage(self, mapping: Dict[str, str]) -> None: argument
408 for resource in self.load():
412 def sync(self) -> None: argument
413 for resource in self.load():
417 def clean(self) -> None: argument
418 for resource in self.load():
422 def build_targets(self) -> Set[str]: argument
425 for resource in self.load() for t in resource.build_targets()
428 def load(self) -> List[Resource]: argument
438 for p in self._template_resource_paths():
440 p.relative_to(self.template_path))
441 stage_path = self.gendir_base_path.joinpath(template_relpath)
442 workspace_path = self.workspace_base_path.joinpath(
451 global_prebuilts_dir=self.global_prebuilts_dir_path,
452 prebuilts_dir_name=self.prebuilts_dir_name))
460 for p in self._static_resource_paths():
461 static_relpath = p.relative_to(self.static_path)
462 stage_path = self.gendir_base_path.joinpath(static_relpath)
463 workspace_path = self.workspace_base_path.joinpath(static_relpath)
471 def _static_resource_paths(self) -> List[pathlib.Path]: argument
472 return [p for p in self.static_path.glob("**/*") if p.is_file()]
474 def _template_resource_paths(self) -> List[pathlib.Path]: argument
475 return [p for p in self.template_path.glob("**/*") if p.is_file()]
535 def __init__(self, env_dict: Dict[str, str] = os.environ): argument
537 self.workspace_top = pathlib.Path(env_dict["ANDROID_BUILD_TOP"])
538 self.host_out = pathlib.Path(env_dict["ANDROID_HOST_OUT"])
539 self.host_testcases = pathlib.Path(
541 self.product_out = pathlib.Path(env_dict["ANDROID_PRODUCT_OUT"])
542 self.target_testcases = pathlib.Path(
548 self.staging_dir = pathlib.Path(self.workspace_top,
550 self.prebuilts_dir_name = BazelTestEnvGenerator.prebuilts_dir_name
551 self.global_prebuilts_dir_path = self.staging_dir.joinpath(
552 self.GLOBAL_PREBUILTS_DIR_PATH)
553 self.year = str(datetime.date.today().year)
554 self.gen_dir = pathlib.Path(self.staging_dir, "gen")
556 self._resources = Resources(self.workspace_top, self.gen_dir,
557 self.global_prebuilts_dir_path,
558 self.prebuilts_dir_name)
559 self._soong = Soong(self.workspace_top)
561 def __repr__(self): argument
562 return "GenerationContext(%s)" % vars(self)
564 def generate(self): argument
567 self._soong.build(self._resources.build_targets())
569 logging.debug("Creating fresh staging dir at: %s", self.staging_dir)
570 _verify_directory(self.staging_dir, clean=True)
572 logging.debug("Creating fresh gen dir at: %s", self.gen_dir)
573 _verify_directory(self.gen_dir, clean=True)
576 self.global_prebuilts_dir_path)
577 _verify_directory(self.global_prebuilts_dir_path, clean=True)
581 self.global_prebuilts_dir_path.joinpath("host").symlink_to(
582 self.host_out)
583 self.global_prebuilts_dir_path.joinpath("host_testcases").symlink_to(
584 self.host_testcases)
585 self.global_prebuilts_dir_path.joinpath("product").symlink_to(
586 self.product_out)
587 self.global_prebuilts_dir_path.joinpath("target_testcases").symlink_to(
588 self.target_testcases)
591 self._resources.stage(mapping=vars(self))
595 "(%s) completed successfully.", self.staging_dir)
597 def sync(self): argument
602 if not self.staging_dir.exists():
607 self._resources.sync()
611 "%s to %s", self.gen_dir, self.workspace_top)
613 def clean(self): argument
619 self._resources.clean()
621 logging.info("Cleaning up staging directory: %s", self.staging_dir)
623 shutil.rmtree(self.staging_dir)