-
Notifications
You must be signed in to change notification settings - Fork 991
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
Promote to_apple_arch in conan.tools.apple #11915
Merged
memsharded
merged 2 commits into
conan-io:develop
from
jcar87:feature/conan-tools-to-apple-arch
Aug 24, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from conans.test.utils.mocks import ConanFileMock, MockSettings | ||
from conan.tools.apple import is_apple_os, to_apple_arch | ||
|
||
def test_tools_apple_is_apple_os(): | ||
conanfile = ConanFileMock() | ||
|
||
conanfile.settings = MockSettings({"os": "Macos"}) | ||
assert is_apple_os(conanfile) == True | ||
|
||
conanfile.settings = MockSettings({"os": "watchOS"}) | ||
assert is_apple_os(conanfile) == True | ||
|
||
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" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am slightly concerned about some recent tools similar to this, as I am wondering what will happen if at some point users want to use it for the build context. They will not be able. So the options would be:
apple_archs(arch)
to_apple_arch_build(conanfile)
(a bit ugly?)I am fine with this change at this moment, but something to have in mind and maybe discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point! If there's a risk that we may end up with too many small tool functions that have a similar issue, I'd be more inclined to try and sort this out sooner rather than later.
to_apple_arch
has very few uses in Conan Center at the moment, so we may have an opportunity to get it right to cover all cases (although we also want to avoid a repeat of the situations where recipes are using it from the "private" moduleapple.apple
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are some other alternatives, like:
with context_switch(ctx="build"): do something
if is_apple_arch(conanfile.build)
whereconanfile.build
isConanFIle
instance with context switched to buildThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related #11926