rules_swift_package_manager icon indicating copy to clipboard operation
rules_swift_package_manager copied to clipboard

feat: add support for aws-crt-swift and complex C dependencies

Open codeman9 opened this issue 1 month ago • 2 comments

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.bzl and module_maps.bzl

Framework Auto-Detection

  • Scan C source files for #include <Framework/Header.h> patterns
  • Automatically add -framework linker flags for detected Apple frameworks
  • Handles cases where frameworks aren't explicitly declared in Package.swift

Default Public Headers Path

  • Default to include/ directory when publicHeadersPath is 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

codeman9 avatar Nov 03 '25 19:11 codeman9

@mergifyio queue

cgrindel avatar Nov 16 '25 19:11 cgrindel

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] -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

mergify[bot] avatar Nov 16 '25 19:11 mergify[bot]

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 avatar Nov 17 '25 15:11 codeman9

@codeman9 When the tests are green, please click the re-request review button so that I know to take a look. Thanks!

cgrindel avatar Nov 17 '25 15:11 cgrindel

@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?

codeman9 avatar Nov 17 '25 16:11 codeman9

@mergifyio queue

cgrindel avatar Nov 22 '25 15:11 cgrindel

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 57b98a8987ea585b9d1d90466da564210844ad58

mergify[bot] avatar Nov 22 '25 15:11 mergify[bot]

Merge Queue Status Beta

✅ 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] any of [🛡 GitHub branch protection]:
    • [X] check-success = conventional_commit_check
    • [ ] check-neutral = conventional_commit_check
    • [ ] check-skipped = conventional_commit_check

mergify[bot] avatar Nov 24 '25 14:11 mergify[bot]

@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 avatar Dec 03 '25 16:12 codeman9

@codeman9 Let's see if this run with an update from main will be green.

cgrindel avatar Dec 03 '25 16:12 cgrindel

I'll create a release later today your contribution. Thank you!

cgrindel avatar Dec 03 '25 19:12 cgrindel