Skip to content

Handle catalyst interface swap #64878

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
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
14 changes: 13 additions & 1 deletion stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,11 @@ function(_compile_swift_files

if(SWIFT_ENABLE_MODULE_INTERFACES)
set(maccatalyst_interface_file "${maccatalyst_module_base}.swiftinterface")
list(APPEND maccatalyst_module_outputs "${maccatalyst_interface_file}")
set(maccatalyst_private_interface_file "${maccatalyst_module_base}.private.swiftinterface")
list(APPEND maccatalyst_module_outputs "${maccatalyst_interface_file}" "${maccatalyst_private_interface_file}")
else()
set(maccatalyst_interface_file)
set(maccatalyst_private_interface_file)
endif()

swift_install_in_component(DIRECTORY ${maccatalyst_specific_module_dir}
Expand Down Expand Up @@ -824,13 +826,23 @@ function(_compile_swift_files
list(APPEND maccatalyst_swift_flags
"-I" "${lib_dir}/${maccatalyst_library_subdir}")
set(maccatalyst_swift_module_flags ${swift_module_flags})

# Remove original interface file
list(FIND maccatalyst_swift_module_flags "${interface_file}" interface_file_index)
if(NOT interface_file_index EQUAL -1)
list(INSERT maccatalyst_swift_module_flags ${interface_file_index} "${maccatalyst_interface_file}")
math(EXPR old_interface_file_index "${interface_file_index} + 1")
list(REMOVE_AT maccatalyst_swift_module_flags ${old_interface_file_index})
endif()

# Remove original private interface
list(FIND maccatalyst_swift_module_flags "${private_interface_file}" private_interface_file_index)
if(NOT private_interface_file_index EQUAL -1)
list(INSERT maccatalyst_swift_module_flags ${private_interface_file_index} "${maccatalyst_private_interface_file}")
math(EXPR old_interface_file_index "${private_interface_file_index} + 1")
list(REMOVE_AT maccatalyst_swift_module_flags ${old_interface_file_index})
endif()

# We still need to change the main swift flags
# so we can use the correct modules
# when building for macOS
Expand Down