Skip to content

Commit 19cc04a

Browse files
committed
Add build-release.py updates from satellite libraries
[ci skip]
1 parent b5c05b6 commit 19cc04a

9 files changed

+58
-21
lines changed

.github/workflows/release.yml

-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ jobs:
600600
-DCMAKE_PREFIX_PATH="${{ steps.sdk.outputs.prefix }}" \
601601
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
602602
-DANDROID_ABI=${android_abi} \
603-
-Werror=dev \
604603
-DCMAKE_BUILD_TYPE=Release \
605604
-B "${android_abi}"
606605
echo "Building ${android_abi}..."

build-scripts/build-release.py

+51-13
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ def configure_text(text: str, context: dict[str, str]) -> str:
328328
return text
329329

330330

331+
def configure_text_list(text_list: list[str], context: dict[str, str]) -> list[str]:
332+
return [configure_text(text=e, context=context) for e in text_list]
333+
334+
331335
class ArchiveFileTree:
332336
def __init__(self):
333337
self._tree: dict[str, NodeInArchive] = {}
@@ -343,7 +347,7 @@ def add_to_archiver(self, archive_base: str, archiver: Archiver):
343347
added_files = dict()
344348

345349
def calculate_symlink_target(s: NodeInArchive) -> str:
346-
dest_dir = os.path.dirname(s.path)
350+
dest_dir = os.path.dirname(s.arcpath)
347351
if dest_dir:
348352
dest_dir += "/"
349353
target = dest_dir + s.symtarget
@@ -357,19 +361,24 @@ def calculate_symlink_target(s: NodeInArchive) -> str:
357361

358362
# Add files in first pass
359363
for arcpath, node in self._tree.items():
364+
assert node is not None, f"{arcpath} -> node"
360365
if node.data is not None:
361366
archiver.add_file_data(arcpath=arc_join(archive_base, arcpath), data=node.data, time=node.time, mode=node.mode)
362-
added_files[node.path] = node
367+
assert node.arcpath is not None, f"{node=}"
368+
added_files[node.arcpath] = node
363369
elif node.path is not None:
364370
archiver.add_file_path(arcpath=arc_join(archive_base, arcpath), path=node.path)
365-
added_files[node.path] = node
371+
assert node.arcpath is not None, f"{node=}"
372+
added_files[node.arcpath] = node
366373
elif node.symtarget is not None:
367374
remaining_symlinks.add(node)
368375
elif node.directory:
369376
pass
370377
else:
371378
raise ValueError(f"Invalid Archive Node: {repr(node)}")
372379

