diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2023-10-23 20:04:37 +0530 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2023-11-17 11:53:21 +0000 |
commit | 7060afc6cfcf73db696dce91e930f5364db85183 (patch) | |
tree | 2fecc5d9a9b0142a21e2910dcbd6c378e5d38b19 | |
parent | 9a34942033a9be909aab2703a9cab5922affc2c3 (diff) |
cerbero: Reject MSYS2 cmake during bootstrap
The previous fix for this was incomplete: we also need to reject MSYS2
cmake during bootstrap.
Also get rid of a useless `which()` reimplementation and an
incorrectly-committed blank file.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1288>
-rw-r--r-- | cerbero/build/build.py | 14 | ||||
-rw-r--r-- | cerbero/utils/shell.py | 35 | ||||
-rw-r--r-- | recipes/glib-networking.recipe | 1 | ||||
-rw-r--r-- | tools/bootstrap- | 0 |
4 files changed, 20 insertions, 30 deletions
diff --git a/cerbero/build/build.py b/cerbero/build/build.py index c046aee9..30e0ad68 100644 --- a/cerbero/build/build.py +++ b/cerbero/build/build.py @@ -30,21 +30,11 @@ from itertools import chain from cerbero.enums import Platform, Architecture, Distro, LibraryType from cerbero.errors import FatalError, InvalidRecipeError -from cerbero.utils import shell, to_unixpath, to_winpath, add_system_libs, determine_num_of_cpus, determine_total_ram +from cerbero.utils import shell, add_system_libs, determine_num_of_cpus, determine_total_ram from cerbero.utils import EnvValue, EnvValueSingle, EnvValueArg, EnvValueCmd, EnvValuePath from cerbero.utils import messages as m -def get_path_minus_msys(env): - path = env['PATH'].split(os.pathsep) - newpath = [] - msys2_prefix = to_winpath('/') - for p in path: - if msys2_prefix not in p: - newpath.append(p) - return os.pathsep.join(newpath) - - def get_optimization_from_config(config): if config.variants.optimization: if config.target_platform in (Platform.ANDROID, Platform.IOS): @@ -649,7 +639,7 @@ class CMake (MakefilesBase): self.config_sh = 'cmake' if self.config.distro == Distro.MSYS2: # We do not want the MSYS2 CMake because it doesn't support MSVC - self.config_sh = shutil.which('cmake', path=get_path_minus_msys(self.env)) + self.config_sh = shutil.which('cmake', path=shell.get_path_minus_msys(self.env['PATH'])) @modify_environment async def configure(self): diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py index ae291e15..757d3028 100644 --- a/cerbero/utils/shell.py +++ b/cerbero/utils/shell.py @@ -37,6 +37,7 @@ from pathlib import Path, PurePath from cerbero.enums import CERBERO_VERSION, Platform, Distro from cerbero.utils import _, system_info, split_version, CerberoSemaphore from cerbero.utils import messages as m +from cerbero.utils import to_winpath from cerbero.errors import CommandError, FatalError @@ -405,13 +406,13 @@ async def download(url, dest, check_cert=True, overwrite=False, logfile=None, mi 'ProgressPreference -Value \'SilentlyContinue\'; ' \ f'Invoke-WebRequest -UserAgent {user_agent} -OutFile {dest} ' \ '-Method Get -Uri %s'] - elif which('wget'): + elif shutil.which('wget'): cmd = ['wget', '--user-agent', user_agent, '--tries=2', '--timeout=20', '--progress=dot:giga', '-O', dest] if not check_cert: cmd += ['--no-check-certificate'] cmd += ['%s'] - elif which('curl'): + elif shutil.which('curl'): cmd = ['curl', '-L', '--fail', '--user-agent', user_agent, '--retry', '2', '--connect-timeout', '20', '--progress-bar', '-o', dest] if not check_cert: @@ -638,20 +639,6 @@ C:\\msys64\\msys2_shell.cmd -ucrt64 -defterm -no-start -here -use-full-path -c ' os.execlpe(shell, shell, env) -def which(pgm, path=None): - if path is None: - path = os.getenv('PATH') - for p in path.split(os.path.pathsep): - p = os.path.join(p, pgm) - if os.path.exists(p) and os.access(p, os.X_OK): - return p - if PLATFORM == Platform.WINDOWS: - for ext in os.getenv('PATHEXT').split(';'): - pext = p + ext - if os.path.exists(pext): - return pext - - def get_tar_cmd(): ''' Returns the tar command to use @@ -667,6 +654,16 @@ def get_tar_cmd(): return TAR +def get_path_minus_msys(path): + path = path.split(os.pathsep) + newpath = [] + msys2_prefix = to_winpath('/') + for p in path: + if msys2_prefix not in p: + newpath.append(p) + return os.pathsep.join(newpath) + + def check_tool_version(tool_name, needed, env, version_arg=None): found = False newer = False @@ -674,7 +671,11 @@ def check_tool_version(tool_name, needed, env, version_arg=None): version_arg = '--version' if env is None: env = os.environ.copy() - tool = which(tool_name, env['PATH']) + path = env['PATH'] + # We do not want the MSYS2 CMake because it doesn't support MSVC + if tool_name == 'cmake' and DISTRO == Distro.MSYS2: + path = get_path_minus_msys(path) + tool = shutil.which(tool_name, path=path) if not tool: return None, False, False try: diff --git a/recipes/glib-networking.recipe b/recipes/glib-networking.recipe index bf76cb30..da4a40c2 100644 --- a/recipes/glib-networking.recipe +++ b/recipes/glib-networking.recipe @@ -1,6 +1,5 @@ # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python import os -from cerbero.utils.shell import which from cerbero.tools.libtool import LibtoolLibrary class Recipe(recipe.Recipe): diff --git a/tools/bootstrap- b/tools/bootstrap- deleted file mode 100644 index e69de29b..00000000 --- a/tools/bootstrap- +++ /dev/null |