-
Notifications
You must be signed in to change notification settings - Fork 45
feat: add support for aws-crt-swift and complex C dependencies #1907
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: main
Are you sure you want to change the base?
feat: add support for aws-crt-swift and complex C dependencies #1907
Conversation
- Add umbrella directory modulemap generation to match SPM behavior - Add framework detection: scan C source files for framework imports and auto-link - Add default include/ path handling when publicHeadersPath is not specified - Add header collection from excluded directories (SPM excludes only affect compilation) - Add aws_crt_example demonstrating aws-crt-swift building successfully Fixes enable building Swift packages with complex C dependencies that have: - Inline implementation files (.inl) that should be conditionally included - Default public header paths (include/) - Excluded directories containing needed headers - System framework dependencies not declared in Package.swift The umbrella directory approach prevents atomics redefinition errors by only processing headers when explicitly included, rather than importing all headers upfront when listed individually in the modulemap.
This example builds and runs successfully, demonstrating that all the fixes for complex C dependencies work with aws-sdk-swift, which transitively depends on aws-crt-swift and its complex C library dependencies.
cgrindel
left a comment
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.
Thank you for the contribution! I will dive into the review later today. However, I noticed that this PR does not update the example_infos. After doing that, you will need to run bazel run //:tidy which will update the generated CI file.
- Added aws_crt_example and aws_sdk_example to example_infos.bzl - Ran bazel run //:tidy to update CI workflow and deleted_packages - CI will now test both new examples on macOS
cgrindel
left a comment
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.
Overall, looks good. Most of my comments are formatting issues. Thanks, again, for the contribution!
- Update .bazelrc files to use shared config imports - Update do_test script to use BIT_BAZEL_BINARY - Wrap long lines in MODULE.bazel to stay under 80 chars - Refactor framework detection with helper function and constants - Move header extensions to constants - Improve line wrapping and formatting throughout
Both examples now include cgrindel_bazel_starlib dependency which is required by the shared.bazelrc configuration.
cgrindel
left a comment
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.
It looks like we are missing a do_test file for the aws_sdk_example. Once that is added, we should be good to go.
- Add .bazelignore files to exclude .build directories from Bazel - Add Gazelle targets for automated BUILD file generation - Add tidy targets to run Gazelle updates - Add swift_package_tool targets for package updates - Update MODULE.bazel files with Gazelle dependencies and swift_deps_info - Add do_test script for aws_sdk_example - Update do_test script for aws_crt_example to run tidy - Exclude Tests directory from Gazelle in aws_crt_example - Fix repository name references to use build_bazel_rules_swift - Standardize bash options and formatting in do_test scripts
Author's note: This was most all generated by AI. I verified the functionality works as I intend and apologize if the coding conventions aren't of the highest quality.
Summary
This PR adds support for building Swift packages with complex C dependencies, specifically enabling aws-crt-swift and aws-sdk-swift to build successfully.
Changes
Umbrella Directory Modulemaps
generate_modulemap.bzlandmodule_maps.bzlFramework Auto-Detection
#include <Framework/Header.h>patterns-frameworklinker flags for detected Apple frameworksDefault Public Headers Path
include/directory whenpublicHeadersPathis not specifiedinclude/from exclude patterns (SPM doesn't exclude public headers)Excluded Directory Headers
Examples
Added two examples demonstrating the fixes:
Both examples build and run successfully.
Testing