Skip to content

OSX detect_api.sdk_version #16355

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

Merged
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
9 changes: 9 additions & 0 deletions conan/internal/api/detect_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,12 @@ def default_compiler_version(compiler, version):
elif compiler == "intel-cc":
return major
return version


def detect_sdk_version(sdk):
if platform.system() != "Darwin":
return
cmd = f'xcrun -sdk {sdk} --show-sdk-version'
result = check_output_runner(cmd)
result = result.strip()
return result
14 changes: 14 additions & 0 deletions test/functional/test_profile_detect_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ def test_profile_detect_libc(self):
user.confvar:libc_version={libc_version}
""")
assert expected in client.out

@pytest.mark.skipif(platform.system() != "Darwin", reason="Only OSX")
def test_profile_detect_darwin_sdk(self):
client = TestClient()
tpl1 = textwrap.dedent("""\
[settings]
os = "Macos"
os.sdk_version = {{ detect_api.detect_sdk_version(sdk="macosx") }}
""")

client.save({"profile1": tpl1})
client.run("profile show -pr=profile1")
sdk_version = detect_api.detect_sdk_version(sdk="macosx")
assert f"os.sdk_version={sdk_version}" in client.out