| 1 |
# SPDX-License-Identifier: Apache-2.0 |
| 2 |
# Copyright 2013-2017 The Meson development team |
| 3 |
|
| 4 |
# This file contains the detection logic for external dependencies that are |
| 5 |
# platform-specific (generally speaking). |
| 6 |
from __future__ import annotations |
| 7 |
|
| 8 |
from .base import DependencyTypeName, ExternalDependency, DependencyException |
| 9 |
from .detect import packages |
| 10 |
from ..mesonlib import MesonException |
| 11 |
import typing as T |
| 12 |
|
| 13 |
if T.TYPE_CHECKING: |
| 14 |
from ..environment import Environment |
| 15 |
from .base import DependencyObjectKWs |
| 16 |
|
| 17 |
class AppleFrameworks(ExternalDependency): |
| 18 |
|
| 19 |
type_name = DependencyTypeName('appleframeworks') |
| 20 |
|
| 21 |
def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs) -> None: |
| 22 |
super().__init__(name, env, kwargs) |
| 23 |
modules = kwargs.get('modules', []) |
| 24 |
if not modules: |
| 25 |
raise DependencyException("AppleFrameworks dependency requires at least one module.") |
| 26 |
self.frameworks = modules |
| 27 |
if not self.clib_compiler: |
| 28 |
raise DependencyException('No C-like compilers are available, cannot find the framework') |
| 29 |
self.is_found = True |
| 30 |
for f in self.frameworks: |
| 31 |
try: |
| 32 |
args = self.clib_compiler.find_framework(f, []) |
| 33 |
except MesonException as e: |
| 34 |
if 'non-clang' in str(e): |
| 35 |
self.is_found = False |
| 36 |
self.link_args = [] |
| 37 |
self.compile_args = [] |
| 38 |
return |
| 39 |
raise |
| 40 |
|
| 41 |
if args is not None: |
| 42 |
# No compile args are needed for system frameworks |
| 43 |
self.link_args += args |
| 44 |
else: |
| 45 |
self.is_found = False |
| 46 |
|
| 47 |
def log_info(self) -> str: |
| 48 |
return ', '.join(self.frameworks) |
| 49 |
|
| 50 |
packages['appleframeworks'] = AppleFrameworks |