Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public import is_apple_os #11896

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions conan/tools/apple/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Keep everything private until we review what is really needed and refactor passing "conanfile"
# from conan.tools.apple.apple import XCRun
# from conan.tools.apple.apple import apple_dot_clean
# from conan.tools.apple.apple import is_apple_os
# from conan.tools.apple.apple import apple_sdk_name
# from conan.tools.apple.apple import apple_deployment_target_flag
# from conan.tools.apple.apple import to_apple_arch
from conan.tools.apple.apple import fix_apple_shared_install_name
from conan.tools.apple.apple import fix_apple_shared_install_name, is_apple_os
from conan.tools.apple.xcodedeps import XcodeDeps
from conan.tools.apple.xcodebuild import XcodeBuild
from conan.tools.apple.xcodetoolchain import XcodeToolchain
5 changes: 3 additions & 2 deletions conan/tools/apple/apple.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from conans.util.runners import check_output_runner


def is_apple_os(os_):
def is_apple_os(conanfile):
"""returns True if OS is Apple one (Macos, iOS, watchOS or tvOS"""
os_ = conanfile.settings.get_safe("os")
return str(os_) in ['Macos', 'iOS', 'watchOS', 'tvOS']


Expand Down Expand Up @@ -176,7 +177,7 @@ def _fix_dep_name(dylib_path, old_name, new_name):

substitutions = {}

if is_apple_os(conanfile.settings.get_safe("os")) and conanfile.options.get_safe("shared", False):
if is_apple_os(conanfile) and conanfile.options.get_safe("shared", False):
libdirs = getattr(conanfile.cpp.package, "libdirs")
for libdir in libdirs:
full_folder = os.path.join(conanfile.package_folder, libdir)
Expand Down
4 changes: 2 additions & 2 deletions conan/tools/cmake/toolchain/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def _apple_sdk_name(self):

def context(self):
os_ = self._conanfile.settings.get_safe("os")
if not is_apple_os(os_):
if not is_apple_os(self._conanfile):
return None

arch = self._conanfile.settings.get_safe("arch")
Expand Down Expand Up @@ -522,7 +522,7 @@ def context(self):
find_package_prefer_config = "OFF"

os_ = self._conanfile.settings.get_safe("os")
is_apple_ = is_apple_os(os_)
is_apple_ = is_apple_os(self._conanfile)

# Read information from host context
host_req = self._conanfile.dependencies.host.values()
Expand Down
1 change: 0 additions & 1 deletion conan/tools/files/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from urllib.request import url2pathname

from conan.tools import CONAN_TOOLCHAIN_ARGS_FILE, CONAN_TOOLCHAIN_ARGS_SECTION
from conan.tools.apple.apple import is_apple_os
from conans.client.downloaders.download import run_downloader
from conans.errors import ConanException
from conans.util.files import rmdir as _internal_rmdir
Expand Down
2 changes: 1 addition & 1 deletion conan/tools/gnu/autotoolstoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from conan.tools._compilers import architecture_flag, build_type_flags, cppstd_flag, \
build_type_link_flags
from conan.tools.apple.apple import apple_min_version_flag, to_apple_arch, \
apple_sdk_path, is_apple_os
apple_sdk_path
from conan.tools.build.cross_building import cross_building, get_cross_building_settings
from conan.tools.env import Environment
from conan.tools.files.files import save_toolchain_args
Expand Down
2 changes: 1 addition & 1 deletion conan/tools/gnu/gnudeps_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _format_frameworks(self, frameworks, is_path=False):
or an empty array, if Apple Frameworks aren't supported by the given compiler
"""
os_ = self._conanfile.settings.get_safe("os")
if not frameworks or not is_apple_os(os_):
if not frameworks or not is_apple_os(self._conanfile):
return []
compiler = self._conanfile.settings.get_safe("compiler")
if str(compiler) not in self._GCC_LIKE:
Expand Down
4 changes: 2 additions & 2 deletions conan/tools/meson/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MesonToolchain(object):
def __init__(self, conanfile, backend=None):
self._conanfile = conanfile
self._os = self._conanfile.settings.get_safe("os")
self._is_apple_system = is_apple_os(self._os)
self._is_apple_system = is_apple_os(self._conanfile)

# Values are kept as Python built-ins so users can modify them more easily, and they are
# only converted to Meson file syntax for rendering
Expand Down Expand Up @@ -147,7 +147,7 @@ def __init__(self, conanfile, backend=None):
os_target = settings_target.get_safe("os")
arch_target = settings_target.get_safe("arch")
self.cross_build["target"] = to_meson_machine(os_target, arch_target)
if is_apple_os(os_host): # default cross-compiler in Apple is common
if is_apple_os(self._conanfile): # default cross-compiler in Apple is common
default_comp = "clang"
default_comp_cpp = "clang++"
else:
Expand Down
2 changes: 1 addition & 1 deletion conans/test/unittests/tools/gnu/gnudepsflags_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_framework_flags_only_for_apple_os(os_):
gnudepsflags = GnuDepsFlags(conanfile, cpp_info)
expected_framework = []
expected_framework_path = []
if is_apple_os(os_):
if is_apple_os(conanfile):
expected_framework = ["-framework Foundation"]
expected_framework_path = ["-F Framework"]
assert gnudepsflags.frameworks == expected_framework
Expand Down