Skip to content

Commit

Permalink
Handle -iquote in copt
Browse files Browse the repository at this point in the history
We need to parse copt for -iquote paths and pass them to the include
scanner.  This mirrors what we already do for -I paths.  Note
currently objc_library documentation (see []
recommends use of -iquote while cc_library documentaiton recommends
([]

While we're at it, sanity check the include path, and add/fix a couple
tests.

RELNOTES: None
PiperOrigin-RevId: 268902183
  • Loading branch information
Googler authored and copybara-github committed Sep 13, 2019
1 parent aa8e8a2 commit abf3905
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,23 @@ public CcCompilationContext getCcCompilationContext() {

@Override
public List<PathFragment> getQuoteIncludeDirs() {
return ccCompilationContext.getQuoteIncludeDirs();
ImmutableList.Builder<PathFragment> result = ImmutableList.builder();
result.addAll(ccCompilationContext.getQuoteIncludeDirs());
ImmutableList<String> copts = compileCommandLine.getCopts();
for (int i = 0; i < copts.size(); i++) {
String opt = copts.get(i);
if (opt.startsWith("-iquote")) {
if (opt.length() > 7) {
result.add(PathFragment.create(opt.substring(7).trim()));
} else if (i + 1 < copts.size()) {
i++;
result.add(PathFragment.create(copts.get(i)));
} else {
System.err.println("WARNING: dangling -iquote flag in options for " + prettyPrint());
}
}
}
return result.build();
}

@Override
Expand Down Expand Up @@ -920,13 +936,11 @@ void verifyActionIncludePaths(List<PathFragment> systemIncludeDirs)
throws ActionExecutionException {
ImmutableSet<PathFragment> ignoredDirs = ImmutableSet.copyOf(getValidationIgnoredDirs());
// We currently do not check the output of:
// - getQuoteIncludeDirs(): those only come from includes attributes, and are checked in
// CcCommon.getIncludeDirsFromIncludesAttribute().
// - getBuiltinIncludeDirs(): while in practice this doesn't happen, bazel can be configured
// to use an absolute system root, in which case the builtin include dirs might be absolute.

Iterable<PathFragment> includePathsToVerify =
Iterables.concat(getIncludeDirs(), systemIncludeDirs);
Iterables.concat(getIncludeDirs(), getQuoteIncludeDirs(), systemIncludeDirs);
for (PathFragment includePath : includePathsToVerify) {
// includePathsToVerify contains all paths that are added as -isystem directive on the command
// line, most of which are added for include directives in the CcCompilationContext and are
Expand Down

0 comments on commit abf3905

Please sign in to comment.