Skip to content

Commit

Permalink
OSX detect_api.sdk_version (#16355)
Browse files Browse the repository at this point in the history
* OSX detect_api.sdk_version

* add Darwin check

* fix
  • Loading branch information
memsharded authored Jun 3, 2024
1 parent e7b87a3 commit 03613d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 03613d5

Please sign in to comment.