Skip to content

Commit

Permalink
Update build-release.py
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Jan 3, 2025
1 parent 9a61982 commit 37c4504
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions build-scripts/build-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
GIT_HASH_FILENAME = ".git-hash"
REVISION_TXT = "REVISION.txt"

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


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

def verify_mingw_library(self, triplet: str, path: Path):
objdump_output = self.executer.check_output([f"{triplet}-objdump", "-p", str(path)])
libraries = re.findall(r"DLL Name: ([^\n]+)", objdump_output)
logger.info("%s (%s) libraries: %r", path, triplet, libraries)
illegal_libraries = list(filter(RE_ILLEGAL_MINGW_LIBRARIES.match, libraries))
logger.error("Detected 'illegal' libraries: %r", illegal_libraries)
if illegal_libraries:
raise Exception(f"{path} links to illegal libraries: {illegal_libraries}")

def create_mingw_archives(self) -> None:
build_type = "Release"
build_parent_dir = self.root / "build-mingw"
Expand Down Expand Up @@ -757,6 +768,7 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
self.executer.run(["make", f"-j{self.cpu_count}"], cwd=build_path, env=new_env)
with self.section_printer.group(f"Install MinGW {triplet} (autotools)"):
self.executer.run(["make", "install"], cwd=build_path, env=new_env)
self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll")
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path)

if "cmake" in self.release_info["mingw"]:
Expand Down Expand Up @@ -801,6 +813,7 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
self.executer.run(["cmake", "--build", str(build_path), "--verbose", "--config", build_type], cwd=build_path, env=new_env)
with self.section_printer.group(f"Install MinGW {triplet} (CMake)"):
self.executer.run(["cmake", "--install", str(build_path)], cwd=build_path, env=new_env)
self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll")
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)

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

0 comments on commit 37c4504

Please sign in to comment.