380+
assert None not in added_files
381+
373382
# Resolve symlinks in second pass: zipfile does not support symlinks, so add files to zip archive
374383
while True:
375384
if not remaining_symlinks:
@@ -380,18 +389,18 @@ def calculate_symlink_target(s: NodeInArchive) -> str:
380389
symlink_files_for_zip = {}
381390
symlink_target_path = calculate_symlink_target(symlink)
382391
if symlink_target_path in added_files:
383-
symlink_files_for_zip[symlink.path] = added_files[symlink_target_path]
392+
symlink_files_for_zip[symlink.arcpath] = added_files[symlink_target_path]
384393
else:
385394
symlink_target_path_slash = symlink_target_path + "/"
386395
for added_file in added_files:
387396
if added_file.startswith(symlink_target_path_slash):
388-
path_in_symlink = symlink.path + "/" + added_file.removeprefix(symlink_target_path_slash)
397+
path_in_symlink = symlink.arcpath + "/" + added_file.removeprefix(symlink_target_path_slash)
389398
symlink_files_for_zip[path_in_symlink] = added_files[added_file]
390399
if symlink_files_for_zip:
391400
symlinks_this_time.add(symlink)
392401
extra_added_files.update(symlink_files_for_zip)
393402
files_for_zip = [{"arcpath": f"{archive_base}/{sym_path}", "data": sym_info.data, "mode": sym_info.mode} for sym_path, sym_info in symlink_files_for_zip.items()]
394-
archiver.add_symlink(arcpath=f"{archive_base}/{symlink.path}", target=symlink.symtarget, time=symlink.time, files_for_zip=files_for_zip)
403+
archiver.add_symlink(arcpath=f"{archive_base}/{symlink.arcpath}", target=symlink.symtarget, time=symlink.time, files_for_zip=files_for_zip)
395404
# if not symlinks_this_time:
396405
# logger.info("files added: %r", set(path for path in added_files.keys()))
397406
assert symlinks_this_time, f"No targets found for symlinks: {remaining_symlinks}"
@@ -545,6 +554,7 @@ def get_context(self, extra_context: typing.Optional[dict[str, str]]=None) -> di
545554
"PROJECT_VERSION": self.version,
546555
"PROJECT_COMMIT": self.commit,
547556
"PROJECT_REVISION": self.revision,
557+
"PROJECT_ROOT": str(self.root),
548558
}
549559
if extra_context:
550560
ctx.update(extra_context)
@@ -741,23 +751,34 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
741751
install_path = build_parent_dir / f"install-{triplet}"
742752
shutil.rmtree(install_path, ignore_errors=True)
743753
build_path.mkdir(parents=True, exist_ok=True)
754+
context = self.get_context({
755+
"ARCH": arch,
756+
"DEP_PREFIX": str(mingw_deps_path / triplet),
757+
})
758+
extra_args = configure_text_list(text_list=self.release_info["mingw"]["autotools"]["args"], context=context)
759+
744760
with self.section_printer.group(f"Configuring MinGW {triplet} (autotools)"):
745-
extra_args = [arg.replace("@DEP_PREFIX@", str(mingw_deps_path / triplet)) for arg in self.release_info["mingw"]["autotools"]["args"]]
746761
assert "@" not in " ".join(extra_args), f"@ should not be present in extra arguments ({extra_args})"
747762
self.executer.run([
748763
self.root / "configure",
749764
f"--prefix={install_path}",
750-
f"--includedir={install_path}/include",
751-
f"--libdir={install_path}/lib",
752-
f"--bindir={install_path}/bin",
765+
f"--includedir=${{prefix}}/include",
766+
f"--libdir=${{prefix}}/lib",
767+
f"--bindir=${{prefix}}/bin",
753768
f"--host={triplet}",
754769
f"--build=x86_64-none-linux-gnu",
755770
] + extra_args, cwd=build_path, env=new_env)
756771
with self.section_printer.group(f"Build MinGW {triplet} (autotools)"):
757772
self.executer.run(["make", f"-j{self.cpu_count}"], cwd=build_path, env=new_env)
758773
with self.section_printer.group(f"Install MinGW {triplet} (autotools)"):
759774
self.executer.run(["make", "install"], cwd=build_path, env=new_env)
760-
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path)
775+
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)
776+
777+
print("Recording arch-dependent extra files for MinGW development archive ...")
778+
extra_context = {
779+
"TRIPLET": ARCH_TO_TRIPLET[arch],
780+
}
781+
archive_file_tree.add_file_mapping(arc_dir=arc_root, file_mapping=self.release_info["mingw"]["autotools"].get("files", {}), file_mapping_root=self.root, context=self.get_context(extra_context=extra_context), time=self.arc_time)
761782

762783
if "cmake" in self.release_info["mingw"]:
763784
assert self.release_info["mingw"]["cmake"]["shared-static"] in ("args", "both")
@@ -770,6 +791,12 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
770791
assert arch not in mingw_archs
771792
mingw_archs.add(arch)
772793

