mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-15 09:18:27 +00:00
release: add Android aar to devel zip archive
[ci skip]
This commit is contained in:
parent
c4f2f7b352
commit
4ba4f0a106
10 changed files with 78 additions and 36 deletions
|
@ -961,7 +961,8 @@ class Releaser:
|
|||
if not cmake_toolchain_file.exists():
|
||||
logger.error("CMake toolchain file does not exist (%s)", cmake_toolchain_file)
|
||||
raise SystemExit(1)
|
||||
aar_path = self.dist_path / f"{self.project}-{self.version}.aar"
|
||||
aar_path = self.root / "build-android" / f"{self.project}-{self.version}.aar"
|
||||
android_dist_path = self.dist_path / f"{self.project}-devel-{self.version}-android.zip"
|
||||
android_abis = self.release_info["android"]["abis"]
|
||||
java_jars_added = False
|
||||
module_data_added = False
|
||||
|
@ -969,14 +970,24 @@ class Releaser:
|
|||
shutil.rmtree(android_deps_path, ignore_errors=True)
|
||||
|
||||
for dep, depinfo in self.release_info["android"].get("dependencies", {}).items():
|
||||
android_aar = self.deps_path / glob.glob(depinfo["artifact"], root_dir=self.deps_path)[0]
|
||||
with self.section_printer.group(f"Extracting Android dependency {dep} ({android_aar.name})"):
|
||||
self.executer.run([sys.executable, str(android_aar), "-o", str(android_deps_path)])
|
||||
dep_devel_zip = self.deps_path / glob.glob(depinfo["artifact"], root_dir=self.deps_path)[0]
|
||||
|
||||
dep_extract_path = self.deps_path / f"extract/android/{dep}"
|
||||
shutil.rmtree(dep_extract_path, ignore_errors=True)
|
||||
dep_extract_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with self.section_printer.group(f"Extracting Android dependency {dep} ({dep_devel_zip})"):
|
||||
with zipfile.ZipFile(dep_devel_zip, "r") as zf:
|
||||
zf.extractall(dep_extract_path)
|
||||
|
||||
dep_devel_aar = dep_extract_path / glob.glob("*.aar", root_dir=dep_extract_path)[0]
|
||||
self.executer.run([sys.executable, str(dep_devel_aar), "-o", str(android_deps_path)])
|
||||
|
||||
for module_name, module_info in self.release_info["android"]["modules"].items():
|
||||
assert "type" in module_info and module_info["type"] in ("interface", "library"), f"module {module_name} must have a valid type"
|
||||
|
||||
archive_file_tree = ArchiveFileTree()
|
||||
aar_file_tree = ArchiveFileTree()
|
||||
android_devel_file_tree = ArchiveFileTree()
|
||||
|
||||
for android_abi in android_abis:
|
||||
with self.section_printer.group(f"Building for Android {android_api} {android_abi}"):
|
||||
|
@ -1027,20 +1038,20 @@ class Releaser:
|
|||
assert library.suffix in (".so", ".a")
|
||||
assert library.is_file(), f"CMake should have built library '{library}' for module {module_name}"
|
||||
arcdir_prefab_libs = f"{arcdir_prefab_module}/libs/android.{android_abi}"
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath=f"{arcdir_prefab_libs}/{library.name}", path=library, time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=f"{arcdir_prefab_libs}/abi.json", text=self._get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=library.suffix == ".so"), time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath=f"{arcdir_prefab_libs}/{library.name}", path=library, time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=f"{arcdir_prefab_libs}/abi.json", text=self._get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=library.suffix == ".so"), time=self.arc_time))
|
||||
|
||||
if not module_data_added:
|
||||
library_name = None
|
||||
if module_info["type"] == "library":
|
||||
library_name = Path(module_info["library"]).stem.removeprefix("lib")
|
||||
export_libraries = module_info.get("export-libraries", [])
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_module, "module.json"), text=self._get_prefab_module_json_text(library_name=library_name, export_libraries=export_libraries), time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_module, "module.json"), text=self._get_prefab_module_json_text(library_name=library_name, export_libraries=export_libraries), time=self.arc_time))
|
||||
arcdir_prefab_include = f"prefab/modules/{module_name}/include"
|
||||
if "includes" in module_info:
|
||||
archive_file_tree.add_file_mapping(arc_dir=arcdir_prefab_include, file_mapping=module_info["includes"], file_mapping_root=install_dir, context=self.get_context(), time=self.arc_time)
|
||||
aar_file_tree.add_file_mapping(arc_dir=arcdir_prefab_include, file_mapping=module_info["includes"], file_mapping_root=install_dir, context=self.get_context(), time=self.arc_time)
|
||||
else:
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_include, ".keep"), text="\n", time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_include, ".keep"), text="\n", time=self.arc_time))
|
||||
module_data_added = True
|
||||
|
||||
if not java_jars_added:
|
||||
|
@ -1053,21 +1064,28 @@ class Releaser:
|
|||
assert sources_jar_path.is_file(), f"CMake should have archived the java sources into a JAR ({sources_jar_path})"
|
||||
assert doc_jar_path.is_file(), f"CMake should have archived javadoc into a JAR ({doc_jar_path})"
|
||||
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes.jar", path=classes_jar_path, time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-sources.jar", path=sources_jar_path, time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-doc.jar", path=doc_jar_path, time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes.jar", path=classes_jar_path, time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-sources.jar", path=sources_jar_path, time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-doc.jar", path=doc_jar_path, time=self.arc_time))
|
||||
|
||||
assert ("jars" in self.release_info["android"] and java_jars_added) or "jars" not in self.release_info["android"], "Must have archived java JAR archives"
|
||||
|
||||
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"].get("files", {}), file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
|
||||
aar_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"]["aar-files"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
|
||||
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath="prefab/prefab.json", text=self._get_prefab_json_text(), time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath="AndroidManifest.xml", text=self._get_android_manifest_text(), time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath="prefab/prefab.json", text=self._get_prefab_json_text(), time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath="AndroidManifest.xml", text=self._get_android_manifest_text(), time=self.arc_time))
|
||||
|
||||
with Archiver(zip_path=aar_path) as archiver:
|
||||
archive_file_tree.add_to_archiver(archive_base="", archiver=archiver)
|
||||
aar_file_tree.add_to_archiver(archive_base="", archiver=archiver)
|
||||
archiver.add_git_hash(arcdir="", commit=self.commit, time=self.arc_time)
|
||||
self.artifacts[f"android-aar"] = aar_path
|
||||
|
||||
android_devel_file_tree.add_file(NodeInArchive.from_fs(arcpath=aar_path.name, path=aar_path))
|
||||
android_devel_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"]["files"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
|
||||
with Archiver(zip_path=android_dist_path) as archiver:
|
||||
android_devel_file_tree.add_to_archiver(archive_base="", archiver=archiver)
|
||||
archiver.add_git_hash(arcdir="", commit=self.commit, time=self.arc_time)
|
||||
|
||||
self.artifacts[f"android-aar"] = android_dist_path
|
||||
|
||||
def download_dependencies(self):
|
||||
shutil.rmtree(self.deps_path, ignore_errors=True)
|
||||
|
@ -1104,7 +1122,7 @@ class Releaser:
|
|||
assert len(msvc_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {msvc_matches}"
|
||||
if "android" in self.release_info:
|
||||
android_matches = glob.glob(self.release_info["android"]["dependencies"][dep]["artifact"], root_dir=self.deps_path)
|
||||
assert len(android_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {msvc_matches}"
|
||||
assert len(android_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {android_matches}"
|
||||
|
||||
@staticmethod
|
||||
def _arch_to_vs_platform(arch: str, configuration: str="Release") -> VsArchPlatformConfig:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue