Add explicit device logic to the iOS build script#1889
Open
a-maurice wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the CMake configuration script for iOS and tvOS to set the -DCMAKE_OSX_SYSROOT parameter when the platform variant is 'device'. The reviewer suggested simplifying the nested conditional blocks by using a dictionary mapping for the platform variants to their respective SDK sysroots to improve readability and maintainability.
Comment on lines
483
to
+493
| cmd.append('-DCMAKE_SYSTEM_NAME=iOS') | ||
| if platform_variant == 'simulator': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=iphonesimulator') | ||
| elif platform_variant == 'device': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=iphoneos') | ||
| elif apple_os == 'tvos': | ||
| cmd.append('-DCMAKE_SYSTEM_NAME=tvOS') | ||
| if platform_variant == 'simulator': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvsimulator') | ||
| elif platform_variant == 'device': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvos') |
Contributor
There was a problem hiding this comment.
To improve readability and maintainability, we can simplify the nested conditional blocks by using a dictionary mapping for the platform variants to their respective SDK sysroots. This avoids repetitive if/elif checks and makes the configuration logic cleaner and more idiomatic.
Suggested change
| cmd.append('-DCMAKE_SYSTEM_NAME=iOS') | |
| if platform_variant == 'simulator': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=iphonesimulator') | |
| elif platform_variant == 'device': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=iphoneos') | |
| elif apple_os == 'tvos': | |
| cmd.append('-DCMAKE_SYSTEM_NAME=tvOS') | |
| if platform_variant == 'simulator': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvsimulator') | |
| elif platform_variant == 'device': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvos') | |
| cmd.append('-DCMAKE_SYSTEM_NAME=iOS') | |
| sysroot = {'simulator': 'iphonesimulator', 'device': 'iphoneos'}.get(platform_variant) | |
| if sysroot: | |
| cmd.append('-DCMAKE_OSX_SYSROOT={0}'.format(sysroot)) | |
| elif apple_os == 'tvos': | |
| cmd.append('-DCMAKE_SYSTEM_NAME=tvOS') | |
| sysroot = {'simulator': 'appletvsimulator', 'device': 'appletvos'}.get(platform_variant) | |
| if sysroot: | |
| cmd.append('-DCMAKE_OSX_SYSROOT={0}'.format(sysroot)) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
When building for iOS and tvOS device, set the appropriate CMAKE_OSX_SYSROOT value. Seems to be necessary based on Xcode and Cmake versions.
Testing
Building locally.
Type of Change
Place an
xthe applicable box:Notes
Release Notessection ofrelease_build_files/readme.md.