Skip to content

[WIP] Objc modular imports - #6243

Closed
ob wants to merge 4 commits into
bazelbuild:masterfrom
ob:objc_modular_imports
Closed

ob wants to merge 4 commits into
bazelbuild:masterfrom
ob:objc_modular_imports

Conversation

@ob

@ob ob commented Sep 26, 2018 •

Copy link
Copy Markdown
Contributor

This adds support for using modular imports (@import module) from objc_library rules.

Implementation note:

I again had to remove the extraneous CcCompilationContext mentioned in #5954, and still have the same question from that PR.

I also cleaned up what looked like unused code (that's why there are two commits).

@iirina iirina added the z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple label Sep 26, 2018
.containsExactly("objc/a.h", "objc/b.h", "objc/f.m");
assertThat(getArifactPaths(depender, HEADER))
.containsExactly("objc/a.h", "objc/b.h", "objc/f.m", "objc2/d.h", "objc2/e.m");
.containsExactly("objc/a.h", "objc/b.h", "objc/f.m", "objc/private.h", "objc2/d.h", "objc2/e.m");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is checking the header field of the ObjcProvider, right? AFAIK, it definitely should not be propagating private headers that are only listed in srcs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was going by this comment from #5954.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, that's a fair point (a public header including a private header). I'd have to dig deeper to see why that hasn't been an issue today, unless people just so habitually glob .h files into hdrs and .m files into srcs that it doesn't ever come up. 🤷‍♂️

As long as the HEADER field is only used to determine which header files end up in downstream actions' sandboxes, that should be fine. But if we ever query that field anywhere else with the assumption that that's the "public interface" of the library, we'd need to figure out what to do there. I don't know if that's an issue anywhere currently, though.

Module map creation uses the hdrs attribute, not the provider, I believe, so that should be unaffected.

@ob

ob commented Sep 26, 2018

Copy link
Copy Markdown
Contributor Author

One thing to consider is that with too many dependencies this has the potential to exceed the maximum command line argument. I should probably pass all the flags as a response file.

@ob ob changed the title Objc modular imports [WIP] Objc modular imports Sep 26, 2018
@lberki
lberki requested review from hlopko and removed request for lberki September 27, 2018 09:22
The CreateSourceAction function is called _per file_, so this was
adding the flags multiple times. Call it before the loop so that
the flags are only added once.
@ob

ob commented Sep 27, 2018

Copy link
Copy Markdown
Contributor Author

I am a bit confused why here -fmodules is only passed to the compiler when Bazel itself generates the module map and not when the user provided a module map. I want to pass -fmodules in both cases.

@jin jin added the WIP label Jan 3, 2019
@ob

ob commented Jan 30, 2019

Copy link
Copy Markdown
Contributor Author

This is no longer being pursued in this form, I'll take another crack once the C++ rules are in StarLark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants