diff options
author | 2016-03-18 17:33:12 +0000 | |
---|---|---|
committer | 2016-03-21 09:34:21 +0000 | |
commit | bb2f07124c7ebf5cb28c8cd4b57cf6156c1c7b0d (patch) | |
tree | ec63ded235fee12bd21b27b82376bf87fc9f568f /src/main/java/com/google/devtools/build/lib/rules | |
parent | 51a491b89a9cd5f15c9a093a5693bc37e696e6e1 (diff) |
Export cc build information in an aspect for IDE support.
--
MOS_MIGRATED_REVID=117560803
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java | 65 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java | 6 |
2 files changed, 71 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java index 674e68c6ca..4f250b7b18 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java @@ -81,6 +81,71 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { } @SkylarkCallable( + name = "defines", + structField = true, + doc = + "Returns the immutable set of defines used to compile this target " + + "(possibly empty but never None).") + public ImmutableList<String> getDefines() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + return ccContext == null ? ImmutableList.<String>of() : ccContext.getDefines(); + } + + @SkylarkCallable( + name = "system_include_directories", + structField = true, + doc = + "Returns the immutable set of system include directories used to compile this target " + + "(possibly empty but never None).") + public ImmutableList<String> getSystemIncludeDirs() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + if (ccContext == null) { + return ImmutableList.of(); + } + ImmutableList.Builder<String> builder = ImmutableList.builder(); + for (PathFragment path : ccContext.getSystemIncludeDirs()) { + builder.add(path.getSafePathString()); + } + return builder.build(); + } + + @SkylarkCallable( + name = "include_directories", + structField = true, + doc = + "Returns the immutable set of include directories used to compile this target " + + "(possibly empty but never None).") + public ImmutableList<String> getIncludeDirs() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + if (ccContext == null) { + return ImmutableList.of(); + } + ImmutableList.Builder<String> builder = ImmutableList.builder(); + for (PathFragment path : ccContext.getIncludeDirs()) { + builder.add(path.getSafePathString()); + } + return builder.build(); + } + + @SkylarkCallable( + name = "quote_include_directories", + structField = true, + doc = + "Returns the immutable set of quote include directories used to compile this target " + + "(possibly empty but never None).") + public ImmutableList<String> getQuoteIncludeDirs() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + if (ccContext == null) { + return ImmutableList.of(); + } + ImmutableList.Builder<String> builder = ImmutableList.builder(); + for (PathFragment path : ccContext.getQuoteIncludeDirs()) { + builder.add(path.getSafePathString()); + } + return builder.build(); + } + + @SkylarkCallable( name = "compile_flags", structField = true, doc = diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index e46d1f76d6..f1adbe878b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -1193,6 +1193,10 @@ public class CppConfiguration extends BuildConfiguration.Fragment { * They may be absolute if they are also installed on the remote build nodes or * for local compilation. */ + @SkylarkCallable(name = "built_in_include_directories", structField = true, + doc = "Built-in system include paths for the toolchain compiler. All paths in this list" + + " should be relative to the exec directory. They may be absolute if they are also installed" + + " on the remote build nodes or for local compilation.") public List<PathFragment> getBuiltInIncludeDirectories() { return builtInIncludeDirectories; } @@ -1699,6 +1703,8 @@ public class CppConfiguration extends BuildConfiguration.Fragment { * Returns the path to the GNU binutils 'cpp' binary that should be used * by this build. Relative paths are relative to the execution root. */ + @SkylarkCallable(name = "preprocessor_executable", structField = true, + doc = "Path to C/C++ preprocessor binary") public PathFragment getCpreprocessorExecutable() { return getToolPathFragment(CppConfiguration.Tool.CPP); } |