Skip to content

Commit 1d95f38

Browse files
committed
Update build-scripts/build-release.py
1 parent 3da5b6d commit 1d95f38

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

build-scripts/build-release.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
GIT_HASH_FILENAME = ".git-hash"
3838
REVISION_TXT = "REVISION.txt"
3939

40+
RE_ILLEGAL_MINGW_LIBRARIES = re.compile(r"(?:lib)?(?:gcc|(?:std)?c[+][+]|(?:win)?pthread).*", flags=re.I)
41+
4042

4143
def safe_isotime_to_datetime(str_isotime: str) -> datetime.datetime:
4244
try:
@@ -659,6 +661,15 @@ def create_dmg(self, configuration: str="Release") -> None:
659661
def git_hash_data(self) -> bytes:
660662
return f"{self.commit}\n".encode()
661663

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+
662673
def create_mingw_archives(self) -> None:
663674
build_type = "Release"
664675
build_parent_dir = self.root / "build-mingw"
@@ -757,6 +768,7 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
757768
self.executer.run(["make", f"-j{self.cpu_count}"], cwd=build_path, env=new_env)
758769
with self.section_printer.group(f"Install MinGW {triplet} (autotools)"):
759770
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")
760772
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path)
761773

762774
if "cmake" in self.release_info["mingw"]:
@@ -801,6 +813,7 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
801813
self.executer.run(["cmake", "--build", str(build_path), "--verbose", "--config", build_type], cwd=build_path, env=new_env)
802814
with self.section_printer.group(f"Install MinGW {triplet} (CMake)"):
803815
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")
804817
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)
805818

806819
print("Recording extra files for MinGW development archive ...")

0 commit comments

Comments
 (0)