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

xcrun settings #12486

Merged
merged 3 commits into from
Nov 8, 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: 2 additions & 1 deletion conan/tools/apple/apple.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(self, conanfile, sdk=None, use_settings_target=False):
settings = conanfile.settings
if use_settings_target and hasattr(conanfile, "settings_target") and conanfile.settings_target is not None:
settings = conanfile.settings_target
self.settings = settings

if sdk is None and settings:
sdk = apple_sdk_name(settings)
Expand Down Expand Up @@ -266,7 +267,7 @@ def _fix_executables(conanfile, substitutions):
if is_apple_os(conanfile) and conanfile.options.get_safe("shared", False):
substitutions = _fix_dylib_files(conanfile)

# Only "fix" executables if dylib files were patched, otherwise
# Only "fix" executables if dylib files were patched, otherwise
# there is nothing to do.
if substitutions:
_fix_executables(conanfile, substitutions)
2 changes: 2 additions & 0 deletions conans/client/migrations_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4029,3 +4029,5 @@
"""

settings_1_54_0 = settings_1_53_0

settings_1_55_0 = settings_1_54_0
czoido marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 16 additions & 4 deletions conans/test/unittests/tools/apple/test_apple_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from conans.test.utils.mocks import ConanFileMock, MockSettings
from conans.test.utils.test_files import temp_folder
from conan.tools.apple import is_apple_os, to_apple_arch, fix_apple_shared_install_name
from conan.tools.apple import is_apple_os, to_apple_arch, fix_apple_shared_install_name, XCRun

def test_tools_apple_is_apple_os():
conanfile = ConanFileMock()

conanfile.settings = MockSettings({"os": "Macos"})
assert is_apple_os(conanfile) == True

Expand All @@ -16,16 +16,17 @@ def test_tools_apple_is_apple_os():
conanfile.settings = MockSettings({"os": "Windows"})
assert is_apple_os(conanfile) == False


def test_tools_apple_to_apple_arch():
conanfile = ConanFileMock()

conanfile.settings = MockSettings({"arch": "armv8"})
assert to_apple_arch(conanfile) == "arm64"

conanfile.settings = MockSettings({"arch": "x86_64"})
assert to_apple_arch(conanfile) == "x86_64"


def test_fix_shared_install_name_no_libraries():
conanfile = ConanFileMock(
options="""{"shared": [True, False]}""",
Expand All @@ -36,3 +37,14 @@ def test_fix_shared_install_name_no_libraries():
with pytest.raises(Exception) as e:
fix_apple_shared_install_name(conanfile)
assert "not found inside package folder" in str(e.value)


def test_xcrun_public_settings():
# https://github.com/conan-io/conan/issues/12485
conanfile = ConanFileMock()
conanfile.settings = MockSettings({"os": "watchOS"})

xcrun = XCRun(conanfile, use_settings_target=True)
settings = xcrun.settings

assert settings.os == "watchOS"