1# Copyright 2013-2017 The Meson development team 2 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6 7# http://www.apache.org/licenses/LICENSE-2.0 8 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# This file contains the detection logic for external dependencies that are 16# platform-specific (generally speaking). 17 18from .base import DependencyTypeName, ExternalDependency, DependencyException 19from ..mesonlib import MesonException 20import typing as T 21 22if T.TYPE_CHECKING: 23 from ..environment import Environment 24 25class AppleFrameworks(ExternalDependency): 26 def __init__(self, env: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: 27 super().__init__(DependencyTypeName('appleframeworks'), env, kwargs) 28 modules = kwargs.get('modules', []) 29 if isinstance(modules, str): 30 modules = [modules] 31 if not modules: 32 raise DependencyException("AppleFrameworks dependency requires at least one module.") 33 self.frameworks = modules 34 if not self.clib_compiler: 35 raise DependencyException('No C-like compilers are available, cannot find the framework') 36 self.is_found = True 37 for f in self.frameworks: 38 try: 39 args = self.clib_compiler.find_framework(f, env, []) 40 except MesonException as e: 41 if 'non-clang' in str(e): 42 self.is_found = False 43 self.link_args = [] 44 self.compile_args = [] 45 return 46 raise 47 48 if args is not None: 49 # No compile args are needed for system frameworks 50 self.link_args += args 51 else: 52 self.is_found = False 53 54 def log_info(self) -> str: 55 return ', '.join(self.frameworks) 56 57 def log_tried(self) -> str: 58 return 'framework' 59