Skip to content

Commit

Permalink
Remove enable_modules from ObjcCppSemantics
Browse files Browse the repository at this point in the history
This was added as a workaround for an include validation problem on
Apple when the objc_library enable_modules attribute is set to true.
There were absolute paths to internal stl wrapper headers that were
showing up in .d files.  I verified that the absolute paths are no
longer showing up, and removing this work around didn't break any
builds.

This finally makes ObjcCppSemantics stateless which is the way it
should be!

PiperOrigin-RevId: 368850814
  • Loading branch information
googlewalt authored and copybara-github committed Apr 16, 2021
1 parent eb02822 commit 38ab3cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,9 @@
* CppSemantics for objc builds.
*/
public class ObjcCppSemantics implements CppSemantics {
public static final ObjcCppSemantics MODULES = new ObjcCppSemantics(true);
public static final ObjcCppSemantics NO_MODULES = new ObjcCppSemantics(false);
public static final ObjcCppSemantics INSTANCE = new ObjcCppSemantics();

private final boolean enableModules;

/**
* Creates an instance of ObjcCppSemantics
*
* @param enableModules whether modules are enabled
*/
public ObjcCppSemantics(boolean enableModules) {
this.enableModules = enableModules;
}
private ObjcCppSemantics() {}

@Override
public void finalizeCompileActionBuilder(
Expand Down Expand Up @@ -88,10 +78,7 @@ public void validateAttributes(RuleContext ruleContext) {

@Override
public boolean needsIncludeValidation() {
// We disable include validation when modules are enabled, because Apple uses absolute paths in
// its module maps, which include validation does not recognize. Modules should only be used
// rarely and in third party code anyways.
return !enableModules;
return true;
}

/** cc_shared_library is not supported with Objective-C */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private CompilationResult ccCompileAndLink(
}

ObjcCppSemantics createObjcCppSemantics() {
return attributes.enableModules() ? ObjcCppSemantics.MODULES : ObjcCppSemantics.NO_MODULES;
return ObjcCppSemantics.INSTANCE;
}

private FeatureConfiguration getFeatureConfiguration(
Expand Down

0 comments on commit 38ab3cf

Please sign in to comment.