Skip to content
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

[Feature Request] Support for changing internal/private import to private_deps automatically #1474

Open
CharlieSuP1 opened this issue Jan 13, 2025 · 1 comment

Comments

@CharlieSuP1
Copy link

CharlieSuP1 commented Jan 13, 2025

Let's say A depends on B,B depends on C。

By default, you need B.swiftmodule and C.swiftmodule to compile A。
So if C‘s public interface changed, module A must be recompiled.

To change this, you will need add C to B's private deps,and use internal/private import C in B's implementation.
(Thanks for swift.experimental.AccessLevelOnImport feature,you won't need to write the _implementationOnly syntax )
So in this way, Bazel will not consider C.swiftmodule as A’s compile inputs,and compiler won't complain about it.

So can this be more automatic?
My requested feature is: as for module B, any internal/private modules it imports, automatically become private deps,and won't propagate to module A.

And is there any support for new swift feature InternalImportsByDefault?
Hopefully, make import internal by default and automatically change these dependencies to private deps will decrease lots of transitive dependencies and decrease build time in non-trivial projects.

One way to archive this may analyze swiftinterface for module B(if any),and find all public imports. Comparing these modules to deps of module B,changing any deps that not in B.swiftinterface to private_deps.

@CharlieSuP1 CharlieSuP1 changed the title Support for changing internal/private import to private_deps automatically [Feature Request] Support for changing internal/private import to private_deps automatically Jan 13, 2025
@CharlieSuP1
Copy link
Author

Updates: I think we can mimic xcodebuild's behavior:
when using "split derived files" feature,pass -emit-dependencies alongside -emit-module.
then use the swiftdeps result from -emit-dependencies, to trim input files for actual swift compilation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant