rules_swift_package_manager
rules_swift_package_manager copied to clipboard
feat: add support for aws-crt-swift and complex C dependencies
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
- Added umbrella directory support to modulemap generation (matching SPM behavior)
- Prevents atomics redefinition errors by only processing headers when explicitly included
- Modified
generate_modulemap.bzlandmodule_maps.bzl
Framework Auto-Detection
- Scan C source files for
#include <Framework/Header.h>patterns - Automatically add
-frameworklinker flags for detected Apple frameworks - Handles cases where frameworks aren't explicitly declared in Package.swift
Default Public Headers Path
- Default to
include/directory whenpublicHeadersPathis not specified - Remove
include/from exclude patterns (SPM doesn't exclude public headers)
Excluded Directory Headers
- Collect headers from excluded directories (SPM excludes only affect compilation)
- Makes headers available for inclusion even when in excluded directories
Examples
Added two examples demonstrating the fixes:
- aws_crt_example: Directly tests aws-crt-swift
- aws_sdk_example: Tests full AWS SDK for Swift (transitively depends on aws-crt-swift)
Both examples build and run successfully.
Testing
cd examples/aws_crt_example && bazel test //...
cd examples/aws_sdk_example && bazel run //:AwsSdkExample
@mergifyio queue
queue
🟠 Waiting for conditions to match
- [ ] any of: [🔀 queue conditions]
- [ ] all of: [📌 queue conditions of queue
default]- [ ]
#approved-reviews-by >= 1[🛡 GitHub branch protection] - [ ]
#changes-requested-reviews-by = 0[🛡 GitHub branch protection] - [ ]
branch-protection-review-decision = APPROVED[🛡 GitHub branch protection] - [ ]
check-success=all_ci_tests - [ ] any of: [🛡 GitHub branch protection]
- [ ]
check-neutral = all_ci_tests - [ ]
check-skipped = all_ci_tests - [ ]
check-success = all_ci_tests
- [ ]
- [X]
#review-threads-unresolved = 0[🛡 GitHub branch protection] - [X]
check-success=conventional_commit_check - [X] any of: [🛡 GitHub branch protection]
- [X]
check-success = conventional_commit_check - [ ]
check-neutral = conventional_commit_check - [ ]
check-skipped = conventional_commit_check
- [X]
- [ ]
- [ ] all of: [📌 queue conditions of queue
- [X]
-closed[📌 queue requirement] - [X]
-conflict[📌 queue requirement] - [X]
-draft[📌 queue requirement] - [X] any of: [📌 queue -> configuration change requirements]
- [X]
-mergify-configuration-changed - [ ]
check-success = Configuration changed
- [X]
It looks like we have some test failures.
~These failures don't look related to my changes? Or am I missing something? I can try to fix the nimble, resources, shake_ios, and tca_example_tests if you want.~ I guess there was a formatting issue in my changes. Updated.
@codeman9 When the tests are green, please click the re-request review button so that I know to take a look. Thanks!
@codeman9 When the tests are green, please click the re-request review button so that I know to take a look. Thanks!
@cgrindel It looks like all the errors are now timeouts in parts of the code unrelated to my changes. How do I poke CI to run again?
@mergifyio queue
queue
✅ The pull request has been merged automatically
The pull request has been merged automatically at 57b98a8987ea585b9d1d90466da564210844ad58
Merge Queue Status 
✅ The pull request has been merged
This pull request spent 9 seconds in the queue, with no time running CI. The checks were run in-place.
Required conditions to merge
#approved-reviews-by >= 1[🛡 GitHub branch protection]- [X] #1907
#changes-requested-reviews-by = 0[🛡 GitHub branch protection]- [X] #1907
#review-threads-unresolved = 0[🛡 GitHub branch protection]- [X] #1907
branch-protection-review-decision = APPROVED[🛡 GitHub branch protection]- [X] #1907
- [X]
check-success=all_ci_tests - [X]
check-success=conventional_commit_check - [X] any of [🛡 GitHub branch protection]:
- [X]
check-success = all_ci_tests - [ ]
check-neutral = all_ci_tests - [ ]
check-skipped = all_ci_tests
- [X]
- [X] any of [🛡 GitHub branch protection]:
- [X]
check-success = conventional_commit_check - [ ]
check-neutral = conventional_commit_check - [ ]
check-skipped = conventional_commit_check
- [X]
@cgrindel Any word on what I can do to help here? This change (aws-sdk-swift support) is needed for a project I'm working on. I can use my branch but would appreciate main line support.
@codeman9 Let's see if this run with an update from main will be green.
I'll create a release later today your contribution. Thank you!