|
37 | 37 | GIT_HASH_FILENAME = ".git-hash" |
38 | 38 | REVISION_TXT = "REVISION.txt" |
39 | 39 |
|
| 40 | +RE_ILLEGAL_MINGW_LIBRARIES = re.compile(r"(?:lib)?(?:gcc|(?:std)?c[+][+]|(?:win)?pthread).*", flags=re.I) |
| 41 | + |
40 | 42 |
|
41 | 43 | def safe_isotime_to_datetime(str_isotime: str) -> datetime.datetime: |
42 | 44 | try: |
@@ -659,6 +661,15 @@ def create_dmg(self, configuration: str="Release") -> None: |
659 | 661 | def git_hash_data(self) -> bytes: |
660 | 662 | return f"{self.commit}\n".encode() |
661 | 663 |
|
| 664 | + def verify_mingw_library(self, triplet: str, path: Path): |
| 665 | + objdump_output = self.executer.check_output([f"{triplet}-objdump", "-p", str(path)]) |
| 666 | + libraries = re.findall(r"DLL Name: ([^\n]+)", objdump_output) |
| 667 | + logger.info("%s (%s) libraries: %r", path, triplet, libraries) |
| 668 | + illegal_libraries = list(filter(RE_ILLEGAL_MINGW_LIBRARIES.match, libraries)) |
| 669 | + logger.error("Detected 'illegal' libraries: %r", illegal_libraries) |
| 670 | + if illegal_libraries: |
| 671 | + raise Exception(f"{path} links to illegal libraries: {illegal_libraries}") |
| 672 | + |
662 | 673 | def create_mingw_archives(self) -> None: |
663 | 674 | build_type = "Release" |
664 | 675 | build_parent_dir = self.root / "build-mingw" |
@@ -757,6 +768,7 @@ def extract_filter(member: tarfile.TarInfo, path: str, /): |
757 | 768 | self.executer.run(["make", f"-j{self.cpu_count}"], cwd=build_path, env=new_env) |
758 | 769 | with self.section_printer.group(f"Install MinGW {triplet} (autotools)"): |
759 | 770 | self.executer.run(["make", "install"], cwd=build_path, env=new_env) |
| 771 | + self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll") |
760 | 772 | archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path) |
761 | 773 |
|
762 | 774 | if "cmake" in self.release_info["mingw"]: |
@@ -801,6 +813,7 @@ def extract_filter(member: tarfile.TarInfo, path: str, /): |
801 | 813 | self.executer.run(["cmake", "--build", str(build_path), "--verbose", "--config", build_type], cwd=build_path, env=new_env) |
802 | 814 | with self.section_printer.group(f"Install MinGW {triplet} (CMake)"): |
803 | 815 | self.executer.run(["cmake", "--install", str(build_path)], cwd=build_path, env=new_env) |
| 816 | + self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll") |
804 | 817 | archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time) |
805 | 818 |
|
806 | 819 | print("Recording extra files for MinGW development archive ...") |
|
0 commit comments