diff --git a/aedi/target/__init__.py b/aedi/target/__init__.py index a9d4c259..22a8001c 100644 --- a/aedi/target/__init__.py +++ b/aedi/target/__init__.py @@ -107,5 +107,6 @@ def targets(): # Special CleanAllTarget(), CleanDepsTarget(), + DownloadCMakeTarget(), TestDepsTarget(), ) diff --git a/aedi/target/special.py b/aedi/target/special.py index 4f4c4311..01d7eb1f 100644 --- a/aedi/target/special.py +++ b/aedi/target/special.py @@ -18,6 +18,7 @@ import os import shlex +import shutil import subprocess from .base import Target, BuildTarget @@ -50,6 +51,45 @@ class CleanDepsTarget(CleanAllTarget): self.args += (state.deps_path,) +DOWNLOAD_CMAKE_TARGET_NAME = 'download-cmake' + + +class DownloadCMakeTarget(Target): + def __init__(self, name=DOWNLOAD_CMAKE_TARGET_NAME): + super().__init__(name) + + def build(self, state: BuildState): + probe_paths = ( + '', + state.bin_path, + '/Applications/CMake.app/Contents/bin/', + ) + + for path in probe_paths: + try: + subprocess.run([path + 'cmake', '--version'], check=True) + return + except (FileNotFoundError, IOError, subprocess.CalledProcessError): + continue + + cmake_version = '3.20.5' + cmake_basename = f'cmake-{cmake_version}-macos-universal' + + state.download_source( + f'https://github.com/Kitware/CMake/releases/download/v{cmake_version}/{cmake_basename}.tar.gz', + '000828af55268853ba21b91f8ce3bfb9365aa72aee960fc7f0c01a71f3a2217a') + + target_path = state.deps_path + 'cmake' + if os.path.exists(target_path): + shutil.rmtree(target_path) + os.makedirs(target_path) + + source_path = state.source + 'CMake.app/Contents/' + shutil.move(source_path + 'bin', target_path) + shutil.move(source_path + 'share', target_path) + shutil.rmtree(state.source) + + class TestDepsTarget(BuildTarget): def __init__(self, name='test-deps'): super().__init__(name) diff --git a/deps/.gitignore b/deps/.gitignore index 0ff6cfa8..b22c34a7 100644 --- a/deps/.gitignore +++ b/deps/.gitignore @@ -55,6 +55,7 @@ /webp/**/libwebpdemux.* # Tools +/cmake/ /nasm/bin/ndisasm /yasm/bin/vsyasm /yasm/bin/ytasm