Lines Matching refs:self

49         self,  argument
78 self.stm32_serie = stm32_serie
79 self.stm32_seriexx = stm32_serie + "xx" # ex:stm32f3xx
80 self.stm32_serie_upper = stm32_serie.upper() # ex:STM32F3
81 self.stm32_seriexx_upper = self.stm32_serie_upper + "xx" # ex:STM32F3xx
82 self.serie = self.stm32_serie_upper[5:]
83 self.noclean = noclean
84 self.version_update = version_update
85 self.debug = debug
86 self.module_patch = f"module_{self.stm32_serie}.patch"
93 self.stm32cube_repo_path = stm32cube_repo_path
94 if not self.stm32cube_repo_path.exists():
95 self.stm32cube_repo_path.mkdir()
97 self.zephyr_hal_stm32_path = REPO_ROOT
98 if not self.zephyr_hal_stm32_path.exists():
101 self.stm32cube_temp = self.stm32cube_repo_path / "temp_stm32xx_update"
102 if self.stm32cube_temp.exists():
104 str(self.stm32cube_temp), onerror=common_utils.remove_readonly
106 self.stm32cube_temp.mkdir()
109 self.stm32cube_serie_path = self.stm32cube_repo_path / Path(
110 "STM32Cube" + self.serie
112 self.zephyr_module_serie_path = (
113 self.zephyr_hal_stm32_path / "stm32cube" / self.stm32_seriexx
115 self.stm32cube_temp_serie = (
116 self.stm32cube_temp / "stm32cube" / self.stm32_seriexx
118 shutil.rmtree(str(self.stm32cube_temp), onerror=common_utils.remove_readonly)
119 self.stm32cube_temp_serie.mkdir(parents=True)
121 self.readme_file_path = self.zephyr_module_serie_path / "README"
122 self.version_tag = []
123 self.current_version = ""
124 self.update_commit = ""
126 if self.debug:
128 self.std_dest = None
131 self.std_dest = subprocess.DEVNULL
133 def os_cmd(self, cmd, cwd=None, shell=False): argument
148 stdout=self.std_dest,
149 stderr=self.std_dest,
153 def rename_conf_template(self, path): argument
160 path / (self.stm32_seriexx + "_hal_conf_template.h")
170 def major_branch(self): argument
174 cwd=self.stm32cube_serie_path,
181 def clone_cube_repo(self): argument
183 repo_name = STM32_CUBE_REPO_BASE + self.serie + ".git"
189 + str(self.stm32cube_serie_path),
191 if self.stm32cube_serie_path.exists():
193 self.os_cmd(("git", "clean", "-fdx"), cwd=self.stm32cube_serie_path)
194 self.os_cmd(("git", "fetch"), cwd=self.stm32cube_serie_path)
197 self.os_cmd(("git", "submodule", "update", "--init"),
198 cwd=self.stm32cube_serie_path)
199 branch = self.major_branch()
205 self.os_cmd(
207 cwd=self.stm32cube_serie_path,
213 self.os_cmd(
215 cwd=self.stm32cube_repo_path,
217 branch = self.major_branch()
223 self.os_cmd(("git", "checkout", branch), cwd=self.stm32cube_serie_path)
224 self.version_tag = subprocess.check_output(
225 ("git", "tag", "-l"), cwd=self.stm32cube_serie_path
227 self.version_tag = [x.decode("utf-8") for x in self.version_tag]
229 if self.version_update == "":
230 self.version_update = self.version_tag[0]
231 for tag in self.version_tag:
232 if version_tuple(tag) > version_tuple(self.version_update):
233 self.version_update = tag
235 def get_zephyr_current_version(self): argument
244 with open(str(self.readme_file_path), "r") as f:
257 i for i, a in enumerate(self.version_tag) if previous_version in a
261 return self.version_tag[pos_version[0]]
263 self.clean_files()
268 def extract_source(self): argument
273 temp_cmsis_soc_path = self.stm32cube_temp_serie / "soc"
277 self.stm32cube_serie_path
282 / self.stm32_seriexx_upper
289 self.stm32cube_serie_path
294 / self.stm32_seriexx_upper
304 temp_drivers_include_path = self.stm32cube_temp_serie / "drivers" / "include"
308 self.stm32cube_serie_path
310 / Path(self.stm32_seriexx_upper + "_HAL_Driver")
320 self.rename_conf_template(temp_drivers_include_path)
322 temp_drivers_src_path = self.stm32cube_temp_serie / "drivers" / "src"
325 self.stm32cube_serie_path
327 / Path(self.stm32_seriexx_upper + "_HAL_Driver")
333 def build_from_current_cube_version(self): argument
338 self.os_cmd(
339 ("git", "checkout", "-f", "--recurse-submodules", self.current_version),
340 cwd=self.stm32cube_serie_path,
344 self.extract_source()
346 "%s", "Building module from STM32Cube_repo " + self.current_version
349 if not self.stm32cube_temp_serie.parent.exists():
350 self.stm32cube_temp_serie.parent.mkdir(parents=True)
352 self.os_cmd(
353 ("git", "add", "-A", "stm32cube/" + self.stm32_seriexx + "/*"),
354 cwd=self.stm32cube_temp,
356 self.os_cmd(
357 ("git", "commit", "-am", '"module' + self.current_version + '"'),
358 cwd=self.stm32cube_temp,
361 self.os_cmd(
363 cwd=self.stm32cube_temp,
366 def build_patch_from_current_zephyr_version(self): argument
372 str(self.stm32cube_temp_serie), onerror=common_utils.remove_readonly
376 shutil.copytree(self.zephyr_module_serie_path, self.stm32cube_temp_serie)
379 self.os_cmd(("git", "add", "*"), cwd=self.stm32cube_temp)
380 self.os_cmd(("git", "commit", "-am", '"module"'), cwd=self.stm32cube_temp)
383 self.os_cmd(
385 cwd=self.stm32cube_temp,
392 + self.current_version
398 self.os_cmd(
399 ("git diff --ignore-space-at-eol HEAD~1 --output=" + self.module_patch),
401 cwd=self.stm32cube_temp,
403 self.os_cmd(("dos2unix", self.module_patch), cwd=self.stm32cube_temp)
405 def update_readme(self, make_version, make_commit): argument
414 readme_path = self.zephyr_module_serie_path / "README"
457 self.os_cmd(("dos2unix", str(readme_path)))
459 def update_cmakelist(self): argument
461 cmakelists_path = self.zephyr_module_serie_path / "CMakeLists.txt"
483 src_path = self.stm32cube_temp_serie / "drivers" / "src"
536 self.os_cmd(("dos2unix", str(cmakelists_path)))
538 def generate_assert_file(self): argument
542 self.stm32cube_temp_serie
552 templates_dir = self.zephyr_hal_stm32_path / "scripts"
560 self.stm32cube_temp_serie / "drivers" / "include" / "stm32_assert.h"
565 stm32_assert_j2_template.render(stm32serie=self.stm32_serie)
568 def build_from_version_update(self): argument
573 self.os_cmd(
574 ("git", "checkout", "-f", "--recurse-submodules", self.version_update),
575 cwd=self.stm32cube_serie_path,
579 self.update_commit = subprocess.check_output(
580 ("git", "rev-parse", "HEAD"), cwd=self.stm32cube_serie_path
585 str(self.stm32cube_temp_serie), onerror=common_utils.remove_readonly
589 self.extract_source()
592 self.os_cmd(("git", "add", "*"), cwd=self.stm32cube_serie_path)
593 self.os_cmd(("git", "reset", "--", "*.patch"), cwd=self.stm32cube_serie_path)
594 self.os_cmd(("git", "reset", "--", "*.log"), cwd=self.stm32cube_serie_path)
595 self.os_cmd(
596 ("git", "commit", "-am", '"module' + self.version_update + '"'),
597 cwd=self.stm32cube_temp_serie,
600 def apply_zephyr_patch(self): argument
602 logging.info("%s", "Apply zephyr patches to " + self.version_update)
606 str(self.zephyr_module_serie_path),
609 shutil.copytree(self.stm32cube_temp_serie, self.zephyr_module_serie_path)
612 for child in self.zephyr_module_serie_path.glob("**/*"):
614 self.os_cmd(("dos2unix", child), cwd=self.zephyr_module_serie_path)
619 if Path(self.zephyr_module_serie_path, file).exists():
620 Path(self.zephyr_module_serie_path, file).unlink()
624 str(self.stm32cube_temp / self.module_patch), self.zephyr_hal_stm32_path
628 patch_path = self.zephyr_hal_stm32_path / self.module_patch
631 shutil.copy(str(self.stm32cube_temp / self.module_patch), patch_path)
634 self.update_readme(self.version_update, self.update_commit)
635 self.update_cmakelist()
638 self.generate_assert_file()
641 self.os_cmd(("git", "add", "*"), cwd=self.zephyr_hal_stm32_path)
642 self.os_cmd(("git", "reset", "--", "*.patch"), cwd=self.zephyr_hal_stm32_path)
643 self.os_cmd(("git", "reset", "--", "*.log"), cwd=self.zephyr_hal_stm32_path)
644 self.os_cmd(("git", "reset", "--", "*.rej"), cwd=self.zephyr_hal_stm32_path)
650 def merge_commit(self, lib=False): argument
662 commit_file_path = self.zephyr_module_serie_path / "commit.msg"
667 + self.stm32_serie
669 + self.version_update.upper()
675 "Update Cube version for " + self.stm32_seriexx_upper + " series" + "\n"
680 self.os_cmd(
682 cwd=self.zephyr_module_serie_path,
684 self.os_cmd(
686 cwd=self.zephyr_module_serie_path,
690 def reject(self): argument
692 reject_files = [f for f in self.zephyr_module_serie_path.glob("**/*.rej")]
697 def cleanup_stm32cube_repo(self): argument
699 self.os_cmd(("git", "checkout", "-f", "--recurse-submodules", "HEAD"),
700 cwd=self.stm32cube_serie_path)
702 def clean_files(self): argument
706 shutil.rmtree(str(self.stm32cube_temp), onerror=common_utils.remove_readonly)
709 if not self.noclean:
710 self.cleanup_stm32cube_repo()
712 str(self.stm32cube_repo_path), onerror=common_utils.remove_readonly
715 self.os_cmd(
717 cwd=self.stm32cube_serie_path,
720 def update_stm32_hal_serie(self): argument
723 self.clone_cube_repo()
726 self.os_cmd(("git", "init"), cwd=self.stm32cube_temp)
727 self.os_cmd(
729 cwd=self.stm32cube_temp,
733 self.current_version = self.get_zephyr_current_version()
736 + self.zephyr_module_serie_path.name
740 if (self.current_version in self.version_update) or (
741 self.version_update in self.current_version
747 self.clean_files()
755 self.build_from_current_cube_version()
758 self.build_patch_from_current_zephyr_version()
761 self.build_from_version_update()
764 self.apply_zephyr_patch()
765 self.merge_commit()
768 if self.stm32_serie == "stm32wb":
770 self.stm32cube_serie_path,
771 Path(self.zephyr_hal_stm32_path / "lib" / "stm32wb"),
772 self.stm32cube_temp,
773 self.current_version,
774 self.version_update,
775 self.update_commit,
776 self.stm32_serie
778 self.merge_commit(lib=True)
781 elif self.stm32_serie == "stm32wba":
783 self.stm32cube_serie_path,
784 Path(self.zephyr_hal_stm32_path / "lib" / "stm32wba"),
785 self.stm32cube_temp,
786 self.current_version,
787 self.version_update,
788 self.update_commit,
789 self.stm32_serie
791 self.merge_commit(lib=True)
794 self.clean_files()