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

fix: correct issues with modulemap generation #1360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

luispadron
Copy link
Collaborator

@luispadron luispadron commented Nov 26, 2024

Fixes duplicate definition errors caused by custom/generated modulemap files.

@luispadron luispadron force-pushed the luis/fix-duplicate-errors-in-non-sandboxed-builds branch 2 times, most recently from 3c0f64c to 51f6d2c Compare November 26, 2024 23:52
@@ -435,7 +438,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target):
noop_modulemap = clang_src_info.modulemap_path != None
modulemap_attrs = {
"deps": bzl_selects.to_starlark(modulemap_deps),
"hdrs": clang_src_info.hdrs,
"hdrs": [] if noop_modulemap else clang_src_info.hdrs,
Copy link
Collaborator Author

@luispadron luispadron Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed but noticed we were adding all the hdrs/deps here even in the noop case which was confusing when looking at the build file

@luispadron luispadron force-pushed the luis/fix-duplicate-errors-in-non-sandboxed-builds branch from 51f6d2c to 5c2019d Compare November 26, 2024 23:59
@luispadron luispadron marked this pull request as ready for review November 26, 2024 23:59
@luispadron luispadron force-pushed the luis/fix-duplicate-errors-in-non-sandboxed-builds branch from 5c2019d to 59e0969 Compare November 27, 2024 00:05
@brentleyjones
Copy link
Collaborator

brentleyjones commented Nov 27, 2024

We should use an aspect hint instead (both for the empty case and the supplied case): https://github.com/bazelbuild/rules_swift/blob/61e2c46dbfac6b9c11ecfb2c8e92f3e157ea9f27/swift/swift_clang_module_aspect.bzl#L221

@luispadron
Copy link
Collaborator Author

We should use an aspect hint instead (both for the empty case and the supplied case): https://github.com/bazelbuild/rules_swift/blob/61e2c46dbfac6b9c11ecfb2c8e92f3e157ea9f27/swift/swift_clang_module_aspect.bzl#L221

hmm, this doesn't seem to work. I believe because its failing during the objc_library (parent) -> objc_library (child) case.

I've tried setting the child aspect_hints to: @build_bazel_rules_swift//swift:no_module and the parent to a custom swift_interop_hint with the module_map and module_name. Is there an equivalent hint for objc_library? I dont think the interop hint does anything when its part of deps of another objc_library right?

@luispadron luispadron force-pushed the luis/fix-duplicate-errors-in-non-sandboxed-builds branch from 59e0969 to dc399d5 Compare November 27, 2024 01:09
@luispadron
Copy link
Collaborator Author

@brentleyjones I did update this to generate a swift_interop_hint for the parent so that we don't set module_map for it. For the child though I'm not sure how to get it working without setting module_map.

@luispadron luispadron force-pushed the luis/fix-duplicate-errors-in-non-sandboxed-builds branch 2 times, most recently from b5e7a42 to eab4c6d Compare November 27, 2024 01:41
Copy link
Owner

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove these lines from the firebase example and ensure that it works? Also, can you remove this section from the FAQ?

Copy link
Owner

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for implementing this! I have a few suggested changes. Otherwise, LGTM.

swiftpkg/internal/swiftpkg_build_files.bzl Outdated Show resolved Hide resolved
@luispadron luispadron force-pushed the luis/fix-duplicate-errors-in-non-sandboxed-builds branch from eab4c6d to 20e3bb9 Compare December 1, 2024 03:15
@luispadron
Copy link
Collaborator Author

@cgrindel

Can you remove these lines from the firebase example and ensure that it works? Also, can you remove this section from the FAQ?

Updated, do_test for that example passes locally let's see what CI says.

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

Successfully merging this pull request may close these issues.

3 participants