-
Notifications
You must be signed in to change notification settings - Fork 0
Mac Catalyst support for bazel / rules_swift / rules_apple #24
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -97,6 +97,10 @@ def _impl(ctx): | |||||||||||||||||||||||||
target_system_name = "x86_64-apple-tvos{}-simulator".format(target_os_version) | ||||||||||||||||||||||||||
elif (ctx.attr.cpu == "watchos_x86_64"): | ||||||||||||||||||||||||||
target_system_name = "x86_64-apple-watchos{}-simulator".format(target_os_version) | ||||||||||||||||||||||||||
elif (ctx.attr.cpu == "catalyst_x86_64"): | ||||||||||||||||||||||||||
target_system_name = "x86_64-apple-ios{}-macabi".format(target_os_version) | ||||||||||||||||||||||||||
elif (ctx.attr.cpu == "catalyst_arm64"): | ||||||||||||||||||||||||||
target_system_name = "arm64-apple-ios{}-macabi".format(target_os_version) | ||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||
fail("Unreachable") | ||||||||||||||||||||||||||
Comment on lines
104
to
105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing Platform CheckThe else clause fails with "Unreachable" but new catalyst platforms were added without updating this error message. This could cause misleading error messages if an unrecognized CPU is encountered. Standards
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -692,7 +696,9 @@ def _impl(ctx): | |||||||||||||||||||||||||
ctx.attr.cpu == "watchos_armv7k" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_i386" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64"): | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_arm64"): | ||||||||||||||||||||||||||
apply_default_compiler_flags_feature = feature( | ||||||||||||||||||||||||||
name = "apply_default_compiler_flags", | ||||||||||||||||||||||||||
flag_sets = [ | ||||||||||||||||||||||||||
|
@@ -941,7 +947,9 @@ def _impl(ctx): | |||||||||||||||||||||||||
ctx.attr.cpu == "watchos_armv7k" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_i386" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64"): | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_arm64"): | ||||||||||||||||||||||||||
contains_objc_source_feature = feature( | ||||||||||||||||||||||||||
name = "contains_objc_source", | ||||||||||||||||||||||||||
flag_sets = [ | ||||||||||||||||||||||||||
|
@@ -1098,6 +1106,32 @@ def _impl(ctx): | |||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (ctx.attr.cpu == "catalyst_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_arm64"): | ||||||||||||||||||||||||||
ios_support_link_flags_feature = feature( | ||||||||||||||||||||||||||
name = "ios_support_link_flags", | ||||||||||||||||||||||||||
enabled = True, | ||||||||||||||||||||||||||
flag_sets = [ | ||||||||||||||||||||||||||
flag_set( | ||||||||||||||||||||||||||
actions = all_link_actions + | ||||||||||||||||||||||||||
["objc-executable", "objc++-executable"], | ||||||||||||||||||||||||||
flag_groups = [ | ||||||||||||||||||||||||||
flag_group( | ||||||||||||||||||||||||||
flags = [ | ||||||||||||||||||||||||||
"-iframeworkwithsysroot", | ||||||||||||||||||||||||||
"System/iOS/System/Library/Frameworks", | ||||||||||||||||||||||||||
"-L%{sdk_dir}/System/iOSSupport/usr/lib", | ||||||||||||||||||||||||||
Comment on lines
+1122
to
+1123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing iOS Framework PathPath appears incorrect - should likely be '/System/iOSSupport/System/Library/Frameworks'. Incorrect framework path will cause build failures for Catalyst targets due to missing system frameworks. Standards
|
||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
Comment on lines
+1119
to
+1124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Framework search path typo breaks linkage
but for macOS Catalyst SDKs the directory is
If left unchanged, - "-iframeworkwithsysroot",
- "System/iOS/System/Library/Frameworks",
+ "-iframeworkwithsysroot",
+ "System/iOSSupport/System/Library/Frameworks", 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||
ios_support_link_flags_feature = feature( | ||||||||||||||||||||||||||
name = "ios_support_link_flags" | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
Comment on lines
+1109
to
+1133
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
no_deduplicate_feature = feature( | ||||||||||||||||||||||||||
name = "no_deduplicate", | ||||||||||||||||||||||||||
enabled = True, | ||||||||||||||||||||||||||
|
@@ -1260,35 +1294,68 @@ def _impl(ctx): | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
coverage_feature = feature(name = "coverage") | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
include_system_dirs_feature = feature( | ||||||||||||||||||||||||||
name = "include_system_dirs", | ||||||||||||||||||||||||||
flag_sets = [ | ||||||||||||||||||||||||||
flag_set( | ||||||||||||||||||||||||||
actions = [ | ||||||||||||||||||||||||||
ACTION_NAMES.c_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_module_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_header_parsing, | ||||||||||||||||||||||||||
ACTION_NAMES.objc_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.objcpp_compile, | ||||||||||||||||||||||||||
"objc-executable", | ||||||||||||||||||||||||||
"objc++-executable", | ||||||||||||||||||||||||||
ACTION_NAMES.assemble, | ||||||||||||||||||||||||||
ACTION_NAMES.preprocess_assemble, | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
flag_groups = [ | ||||||||||||||||||||||||||
flag_group( | ||||||||||||||||||||||||||
flags = [ | ||||||||||||||||||||||||||
"-isysroot", | ||||||||||||||||||||||||||
"%{sdk_dir}", | ||||||||||||||||||||||||||
"-F%{sdk_framework_dir}", | ||||||||||||||||||||||||||
"-F%{platform_developer_framework_dir}", | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
if (ctx.attr.cpu == "catalyst_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_arm64"): | ||||||||||||||||||||||||||
include_system_dirs_feature = feature( | ||||||||||||||||||||||||||
name = "include_system_dirs", | ||||||||||||||||||||||||||
flag_sets = [ | ||||||||||||||||||||||||||
flag_set( | ||||||||||||||||||||||||||
actions = [ | ||||||||||||||||||||||||||
ACTION_NAMES.c_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_module_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_header_parsing, | ||||||||||||||||||||||||||
ACTION_NAMES.objc_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.objcpp_compile, | ||||||||||||||||||||||||||
"objc-executable", | ||||||||||||||||||||||||||
"objc++-executable", | ||||||||||||||||||||||||||
ACTION_NAMES.assemble, | ||||||||||||||||||||||||||
ACTION_NAMES.preprocess_assemble, | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
flag_groups = [ | ||||||||||||||||||||||||||
flag_group( | ||||||||||||||||||||||||||
flags = [ | ||||||||||||||||||||||||||
"-isysroot", | ||||||||||||||||||||||||||
"%{sdk_dir}", | ||||||||||||||||||||||||||
"-F%{sdk_framework_dir}", | ||||||||||||||||||||||||||
"-F%{platform_developer_framework_dir}", | ||||||||||||||||||||||||||
"-F%{sdk_dir}/System/iOSSupport/System/Library/Frameworks", | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||
include_system_dirs_feature = feature( | ||||||||||||||||||||||||||
name = "include_system_dirs", | ||||||||||||||||||||||||||
flag_sets = [ | ||||||||||||||||||||||||||
flag_set( | ||||||||||||||||||||||||||
actions = [ | ||||||||||||||||||||||||||
ACTION_NAMES.c_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_module_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.cpp_header_parsing, | ||||||||||||||||||||||||||
ACTION_NAMES.objc_compile, | ||||||||||||||||||||||||||
ACTION_NAMES.objcpp_compile, | ||||||||||||||||||||||||||
"objc-executable", | ||||||||||||||||||||||||||
"objc++-executable", | ||||||||||||||||||||||||||
ACTION_NAMES.assemble, | ||||||||||||||||||||||||||
ACTION_NAMES.preprocess_assemble, | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
flag_groups = [ | ||||||||||||||||||||||||||
flag_group( | ||||||||||||||||||||||||||
flags = [ | ||||||||||||||||||||||||||
"-isysroot", | ||||||||||||||||||||||||||
"%{sdk_dir}", | ||||||||||||||||||||||||||
"-F%{sdk_framework_dir}", | ||||||||||||||||||||||||||
"-F%{platform_developer_framework_dir}", | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
Comment on lines
+1297
to
+1358
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Comment on lines
+1297
to
+1358
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated Platform LogicSignificant code duplication in include_system_dirs_feature definition with only one flag difference. This violates DRY principle and increases maintenance burden when updating common flags across platform variants. Standards
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
input_param_flags_feature = feature( | ||||||||||||||||||||||||||
name = "input_param_flags", | ||||||||||||||||||||||||||
|
@@ -1542,7 +1609,9 @@ def _impl(ctx): | |||||||||||||||||||||||||
ctx.attr.cpu == "watchos_armv7k" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_i386" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64"): | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_arm64"): | ||||||||||||||||||||||||||
apply_implicit_frameworks_feature = feature( | ||||||||||||||||||||||||||
name = "apply_implicit_frameworks", | ||||||||||||||||||||||||||
flag_sets = [ | ||||||||||||||||||||||||||
|
@@ -2395,6 +2464,8 @@ def _impl(ctx): | |||||||||||||||||||||||||
ctx.attr.cpu == "tvos_arm64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64_32" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_armv7k" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_arm64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "darwin_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "darwin_arm64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "darwin_arm64e"): | ||||||||||||||||||||||||||
|
@@ -2652,7 +2723,9 @@ def _impl(ctx): | |||||||||||||||||||||||||
ctx.attr.cpu == "watchos_armv7k" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_i386" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64"): | ||||||||||||||||||||||||||
ctx.attr.cpu == "watchos_arm64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_x86_64" or | ||||||||||||||||||||||||||
ctx.attr.cpu == "catalyst_arm64"): | ||||||||||||||||||||||||||
features = [ | ||||||||||||||||||||||||||
fastbuild_feature, | ||||||||||||||||||||||||||
no_legacy_features_feature, | ||||||||||||||||||||||||||
|
@@ -2711,6 +2784,7 @@ def _impl(ctx): | |||||||||||||||||||||||||
relative_ast_path_feature, | ||||||||||||||||||||||||||
user_link_flags_feature, | ||||||||||||||||||||||||||
default_link_flags_feature, | ||||||||||||||||||||||||||
ios_support_link_flags_feature, | ||||||||||||||||||||||||||
no_deduplicate_feature, | ||||||||||||||||||||||||||
dead_strip_feature, | ||||||||||||||||||||||||||
cpp_linker_flags_feature, | ||||||||||||||||||||||||||
|
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.
Consider adding a comment explaining why both x86_64 and arm64 are included for Catalyst. This would improve readability and help future maintainers understand the reasoning behind this choice.