794+
context = self.get_context({
795+
"ARCH": arch,
796+
"DEP_PREFIX": str(mingw_deps_path / triplet),
797+
})
798+
extra_args = configure_text_list(text_list=self.release_info["mingw"]["cmake"]["args"], context=context)
799+
773800
build_path = build_parent_dir / f"build-{triplet}"
774801
install_path = build_parent_dir / f"install-{triplet}"
775802
shutil.rmtree(install_path, ignore_errors=True)
@@ -780,7 +807,6 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
780807
args_for_shared_static = (["-DBUILD_SHARED_LIBS=ON"], ["-DBUILD_SHARED_LIBS=OFF"])
781808
for arg_for_shared_static in args_for_shared_static:
782809
with self.section_printer.group(f"Configuring MinGW {triplet} (CMake)"):
783-
extra_args = [arg.replace("@DEP_PREFIX@", str(mingw_deps_path / triplet)) for arg in self.release_info["mingw"]["cmake"]["args"]]
784810
assert "@" not in " ".join(extra_args), f"@ should not be present in extra arguments ({extra_args})"
785811
self.executer.run([
786812
f"cmake",
@@ -803,6 +829,13 @@ def extract_filter(member: tarfile.TarInfo, path: str, /):
803829
self.executer.run(["cmake", "--install", str(build_path)], cwd=build_path, env=new_env)
804830
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)
805831

832+
print("Recording arch-dependent extra files for MinGW development archive ...")
833+
extra_context = {
834+
"TRIPLET": ARCH_TO_TRIPLET[arch],
835+
}
836+
archive_file_tree.add_file_mapping(arc_dir=arc_root, file_mapping=self.release_info["mingw"]["cmake"].get("files", {}), file_mapping_root=self.root, context=self.get_context(extra_context=extra_context), time=self.arc_time)
837+
print("... done")
838+
806839
print("Recording extra files for MinGW development archive ...")
807840
archive_file_tree.add_file_mapping(arc_dir=arc_root, file_mapping=self.release_info["mingw"].get("files", {}), file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
808841
print("... done")
@@ -1231,19 +1264,24 @@ def _build_msvc_devel(self) -> None:
12311264
zip_path = self.dist_path / f"{self.project}-devel-{self.version}-VC.zip"
12321265
arc_root = f"{self.project}-{self.version}"
12331266

1267+
def copy_files_devel(ctx):
1268+
archive_file_tree.add_file_mapping(arc_dir=arc_root, file_mapping=self.release_info["msvc"]["files-devel"], file_mapping_root=self.root, context=ctx, time=self.arc_time)
1269+
1270+
12341271
logger.info("Collecting files...")
12351272
archive_file_tree = ArchiveFileTree()
12361273
if "msbuild" in self.release_info["msvc"]:
12371274
for arch in self.release_info["msvc"]["msbuild"]["archs"]:
12381275
arch_platform = self._arch_to_vs_platform(arch=arch)
12391276
platform_context = self.get_context(arch_platform.extra_context())
12401277
archive_file_tree.add_file_mapping(arc_dir=arc_root, file_mapping=self.release_info["msvc"]["msbuild"]["files-devel"], file_mapping_root=self.root, context=platform_context, time=self.arc_time)
1278+
copy_files_devel(ctx=platform_context)
12411279
if "cmake" in self.release_info["msvc"]:
12421280
for arch in self.release_info["msvc"]["cmake"]["archs"]:
12431281
arch_platform = self._arch_to_vs_platform(arch=arch)
12441282
platform_context = self.get_context(arch_platform.extra_context())
12451283
archive_file_tree.add_file_mapping(arc_dir=arc_root, file_mapping=self.release_info["msvc"]["cmake"]["files-devel"], file_mapping_root=self._arch_platform_to_install_path(arch_platform), context=platform_context, time=self.arc_time)
1246-
archive_file_tree.add_file_mapping(arc_dir=arc_root, file_mapping=self.release_info["msvc"]["files-devel"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
1284+
copy_files_devel(ctx=platform_context)
12471285

12481286
with Archiver(zip_path=zip_path) as archiver:
12491287
archive_file_tree.add_to_archiver(archive_base="", archiver=archiver)

build-scripts/pkg-support/android/cmake/SDL3Config.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SDL CMake configuration file:
22
# This file is meant to be placed in lib/cmake/SDL3 subfolder of a reconstructed Android SDL3 SDK
33

4-
cmake_minimum_required(VERSION 3.0...3.5)
4+
cmake_minimum_required(VERSION 3.0...3.28)
55

66
include(FeatureSummary)
77
set_package_properties(SDL3 PROPERTIES

build-scripts/pkg-support/msvc/cmake/SDL3Config.cmake.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# @<@PROJECT_NAME@>@ CMake configuration file:
22
# This file is meant to be placed in a cmake subfolder of @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip
33

4-
cmake_minimum_required(VERSION 3.0...3.5)
4+
cmake_minimum_required(VERSION 3.0...3.28)
55

66
include(FeatureSummary)
77
set_package_properties(SDL3 PROPERTIES

cmake/android/FindSdlAndroid.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This module will set the following variables in your project:
6161
6262
#]=======================================================================]
6363

64-
cmake_minimum_required(VERSION 3.7)
64+
cmake_minimum_required(VERSION 3.7...3.28)
6565

6666
if(NOT PROJECT_NAME MATCHES "^SDL.*")
6767
message(WARNING "This module is internal to SDL and is currently not supported.")

cmake/android/FindSdlAndroidBuildTools.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ This module responds to the flags:
5252
5353
#]=======================================================================]
5454

55-
cmake_minimum_required(VERSION 3.7)
55+
cmake_minimum_required(VERSION 3.7...3.28)
5656

5757
if(NOT PROJECT_NAME MATCHES "^SDL.*")
5858
message(WARNING "This module is internal to SDL and is currently not supported.")

cmake/android/FindSdlAndroidPlatform.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This module responds to the flags:
5555
5656
#]=======================================================================]
5757

58-
cmake_minimum_required(VERSION 3.7)
58+
cmake_minimum_required(VERSION 3.7...3.28)
5959

6060
if(NOT PROJECT_NAME MATCHES "^SDL.*")
6161
message(WARNING "This module is internal to SDL and is currently not supported.")

cmake/android/SdlAndroidFunctions.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ It is (currently) limited to packaging binaries for a single architecture.
55
66
#]=======================================================================]
77

8-
cmake_minimum_required(VERSION 3.7)
8+
cmake_minimum_required(VERSION 3.7...3.28)
99

1010
if(NOT PROJECT_NAME MATCHES "^SDL.*")
1111
message(WARNING "This module is internal to SDL and is currently not supported.")

cmake/android/SdlAndroidScript.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Because
66
77
#]=======================================================================]
88

9-
cmake_minimum_required(VERSION 3.16)
9+
cmake_minimum_required(VERSION 3.16...3.28)
1010

1111
if(NOT CMAKE_SCRIPT_MODE_FILE)
1212
message(FATAL_ERROR "This file can only be used in CMake script mode")

0 commit comments

Comments
 (0)